Fossil SCM
Additional cleanup in the differencing engine. The new "dir" webpage now uses name= instead of the d= for the query parameter.
Commit
e81cc91aa4024898fa44492779e6b94396922337
Parent
eeea77f340918d8…
2 files changed
+5
-5
+12
-18
+5
-5
| --- src/browse.c | ||
| +++ src/browse.c | ||
| @@ -71,14 +71,14 @@ | ||
| 71 | 71 | /* |
| 72 | 72 | ** WEBPAGE: dir |
| 73 | 73 | ** |
| 74 | 74 | ** Query parameters: |
| 75 | 75 | ** |
| 76 | -** d=PATH Directory to display. Required. | |
| 76 | +** name=PATH Directory to display. Required. | |
| 77 | 77 | */ |
| 78 | 78 | void page_dir(void){ |
| 79 | - const char *zD = P("d"); | |
| 79 | + const char *zD = P("name"); | |
| 80 | 80 | int mxLen; |
| 81 | 81 | int nCol, nRow; |
| 82 | 82 | int cnt, i; |
| 83 | 83 | char *zPrefix; |
| 84 | 84 | Stmt q; |
| @@ -87,11 +87,11 @@ | ||
| 87 | 87 | if( !g.okHistory ){ login_needed(); return; } |
| 88 | 88 | style_header("File List"); |
| 89 | 89 | sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0, |
| 90 | 90 | pathelementFunc, 0, 0); |
| 91 | 91 | |
| 92 | - /* If the d= parameter is an empty string, make it a NULL pointer */ | |
| 92 | + /* If the name= parameter is an empty string, make it a NULL pointer */ | |
| 93 | 93 | if( zD && strlen(zD)==0 ){ zD = 0; } |
| 94 | 94 | |
| 95 | 95 | /* Compute the title of the page */ |
| 96 | 96 | if( zD ){ |
| 97 | 97 | int i, j; |
| @@ -106,11 +106,11 @@ | ||
| 106 | 106 | ); |
| 107 | 107 | for(i=0; zD[i]; i=j){ |
| 108 | 108 | for(j=i; zD[j] && zD[j]!='/'; j++){} |
| 109 | 109 | if( zD[j] ){ |
| 110 | 110 | zCopy[j] = 0; |
| 111 | - blob_appendf(&title, "/<a href=\"%s/dir?d=%T\">%h</a>", | |
| 111 | + blob_appendf(&title, "/<a href=\"%s/dir?name=%T\">%h</a>", | |
| 112 | 112 | g.zBaseURL, zCopy, &zCopy[i]); |
| 113 | 113 | zCopy[j] = '/'; |
| 114 | 114 | }else{ |
| 115 | 115 | blob_appendf(&title, "/%h", &zCopy[i]); |
| 116 | 116 | } |
| @@ -165,11 +165,11 @@ | ||
| 165 | 165 | } |
| 166 | 166 | i++; |
| 167 | 167 | zFName = db_column_text(&q, 0); |
| 168 | 168 | if( zFName[0]=='/' ){ |
| 169 | 169 | zFName++; |
| 170 | - @ <li><a href="%s(g.zBaseURL)/dir?d=%T(zPrefix)%T(zFName)"> | |
| 170 | + @ <li><a href="%s(g.zBaseURL)/dir?name=%T(zPrefix)%T(zFName)"> | |
| 171 | 171 | @ %h(zFName)/</a></li> |
| 172 | 172 | }else{ |
| 173 | 173 | @ <li><a href="%s(g.zBaseURL)/finfo?name=%T(zPrefix)%T(zFName)"> |
| 174 | 174 | @ %h(zFName)</a></li> |
| 175 | 175 | } |
| 176 | 176 |
| --- src/browse.c | |
| +++ src/browse.c | |
| @@ -71,14 +71,14 @@ | |
| 71 | /* |
| 72 | ** WEBPAGE: dir |
| 73 | ** |
| 74 | ** Query parameters: |
| 75 | ** |
| 76 | ** d=PATH Directory to display. Required. |
| 77 | */ |
| 78 | void page_dir(void){ |
| 79 | const char *zD = P("d"); |
| 80 | int mxLen; |
| 81 | int nCol, nRow; |
| 82 | int cnt, i; |
| 83 | char *zPrefix; |
| 84 | Stmt q; |
| @@ -87,11 +87,11 @@ | |
| 87 | if( !g.okHistory ){ login_needed(); return; } |
| 88 | style_header("File List"); |
| 89 | sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0, |
| 90 | pathelementFunc, 0, 0); |
| 91 | |
| 92 | /* If the d= parameter is an empty string, make it a NULL pointer */ |
| 93 | if( zD && strlen(zD)==0 ){ zD = 0; } |
| 94 | |
| 95 | /* Compute the title of the page */ |
| 96 | if( zD ){ |
| 97 | int i, j; |
| @@ -106,11 +106,11 @@ | |
| 106 | ); |
| 107 | for(i=0; zD[i]; i=j){ |
| 108 | for(j=i; zD[j] && zD[j]!='/'; j++){} |
| 109 | if( zD[j] ){ |
| 110 | zCopy[j] = 0; |
| 111 | blob_appendf(&title, "/<a href=\"%s/dir?d=%T\">%h</a>", |
| 112 | g.zBaseURL, zCopy, &zCopy[i]); |
| 113 | zCopy[j] = '/'; |
| 114 | }else{ |
| 115 | blob_appendf(&title, "/%h", &zCopy[i]); |
| 116 | } |
| @@ -165,11 +165,11 @@ | |
| 165 | } |
| 166 | i++; |
| 167 | zFName = db_column_text(&q, 0); |
| 168 | if( zFName[0]=='/' ){ |
| 169 | zFName++; |
| 170 | @ <li><a href="%s(g.zBaseURL)/dir?d=%T(zPrefix)%T(zFName)"> |
| 171 | @ %h(zFName)/</a></li> |
| 172 | }else{ |
| 173 | @ <li><a href="%s(g.zBaseURL)/finfo?name=%T(zPrefix)%T(zFName)"> |
| 174 | @ %h(zFName)</a></li> |
| 175 | } |
| 176 |
| --- src/browse.c | |
| +++ src/browse.c | |
| @@ -71,14 +71,14 @@ | |
| 71 | /* |
| 72 | ** WEBPAGE: dir |
| 73 | ** |
| 74 | ** Query parameters: |
| 75 | ** |
| 76 | ** name=PATH Directory to display. Required. |
| 77 | */ |
| 78 | void page_dir(void){ |
| 79 | const char *zD = P("name"); |
| 80 | int mxLen; |
| 81 | int nCol, nRow; |
| 82 | int cnt, i; |
| 83 | char *zPrefix; |
| 84 | Stmt q; |
| @@ -87,11 +87,11 @@ | |
| 87 | if( !g.okHistory ){ login_needed(); return; } |
| 88 | style_header("File List"); |
| 89 | sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0, |
| 90 | pathelementFunc, 0, 0); |
| 91 | |
| 92 | /* If the name= parameter is an empty string, make it a NULL pointer */ |
| 93 | if( zD && strlen(zD)==0 ){ zD = 0; } |
| 94 | |
| 95 | /* Compute the title of the page */ |
| 96 | if( zD ){ |
| 97 | int i, j; |
| @@ -106,11 +106,11 @@ | |
| 106 | ); |
| 107 | for(i=0; zD[i]; i=j){ |
| 108 | for(j=i; zD[j] && zD[j]!='/'; j++){} |
| 109 | if( zD[j] ){ |
| 110 | zCopy[j] = 0; |
| 111 | blob_appendf(&title, "/<a href=\"%s/dir?name=%T\">%h</a>", |
| 112 | g.zBaseURL, zCopy, &zCopy[i]); |
| 113 | zCopy[j] = '/'; |
| 114 | }else{ |
| 115 | blob_appendf(&title, "/%h", &zCopy[i]); |
| 116 | } |
| @@ -165,11 +165,11 @@ | |
| 165 | } |
| 166 | i++; |
| 167 | zFName = db_column_text(&q, 0); |
| 168 | if( zFName[0]=='/' ){ |
| 169 | zFName++; |
| 170 | @ <li><a href="%s(g.zBaseURL)/dir?name=%T(zPrefix)%T(zFName)"> |
| 171 | @ %h(zFName)/</a></li> |
| 172 | }else{ |
| 173 | @ <li><a href="%s(g.zBaseURL)/finfo?name=%T(zPrefix)%T(zFName)"> |
| 174 | @ %h(zFName)</a></li> |
| 175 | } |
| 176 |
+12
-18
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -27,41 +27,35 @@ | ||
| 27 | 27 | #include "config.h" |
| 28 | 28 | #include "diff.h" |
| 29 | 29 | #include <assert.h> |
| 30 | 30 | |
| 31 | 31 | |
| 32 | -#if 0 | |
| 33 | -#define DEBUG(X) X | |
| 34 | -#else | |
| 35 | -#define DEBUG(X) | |
| 36 | -#endif | |
| 32 | +/* | |
| 33 | +** Maximum length of a line in a text file. (8192) | |
| 34 | +*/ | |
| 35 | +#define LENGTH_MASK_SZ 13 | |
| 36 | +#define LENGTH_MASK ((1<<LENGTH_MASK_SZ)-1) | |
| 37 | 37 | |
| 38 | 38 | /* |
| 39 | 39 | ** Information about each line of a file being diffed. |
| 40 | 40 | ** |
| 41 | -** The lower 20 bits of the hash are the length of the | |
| 42 | -** line. If any line is longer than 1048575 characters, | |
| 41 | +** The lower LENGTH_MASK_SZ bits of the hash (DLine.h) are the length | |
| 42 | +** of the line. If any line is longer than LENGTH_MASK characters, | |
| 43 | 43 | ** the file is considered binary. |
| 44 | 44 | */ |
| 45 | 45 | typedef struct DLine DLine; |
| 46 | 46 | struct DLine { |
| 47 | 47 | const char *z; /* The text of the line */ |
| 48 | 48 | unsigned int h; /* Hash of the line */ |
| 49 | - unsigned int iNext; /* Index+1 of next line with same the same hash */ | |
| 49 | + unsigned int iNext; /* 1+(Index of next line with same the same hash) */ | |
| 50 | 50 | |
| 51 | 51 | /* an array of DLine elements services two purposes. The fields |
| 52 | 52 | ** above are one per line of input text. But each entry is also |
| 53 | - ** a bucket in a hash table. */ | |
| 54 | - unsigned int iHash; /* First entry+1 in the hash array */ | |
| 53 | + ** a bucket in a hash table, as follows: */ | |
| 54 | + unsigned int iHash; /* 1+(first entry in the hash chain) */ | |
| 55 | 55 | }; |
| 56 | 56 | |
| 57 | -/* | |
| 58 | -** Maximum length of a line in a text file. (8192) | |
| 59 | -*/ | |
| 60 | -#define LENGTH_MASK_SZ 13 | |
| 61 | -#define LENGTH_MASK ((1<<LENGTH_MASK_SZ)-1) | |
| 62 | - | |
| 63 | 57 | /* |
| 64 | 58 | ** A context for running a diff. |
| 65 | 59 | */ |
| 66 | 60 | typedef struct DContext DContext; |
| 67 | 61 | struct DContext { |
| @@ -82,11 +76,11 @@ | ||
| 82 | 76 | ** Trailing whitespace is removed from each line. |
| 83 | 77 | ** |
| 84 | 78 | ** Return 0 if the file is binary or contains a line that is |
| 85 | 79 | ** too long. |
| 86 | 80 | */ |
| 87 | -static DLine *break_into_lines(char *z, int *pnLine){ | |
| 81 | +static DLine *break_into_lines(const char *z, int *pnLine){ | |
| 88 | 82 | int nLine, i, j, k, x; |
| 89 | 83 | unsigned int h, h2; |
| 90 | 84 | DLine *a; |
| 91 | 85 | |
| 92 | 86 | /* Count the number of lines. Allocate space to hold |
| @@ -221,11 +215,11 @@ | ||
| 221 | 215 | mxr = p->nEdit; |
| 222 | 216 | if( mxr>2 && R[mxr-1]==0 && R[mxr-2]==0 ){ mxr -= 3; } |
| 223 | 217 | for(r=0; r<mxr; r += 3*nr){ |
| 224 | 218 | /* Figure out how many triples to show in a single block */ |
| 225 | 219 | for(nr=1; R[r+nr*3]>0 && R[r+nr*3]<nContext*2; nr++){} |
| 226 | - DEBUG( printf("r=%d nr=%d\n", r, nr); ) | |
| 220 | + /* printf("r=%d nr=%d\n", r, nr); */ | |
| 227 | 221 | |
| 228 | 222 | /* For the current block comprising nr triples, figure out |
| 229 | 223 | ** how many lines of A and B are to be displayed |
| 230 | 224 | */ |
| 231 | 225 | if( R[r]>nContext ){ |
| 232 | 226 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -27,41 +27,35 @@ | |
| 27 | #include "config.h" |
| 28 | #include "diff.h" |
| 29 | #include <assert.h> |
| 30 | |
| 31 | |
| 32 | #if 0 |
| 33 | #define DEBUG(X) X |
| 34 | #else |
| 35 | #define DEBUG(X) |
| 36 | #endif |
| 37 | |
| 38 | /* |
| 39 | ** Information about each line of a file being diffed. |
| 40 | ** |
| 41 | ** The lower 20 bits of the hash are the length of the |
| 42 | ** line. If any line is longer than 1048575 characters, |
| 43 | ** the file is considered binary. |
| 44 | */ |
| 45 | typedef struct DLine DLine; |
| 46 | struct DLine { |
| 47 | const char *z; /* The text of the line */ |
| 48 | unsigned int h; /* Hash of the line */ |
| 49 | unsigned int iNext; /* Index+1 of next line with same the same hash */ |
| 50 | |
| 51 | /* an array of DLine elements services two purposes. The fields |
| 52 | ** above are one per line of input text. But each entry is also |
| 53 | ** a bucket in a hash table. */ |
| 54 | unsigned int iHash; /* First entry+1 in the hash array */ |
| 55 | }; |
| 56 | |
| 57 | /* |
| 58 | ** Maximum length of a line in a text file. (8192) |
| 59 | */ |
| 60 | #define LENGTH_MASK_SZ 13 |
| 61 | #define LENGTH_MASK ((1<<LENGTH_MASK_SZ)-1) |
| 62 | |
| 63 | /* |
| 64 | ** A context for running a diff. |
| 65 | */ |
| 66 | typedef struct DContext DContext; |
| 67 | struct DContext { |
| @@ -82,11 +76,11 @@ | |
| 82 | ** Trailing whitespace is removed from each line. |
| 83 | ** |
| 84 | ** Return 0 if the file is binary or contains a line that is |
| 85 | ** too long. |
| 86 | */ |
| 87 | static DLine *break_into_lines(char *z, int *pnLine){ |
| 88 | int nLine, i, j, k, x; |
| 89 | unsigned int h, h2; |
| 90 | DLine *a; |
| 91 | |
| 92 | /* Count the number of lines. Allocate space to hold |
| @@ -221,11 +215,11 @@ | |
| 221 | mxr = p->nEdit; |
| 222 | if( mxr>2 && R[mxr-1]==0 && R[mxr-2]==0 ){ mxr -= 3; } |
| 223 | for(r=0; r<mxr; r += 3*nr){ |
| 224 | /* Figure out how many triples to show in a single block */ |
| 225 | for(nr=1; R[r+nr*3]>0 && R[r+nr*3]<nContext*2; nr++){} |
| 226 | DEBUG( printf("r=%d nr=%d\n", r, nr); ) |
| 227 | |
| 228 | /* For the current block comprising nr triples, figure out |
| 229 | ** how many lines of A and B are to be displayed |
| 230 | */ |
| 231 | if( R[r]>nContext ){ |
| 232 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -27,41 +27,35 @@ | |
| 27 | #include "config.h" |
| 28 | #include "diff.h" |
| 29 | #include <assert.h> |
| 30 | |
| 31 | |
| 32 | /* |
| 33 | ** Maximum length of a line in a text file. (8192) |
| 34 | */ |
| 35 | #define LENGTH_MASK_SZ 13 |
| 36 | #define LENGTH_MASK ((1<<LENGTH_MASK_SZ)-1) |
| 37 | |
| 38 | /* |
| 39 | ** Information about each line of a file being diffed. |
| 40 | ** |
| 41 | ** The lower LENGTH_MASK_SZ bits of the hash (DLine.h) are the length |
| 42 | ** of the line. If any line is longer than LENGTH_MASK characters, |
| 43 | ** the file is considered binary. |
| 44 | */ |
| 45 | typedef struct DLine DLine; |
| 46 | struct DLine { |
| 47 | const char *z; /* The text of the line */ |
| 48 | unsigned int h; /* Hash of the line */ |
| 49 | unsigned int iNext; /* 1+(Index of next line with same the same hash) */ |
| 50 | |
| 51 | /* an array of DLine elements services two purposes. The fields |
| 52 | ** above are one per line of input text. But each entry is also |
| 53 | ** a bucket in a hash table, as follows: */ |
| 54 | unsigned int iHash; /* 1+(first entry in the hash chain) */ |
| 55 | }; |
| 56 | |
| 57 | /* |
| 58 | ** A context for running a diff. |
| 59 | */ |
| 60 | typedef struct DContext DContext; |
| 61 | struct DContext { |
| @@ -82,11 +76,11 @@ | |
| 76 | ** Trailing whitespace is removed from each line. |
| 77 | ** |
| 78 | ** Return 0 if the file is binary or contains a line that is |
| 79 | ** too long. |
| 80 | */ |
| 81 | static DLine *break_into_lines(const char *z, int *pnLine){ |
| 82 | int nLine, i, j, k, x; |
| 83 | unsigned int h, h2; |
| 84 | DLine *a; |
| 85 | |
| 86 | /* Count the number of lines. Allocate space to hold |
| @@ -221,11 +215,11 @@ | |
| 215 | mxr = p->nEdit; |
| 216 | if( mxr>2 && R[mxr-1]==0 && R[mxr-2]==0 ){ mxr -= 3; } |
| 217 | for(r=0; r<mxr; r += 3*nr){ |
| 218 | /* Figure out how many triples to show in a single block */ |
| 219 | for(nr=1; R[r+nr*3]>0 && R[r+nr*3]<nContext*2; nr++){} |
| 220 | /* printf("r=%d nr=%d\n", r, nr); */ |
| 221 | |
| 222 | /* For the current block comprising nr triples, figure out |
| 223 | ** how many lines of A and B are to be displayed |
| 224 | */ |
| 225 | if( R[r]>nContext ){ |
| 226 |