Fossil SCM

Fix up some comments on the command and webpage name lookup logic. No changes to code.

drh 2016-09-13 18:03 trunk
Commit 49703de740a8d74270610d907e5e5e542b936f16
2 files changed +10 -14 +9
+10 -14
--- src/dispatch.c
+++ src/dispatch.c
@@ -29,11 +29,11 @@
2929
/*
3030
** An instance of this object defines everything we need to know about an
3131
** individual command or webpage.
3232
*/
3333
struct CmdOrPage {
34
- const char *zName; /* Name. Webpages start with "/". Commands do not */
34
+ const char *zName; /* Name. Webpages start with "/". Commands do not */
3535
void (*xFunc)(void); /* Function that implements the command or webpage */
3636
const char *zHelp; /* Raw help text */
3737
unsigned eCmdFlags; /* Flags */
3838
};
3939
@@ -53,18 +53,18 @@
5353
** of CmdOrPage objects that defines all available commands and webpages
5454
** known to Fossil.
5555
**
5656
** The entries in aCommand[] are in sorted order by name. Since webpage names
5757
** always begin with "/", all webpage names occur first. The page_index.h file
58
-** also sets the FOSSIL_FIRST_CMD macro to be the approximate index
59
-** in aCommand[] of the first command entry. FOSSIL_FIRST_CMD might be slightly
60
-** too low, and so the range FOSSIL_FIRST_CMD...end might contain a few webpage
61
-** entries at the beginning.
58
+** also sets the FOSSIL_FIRST_CMD macro to be the *approximate* index
59
+** in aCommand[] of the first command entry. FOSSIL_FIRST_CMD might be
60
+** slightly too low, and so the range FOSSIL_FIRST_CMD...MX_COMMAND might
61
+** contain a few webpage entries at the beginning.
6262
**
6363
** The page_index.h file is generated by the mkindex program which scans all
64
-** source code files looking for header comments on the functions that implement
65
-** command and webpages.
64
+** source code files looking for header comments on the functions that
65
+** implement command and webpages.
6666
*/
6767
#include "page_index.h"
6868
#define MX_COMMAND (sizeof(aCommand)/sizeof(aCommand[0]))
6969
7070
/*
@@ -79,22 +79,18 @@
7979
** 0: Success. *ppCmd is set to the appropriate CmdOrPage
8080
** 1: Not found.
8181
** 2: Ambiguous. Two or more entries match.
8282
*/
8383
int dispatch_name_search(
84
- const char *zName,
85
- unsigned eType,
86
- const CmdOrPage **ppCmd
84
+ const char *zName, /* Look for this name */
85
+ unsigned eType, /* CMDFLAGS_* bits */
86
+ const CmdOrPage **ppCmd /* Write the matching CmdOrPage object here */
8787
){
8888
int upr, lwr, mid;
8989
int nName = strlen(zName);
9090
lwr = 0;
9191
upr = MX_COMMAND - 1;
92
-#if 0
93
- if( (eType&CMDFLAG_WEBPAGE)==0 ) lwr = FOSSIL_FIRST_CMD;
94
- if( (eType&CMDFLAG_COMMAND)==0 ) upr = FOSSIL_FIRST_CMD-1;
95
-#endif
9692
while( lwr<=upr ){
9793
int c;
9894
mid = (upr+lwr)/2;
9995
c = strcmp(zName, aCommand[mid].zName);
10096
if( c==0 ){
10197
--- src/dispatch.c
+++ src/dispatch.c
@@ -29,11 +29,11 @@
29 /*
30 ** An instance of this object defines everything we need to know about an
31 ** individual command or webpage.
32 */
33 struct CmdOrPage {
34 const char *zName; /* Name. Webpages start with "/". Commands do not */
35 void (*xFunc)(void); /* Function that implements the command or webpage */
36 const char *zHelp; /* Raw help text */
37 unsigned eCmdFlags; /* Flags */
38 };
39
@@ -53,18 +53,18 @@
53 ** of CmdOrPage objects that defines all available commands and webpages
54 ** known to Fossil.
55 **
56 ** The entries in aCommand[] are in sorted order by name. Since webpage names
57 ** always begin with "/", all webpage names occur first. The page_index.h file
58 ** also sets the FOSSIL_FIRST_CMD macro to be the approximate index
59 ** in aCommand[] of the first command entry. FOSSIL_FIRST_CMD might be slightly
60 ** too low, and so the range FOSSIL_FIRST_CMD...end might contain a few webpage
61 ** entries at the beginning.
62 **
63 ** The page_index.h file is generated by the mkindex program which scans all
64 ** source code files looking for header comments on the functions that implement
65 ** command and webpages.
66 */
67 #include "page_index.h"
68 #define MX_COMMAND (sizeof(aCommand)/sizeof(aCommand[0]))
69
70 /*
@@ -79,22 +79,18 @@
79 ** 0: Success. *ppCmd is set to the appropriate CmdOrPage
80 ** 1: Not found.
81 ** 2: Ambiguous. Two or more entries match.
82 */
83 int dispatch_name_search(
84 const char *zName,
85 unsigned eType,
86 const CmdOrPage **ppCmd
87 ){
88 int upr, lwr, mid;
89 int nName = strlen(zName);
90 lwr = 0;
91 upr = MX_COMMAND - 1;
92 #if 0
93 if( (eType&CMDFLAG_WEBPAGE)==0 ) lwr = FOSSIL_FIRST_CMD;
94 if( (eType&CMDFLAG_COMMAND)==0 ) upr = FOSSIL_FIRST_CMD-1;
95 #endif
96 while( lwr<=upr ){
97 int c;
98 mid = (upr+lwr)/2;
99 c = strcmp(zName, aCommand[mid].zName);
100 if( c==0 ){
101
--- src/dispatch.c
+++ src/dispatch.c
@@ -29,11 +29,11 @@
29 /*
30 ** An instance of this object defines everything we need to know about an
31 ** individual command or webpage.
32 */
33 struct CmdOrPage {
34 const char *zName; /* Name. Webpages start with "/". Commands do not */
35 void (*xFunc)(void); /* Function that implements the command or webpage */
36 const char *zHelp; /* Raw help text */
37 unsigned eCmdFlags; /* Flags */
38 };
39
@@ -53,18 +53,18 @@
53 ** of CmdOrPage objects that defines all available commands and webpages
54 ** known to Fossil.
55 **
56 ** The entries in aCommand[] are in sorted order by name. Since webpage names
57 ** always begin with "/", all webpage names occur first. The page_index.h file
58 ** also sets the FOSSIL_FIRST_CMD macro to be the *approximate* index
59 ** in aCommand[] of the first command entry. FOSSIL_FIRST_CMD might be
60 ** slightly too low, and so the range FOSSIL_FIRST_CMD...MX_COMMAND might
61 ** contain a few webpage entries at the beginning.
62 **
63 ** The page_index.h file is generated by the mkindex program which scans all
64 ** source code files looking for header comments on the functions that
65 ** implement command and webpages.
66 */
67 #include "page_index.h"
68 #define MX_COMMAND (sizeof(aCommand)/sizeof(aCommand[0]))
69
70 /*
@@ -79,22 +79,18 @@
79 ** 0: Success. *ppCmd is set to the appropriate CmdOrPage
80 ** 1: Not found.
81 ** 2: Ambiguous. Two or more entries match.
82 */
83 int dispatch_name_search(
84 const char *zName, /* Look for this name */
85 unsigned eType, /* CMDFLAGS_* bits */
86 const CmdOrPage **ppCmd /* Write the matching CmdOrPage object here */
87 ){
88 int upr, lwr, mid;
89 int nName = strlen(zName);
90 lwr = 0;
91 upr = MX_COMMAND - 1;
 
 
 
 
92 while( lwr<=upr ){
93 int c;
94 mid = (upr+lwr)/2;
95 c = strcmp(zName, aCommand[mid].zName);
96 if( c==0 ){
97
--- src/mkindex.c
+++ src/mkindex.c
@@ -249,10 +249,19 @@
249249
void build_table(void){
250250
int i;
251251
int nWeb = 0;
252252
253253
qsort(aEntry, nFixed, sizeof(aEntry[0]), e_compare);
254
+
255
+ printf(
256
+ "/* Automatically generated code\n"
257
+ "** DO NOT EDIT!\n"
258
+ "**\n"
259
+ "** This file was generated by the mkindex.exe program based on\n"
260
+ "** comments in other Fossil source files.\n"
261
+ "*/\n"
262
+ );
254263
255264
/* Output declarations for all the action functions */
256265
for(i=0; i<nFixed; i++){
257266
if( aEntry[i].zIf ) printf("%s", aEntry[i].zIf);
258267
printf("extern void %s(void);\n", aEntry[i].zFunc);
259268
--- src/mkindex.c
+++ src/mkindex.c
@@ -249,10 +249,19 @@
249 void build_table(void){
250 int i;
251 int nWeb = 0;
252
253 qsort(aEntry, nFixed, sizeof(aEntry[0]), e_compare);
 
 
 
 
 
 
 
 
 
254
255 /* Output declarations for all the action functions */
256 for(i=0; i<nFixed; i++){
257 if( aEntry[i].zIf ) printf("%s", aEntry[i].zIf);
258 printf("extern void %s(void);\n", aEntry[i].zFunc);
259
--- src/mkindex.c
+++ src/mkindex.c
@@ -249,10 +249,19 @@
249 void build_table(void){
250 int i;
251 int nWeb = 0;
252
253 qsort(aEntry, nFixed, sizeof(aEntry[0]), e_compare);
254
255 printf(
256 "/* Automatically generated code\n"
257 "** DO NOT EDIT!\n"
258 "**\n"
259 "** This file was generated by the mkindex.exe program based on\n"
260 "** comments in other Fossil source files.\n"
261 "*/\n"
262 );
263
264 /* Output declarations for all the action functions */
265 for(i=0; i<nFixed; i++){
266 if( aEntry[i].zIf ) printf("%s", aEntry[i].zIf);
267 printf("extern void %s(void);\n", aEntry[i].zFunc);
268

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button