Fossil SCM

Revert unintended, incomplete change to timeline.c

andygoth 2016-10-24 18:33 andygoth-timeline-ms
Commit 5cb36bdd52932c1916e7e1b9a9f3ff480b8b4e5f
1 file changed +32 -35
+32 -35
--- src/timeline.c
+++ src/timeline.c
@@ -1241,34 +1241,29 @@
12411241
** the tag table to access the "tagname" column.
12421242
**
12431243
** Each pattern is adjusted to to start with "sym-" and be anchored at end.
12441244
**
12451245
** In MS_REGEXP mode, backslash can be used to protect delimiter characters.
1246
-**
1247
-** In addition to assembling and returning an SQL expression, this function
1248
-** makes an English-language description of the patterns being matched, suitable
1249
-** for display in the web interface.
12501246
*/
12511247
static const char *tagMatchExpression(
12521248
MatchStyle matchStyle, /* Match style code */
12531249
const char *zTag, /* Tag name, match pattern, or list of patterns */
1254
- const char **zDesc /* Output expression description string */
1250
+ int *pCount /* Pointer to match pattern count variable */
12551251
){
1256
- Blob expr = BLOB_INITIALIZER; /* SQL expression string assembly buffer */
1257
- Blob desc = BLOB_INITIALIZER; /* English description of match patterns */
1252
+ Blob blob = BLOB_INITIALIZER; /* SQL expression string assembly buffer */
12581253
const char *zStart; /* Text at start of expression */
12591254
const char *zDelimiter; /* Text between expression terms */
12601255
const char *zEnd; /* Text at end of expression */
12611256
const char *zPrefix; /* Text before each match pattern */
12621257
const char *zSuffix; /* Text after each match pattern */
1263
- char cInputDelim; /* Input delimiter character */
1264
- char cDescDelim; /* Description delimiter character */
1258
+ char cDel; /* Input delimiter character */
12651259
int i; /* Input match pattern length counter */
12661260
12671261
/* Optimize exact matches by looking up the ID in advance to create a simple
12681262
* numeric comparison. Bypass the remainder of this function. */
12691263
if( matchStyle==MS_EXACT ){
1264
+ *pCount = 1;
12701265
return mprintf("(tagid=%d)", db_int(-1,
12711266
"SELECT tagid FROM tag WHERE tagname='sym-%q'", zTag));
12721267
}
12731268
12741269
/* Decide pattern prefix and suffix strings according to match style. */
@@ -1290,13 +1285,13 @@
12901285
zEnd = ")$')";
12911286
zPrefix = "";
12921287
zSuffix = "";
12931288
}
12941289
1295
- /* Convert the list of matches into an SQL expression and text description. */
1296
- blob_zero(&expr);
1297
- blob_zero(&desc);
1290
+ /* Convert the list of matches into an SQL expression. */
1291
+ *pCount = 0;
1292
+ blob_zero(&blob);
12981293
while( 1 ){
12991294
/* Skip leading delimiters. */
13001295
for( ; fossil_isspace(*zTag) || *zTag==','; ++zTag );
13011296
13021297
/* Next non-delimiter character determines quoting. */
@@ -1303,21 +1298,21 @@
13031298
if( !*zTag ){
13041299
/* Terminate loop at end of string. */
13051300
break;
13061301
}else if( *zTag=='\'' || *zTag=='"' ){
13071302
/* If word is quoted, prepare to stop at end quote. */
1308
- cInputDelim = *zTag;
1303
+ cDel = *zTag;
13091304
++zTag;
13101305
}else{
13111306
/* If word is not quoted, prepare to stop at delimiter. */
1312
- cInputDelim = ',';
1307
+ cDel = ',';
13131308
}
13141309
13151310
/* Find the next delimiter character or end of string. */
1316
- for( i=0; zTag[i] && zTag[i]!=cInputDelim; ++i ){
1311
+ for( i=0; zTag[i] && zTag[i]!=cDel; ++i ){
13171312
/* If delimiter is comma, also recognize spaces as delimiters. */
1318
- if( cInputDelim==',' && fossil_isspace(zTag[i]) ){
1313
+ if( cDel==',' && fossil_isspace(zTag[i]) ){
13191314
break;
13201315
}
13211316
13221317
/* In regexp mode, ignore delimiters following backslashes. */
13231318
if( matchStyle==MS_REGEXP && zTag[i]=='\\' && zTag[i+1] ){
@@ -1325,24 +1320,27 @@
13251320
}
13261321
}
13271322
13281323
/* Incorporate the match word into the output expression. The %q format is
13291324
* used to protect against SQL injection attacks by replacing ' with ''. */
1330
- blob_appendf(&expr, "%s%s%#q%s", blob_size(&expr) ? zDelimiter : zStart,
1325
+ blob_appendf(&blob, "%s%s%#q%s", *pCount ? zDelimiter : zStart,
13311326
zPrefix, i, zTag, zSuffix);
1327
+
1328
+ /* Keep track of the number of match expressions. */
1329
+ ++*pCount;
13321330
13331331
/* Advance past all consumed input characters. */
13341332
zTag += i;
1335
- if( cInputDelim!=',' && *zTag==cInputDelim ){
1333
+ if( cDel!=',' && *zTag==cDel ){
13361334
++zTag;
13371335
}
13381336
}
13391337
13401338
/* Finalize and extract the SQL expression. */
1341
- if( blob_size(&expr) ){
1342
- blob_append(&expr, zEnd, -1);
1343
- return blob_str(&expr);
1339
+ if( *pCount ){
1340
+ blob_append(&blob, zEnd, -1);
1341
+ return blob_str(&blob);
13441342
}
13451343
13461344
/* If execution reaches this point, the pattern was empty. Return NULL. */
13471345
return 0;
13481346
}
@@ -1406,12 +1404,12 @@
14061404
const char *zMark = P("m"); /* Mark this event or an event this time */
14071405
const char *zTagName = P("t"); /* Show events with this tag */
14081406
const char *zBrName = P("r"); /* Show events related to this tag */
14091407
const char *zMatchStyle = P("ms"); /* Tag/branch match style string */
14101408
MatchStyle matchStyle = MS_EXACT; /* Match style code */
1411
- const char *zMatchDesc = 0; /* Tag match expression description text */
14121409
const char *zTagSql = 0; /* Tag/branch match SQL expression */
1410
+ int tagMatchCount = 0; /* Number of tag match patterns */
14131411
const char *zSearch = P("s"); /* Search string */
14141412
const char *zUses = P("uf"); /* Only show check-ins hold this file */
14151413
const char *zYearMonth = P("ym"); /* Show check-ins for the given YYYY-MM */
14161414
const char *zYearWeek = P("yw"); /* Check-ins for YYYY-WW (week-of-year) */
14171415
const char *zDay = P("ymd"); /* Check-ins for the day YYYY-MM-DD */
@@ -1490,11 +1488,11 @@
14901488
}
14911489
}
14921490
14931491
/* Construct the tag match expression. */
14941492
if( zThisTag ){
1495
- zTagSql = tagMatchExpression(matchStyle, zThisTag, &zMatchDesc);
1493
+ zTagSql = tagMatchExpression(matchStyle, zThisTag, &tagMatchCount);
14961494
}
14971495
14981496
if( zTagName && g.perm.Read ){
14991497
style_submenu_element("Related", "Related", "%s",
15001498
url_render(&url, "r", zTagName, "t", 0));
@@ -1921,22 +1919,21 @@
19211919
if( zTagName ){
19221920
blob_append(&desc, " with tags matching ", -1);
19231921
}else{
19241922
blob_append(&desc, " related to tags matching ", -1);
19251923
}
1926
- blob_append(&desc, zMatchDesc, -1);
1927
-// if( matchStyle==MS_LIKE ){
1928
-// blob_append(&desc, " SQL LIKE pattern", -1);
1929
-// }else if( matchStyle==MS_GLOB ){
1930
-// blob_append(&desc, " glob pattern", -1);
1931
-// }else/* if( matchStyle==MS_REGEXP )*/{
1932
-// blob_append(&desc, " regular expression", -1);
1933
-// }
1934
-// if( tagMatchCount!=1 ){
1935
-// blob_append(&desc, "s", 1);
1936
-// }
1937
-// blob_appendf(&desc, " (%h)", zThisTag);
1924
+ if( matchStyle==MS_LIKE ){
1925
+ blob_append(&desc, " SQL LIKE pattern", -1);
1926
+ }else if( matchStyle==MS_GLOB ){
1927
+ blob_append(&desc, " glob pattern", -1);
1928
+ }else/* if( matchStyle==MS_REGEXP )*/{
1929
+ blob_append(&desc, " regular expression", -1);
1930
+ }
1931
+ if( tagMatchCount!=1 ){
1932
+ blob_append(&desc, "s", 1);
1933
+ }
1934
+ blob_appendf(&desc, " (%h)", zThisTag);
19381935
}else if( zTagName ){
19391936
blob_appendf(&desc, " tagged with \"%h\"", zTagName);
19401937
}else{
19411938
blob_appendf(&desc, " related to \"%h\"", zBrName);
19421939
}
19431940
--- src/timeline.c
+++ src/timeline.c
@@ -1241,34 +1241,29 @@
1241 ** the tag table to access the "tagname" column.
1242 **
1243 ** Each pattern is adjusted to to start with "sym-" and be anchored at end.
1244 **
1245 ** In MS_REGEXP mode, backslash can be used to protect delimiter characters.
1246 **
1247 ** In addition to assembling and returning an SQL expression, this function
1248 ** makes an English-language description of the patterns being matched, suitable
1249 ** for display in the web interface.
1250 */
1251 static const char *tagMatchExpression(
1252 MatchStyle matchStyle, /* Match style code */
1253 const char *zTag, /* Tag name, match pattern, or list of patterns */
1254 const char **zDesc /* Output expression description string */
1255 ){
1256 Blob expr = BLOB_INITIALIZER; /* SQL expression string assembly buffer */
1257 Blob desc = BLOB_INITIALIZER; /* English description of match patterns */
1258 const char *zStart; /* Text at start of expression */
1259 const char *zDelimiter; /* Text between expression terms */
1260 const char *zEnd; /* Text at end of expression */
1261 const char *zPrefix; /* Text before each match pattern */
1262 const char *zSuffix; /* Text after each match pattern */
1263 char cInputDelim; /* Input delimiter character */
1264 char cDescDelim; /* Description delimiter character */
1265 int i; /* Input match pattern length counter */
1266
1267 /* Optimize exact matches by looking up the ID in advance to create a simple
1268 * numeric comparison. Bypass the remainder of this function. */
1269 if( matchStyle==MS_EXACT ){
 
1270 return mprintf("(tagid=%d)", db_int(-1,
1271 "SELECT tagid FROM tag WHERE tagname='sym-%q'", zTag));
1272 }
1273
1274 /* Decide pattern prefix and suffix strings according to match style. */
@@ -1290,13 +1285,13 @@
1290 zEnd = ")$')";
1291 zPrefix = "";
1292 zSuffix = "";
1293 }
1294
1295 /* Convert the list of matches into an SQL expression and text description. */
1296 blob_zero(&expr);
1297 blob_zero(&desc);
1298 while( 1 ){
1299 /* Skip leading delimiters. */
1300 for( ; fossil_isspace(*zTag) || *zTag==','; ++zTag );
1301
1302 /* Next non-delimiter character determines quoting. */
@@ -1303,21 +1298,21 @@
1303 if( !*zTag ){
1304 /* Terminate loop at end of string. */
1305 break;
1306 }else if( *zTag=='\'' || *zTag=='"' ){
1307 /* If word is quoted, prepare to stop at end quote. */
1308 cInputDelim = *zTag;
1309 ++zTag;
1310 }else{
1311 /* If word is not quoted, prepare to stop at delimiter. */
1312 cInputDelim = ',';
1313 }
1314
1315 /* Find the next delimiter character or end of string. */
1316 for( i=0; zTag[i] && zTag[i]!=cInputDelim; ++i ){
1317 /* If delimiter is comma, also recognize spaces as delimiters. */
1318 if( cInputDelim==',' && fossil_isspace(zTag[i]) ){
1319 break;
1320 }
1321
1322 /* In regexp mode, ignore delimiters following backslashes. */
1323 if( matchStyle==MS_REGEXP && zTag[i]=='\\' && zTag[i+1] ){
@@ -1325,24 +1320,27 @@
1325 }
1326 }
1327
1328 /* Incorporate the match word into the output expression. The %q format is
1329 * used to protect against SQL injection attacks by replacing ' with ''. */
1330 blob_appendf(&expr, "%s%s%#q%s", blob_size(&expr) ? zDelimiter : zStart,
1331 zPrefix, i, zTag, zSuffix);
 
 
 
1332
1333 /* Advance past all consumed input characters. */
1334 zTag += i;
1335 if( cInputDelim!=',' && *zTag==cInputDelim ){
1336 ++zTag;
1337 }
1338 }
1339
1340 /* Finalize and extract the SQL expression. */
1341 if( blob_size(&expr) ){
1342 blob_append(&expr, zEnd, -1);
1343 return blob_str(&expr);
1344 }
1345
1346 /* If execution reaches this point, the pattern was empty. Return NULL. */
1347 return 0;
1348 }
@@ -1406,12 +1404,12 @@
1406 const char *zMark = P("m"); /* Mark this event or an event this time */
1407 const char *zTagName = P("t"); /* Show events with this tag */
1408 const char *zBrName = P("r"); /* Show events related to this tag */
1409 const char *zMatchStyle = P("ms"); /* Tag/branch match style string */
1410 MatchStyle matchStyle = MS_EXACT; /* Match style code */
1411 const char *zMatchDesc = 0; /* Tag match expression description text */
1412 const char *zTagSql = 0; /* Tag/branch match SQL expression */
 
1413 const char *zSearch = P("s"); /* Search string */
1414 const char *zUses = P("uf"); /* Only show check-ins hold this file */
1415 const char *zYearMonth = P("ym"); /* Show check-ins for the given YYYY-MM */
1416 const char *zYearWeek = P("yw"); /* Check-ins for YYYY-WW (week-of-year) */
1417 const char *zDay = P("ymd"); /* Check-ins for the day YYYY-MM-DD */
@@ -1490,11 +1488,11 @@
1490 }
1491 }
1492
1493 /* Construct the tag match expression. */
1494 if( zThisTag ){
1495 zTagSql = tagMatchExpression(matchStyle, zThisTag, &zMatchDesc);
1496 }
1497
1498 if( zTagName && g.perm.Read ){
1499 style_submenu_element("Related", "Related", "%s",
1500 url_render(&url, "r", zTagName, "t", 0));
@@ -1921,22 +1919,21 @@
1921 if( zTagName ){
1922 blob_append(&desc, " with tags matching ", -1);
1923 }else{
1924 blob_append(&desc, " related to tags matching ", -1);
1925 }
1926 blob_append(&desc, zMatchDesc, -1);
1927 // if( matchStyle==MS_LIKE ){
1928 // blob_append(&desc, " SQL LIKE pattern", -1);
1929 // }else if( matchStyle==MS_GLOB ){
1930 // blob_append(&desc, " glob pattern", -1);
1931 // }else/* if( matchStyle==MS_REGEXP )*/{
1932 // blob_append(&desc, " regular expression", -1);
1933 // }
1934 // if( tagMatchCount!=1 ){
1935 // blob_append(&desc, "s", 1);
1936 // }
1937 // blob_appendf(&desc, " (%h)", zThisTag);
1938 }else if( zTagName ){
1939 blob_appendf(&desc, " tagged with \"%h\"", zTagName);
1940 }else{
1941 blob_appendf(&desc, " related to \"%h\"", zBrName);
1942 }
1943
--- src/timeline.c
+++ src/timeline.c
@@ -1241,34 +1241,29 @@
1241 ** the tag table to access the "tagname" column.
1242 **
1243 ** Each pattern is adjusted to to start with "sym-" and be anchored at end.
1244 **
1245 ** In MS_REGEXP mode, backslash can be used to protect delimiter characters.
 
 
 
 
1246 */
1247 static const char *tagMatchExpression(
1248 MatchStyle matchStyle, /* Match style code */
1249 const char *zTag, /* Tag name, match pattern, or list of patterns */
1250 int *pCount /* Pointer to match pattern count variable */
1251 ){
1252 Blob blob = BLOB_INITIALIZER; /* SQL expression string assembly buffer */
 
1253 const char *zStart; /* Text at start of expression */
1254 const char *zDelimiter; /* Text between expression terms */
1255 const char *zEnd; /* Text at end of expression */
1256 const char *zPrefix; /* Text before each match pattern */
1257 const char *zSuffix; /* Text after each match pattern */
1258 char cDel; /* Input delimiter character */
 
1259 int i; /* Input match pattern length counter */
1260
1261 /* Optimize exact matches by looking up the ID in advance to create a simple
1262 * numeric comparison. Bypass the remainder of this function. */
1263 if( matchStyle==MS_EXACT ){
1264 *pCount = 1;
1265 return mprintf("(tagid=%d)", db_int(-1,
1266 "SELECT tagid FROM tag WHERE tagname='sym-%q'", zTag));
1267 }
1268
1269 /* Decide pattern prefix and suffix strings according to match style. */
@@ -1290,13 +1285,13 @@
1285 zEnd = ")$')";
1286 zPrefix = "";
1287 zSuffix = "";
1288 }
1289
1290 /* Convert the list of matches into an SQL expression. */
1291 *pCount = 0;
1292 blob_zero(&blob);
1293 while( 1 ){
1294 /* Skip leading delimiters. */
1295 for( ; fossil_isspace(*zTag) || *zTag==','; ++zTag );
1296
1297 /* Next non-delimiter character determines quoting. */
@@ -1303,21 +1298,21 @@
1298 if( !*zTag ){
1299 /* Terminate loop at end of string. */
1300 break;
1301 }else if( *zTag=='\'' || *zTag=='"' ){
1302 /* If word is quoted, prepare to stop at end quote. */
1303 cDel = *zTag;
1304 ++zTag;
1305 }else{
1306 /* If word is not quoted, prepare to stop at delimiter. */
1307 cDel = ',';
1308 }
1309
1310 /* Find the next delimiter character or end of string. */
1311 for( i=0; zTag[i] && zTag[i]!=cDel; ++i ){
1312 /* If delimiter is comma, also recognize spaces as delimiters. */
1313 if( cDel==',' && fossil_isspace(zTag[i]) ){
1314 break;
1315 }
1316
1317 /* In regexp mode, ignore delimiters following backslashes. */
1318 if( matchStyle==MS_REGEXP && zTag[i]=='\\' && zTag[i+1] ){
@@ -1325,24 +1320,27 @@
1320 }
1321 }
1322
1323 /* Incorporate the match word into the output expression. The %q format is
1324 * used to protect against SQL injection attacks by replacing ' with ''. */
1325 blob_appendf(&blob, "%s%s%#q%s", *pCount ? zDelimiter : zStart,
1326 zPrefix, i, zTag, zSuffix);
1327
1328 /* Keep track of the number of match expressions. */
1329 ++*pCount;
1330
1331 /* Advance past all consumed input characters. */
1332 zTag += i;
1333 if( cDel!=',' && *zTag==cDel ){
1334 ++zTag;
1335 }
1336 }
1337
1338 /* Finalize and extract the SQL expression. */
1339 if( *pCount ){
1340 blob_append(&blob, zEnd, -1);
1341 return blob_str(&blob);
1342 }
1343
1344 /* If execution reaches this point, the pattern was empty. Return NULL. */
1345 return 0;
1346 }
@@ -1406,12 +1404,12 @@
1404 const char *zMark = P("m"); /* Mark this event or an event this time */
1405 const char *zTagName = P("t"); /* Show events with this tag */
1406 const char *zBrName = P("r"); /* Show events related to this tag */
1407 const char *zMatchStyle = P("ms"); /* Tag/branch match style string */
1408 MatchStyle matchStyle = MS_EXACT; /* Match style code */
 
1409 const char *zTagSql = 0; /* Tag/branch match SQL expression */
1410 int tagMatchCount = 0; /* Number of tag match patterns */
1411 const char *zSearch = P("s"); /* Search string */
1412 const char *zUses = P("uf"); /* Only show check-ins hold this file */
1413 const char *zYearMonth = P("ym"); /* Show check-ins for the given YYYY-MM */
1414 const char *zYearWeek = P("yw"); /* Check-ins for YYYY-WW (week-of-year) */
1415 const char *zDay = P("ymd"); /* Check-ins for the day YYYY-MM-DD */
@@ -1490,11 +1488,11 @@
1488 }
1489 }
1490
1491 /* Construct the tag match expression. */
1492 if( zThisTag ){
1493 zTagSql = tagMatchExpression(matchStyle, zThisTag, &tagMatchCount);
1494 }
1495
1496 if( zTagName && g.perm.Read ){
1497 style_submenu_element("Related", "Related", "%s",
1498 url_render(&url, "r", zTagName, "t", 0));
@@ -1921,22 +1919,21 @@
1919 if( zTagName ){
1920 blob_append(&desc, " with tags matching ", -1);
1921 }else{
1922 blob_append(&desc, " related to tags matching ", -1);
1923 }
1924 if( matchStyle==MS_LIKE ){
1925 blob_append(&desc, " SQL LIKE pattern", -1);
1926 }else if( matchStyle==MS_GLOB ){
1927 blob_append(&desc, " glob pattern", -1);
1928 }else/* if( matchStyle==MS_REGEXP )*/{
1929 blob_append(&desc, " regular expression", -1);
1930 }
1931 if( tagMatchCount!=1 ){
1932 blob_append(&desc, "s", 1);
1933 }
1934 blob_appendf(&desc, " (%h)", zThisTag);
 
1935 }else if( zTagName ){
1936 blob_appendf(&desc, " tagged with \"%h\"", zTagName);
1937 }else{
1938 blob_appendf(&desc, " related to \"%h\"", zBrName);
1939 }
1940

Keyboard Shortcuts

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