CVSTrac Legacy Code

Check-in [167d2fdefd]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:(#789) searching on a ticket or checking number in the appropriate format will take the user directly to the appropriate page. Implemented =is_ticket()= and =is_chng()= functions to simplify the process and use them in /cvstrac/format.c as well.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:167d2fdefdab117fce8add29c75b82f62e3842c6
User & Date: cpb 2009-12-06 15:57:53
Context
2009-12-09
15:42
minor fixups to the RSS HTML, cleans up inspections a touch check-in: d3b0aa6518 user: cpb tags: trunk
2009-12-06
15:57
(#789) searching on a ticket or checking number in the appropriate format will take the user directly to the appropriate page. Implemented =is_ticket()= and =is_chng()= functions to simplify the process and use them in /cvstrac/format.c as well. check-in: 167d2fdefd user: cpb tags: trunk
2009-10-24
11:23
(#810) identify milestones in the ticket history check-in: c0f2ef4f33 user: cpb tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to format.c.

758
759
760
761
762
763
764













































765
766
767
768
769
770
771
....
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
....
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
    cgi_printf("<");
    zText += i+1;
    nText -= i+1;
    i = -1;
  }
  cgi_append_content(zText,i);
}














































/*
** Output a formatted ticket link
*/
void output_ticket(int tn, int rn){
  @ <span class="ticket">\
  if( g.okRead ){
................................................................................
  int inTab = 0;
  int v;
  int wordStart = 1;     /* At the start of a word */
  int lineStart = 1;     /* At the start of a line */
  int paraStart = 1;     /* At the start of a paragraph */
  const char *zEndB;     /* Text used to end a run of bold */
  char **azAttach;       /* Attachments to zPageId */
  static int once = 1;
  static int nTicket, nCommit;
  if( once ){
    nTicket = atoi(db_short_query("SELECT max(tn) FROM ticket"));
    nCommit = atoi(db_short_query("SELECT max(cn) FROM chng"));
    once = 0;
  }

  i = 0;
  aList[0] = 0;
  azAttach = 0;
  zEndB = "";
  while( zText[i] ){
    char *z;
................................................................................
        continue;
      }

      /* If word is of the form "#NNN" where NNN is a sequence of digits,
      ** then output a ticket number. output_ticket() will take care of
      ** ticket permissions.
      */
      if( c=='#' && (j = ndigit(&zText[i+1]))>0 
                 && is_eow(&zText[i+1+j],0)
                 && (v = atoi(&zText[i+1]))>0 && v<=nTicket ){
        put_htmlized_text(&zText, i);
        output_ticket(v,0);
        zText += j;
        if( *zText ) zText++;
        i = 0;
        wordStart = lineStart = paraStart = 0;
        continue;
      }

      /* If the word is of the form "[NNN]" where NNN is a checkin number,
      ** then generate a hyperlink to check-in NNN. output_chng() will take
      ** care of checkout permission checks.
      */
      if( c=='[' && (j = ndigit(&zText[i+1]))>0
                 && is_eow(&zText[i+j+2],0)
                 && (v = atoi(&zText[i+1]))>0 && v<=nCommit 
                 && zText[i+j+1]==']' ){
        put_htmlized_text(&zText, i);
        output_chng(v);
        zText += j+1;
        if( *zText ) zText++;
        i  = 0;
        wordStart = lineStart = paraStart = 0;
        continue;
      }
    } /* end if( wordStart && !inPre ) */








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







<
<
<
<
<
<
<







 







|
<
<


|










|
<
<
<


|







758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
....
1188
1189
1190
1191
1192
1193
1194







1195
1196
1197
1198
1199
1200
1201
....
1704
1705
1706
1707
1708
1709
1710
1711


1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725



1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
    cgi_printf("&lt;");
    zText += i+1;
    nText -= i+1;
    i = -1;
  }
  cgi_append_content(zText,i);
}

/*
** Return length of matching string if the given string is a ticket
** identifier of down #nnn. *rtn gets the ticket number.
*/
int is_ticket(const char *z, int *rtn){
  int j = 0;
  int v = 0;
  static int nTicket = 0;
  static int once = 0;
  if( !once ) {
    nTicket = atoi(db_short_query("SELECT max(tn) FROM ticket"));
    once = 1;
  }
  if( z[0]=='#' && (j = ndigit(&z[1]))>0
                && is_eow(&z[1+j],0)
                && (v = atoi(&z[1]))>0 && v<=nTicket){
    if( rtn ) *rtn = v;
    return j+1;
  }
  return 0;
}

/*
** Return length of matching string if the given string is a checkin
** identifier of down #nnn. *rcn gets the checkin number.
*/
int is_chng(const char *z, int *rcn){
  int j = 0;
  int v = 0;
  static int nCommit = 0;
  static int once = 0;
  if( !once ) {
    nCommit = atoi(db_short_query("SELECT max(cn) FROM chng"));
    once = 1;
  }
  if( z[0]=='[' && (j = ndigit(&z[1]))>0
             && is_eow(&z[j+2],0)
             && (v = atoi(&z[1]))>0 && v<=nCommit 
             && z[j+1]==']' ){
    if( rcn ) *rcn = v;
    return j+2;
  }
  return 0;
}

/*
** Output a formatted ticket link
*/
void output_ticket(int tn, int rn){
  @ <span class="ticket">\
  if( g.okRead ){
................................................................................
  int inTab = 0;
  int v;
  int wordStart = 1;     /* At the start of a word */
  int lineStart = 1;     /* At the start of a line */
  int paraStart = 1;     /* At the start of a paragraph */
  const char *zEndB;     /* Text used to end a run of bold */
  char **azAttach;       /* Attachments to zPageId */








  i = 0;
  aList[0] = 0;
  azAttach = 0;
  zEndB = "";
  while( zText[i] ){
    char *z;
................................................................................
        continue;
      }

      /* If word is of the form "#NNN" where NNN is a sequence of digits,
      ** then output a ticket number. output_ticket() will take care of
      ** ticket permissions.
      */
      if( (j = is_ticket(&zText[i],&v))>0 ){


        put_htmlized_text(&zText, i);
        output_ticket(v,0);
        zText += j-1;
        if( *zText ) zText++;
        i = 0;
        wordStart = lineStart = paraStart = 0;
        continue;
      }

      /* If the word is of the form "[NNN]" where NNN is a checkin number,
      ** then generate a hyperlink to check-in NNN. output_chng() will take
      ** care of checkout permission checks.
      */
      if( (j = is_chng(&zText[i],&v))>0 ){



        put_htmlized_text(&zText, i);
        output_chng(v);
        zText += j-1;
        if( *zText ) zText++;
        i  = 0;
        wordStart = lineStart = paraStart = 0;
        continue;
      }
    } /* end if( wordStart && !inPre ) */

Changes to search.c.

329
330
331
332
333
334
335

336
337
338
339
340
341
342
...
350
351
352
353
354
355
356
357
358
359






360
361
362
363
364
365
366
*/
void search_page(void){
  int srchTkt = PD("t","0")[0]!='0';
  int srchCkin = PD("c","0")[0]!='0';
  int srchWiki = PD("w","0")[0]!='0';
  int srchFile = PD("f","0")[0]!='0';
  int nPage = atoi(PD("p","0"));

  const char *zPattern;
  char **azResult = 0;
  char *zPage;
  sqlite3 *db;
  char zSql[10000];

  login_check_credentials();
................................................................................
  if( !g.okRead ) srchTkt = 0;
  if( !g.okCheckout ) srchFile = srchCkin = 0;
  if( !g.okRdWiki ) srchWiki = 0;
  if( srchTkt==0 && srchCkin==0 && srchWiki==0 && srchFile==0 ){
    login_needed();
    return;
  }
  if( zPattern && zPattern[0] && strlen(zPattern)<100 ){
    int i = 0;
    char *zConnect = " (";







    db = db_open();
    db_add_functions();
    sqlite3_create_function(db, "highlight", -1, SQLITE_ANY, 0,
                            highlightFunc, 0, 0);

    appendf(zSql,&i,sizeof(zSql),"SELECT type, score, obj, title, body FROM");







>







 







|


>
>
>
>
>
>







329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
...
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
*/
void search_page(void){
  int srchTkt = PD("t","0")[0]!='0';
  int srchCkin = PD("c","0")[0]!='0';
  int srchWiki = PD("w","0")[0]!='0';
  int srchFile = PD("f","0")[0]!='0';
  int nPage = atoi(PD("p","0"));
  int len = 0;
  const char *zPattern;
  char **azResult = 0;
  char *zPage;
  sqlite3 *db;
  char zSql[10000];

  login_check_credentials();
................................................................................
  if( !g.okRead ) srchTkt = 0;
  if( !g.okCheckout ) srchFile = srchCkin = 0;
  if( !g.okRdWiki ) srchWiki = 0;
  if( srchTkt==0 && srchCkin==0 && srchWiki==0 && srchFile==0 ){
    login_needed();
    return;
  }
  if( zPattern && zPattern[0] && (len = strlen(zPattern))<100 ){
    int i = 0;
    char *zConnect = " (";

    if( len == is_ticket(zPattern,&i) ){
      cgi_redirect(mprintf("tktview?tn=%d", i));
    }else if( len == is_chng(zPattern,&i) ){
      cgi_redirect(mprintf("chngview?cn=%d", i));
    }

    db = db_open();
    db_add_functions();
    sqlite3_create_function(db, "highlight", -1, SQLITE_ANY, 0,
                            highlightFunc, 0, 0);

    appendf(zSql,&i,sizeof(zSql),"SELECT type, score, obj, title, body FROM");

Changes to wikiinit.c.

689
690
691
692
693
694
695
696



697

698
699
700
701
702
703
704
@ 
@ Additionally, it can search for attachment and repository filenames. This is a
@ convenient way to navigate to files deep in a repository.
@ 
@ CVSTrac _cannot_ currently do full-text searches on the contents of files.
@ 
@ **Search Syntax**
@ 



@ There is not special syntax. The search algorithm takes all the search keywords

@ and scores them against the various database fields. Results are returned in
@ decreasing score order.
;
static const char zCvstracTicket[] =
@ ***CVSTrac Tickets***
@ 
@ A ticket is an object describing and tracking a bug, feature request, project,







|
>
>
>
|
>







689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
@ 
@ Additionally, it can search for attachment and repository filenames. This is a
@ convenient way to navigate to files deep in a repository.
@ 
@ CVSTrac _cannot_ currently do full-text searches on the contents of files.
@ 
@ **Search Syntax**
@
@ Entering a valid ticket ({quote:#nnn}) or checkin number ({quote:[nnn]})
@ will take you directly to the appropriate page.
@ 
@ Otherwise, there is not special syntax. The search algorithm takes all
@ the search keywords
@ and scores them against the various database fields. Results are returned in
@ decreasing score order.
;
static const char zCvstracTicket[] =
@ ***CVSTrac Tickets***
@ 
@ A ticket is an object describing and tracking a bug, feature request, project,