Fossil SCM

Additional cleanup in the differencing engine. The new "dir" webpage now uses name= instead of the d= for the query parameter.

drh 2008-02-04 14:24 trunk
Commit e81cc91aa4024898fa44492779e6b94396922337
2 files changed +5 -5 +12 -18
+5 -5
--- src/browse.c
+++ src/browse.c
@@ -71,14 +71,14 @@
7171
/*
7272
** WEBPAGE: dir
7373
**
7474
** Query parameters:
7575
**
76
-** d=PATH Directory to display. Required.
76
+** name=PATH Directory to display. Required.
7777
*/
7878
void page_dir(void){
79
- const char *zD = P("d");
79
+ const char *zD = P("name");
8080
int mxLen;
8181
int nCol, nRow;
8282
int cnt, i;
8383
char *zPrefix;
8484
Stmt q;
@@ -87,11 +87,11 @@
8787
if( !g.okHistory ){ login_needed(); return; }
8888
style_header("File List");
8989
sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0,
9090
pathelementFunc, 0, 0);
9191
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 */
9393
if( zD && strlen(zD)==0 ){ zD = 0; }
9494
9595
/* Compute the title of the page */
9696
if( zD ){
9797
int i, j;
@@ -106,11 +106,11 @@
106106
);
107107
for(i=0; zD[i]; i=j){
108108
for(j=i; zD[j] && zD[j]!='/'; j++){}
109109
if( zD[j] ){
110110
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>",
112112
g.zBaseURL, zCopy, &zCopy[i]);
113113
zCopy[j] = '/';
114114
}else{
115115
blob_appendf(&title, "/%h", &zCopy[i]);
116116
}
@@ -165,11 +165,11 @@
165165
}
166166
i++;
167167
zFName = db_column_text(&q, 0);
168168
if( zFName[0]=='/' ){
169169
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)">
171171
@ %h(zFName)/</a></li>
172172
}else{
173173
@ <li><a href="%s(g.zBaseURL)/finfo?name=%T(zPrefix)%T(zFName)">
174174
@ %h(zFName)</a></li>
175175
}
176176
--- 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 @@
2727
#include "config.h"
2828
#include "diff.h"
2929
#include <assert.h>
3030
3131
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)
3737
3838
/*
3939
** Information about each line of a file being diffed.
4040
**
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,
4343
** the file is considered binary.
4444
*/
4545
typedef struct DLine DLine;
4646
struct DLine {
4747
const char *z; /* The text of the line */
4848
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) */
5050
5151
/* an array of DLine elements services two purposes. The fields
5252
** 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) */
5555
};
5656
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
-
6357
/*
6458
** A context for running a diff.
6559
*/
6660
typedef struct DContext DContext;
6761
struct DContext {
@@ -82,11 +76,11 @@
8276
** Trailing whitespace is removed from each line.
8377
**
8478
** Return 0 if the file is binary or contains a line that is
8579
** too long.
8680
*/
87
-static DLine *break_into_lines(char *z, int *pnLine){
81
+static DLine *break_into_lines(const char *z, int *pnLine){
8882
int nLine, i, j, k, x;
8983
unsigned int h, h2;
9084
DLine *a;
9185
9286
/* Count the number of lines. Allocate space to hold
@@ -221,11 +215,11 @@
221215
mxr = p->nEdit;
222216
if( mxr>2 && R[mxr-1]==0 && R[mxr-2]==0 ){ mxr -= 3; }
223217
for(r=0; r<mxr; r += 3*nr){
224218
/* Figure out how many triples to show in a single block */
225219
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); */
227221
228222
/* For the current block comprising nr triples, figure out
229223
** how many lines of A and B are to be displayed
230224
*/
231225
if( R[r]>nContext ){
232226
--- 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

Keyboard Shortcuts

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