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].
Commit
e5e6ca46597a50d215fa08a6ef1bd7b7939e3dea
Parent
3abab7e177f063e…
4 files changed
+1
-1
+1
-1
+2
-2
+2
-2
+1
-1
| --- src/glob.c | ||
| +++ src/glob.c | ||
| @@ -58,11 +58,11 @@ | ||
| 58 | 58 | } |
| 59 | 59 | for(i=0; zGlobList[i] && zGlobList[i]!=cTerm; i++){} |
| 60 | 60 | if( cTerm==',' ){ |
| 61 | 61 | while( i>0 && fossil_isspace(zGlobList[i-1]) ){ i--; } |
| 62 | 62 | } |
| 63 | - blob_appendf(&expr, "%s%s GLOB '%.*q'", zSep, zVal, i, zGlobList); | |
| 63 | + blob_appendf(&expr, "%s%s GLOB '%#q'", zSep, zVal, i, zGlobList); | |
| 64 | 64 | zSep = " OR "; |
| 65 | 65 | if( cTerm!=',' && zGlobList[i] ) i++; |
| 66 | 66 | zGlobList += i; |
| 67 | 67 | if( zGlobList[0] ) zGlobList++; |
| 68 | 68 | nTerm++; |
| 69 | 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 |
| --- 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 @@ | ||
| 96 | 96 | ){ |
| 97 | 97 | int i; |
| 98 | 98 | for(i=nName-1; i>0 && zName[i]!='/'; i--){} |
| 99 | 99 | if( i<=0 ) return; |
| 100 | 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); | |
| 101 | + db_multi_exec("INSERT OR IGNORE INTO dir VALUES('%#q')", i, zName); | |
| 102 | 102 | if( sqlite3_changes(g.db)==0 ) return; |
| 103 | 103 | tar_add_directory_of(zName, i-1, mTime); |
| 104 | 104 | tar_add_header(zName, i, 0755, mTime, 0, 5); |
| 105 | 105 | memcpy(tball.zPrevDir, zName, i); |
| 106 | 106 | tball.zPrevDir[i] = 0; |
| 107 | 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 |
| --- 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 @@ | ||
| 208 | 208 | if( argc!=2 ){ |
| 209 | 209 | return Th_WrongNumArgs(interp, "hascap STRING"); |
| 210 | 210 | } |
| 211 | 211 | rc = login_has_capability((char*)argv[1],argl[1]); |
| 212 | 212 | 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); | |
| 214 | 214 | } |
| 215 | 215 | Th_SetResultInt(interp, rc); |
| 216 | 216 | return TH_OK; |
| 217 | 217 | } |
| 218 | 218 | |
| @@ -235,11 +235,11 @@ | ||
| 235 | 235 | } |
| 236 | 236 | for(i=0; rc==0 && i<argl[1]; i++){ |
| 237 | 237 | rc = login_has_capability((char*)&argv[1][i],1); |
| 238 | 238 | } |
| 239 | 239 | 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); | |
| 241 | 241 | } |
| 242 | 242 | Th_SetResultInt(interp, rc); |
| 243 | 243 | return TH_OK; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 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 |
| --- 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 @@ | ||
| 300 | 300 | blob_zero(&links); |
| 301 | 301 | while( z && z[0] ){ |
| 302 | 302 | for(i=0; z[i] && (z[i]!=',' || z[i+1]!=' '); i++){} |
| 303 | 303 | if( zThisTag==0 || memcmp(z, zThisTag, i)!=0 || zThisTag[i]!=0 ){ |
| 304 | 304 | 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", | |
| 306 | 306 | g.zTop, i, z, zDate, i, z, &z[i] |
| 307 | 307 | ); |
| 308 | 308 | }else{ |
| 309 | - blob_appendf(&links, "%.*h", i+2, z); | |
| 309 | + blob_appendf(&links, "%#h", i+2, z); | |
| 310 | 310 | } |
| 311 | 311 | if( z[i]==0 ) break; |
| 312 | 312 | z += i+2; |
| 313 | 313 | } |
| 314 | 314 | @ tags: %s(blob_str(&links))) |
| 315 | 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 |
| --- 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 |