Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Clean up the command-search logic. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
bcb7c7a9b1e947035ca41469de37e93b |
| User & Date: | drh 2014-07-16 22:17:14.326 |
Context
|
2014-07-16
| ||
| 23:01 | Add the "fossil all info" command. ... (check-in: 3f9ff2a9fa user: drh tags: trunk) | |
| 22:17 | Clean up the command-search logic. ... (check-in: bcb7c7a9b1 user: drh tags: trunk) | |
| 07:57 | In the UI and CL, output UUID's the same (almost) everywhere: The first 10 characters of UUID's are always displayed, but more are added until the UUID contains at least a single 'a'-'f'. Hyperlinks still usee the full-length UUID. ... (check-in: fe6d393021 user: jan.nijtmans tags: trunk) | |
Changes
Changes to src/main.c.
| ︙ | ︙ | |||
296 297 298 299 300 301 302 303 304 305 306 |
** defined in the page_index.h header file which is automatically
** generated by mkindex.c program.
*/
static int name_search(
const char *zName, /* The name we are looking for */
const NameMap *aMap, /* Search in this array */
int nMap, /* Number of slots in aMap[] */
int *pIndex /* OUT: The index in aMap[] of the match */
){
int upr, lwr, cnt, m, i;
int n = strlen(zName);
| > | | | 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
** defined in the page_index.h header file which is automatically
** generated by mkindex.c program.
*/
static int name_search(
const char *zName, /* The name we are looking for */
const NameMap *aMap, /* Search in this array */
int nMap, /* Number of slots in aMap[] */
int iBegin, /* Lower bound on the array search */
int *pIndex /* OUT: The index in aMap[] of the match */
){
int upr, lwr, cnt, m, i;
int n = strlen(zName);
lwr = iBegin;
upr = nMap-1;
while( lwr<=upr ){
int mid, c;
mid = (upr+lwr)/2;
c = fossil_strcmp(zName, aMap[mid].zName);
if( c==0 ){
*pIndex = mid;
return 0;
}else if( c<0 ){
upr = mid - 1;
}else{
lwr = mid + 1;
}
}
for(m=cnt=0, i=upr-2; cnt<2 && i<=upr+3 && i<nMap; i++){
if( i<iBegin ) continue;
if( strncmp(zName, aMap[i].zName, n)==0 ){
m = i;
cnt++;
}
}
if( cnt==1 ){
*pIndex = m;
|
| ︙ | ︙ | |||
653 654 655 656 657 658 659 |
}
zCmdName = g.argv[1];
}
#ifndef _WIN32
if( !is_valid_fd(2) ) fossil_panic("file descriptor 2 not open");
/* if( is_valid_fd(3) ) fossil_warning("file descriptor 3 is open"); */
#endif
| | < < | 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 |
}
zCmdName = g.argv[1];
}
#ifndef _WIN32
if( !is_valid_fd(2) ) fossil_panic("file descriptor 2 not open");
/* if( is_valid_fd(3) ) fossil_warning("file descriptor 3 is open"); */
#endif
rc = name_search(zCmdName, aCommand, count(aCommand), FOSSIL_FIRST_CMD, &idx);
if( rc==1 ){
#ifdef FOSSIL_ENABLE_TH1_HOOKS
if( !g.isHTTP && !g.fNoThHook ){
rc = Th_CommandHook(zCmdName, 0);
}else{
rc = TH_OK;
}
|
| ︙ | ︙ | |||
1015 1016 1017 1018 1019 1020 1021 |
if(isPage){
zCmdOrPage = "page";
zCmdOrPagePlural = "pages";
}else{
zCmdOrPage = "command";
zCmdOrPagePlural = "commands";
}
| | | 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 |
if(isPage){
zCmdOrPage = "page";
zCmdOrPagePlural = "pages";
}else{
zCmdOrPage = "command";
zCmdOrPagePlural = "commands";
}
rc = name_search(g.argv[2], aCommand, count(aCommand), 0, &idx);
if( rc==1 ){
fossil_print("unknown %s: %s\nAvailable %s:\n",
zCmdOrPage, g.argv[2], zCmdOrPagePlural);
command_list(0, isPage ? CMDFLAG_WEBPAGE : (0xff & ~CMDFLAG_WEBPAGE));
fossil_exit(1);
}else if( rc==2 ){
fossil_print("ambiguous %s prefix: %s\nMatching %s:\n",
|
| ︙ | ︙ | |||
1059 1060 1061 1062 1063 1064 1065 |
style_header("Command-line Help");
if( zCmd ){
int rc, idx;
char *z, *s, *d;
char const * zCmdOrPage = ('/'==*zCmd) ? "page" : "command";
style_submenu_element("Command-List", "Command-List", "%s/help", g.zTop);
@ <h1>The "%s(zCmd)" %s(zCmdOrPage):</h1>
| | | 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 |
style_header("Command-line Help");
if( zCmd ){
int rc, idx;
char *z, *s, *d;
char const * zCmdOrPage = ('/'==*zCmd) ? "page" : "command";
style_submenu_element("Command-List", "Command-List", "%s/help", g.zTop);
@ <h1>The "%s(zCmd)" %s(zCmdOrPage):</h1>
rc = name_search(zCmd, aCommand, count(aCommand), 0, &idx);
if( rc==1 ){
@ unknown command: %s(zCmd)
}else if( rc==2 ){
@ ambiguous command prefix: %s(zCmd)
}else{
z = (char*)aCmdHelp[idx].zText;
if( z==0 ){
|
| ︙ | ︙ | |||
1561 1562 1563 1564 1565 1566 1567 |
}
#endif
}
/* Locate the method specified by the path and execute the function
** that implements that method.
*/
| | | 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 |
}
#endif
}
/* Locate the method specified by the path and execute the function
** that implements that method.
*/
if( name_search(g.zPath, aWebpage, count(aWebpage), 0, &idx) ){
#ifdef FOSSIL_ENABLE_JSON
if(g.json.isJsonMode){
json_err(FSL_JSON_E_RESOURCE_NOT_FOUND,NULL,0);
}else
#endif
{
#ifdef FOSSIL_ENABLE_TH1_HOOKS
|
| ︙ | ︙ |
Changes to src/mkindex.c.
| ︙ | ︙ | |||
281 282 283 284 285 286 287 |
printf(
"static const NameMap aCommand[] = {\n"
);
for(i=0; i<nFixed /*&& aEntry[i].eType==1*/; i++){
const char *z = aEntry[i].zPath;
int n = strlen(z);
int cmdFlags = (1==aEntry[i].eType) ? 0x01 : 0x08;
| | > | 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
printf(
"static const NameMap aCommand[] = {\n"
);
for(i=0; i<nFixed /*&& aEntry[i].eType==1*/; i++){
const char *z = aEntry[i].zPath;
int n = strlen(z);
int cmdFlags = (1==aEntry[i].eType) ? 0x01 : 0x08;
if( 0x01==cmdFlags ){
if( z[n-1]=='*' ){
n--;
cmdFlags = 0x02;
}else if( memcmp(z, "test-", 5)==0 ){
cmdFlags = 0x04;
}
}
if( aEntry[i].zIf ) printf("%s", aEntry[i].zIf);
printf(" { \"%s%.*s\",%*s %s,%*s %d },\n",
(0x08 & cmdFlags) ? "/" : "",
n, z,
25-n, "",
aEntry[i].zFunc,
(int)(35-strlen(aEntry[i].zFunc)), "",
cmdFlags
);
if( aEntry[i].zIf ) printf("#endif\n");
}
printf("};\n");
printf("#define FOSSIL_FIRST_CMD (sizeof(aWebpage)/sizeof(aWebpage[0]))\n");
for(i=0; i<nFixed; i++){
char *z = aEntry[i].zHelp;
if( z && z[0] ){
if( aEntry[i].zIf ) printf("%s", aEntry[i].zIf);
printf("static const char zHelp_%s[] = \n", aEntry[i].zFunc);
printf(" \"");
while( *z ){
|
| ︙ | ︙ |