Fossil SCM

Cleanup of help_page() in preparation for merging with trunk.

drh 2010-11-09 01:17 UTC StvPrivateHook2
Commit a298a0e2f95c001a38f73a907f1f401ad5e12746
1 file changed +95 -122
+95 -122
--- src/main.c
+++ src/main.c
@@ -657,132 +657,105 @@
657657
/*
658658
** WEBPAGE: help
659659
** URL: /help?cmd=CMD
660660
*/
661661
void help_page(void){
662
- const char * zCmd = P("cmd");
663
-
664
- style_header("Command line help %s%s",zCmd?" - ":"",zCmd?zCmd:"");
665
- if( zCmd && zCmd[0] && strcmp(zCmd,"test") ){
666
- int rc, idx;
667
-
668
- rc = name_search(zCmd, aCommand, count(aCommand), &idx);
669
- if( rc==1 ){
670
- @ <h1>unknown command: %s(zCmd)</h1>
671
- }else if( rc==2 ){
672
- @ <h1>ambiguous command prefix: %s(zCmd)</h1>
673
- }else{
674
- char *zSrc, *zDest;
675
- int src,dest,len;
676
-
677
- @ <h1>%s(aCommand[idx].zName)</h1>
678
- zSrc = (char*)aCmdHelp[idx];
679
- if( zSrc==0 || *zSrc==0 ){
680
- @ no help available for the %s(aCommand[idx].zName) command
681
- }else{
682
- len = strlen(zSrc);
683
- zDest = malloc(len+1);
684
- for(src=dest=0;zSrc[src];){
685
- if( zSrc[src]=='%' && strncmp(zSrc+src, "%fossil", 7)==0 ){
686
- src++; /* skip % for fossil argv[0] expansion */
687
- }else if( zSrc[src]=='<' && strncmp(zSrc+src, "</a>", 3)==0 ){
688
- src += 4;
689
- zDest[dest++]='<';
690
- zDest[dest++]='/';
691
- zDest[dest++]='a';
692
- zDest[dest++]='>';
693
- zDest[dest++]='"';
694
- }else if( zSrc[src]=='<' && strncmp(zSrc+src, "<a ", 3)==0 ){
695
- len += 2;
696
- zDest=realloc(zDest,len);
697
- zDest[dest++]='"';
698
- while( zSrc[src] && zSrc[src]!='>' ){
699
- zDest[dest++]=zSrc[src++];
700
- }
701
- if( zSrc[src] ) zDest[dest++]=zSrc[src++];
702
- }else if( zSrc[src]=='<' && strncmp(zSrc+src, "<a>", 3)==0 ){
703
- /* found an internal command cross reference,
704
- ** create an additional link
705
- */
706
- int start;
707
-
708
- len+=80;
709
- zDest=realloc(zDest,len);
710
- zDest[dest++]='"';
711
- zDest[dest++]=zSrc[src++]; /* < */
712
- zDest[dest++]=zSrc[src++]; /* a */
713
- zDest[dest++]=' ';
714
- zDest[dest++]='h';
715
- zDest[dest++]='r';
716
- zDest[dest++]='e';
717
- zDest[dest++]='f';
718
- zDest[dest++]='=';
719
- zDest[dest++]='"';
720
- zDest[dest++]='h';
721
- zDest[dest++]='e';
722
- zDest[dest++]='l';
723
- zDest[dest++]='p';
724
- zDest[dest++]='?';
725
- zDest[dest++]='c';
726
- zDest[dest++]='m';
727
- zDest[dest++]='d';
728
- zDest[dest++]='=';
729
- start = src+1;
730
- for( src=start; zSrc[src] && zSrc[src]!='<'; ){
731
- zDest[dest++]=zSrc[src++]; /* command name */
732
- }
733
- zDest[dest++]='"';
734
- zDest[dest++]='>';
735
- for( src=start; zSrc[src] && zSrc[src]!='<'; ){
736
- zDest[dest++]=zSrc[src++]; /* command name */
737
- }
738
- }else{
739
- zDest[dest++] = zSrc[src++];
740
- }
741
- }
742
- zDest[dest] = 0;
743
- @ <div class="cmdhelp">%s(zDest)</div>
744
- free(zDest);
745
- @ <hr/>additional information may be found in the web documentation:
746
- @ <a href="http://www.fossil-scm.org/fossil/doc/tip/www/cmd_%s(aCommand[idx].zName).wiki">
747
- @ cmd_%s(aCommand[idx].zName)</a>,
748
- }
749
- }
750
- @ see also the list of
751
- @ <a href="help">available commands</a> in fossil
752
- @ version %s(MANIFEST_VERSION" "MANIFEST_DATE) UTC
753
- }else{
754
- int nCol, nRow, i, ignored, cnt, showTest;
755
-
756
- /* detect, if we show normal or test commands */
757
- showTest = ( zCmd && !strncmp(zCmd,"test",4) );
758
- for( i=0,ignored=0; i<count(aCommand); i++){
759
- if( (strncmp(aCommand[i].zName,"test",4)==0) ^ showTest ) ignored++;
760
- }
761
- nCol = 4;
762
- nRow = (count(aCommand)-ignored+nCol-1)/nCol;
763
- @ <h1>Available commands</h1>
764
- @ <table class="browser"><tr><td class="browser"><ul class="browser">
765
- for( i=cnt=0; i<count(aCommand); i++ ){
766
- if( cnt==nRow ){
767
- @ </ul></td><td class="browser"><ul class="browser">
768
- cnt=0;
769
- }
770
- if( (strncmp(aCommand[i].zName,"test",4)==0) ^ showTest ) continue;
771
- @ <li><kbd><a href="help?cmd=%s(aCommand[i].zName)">
772
- @ %s(aCommand[i].zName)</a></kbd></li>
773
- cnt++;
774
- }
775
- @ </ul></td></tr></table>
776
- if( showTest ){
777
- @ <a href="help">show standard commands</a>
778
- }else{
779
- @ <a class="hidden" href="help?cmd=test">show test commands</a>
780
- }
781
- @ <hr/>fossil version %s(MANIFEST_VERSION" "MANIFEST_DATE) UTC
782
- }
783
- style_footer();
662
+ const char * zCmd = P("cmd");
663
+
664
+ style_header("Command line help %s%s",zCmd?" - ":"",zCmd?zCmd:"");
665
+ if( zCmd && zCmd[0] && strcmp(zCmd,"test") ){
666
+ int rc, idx;
667
+
668
+ rc = name_search(zCmd, aCommand, count(aCommand), &idx);
669
+ if( rc==1 ){
670
+ @ <h1>unknown command: %s(zCmd)</h1>
671
+ }else if( rc==2 ){
672
+ @ <h1>ambiguous command prefix: %s(zCmd)</h1>
673
+ }else{
674
+ const char *zHelp;
675
+ int i;
676
+
677
+ zHelp = aCmdHelp[idx];
678
+ @ <h1>%s(aCommand[idx].zName)</h1>
679
+ if( zHelp==0 || zHelp[0]==0 ){
680
+ @ no help available for the %s(aCommand[idx].zName) command
681
+ }else{
682
+ int c;
683
+ @ <div class="cmdhelp">
684
+ for(i=0; (c = zHelp[i])!=0; i++){
685
+ if( c=='%' && memcmp(zHelp+i, "%fossil", 7)==0 ){
686
+ /* Skip over the "%" */
687
+ cgi_append_content(zHelp, i);
688
+ i++;
689
+ zHelp += i;
690
+ i = 0;
691
+ }else if( c=='<' && memcmp(zHelp+i, "</a>", 3)==0 ){
692
+ cgi_append_content(zHelp, i+4);
693
+ zHelp += i+4;
694
+ i = -1;
695
+ cgi_append_content("\"", 1);
696
+ }else if( c=='<' && memcmp(zHelp+i, "<a ", 3)==0 ){
697
+ cgi_append_content(zHelp, i);
698
+ cgi_append_content("\"", 1);
699
+ zHelp += i;
700
+ i = 0;
701
+ }else if( c=='<' && strncmp(zHelp+i, "<a>", 3)==0 ){
702
+ /* found an internal command cross reference,
703
+ ** create an additional link
704
+ */
705
+ cgi_append_content(zHelp, i);
706
+ cgi_append_content("\"<a href=\"help?cmd=", -1);
707
+ zHelp += i+3;
708
+ i = 0;
709
+ while( zHelp[i] && memcmp(zHelp+i,"</a>",4)!=0 ){
710
+ i++;
711
+ }
712
+ cgi_append_content(zHelp, i);
713
+ cgi_append_content("\">", -1);
714
+ cgi_append_content(zHelp, i);
715
+ cgi_append_content("</a>\"", -1);
716
+ zHelp += i+4;
717
+ i = -1;
718
+ }
719
+ }
720
+ cgi_append_content(zHelp, i);
721
+ @ </div>
722
+ }
723
+ }
724
+ @ see also the list of
725
+ @ <a href="help">available commands</a> in fossil
726
+ @ version %s(MANIFEST_VERSION" "MANIFEST_DATE) UTC
727
+ }else{
728
+ int nCol, nRow, i, ignored, cnt, showTest;
729
+
730
+ /* detect, if we show normal or test commands */
731
+ showTest = ( zCmd && !strncmp(zCmd,"test",4) );
732
+ for( i=0,ignored=0; i<count(aCommand); i++){
733
+ if( (strncmp(aCommand[i].zName,"test",4)==0) ^ showTest ) ignored++;
734
+ }
735
+ nCol = 4;
736
+ nRow = (count(aCommand)-ignored+nCol-1)/nCol;
737
+ @ <h1>Available commands</h1>
738
+ @ <table class="browser"><tr><td class="browser"><ul class="browser">
739
+ for( i=cnt=0; i<count(aCommand); i++ ){
740
+ if( cnt==nRow ){
741
+ @ </ul></td><td class="browser"><ul class="browser">
742
+ cnt=0;
743
+ }
744
+ if( (strncmp(aCommand[i].zName,"test",4)==0) ^ showTest ) continue;
745
+ @ <li><kbd><a href="help?cmd=%s(aCommand[i].zName)">
746
+ @ %s(aCommand[i].zName)</a></kbd></li>
747
+ cnt++;
748
+ }
749
+ @ </ul></td></tr></table>
750
+ if( showTest ){
751
+ @ <a href="help">show standard commands</a>
752
+ }else{
753
+ @ <a class="hidden" href="help?cmd=test">show test commands</a>
754
+ }
755
+ }
756
+ style_footer();
784757
}
785758
786759
/*
787760
** Set the g.zBaseURL value to the full URL for the toplevel of
788761
** the fossil tree. Set g.zTop to g.zBaseURL without the
789762
--- src/main.c
+++ src/main.c
@@ -657,132 +657,105 @@
657 /*
658 ** WEBPAGE: help
659 ** URL: /help?cmd=CMD
660 */
661 void help_page(void){
662 const char * zCmd = P("cmd");
663
664 style_header("Command line help %s%s",zCmd?" - ":"",zCmd?zCmd:"");
665 if( zCmd && zCmd[0] && strcmp(zCmd,"test") ){
666 int rc, idx;
667
668 rc = name_search(zCmd, aCommand, count(aCommand), &idx);
669 if( rc==1 ){
670 @ <h1>unknown command: %s(zCmd)</h1>
671 }else if( rc==2 ){
672 @ <h1>ambiguous command prefix: %s(zCmd)</h1>
673 }else{
674 char *zSrc, *zDest;
675 int src,dest,len;
676
677 @ <h1>%s(aCommand[idx].zName)</h1>
678 zSrc = (char*)aCmdHelp[idx];
679 if( zSrc==0 || *zSrc==0 ){
680 @ no help available for the %s(aCommand[idx].zName) command
681 }else{
682 len = strlen(zSrc);
683 zDest = malloc(len+1);
684 for(src=dest=0;zSrc[src];){
685 if( zSrc[src]=='%' && strncmp(zSrc+src, "%fossil", 7)==0 ){
686 src++; /* skip % for fossil argv[0] expansion */
687 }else if( zSrc[src]=='<' && strncmp(zSrc+src, "</a>", 3)==0 ){
688 src += 4;
689 zDest[dest++]='<';
690 zDest[dest++]='/';
691 zDest[dest++]='a';
692 zDest[dest++]='>';
693 zDest[dest++]='"';
694 }else if( zSrc[src]=='<' && strncmp(zSrc+src, "<a ", 3)==0 ){
695 len += 2;
696 zDest=realloc(zDest,len);
697 zDest[dest++]='"';
698 while( zSrc[src] && zSrc[src]!='>' ){
699 zDest[dest++]=zSrc[src++];
700 }
701 if( zSrc[src] ) zDest[dest++]=zSrc[src++];
702 }else if( zSrc[src]=='<' && strncmp(zSrc+src, "<a>", 3)==0 ){
703 /* found an internal command cross reference,
704 ** create an additional link
705 */
706 int start;
707
708 len+=80;
709 zDest=realloc(zDest,len);
710 zDest[dest++]='"';
711 zDest[dest++]=zSrc[src++]; /* < */
712 zDest[dest++]=zSrc[src++]; /* a */
713 zDest[dest++]=' ';
714 zDest[dest++]='h';
715 zDest[dest++]='r';
716 zDest[dest++]='e';
717 zDest[dest++]='f';
718 zDest[dest++]='=';
719 zDest[dest++]='"';
720 zDest[dest++]='h';
721 zDest[dest++]='e';
722 zDest[dest++]='l';
723 zDest[dest++]='p';
724 zDest[dest++]='?';
725 zDest[dest++]='c';
726 zDest[dest++]='m';
727 zDest[dest++]='d';
728 zDest[dest++]='=';
729 start = src+1;
730 for( src=start; zSrc[src] && zSrc[src]!='<'; ){
731 zDest[dest++]=zSrc[src++]; /* command name */
732 }
733 zDest[dest++]='"';
734 zDest[dest++]='>';
735 for( src=start; zSrc[src] && zSrc[src]!='<'; ){
736 zDest[dest++]=zSrc[src++]; /* command name */
737 }
738 }else{
739 zDest[dest++] = zSrc[src++];
740 }
741 }
742 zDest[dest] = 0;
743 @ <div class="cmdhelp">%s(zDest)</div>
744 free(zDest);
745 @ <hr/>additional information may be found in the web documentation:
746 @ <a href="http://www.fossil-scm.org/fossil/doc/tip/www/cmd_%s(aCommand[idx].zName).wiki">
747 @ cmd_%s(aCommand[idx].zName)</a>,
748 }
749 }
750 @ see also the list of
751 @ <a href="help">available commands</a> in fossil
752 @ version %s(MANIFEST_VERSION" "MANIFEST_DATE) UTC
753 }else{
754 int nCol, nRow, i, ignored, cnt, showTest;
755
756 /* detect, if we show normal or test commands */
757 showTest = ( zCmd && !strncmp(zCmd,"test",4) );
758 for( i=0,ignored=0; i<count(aCommand); i++){
759 if( (strncmp(aCommand[i].zName,"test",4)==0) ^ showTest ) ignored++;
760 }
761 nCol = 4;
762 nRow = (count(aCommand)-ignored+nCol-1)/nCol;
763 @ <h1>Available commands</h1>
764 @ <table class="browser"><tr><td class="browser"><ul class="browser">
765 for( i=cnt=0; i<count(aCommand); i++ ){
766 if( cnt==nRow ){
767 @ </ul></td><td class="browser"><ul class="browser">
768 cnt=0;
769 }
770 if( (strncmp(aCommand[i].zName,"test",4)==0) ^ showTest ) continue;
771 @ <li><kbd><a href="help?cmd=%s(aCommand[i].zName)">
772 @ %s(aCommand[i].zName)</a></kbd></li>
773 cnt++;
774 }
775 @ </ul></td></tr></table>
776 if( showTest ){
777 @ <a href="help">show standard commands</a>
778 }else{
779 @ <a class="hidden" href="help?cmd=test">show test commands</a>
780 }
781 @ <hr/>fossil version %s(MANIFEST_VERSION" "MANIFEST_DATE) UTC
782 }
783 style_footer();
784 }
785
786 /*
787 ** Set the g.zBaseURL value to the full URL for the toplevel of
788 ** the fossil tree. Set g.zTop to g.zBaseURL without the
789
--- src/main.c
+++ src/main.c
@@ -657,132 +657,105 @@
657 /*
658 ** WEBPAGE: help
659 ** URL: /help?cmd=CMD
660 */
661 void help_page(void){
662 const char * zCmd = P("cmd");
663
664 style_header("Command line help %s%s",zCmd?" - ":"",zCmd?zCmd:"");
665 if( zCmd && zCmd[0] && strcmp(zCmd,"test") ){
666 int rc, idx;
667
668 rc = name_search(zCmd, aCommand, count(aCommand), &idx);
669 if( rc==1 ){
670 @ <h1>unknown command: %s(zCmd)</h1>
671 }else if( rc==2 ){
672 @ <h1>ambiguous command prefix: %s(zCmd)</h1>
673 }else{
674 const char *zHelp;
675 int i;
676
677 zHelp = aCmdHelp[idx];
678 @ <h1>%s(aCommand[idx].zName)</h1>
679 if( zHelp==0 || zHelp[0]==0 ){
680 @ no help available for the %s(aCommand[idx].zName) command
681 }else{
682 int c;
683 @ <div class="cmdhelp">
684 for(i=0; (c = zHelp[i])!=0; i++){
685 if( c=='%' && memcmp(zHelp+i, "%fossil", 7)==0 ){
686 /* Skip over the "%" */
687 cgi_append_content(zHelp, i);
688 i++;
689 zHelp += i;
690 i = 0;
691 }else if( c=='<' && memcmp(zHelp+i, "</a>", 3)==0 ){
692 cgi_append_content(zHelp, i+4);
693 zHelp += i+4;
694 i = -1;
695 cgi_append_content("\"", 1);
696 }else if( c=='<' && memcmp(zHelp+i, "<a ", 3)==0 ){
697 cgi_append_content(zHelp, i);
698 cgi_append_content("\"", 1);
699 zHelp += i;
700 i = 0;
701 }else if( c=='<' && strncmp(zHelp+i, "<a>", 3)==0 ){
702 /* found an internal command cross reference,
703 ** create an additional link
704 */
705 cgi_append_content(zHelp, i);
706 cgi_append_content("\"<a href=\"help?cmd=", -1);
707 zHelp += i+3;
708 i = 0;
709 while( zHelp[i] && memcmp(zHelp+i,"</a>",4)!=0 ){
710 i++;
711 }
712 cgi_append_content(zHelp, i);
713 cgi_append_content("\">", -1);
714 cgi_append_content(zHelp, i);
715 cgi_append_content("</a>\"", -1);
716 zHelp += i+4;
717 i = -1;
718 }
719 }
720 cgi_append_content(zHelp, i);
721 @ </div>
722 }
723 }
724 @ see also the list of
725 @ <a href="help">available commands</a> in fossil
726 @ version %s(MANIFEST_VERSION" "MANIFEST_DATE) UTC
727 }else{
728 int nCol, nRow, i, ignored, cnt, showTest;
729
730 /* detect, if we show normal or test commands */
731 showTest = ( zCmd && !strncmp(zCmd,"test",4) );
732 for( i=0,ignored=0; i<count(aCommand); i++){
733 if( (strncmp(aCommand[i].zName,"test",4)==0) ^ showTest ) ignored++;
734 }
735 nCol = 4;
736 nRow = (count(aCommand)-ignored+nCol-1)/nCol;
737 @ <h1>Available commands</h1>
738 @ <table class="browser"><tr><td class="browser"><ul class="browser">
739 for( i=cnt=0; i<count(aCommand); i++ ){
740 if( cnt==nRow ){
741 @ </ul></td><td class="browser"><ul class="browser">
742 cnt=0;
743 }
744 if( (strncmp(aCommand[i].zName,"test",4)==0) ^ showTest ) continue;
745 @ <li><kbd><a href="help?cmd=%s(aCommand[i].zName)">
746 @ %s(aCommand[i].zName)</a></kbd></li>
747 cnt++;
748 }
749 @ </ul></td></tr></table>
750 if( showTest ){
751 @ <a href="help">show standard commands</a>
752 }else{
753 @ <a class="hidden" href="help?cmd=test">show test commands</a>
754 }
755 }
756 style_footer();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
757 }
758
759 /*
760 ** Set the g.zBaseURL value to the full URL for the toplevel of
761 ** the fossil tree. Set g.zTop to g.zBaseURL without the
762

Keyboard Shortcuts

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