Fossil SCM
Fix overlength source lines in diff.c. Raise limits and fix inappropriate use of memcmp() in mkindex.c.
Commit
df80ab0ce93c9ca0c963cf0cc19da5fc07146b74
Parent
cd822353fa6e4b8…
2 files changed
+21
-10
+7
-7
+21
-10
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -113,11 +113,11 @@ | ||
| 113 | 113 | int nEditAlloc; /* Space allocated for aEdit[] */ |
| 114 | 114 | DLine *aFrom; /* File on left side of the diff */ |
| 115 | 115 | int nFrom; /* Number of lines in aFrom[] */ |
| 116 | 116 | DLine *aTo; /* File on right side of the diff */ |
| 117 | 117 | int nTo; /* Number of lines in aTo[] */ |
| 118 | - int (*same_fn)(const DLine *, const DLine *); /* Function to be used for comparing */ | |
| 118 | + int (*same_fn)(const DLine*,const DLine*); /* comparison function */ | |
| 119 | 119 | }; |
| 120 | 120 | |
| 121 | 121 | /* |
| 122 | 122 | ** Return an array of DLine objects containing a pointer to the |
| 123 | 123 | ** start of each line and a hash of that line. The lower |
| @@ -131,11 +131,16 @@ | ||
| 131 | 131 | ** too long. |
| 132 | 132 | ** |
| 133 | 133 | ** Profiling show that in most cases this routine consumes the bulk of |
| 134 | 134 | ** the CPU time on a diff. |
| 135 | 135 | */ |
| 136 | -static DLine *break_into_lines(const char *z, int n, int *pnLine, u64 diffFlags){ | |
| 136 | +static DLine *break_into_lines( | |
| 137 | + const char *z, | |
| 138 | + int n, | |
| 139 | + int *pnLine, | |
| 140 | + u64 diffFlags | |
| 141 | +){ | |
| 137 | 142 | int nLine, i, j, k, s, x; |
| 138 | 143 | unsigned int h, h2; |
| 139 | 144 | DLine *a; |
| 140 | 145 | |
| 141 | 146 | /* Count the number of lines. Allocate space to hold |
| @@ -2090,11 +2095,16 @@ | ||
| 2090 | 2095 | /* |
| 2091 | 2096 | ** The input pParent is the next most recent ancestor of the file |
| 2092 | 2097 | ** being annotated. Do another step of the annotation. Return true |
| 2093 | 2098 | ** if additional annotation is required. |
| 2094 | 2099 | */ |
| 2095 | -static int annotation_step(Annotator *p, Blob *pParent, int iVers, u64 diffFlags){ | |
| 2100 | +static int annotation_step( | |
| 2101 | + Annotator *p, | |
| 2102 | + Blob *pParent, | |
| 2103 | + int iVers, | |
| 2104 | + u64 diffFlags | |
| 2105 | +){ | |
| 2096 | 2106 | int i, j; |
| 2097 | 2107 | int lnTo; |
| 2098 | 2108 | |
| 2099 | 2109 | /* Prepare the parent file to be diffed */ |
| 2100 | 2110 | p->c.aFrom = break_into_lines(blob_str(pParent), blob_size(pParent), |
| @@ -2134,12 +2144,12 @@ | ||
| 2134 | 2144 | return 0; |
| 2135 | 2145 | } |
| 2136 | 2146 | |
| 2137 | 2147 | |
| 2138 | 2148 | /* Annotation flags (any DIFF flag can be used as Annotation flag as well) */ |
| 2139 | -#define ANN_FILE_VERS (((u64)0x20)<<32) /* Show file vers rather than commit vers */ | |
| 2140 | -#define ANN_FILE_ANCEST (((u64)0x40)<<32) /* Prefer check-ins in the ANCESTOR table */ | |
| 2149 | +#define ANN_FILE_VERS (((u64)0x20)<<32) /* File vers not commit vers */ | |
| 2150 | +#define ANN_FILE_ANCEST (((u64)0x40)<<32) /* Prefer checkins in the ANCESTOR */ | |
| 2141 | 2151 | |
| 2142 | 2152 | /* |
| 2143 | 2153 | ** Compute a complete annotation on a file. The file is identified |
| 2144 | 2154 | ** by its filename number (filename.fnid) and check-in (mlink.mid). |
| 2145 | 2155 | */ |
| @@ -2443,15 +2453,16 @@ | ||
| 2443 | 2453 | ** the file was last modified. The "annotate" command shows line numbers |
| 2444 | 2454 | ** and omits the username. The "blame" and "praise" commands show the user |
| 2445 | 2455 | ** who made each check-in and omits the line number. |
| 2446 | 2456 | ** |
| 2447 | 2457 | ** Options: |
| 2448 | -** --filevers Show file version numbers rather than check-in versions | |
| 2449 | -** -l|--log List all versions analyzed | |
| 2450 | -** -n|--limit N Only look backwards in time by N versions | |
| 2451 | -** -w|--ignore-all-space Ignore white space when comparing lines | |
| 2452 | -** -Z|--ignore-trailing-space Ignore whitespace at line end | |
| 2458 | +** --filevers Show file version numbers rather than | |
| 2459 | +** check-in versions | |
| 2460 | +** -l|--log List all versions analyzed | |
| 2461 | +** -n|--limit N Only look backwards in time by N versions | |
| 2462 | +** -w|--ignore-all-space Ignore white space when comparing lines | |
| 2463 | +** -Z|--ignore-trailing-space Ignore whitespace at line end | |
| 2453 | 2464 | ** |
| 2454 | 2465 | ** See also: info, finfo, timeline |
| 2455 | 2466 | */ |
| 2456 | 2467 | void annotate_cmd(void){ |
| 2457 | 2468 | int fnid; /* Filename ID */ |
| 2458 | 2469 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -113,11 +113,11 @@ | |
| 113 | int nEditAlloc; /* Space allocated for aEdit[] */ |
| 114 | DLine *aFrom; /* File on left side of the diff */ |
| 115 | int nFrom; /* Number of lines in aFrom[] */ |
| 116 | DLine *aTo; /* File on right side of the diff */ |
| 117 | int nTo; /* Number of lines in aTo[] */ |
| 118 | int (*same_fn)(const DLine *, const DLine *); /* Function to be used for comparing */ |
| 119 | }; |
| 120 | |
| 121 | /* |
| 122 | ** Return an array of DLine objects containing a pointer to the |
| 123 | ** start of each line and a hash of that line. The lower |
| @@ -131,11 +131,16 @@ | |
| 131 | ** too long. |
| 132 | ** |
| 133 | ** Profiling show that in most cases this routine consumes the bulk of |
| 134 | ** the CPU time on a diff. |
| 135 | */ |
| 136 | static DLine *break_into_lines(const char *z, int n, int *pnLine, u64 diffFlags){ |
| 137 | int nLine, i, j, k, s, x; |
| 138 | unsigned int h, h2; |
| 139 | DLine *a; |
| 140 | |
| 141 | /* Count the number of lines. Allocate space to hold |
| @@ -2090,11 +2095,16 @@ | |
| 2090 | /* |
| 2091 | ** The input pParent is the next most recent ancestor of the file |
| 2092 | ** being annotated. Do another step of the annotation. Return true |
| 2093 | ** if additional annotation is required. |
| 2094 | */ |
| 2095 | static int annotation_step(Annotator *p, Blob *pParent, int iVers, u64 diffFlags){ |
| 2096 | int i, j; |
| 2097 | int lnTo; |
| 2098 | |
| 2099 | /* Prepare the parent file to be diffed */ |
| 2100 | p->c.aFrom = break_into_lines(blob_str(pParent), blob_size(pParent), |
| @@ -2134,12 +2144,12 @@ | |
| 2134 | return 0; |
| 2135 | } |
| 2136 | |
| 2137 | |
| 2138 | /* Annotation flags (any DIFF flag can be used as Annotation flag as well) */ |
| 2139 | #define ANN_FILE_VERS (((u64)0x20)<<32) /* Show file vers rather than commit vers */ |
| 2140 | #define ANN_FILE_ANCEST (((u64)0x40)<<32) /* Prefer check-ins in the ANCESTOR table */ |
| 2141 | |
| 2142 | /* |
| 2143 | ** Compute a complete annotation on a file. The file is identified |
| 2144 | ** by its filename number (filename.fnid) and check-in (mlink.mid). |
| 2145 | */ |
| @@ -2443,15 +2453,16 @@ | |
| 2443 | ** the file was last modified. The "annotate" command shows line numbers |
| 2444 | ** and omits the username. The "blame" and "praise" commands show the user |
| 2445 | ** who made each check-in and omits the line number. |
| 2446 | ** |
| 2447 | ** Options: |
| 2448 | ** --filevers Show file version numbers rather than check-in versions |
| 2449 | ** -l|--log List all versions analyzed |
| 2450 | ** -n|--limit N Only look backwards in time by N versions |
| 2451 | ** -w|--ignore-all-space Ignore white space when comparing lines |
| 2452 | ** -Z|--ignore-trailing-space Ignore whitespace at line end |
| 2453 | ** |
| 2454 | ** See also: info, finfo, timeline |
| 2455 | */ |
| 2456 | void annotate_cmd(void){ |
| 2457 | int fnid; /* Filename ID */ |
| 2458 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -113,11 +113,11 @@ | |
| 113 | int nEditAlloc; /* Space allocated for aEdit[] */ |
| 114 | DLine *aFrom; /* File on left side of the diff */ |
| 115 | int nFrom; /* Number of lines in aFrom[] */ |
| 116 | DLine *aTo; /* File on right side of the diff */ |
| 117 | int nTo; /* Number of lines in aTo[] */ |
| 118 | int (*same_fn)(const DLine*,const DLine*); /* comparison function */ |
| 119 | }; |
| 120 | |
| 121 | /* |
| 122 | ** Return an array of DLine objects containing a pointer to the |
| 123 | ** start of each line and a hash of that line. The lower |
| @@ -131,11 +131,16 @@ | |
| 131 | ** too long. |
| 132 | ** |
| 133 | ** Profiling show that in most cases this routine consumes the bulk of |
| 134 | ** the CPU time on a diff. |
| 135 | */ |
| 136 | static DLine *break_into_lines( |
| 137 | const char *z, |
| 138 | int n, |
| 139 | int *pnLine, |
| 140 | u64 diffFlags |
| 141 | ){ |
| 142 | int nLine, i, j, k, s, x; |
| 143 | unsigned int h, h2; |
| 144 | DLine *a; |
| 145 | |
| 146 | /* Count the number of lines. Allocate space to hold |
| @@ -2090,11 +2095,16 @@ | |
| 2095 | /* |
| 2096 | ** The input pParent is the next most recent ancestor of the file |
| 2097 | ** being annotated. Do another step of the annotation. Return true |
| 2098 | ** if additional annotation is required. |
| 2099 | */ |
| 2100 | static int annotation_step( |
| 2101 | Annotator *p, |
| 2102 | Blob *pParent, |
| 2103 | int iVers, |
| 2104 | u64 diffFlags |
| 2105 | ){ |
| 2106 | int i, j; |
| 2107 | int lnTo; |
| 2108 | |
| 2109 | /* Prepare the parent file to be diffed */ |
| 2110 | p->c.aFrom = break_into_lines(blob_str(pParent), blob_size(pParent), |
| @@ -2134,12 +2144,12 @@ | |
| 2144 | return 0; |
| 2145 | } |
| 2146 | |
| 2147 | |
| 2148 | /* Annotation flags (any DIFF flag can be used as Annotation flag as well) */ |
| 2149 | #define ANN_FILE_VERS (((u64)0x20)<<32) /* File vers not commit vers */ |
| 2150 | #define ANN_FILE_ANCEST (((u64)0x40)<<32) /* Prefer checkins in the ANCESTOR */ |
| 2151 | |
| 2152 | /* |
| 2153 | ** Compute a complete annotation on a file. The file is identified |
| 2154 | ** by its filename number (filename.fnid) and check-in (mlink.mid). |
| 2155 | */ |
| @@ -2443,15 +2453,16 @@ | |
| 2453 | ** the file was last modified. The "annotate" command shows line numbers |
| 2454 | ** and omits the username. The "blame" and "praise" commands show the user |
| 2455 | ** who made each check-in and omits the line number. |
| 2456 | ** |
| 2457 | ** Options: |
| 2458 | ** --filevers Show file version numbers rather than |
| 2459 | ** check-in versions |
| 2460 | ** -l|--log List all versions analyzed |
| 2461 | ** -n|--limit N Only look backwards in time by N versions |
| 2462 | ** -w|--ignore-all-space Ignore white space when comparing lines |
| 2463 | ** -Z|--ignore-trailing-space Ignore whitespace at line end |
| 2464 | ** |
| 2465 | ** See also: info, finfo, timeline |
| 2466 | */ |
| 2467 | void annotate_cmd(void){ |
| 2468 | int fnid; /* Filename ID */ |
| 2469 |
+7
-7
| --- src/mkindex.c | ||
| +++ src/mkindex.c | ||
| @@ -70,16 +70,16 @@ | ||
| 70 | 70 | } Entry; |
| 71 | 71 | |
| 72 | 72 | /* |
| 73 | 73 | ** Maximum number of entries |
| 74 | 74 | */ |
| 75 | -#define N_ENTRY 500 | |
| 75 | +#define N_ENTRY 5000 | |
| 76 | 76 | |
| 77 | 77 | /* |
| 78 | 78 | ** Maximum size of a help message |
| 79 | 79 | */ |
| 80 | -#define MX_HELP 25000 | |
| 80 | +#define MX_HELP 250000 | |
| 81 | 81 | |
| 82 | 82 | /* |
| 83 | 83 | ** Table of entries |
| 84 | 84 | */ |
| 85 | 85 | Entry aEntry[N_ENTRY]; |
| @@ -91,11 +91,11 @@ | ||
| 91 | 91 | int nHelp; |
| 92 | 92 | |
| 93 | 93 | /* |
| 94 | 94 | ** Most recently encountered #if |
| 95 | 95 | */ |
| 96 | -char zIf[200]; | |
| 96 | +char zIf[2000]; | |
| 97 | 97 | |
| 98 | 98 | /* |
| 99 | 99 | ** How many entries are used |
| 100 | 100 | */ |
| 101 | 101 | int nUsed; |
| @@ -154,11 +154,11 @@ | ||
| 154 | 154 | int len; |
| 155 | 155 | if( zLine[0]!='#' ) return; |
| 156 | 156 | for(i=1; isspace(zLine[i]); i++){} |
| 157 | 157 | if( zLine[i]==0 ) return; |
| 158 | 158 | len = strlen(&zLine[i]); |
| 159 | - if( memcmp(&zLine[i],"if",2)==0 ){ | |
| 159 | + if( strncmp(&zLine[i],"if",2)==0 ){ | |
| 160 | 160 | zIf[0] = '#'; |
| 161 | 161 | memcpy(&zIf[1], &zLine[i], len+1); |
| 162 | 162 | }else if( zLine[i]=='e' ){ |
| 163 | 163 | zIf[0] = 0; |
| 164 | 164 | } |
| @@ -173,12 +173,12 @@ | ||
| 173 | 173 | if( nUsed<=nFixed ) return; |
| 174 | 174 | if( strncmp(zLine, "**", 2)==0 |
| 175 | 175 | && isspace(zLine[2]) |
| 176 | 176 | && strlen(zLine)<sizeof(zHelp)-nHelp-1 |
| 177 | 177 | && nUsed>nFixed |
| 178 | - && memcmp(zLine,"** COMMAND:",11)!=0 | |
| 179 | - && memcmp(zLine,"** WEBPAGE:",11)!=0 | |
| 178 | + && strncmp(zLine,"** COMMAND:",11)!=0 | |
| 179 | + && strncmp(zLine,"** WEBPAGE:",11)!=0 | |
| 180 | 180 | ){ |
| 181 | 181 | if( zLine[2]=='\n' ){ |
| 182 | 182 | zHelp[nHelp++] = '\n'; |
| 183 | 183 | }else{ |
| 184 | 184 | if( strncmp(&zLine[3], "Usage: ", 6)==0 ) nHelp = 0; |
| @@ -287,11 +287,11 @@ | ||
| 287 | 287 | int cmdFlags = (1==aEntry[i].eType) ? 0x01 : 0x08; |
| 288 | 288 | if( 0x01==cmdFlags ){ |
| 289 | 289 | if( z[n-1]=='*' ){ |
| 290 | 290 | n--; |
| 291 | 291 | cmdFlags = 0x02; |
| 292 | - }else if( memcmp(z, "test-", 5)==0 ){ | |
| 292 | + }else if( strncmp(z, "test-", 5)==0 ){ | |
| 293 | 293 | cmdFlags = 0x04; |
| 294 | 294 | } |
| 295 | 295 | } |
| 296 | 296 | if( aEntry[i].zIf ) printf("%s", aEntry[i].zIf); |
| 297 | 297 | printf(" { \"%s%.*s\",%*s %s,%*s %d },\n", |
| 298 | 298 |
| --- src/mkindex.c | |
| +++ src/mkindex.c | |
| @@ -70,16 +70,16 @@ | |
| 70 | } Entry; |
| 71 | |
| 72 | /* |
| 73 | ** Maximum number of entries |
| 74 | */ |
| 75 | #define N_ENTRY 500 |
| 76 | |
| 77 | /* |
| 78 | ** Maximum size of a help message |
| 79 | */ |
| 80 | #define MX_HELP 25000 |
| 81 | |
| 82 | /* |
| 83 | ** Table of entries |
| 84 | */ |
| 85 | Entry aEntry[N_ENTRY]; |
| @@ -91,11 +91,11 @@ | |
| 91 | int nHelp; |
| 92 | |
| 93 | /* |
| 94 | ** Most recently encountered #if |
| 95 | */ |
| 96 | char zIf[200]; |
| 97 | |
| 98 | /* |
| 99 | ** How many entries are used |
| 100 | */ |
| 101 | int nUsed; |
| @@ -154,11 +154,11 @@ | |
| 154 | int len; |
| 155 | if( zLine[0]!='#' ) return; |
| 156 | for(i=1; isspace(zLine[i]); i++){} |
| 157 | if( zLine[i]==0 ) return; |
| 158 | len = strlen(&zLine[i]); |
| 159 | if( memcmp(&zLine[i],"if",2)==0 ){ |
| 160 | zIf[0] = '#'; |
| 161 | memcpy(&zIf[1], &zLine[i], len+1); |
| 162 | }else if( zLine[i]=='e' ){ |
| 163 | zIf[0] = 0; |
| 164 | } |
| @@ -173,12 +173,12 @@ | |
| 173 | if( nUsed<=nFixed ) return; |
| 174 | if( strncmp(zLine, "**", 2)==0 |
| 175 | && isspace(zLine[2]) |
| 176 | && strlen(zLine)<sizeof(zHelp)-nHelp-1 |
| 177 | && nUsed>nFixed |
| 178 | && memcmp(zLine,"** COMMAND:",11)!=0 |
| 179 | && memcmp(zLine,"** WEBPAGE:",11)!=0 |
| 180 | ){ |
| 181 | if( zLine[2]=='\n' ){ |
| 182 | zHelp[nHelp++] = '\n'; |
| 183 | }else{ |
| 184 | if( strncmp(&zLine[3], "Usage: ", 6)==0 ) nHelp = 0; |
| @@ -287,11 +287,11 @@ | |
| 287 | int cmdFlags = (1==aEntry[i].eType) ? 0x01 : 0x08; |
| 288 | if( 0x01==cmdFlags ){ |
| 289 | if( z[n-1]=='*' ){ |
| 290 | n--; |
| 291 | cmdFlags = 0x02; |
| 292 | }else if( memcmp(z, "test-", 5)==0 ){ |
| 293 | cmdFlags = 0x04; |
| 294 | } |
| 295 | } |
| 296 | if( aEntry[i].zIf ) printf("%s", aEntry[i].zIf); |
| 297 | printf(" { \"%s%.*s\",%*s %s,%*s %d },\n", |
| 298 |
| --- src/mkindex.c | |
| +++ src/mkindex.c | |
| @@ -70,16 +70,16 @@ | |
| 70 | } Entry; |
| 71 | |
| 72 | /* |
| 73 | ** Maximum number of entries |
| 74 | */ |
| 75 | #define N_ENTRY 5000 |
| 76 | |
| 77 | /* |
| 78 | ** Maximum size of a help message |
| 79 | */ |
| 80 | #define MX_HELP 250000 |
| 81 | |
| 82 | /* |
| 83 | ** Table of entries |
| 84 | */ |
| 85 | Entry aEntry[N_ENTRY]; |
| @@ -91,11 +91,11 @@ | |
| 91 | int nHelp; |
| 92 | |
| 93 | /* |
| 94 | ** Most recently encountered #if |
| 95 | */ |
| 96 | char zIf[2000]; |
| 97 | |
| 98 | /* |
| 99 | ** How many entries are used |
| 100 | */ |
| 101 | int nUsed; |
| @@ -154,11 +154,11 @@ | |
| 154 | int len; |
| 155 | if( zLine[0]!='#' ) return; |
| 156 | for(i=1; isspace(zLine[i]); i++){} |
| 157 | if( zLine[i]==0 ) return; |
| 158 | len = strlen(&zLine[i]); |
| 159 | if( strncmp(&zLine[i],"if",2)==0 ){ |
| 160 | zIf[0] = '#'; |
| 161 | memcpy(&zIf[1], &zLine[i], len+1); |
| 162 | }else if( zLine[i]=='e' ){ |
| 163 | zIf[0] = 0; |
| 164 | } |
| @@ -173,12 +173,12 @@ | |
| 173 | if( nUsed<=nFixed ) return; |
| 174 | if( strncmp(zLine, "**", 2)==0 |
| 175 | && isspace(zLine[2]) |
| 176 | && strlen(zLine)<sizeof(zHelp)-nHelp-1 |
| 177 | && nUsed>nFixed |
| 178 | && strncmp(zLine,"** COMMAND:",11)!=0 |
| 179 | && strncmp(zLine,"** WEBPAGE:",11)!=0 |
| 180 | ){ |
| 181 | if( zLine[2]=='\n' ){ |
| 182 | zHelp[nHelp++] = '\n'; |
| 183 | }else{ |
| 184 | if( strncmp(&zLine[3], "Usage: ", 6)==0 ) nHelp = 0; |
| @@ -287,11 +287,11 @@ | |
| 287 | int cmdFlags = (1==aEntry[i].eType) ? 0x01 : 0x08; |
| 288 | if( 0x01==cmdFlags ){ |
| 289 | if( z[n-1]=='*' ){ |
| 290 | n--; |
| 291 | cmdFlags = 0x02; |
| 292 | }else if( strncmp(z, "test-", 5)==0 ){ |
| 293 | cmdFlags = 0x04; |
| 294 | } |
| 295 | } |
| 296 | if( aEntry[i].zIf ) printf("%s", aEntry[i].zIf); |
| 297 | printf(" { \"%s%.*s\",%*s %s,%*s %d },\n", |
| 298 |