Fossil SCM

Always use the alternate-form flag "#" to control the number of input bytes to printf conversions like %t, %h, and %q. Do not use precision in those cases since precision limits the number of output characters, not the number of input characters. Ticket [8967ea1df4f51af].

drh 2011-05-31 12:52 trunk
Commit e5e6ca46597a50d215fa08a6ef1bd7b7939e3dea
+1 -1
--- src/glob.c
+++ src/glob.c
@@ -58,11 +58,11 @@
5858
}
5959
for(i=0; zGlobList[i] && zGlobList[i]!=cTerm; i++){}
6060
if( cTerm==',' ){
6161
while( i>0 && fossil_isspace(zGlobList[i-1]) ){ i--; }
6262
}
63
- blob_appendf(&expr, "%s%s GLOB '%.*q'", zSep, zVal, i, zGlobList);
63
+ blob_appendf(&expr, "%s%s GLOB '%#q'", zSep, zVal, i, zGlobList);
6464
zSep = " OR ";
6565
if( cTerm!=',' && zGlobList[i] ) i++;
6666
zGlobList += i;
6767
if( zGlobList[0] ) zGlobList++;
6868
nTerm++;
6969
--- src/glob.c
+++ src/glob.c
@@ -58,11 +58,11 @@
58 }
59 for(i=0; zGlobList[i] && zGlobList[i]!=cTerm; i++){}
60 if( cTerm==',' ){
61 while( i>0 && fossil_isspace(zGlobList[i-1]) ){ i--; }
62 }
63 blob_appendf(&expr, "%s%s GLOB '%.*q'", zSep, zVal, i, zGlobList);
64 zSep = " OR ";
65 if( cTerm!=',' && zGlobList[i] ) i++;
66 zGlobList += i;
67 if( zGlobList[0] ) zGlobList++;
68 nTerm++;
69
--- src/glob.c
+++ src/glob.c
@@ -58,11 +58,11 @@
58 }
59 for(i=0; zGlobList[i] && zGlobList[i]!=cTerm; i++){}
60 if( cTerm==',' ){
61 while( i>0 && fossil_isspace(zGlobList[i-1]) ){ i--; }
62 }
63 blob_appendf(&expr, "%s%s GLOB '%#q'", zSep, zVal, i, zGlobList);
64 zSep = " OR ";
65 if( cTerm!=',' && zGlobList[i] ) i++;
66 zGlobList += i;
67 if( zGlobList[0] ) zGlobList++;
68 nTerm++;
69
+1 -1
--- src/tar.c
+++ src/tar.c
@@ -96,11 +96,11 @@
9696
){
9797
int i;
9898
for(i=nName-1; i>0 && zName[i]!='/'; i--){}
9999
if( i<=0 ) return;
100100
if( tball.zPrevDir[i]==0 && memcmp(tball.zPrevDir, zName, i)==0 ) return;
101
- db_multi_exec("INSERT OR IGNORE INTO dir VALUES('%.*q')", i, zName);
101
+ db_multi_exec("INSERT OR IGNORE INTO dir VALUES('%#q')", i, zName);
102102
if( sqlite3_changes(g.db)==0 ) return;
103103
tar_add_directory_of(zName, i-1, mTime);
104104
tar_add_header(zName, i, 0755, mTime, 0, 5);
105105
memcpy(tball.zPrevDir, zName, i);
106106
tball.zPrevDir[i] = 0;
107107
--- src/tar.c
+++ src/tar.c
@@ -96,11 +96,11 @@
96 ){
97 int i;
98 for(i=nName-1; i>0 && zName[i]!='/'; i--){}
99 if( i<=0 ) return;
100 if( tball.zPrevDir[i]==0 && memcmp(tball.zPrevDir, zName, i)==0 ) return;
101 db_multi_exec("INSERT OR IGNORE INTO dir VALUES('%.*q')", i, zName);
102 if( sqlite3_changes(g.db)==0 ) return;
103 tar_add_directory_of(zName, i-1, mTime);
104 tar_add_header(zName, i, 0755, mTime, 0, 5);
105 memcpy(tball.zPrevDir, zName, i);
106 tball.zPrevDir[i] = 0;
107
--- src/tar.c
+++ src/tar.c
@@ -96,11 +96,11 @@
96 ){
97 int i;
98 for(i=nName-1; i>0 && zName[i]!='/'; i--){}
99 if( i<=0 ) return;
100 if( tball.zPrevDir[i]==0 && memcmp(tball.zPrevDir, zName, i)==0 ) return;
101 db_multi_exec("INSERT OR IGNORE INTO dir VALUES('%#q')", i, zName);
102 if( sqlite3_changes(g.db)==0 ) return;
103 tar_add_directory_of(zName, i-1, mTime);
104 tar_add_header(zName, i, 0755, mTime, 0, 5);
105 memcpy(tball.zPrevDir, zName, i);
106 tball.zPrevDir[i] = 0;
107
+2 -2
--- src/th_main.c
+++ src/th_main.c
@@ -208,11 +208,11 @@
208208
if( argc!=2 ){
209209
return Th_WrongNumArgs(interp, "hascap STRING");
210210
}
211211
rc = login_has_capability((char*)argv[1],argl[1]);
212212
if( g.thTrace ){
213
- Th_Trace("[hascap %.*h] => %d<br />\n", argl[1], argv[1], rc);
213
+ Th_Trace("[hascap %#h] => %d<br />\n", argl[1], argv[1], rc);
214214
}
215215
Th_SetResultInt(interp, rc);
216216
return TH_OK;
217217
}
218218
@@ -235,11 +235,11 @@
235235
}
236236
for(i=0; rc==0 && i<argl[1]; i++){
237237
rc = login_has_capability((char*)&argv[1][i],1);
238238
}
239239
if( g.thTrace ){
240
- Th_Trace("[hascap %.*h] => %d<br />\n", argl[1], argv[1], rc);
240
+ Th_Trace("[hascap %#h] => %d<br />\n", argl[1], argv[1], rc);
241241
}
242242
Th_SetResultInt(interp, rc);
243243
return TH_OK;
244244
}
245245
246246
--- src/th_main.c
+++ src/th_main.c
@@ -208,11 +208,11 @@
208 if( argc!=2 ){
209 return Th_WrongNumArgs(interp, "hascap STRING");
210 }
211 rc = login_has_capability((char*)argv[1],argl[1]);
212 if( g.thTrace ){
213 Th_Trace("[hascap %.*h] => %d<br />\n", argl[1], argv[1], rc);
214 }
215 Th_SetResultInt(interp, rc);
216 return TH_OK;
217 }
218
@@ -235,11 +235,11 @@
235 }
236 for(i=0; rc==0 && i<argl[1]; i++){
237 rc = login_has_capability((char*)&argv[1][i],1);
238 }
239 if( g.thTrace ){
240 Th_Trace("[hascap %.*h] => %d<br />\n", argl[1], argv[1], rc);
241 }
242 Th_SetResultInt(interp, rc);
243 return TH_OK;
244 }
245
246
--- src/th_main.c
+++ src/th_main.c
@@ -208,11 +208,11 @@
208 if( argc!=2 ){
209 return Th_WrongNumArgs(interp, "hascap STRING");
210 }
211 rc = login_has_capability((char*)argv[1],argl[1]);
212 if( g.thTrace ){
213 Th_Trace("[hascap %#h] => %d<br />\n", argl[1], argv[1], rc);
214 }
215 Th_SetResultInt(interp, rc);
216 return TH_OK;
217 }
218
@@ -235,11 +235,11 @@
235 }
236 for(i=0; rc==0 && i<argl[1]; i++){
237 rc = login_has_capability((char*)&argv[1][i],1);
238 }
239 if( g.thTrace ){
240 Th_Trace("[hascap %#h] => %d<br />\n", argl[1], argv[1], rc);
241 }
242 Th_SetResultInt(interp, rc);
243 return TH_OK;
244 }
245
246
+2 -2
--- src/timeline.c
+++ src/timeline.c
@@ -300,15 +300,15 @@
300300
blob_zero(&links);
301301
while( z && z[0] ){
302302
for(i=0; z[i] && (z[i]!=',' || z[i+1]!=' '); i++){}
303303
if( zThisTag==0 || memcmp(z, zThisTag, i)!=0 || zThisTag[i]!=0 ){
304304
blob_appendf(&links,
305
- "<a href=\"%s/timeline?r=%.*t&nd&c=%s\">%.*h</a>%.2s",
305
+ "<a href=\"%s/timeline?r=%#t&nd&c=%s\">%#h</a>%.2s",
306306
g.zTop, i, z, zDate, i, z, &z[i]
307307
);
308308
}else{
309
- blob_appendf(&links, "%.*h", i+2, z);
309
+ blob_appendf(&links, "%#h", i+2, z);
310310
}
311311
if( z[i]==0 ) break;
312312
z += i+2;
313313
}
314314
@ tags: %s(blob_str(&links)))
315315
--- src/timeline.c
+++ src/timeline.c
@@ -300,15 +300,15 @@
300 blob_zero(&links);
301 while( z && z[0] ){
302 for(i=0; z[i] && (z[i]!=',' || z[i+1]!=' '); i++){}
303 if( zThisTag==0 || memcmp(z, zThisTag, i)!=0 || zThisTag[i]!=0 ){
304 blob_appendf(&links,
305 "<a href=\"%s/timeline?r=%.*t&nd&c=%s\">%.*h</a>%.2s",
306 g.zTop, i, z, zDate, i, z, &z[i]
307 );
308 }else{
309 blob_appendf(&links, "%.*h", i+2, z);
310 }
311 if( z[i]==0 ) break;
312 z += i+2;
313 }
314 @ tags: %s(blob_str(&links)))
315
--- src/timeline.c
+++ src/timeline.c
@@ -300,15 +300,15 @@
300 blob_zero(&links);
301 while( z && z[0] ){
302 for(i=0; z[i] && (z[i]!=',' || z[i+1]!=' '); i++){}
303 if( zThisTag==0 || memcmp(z, zThisTag, i)!=0 || zThisTag[i]!=0 ){
304 blob_appendf(&links,
305 "<a href=\"%s/timeline?r=%#t&nd&c=%s\">%#h</a>%.2s",
306 g.zTop, i, z, zDate, i, z, &z[i]
307 );
308 }else{
309 blob_appendf(&links, "%#h", i+2, z);
310 }
311 if( z[i]==0 ) break;
312 z += i+2;
313 }
314 @ tags: %s(blob_str(&links)))
315

Keyboard Shortcuts

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