Fossil

Check-in [c1afe56f]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Improve comment
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | andygoth-timeline-ms
Files: files | file ages | folders
SHA1:c1afe56ffa50bf118c06284413f5a3e680180224
User & Date: andygoth 2016-10-23 15:42:29
Context
2016-10-23
21:50
Optimize REGEXP matching by folding all regular expressions into one check-in: b4800dc5 user: andygoth tags: andygoth-timeline-ms
15:42
Improve comment check-in: c1afe56f user: andygoth tags: andygoth-timeline-ms
15:36
Add ms=EXACT|LIKE|GLOB|REGEXP timeline query parameter which changes the interpretation of the t= and r= query parameters to exact (default), SQL LIKE, glob, or regular expression matching. Other than exact matching, the t= or r= parameter value is interpreted as a whitespace- or comma-delimited list of match patterns, with the option to quote a pattern using single or double quotes in case it contains commas or whitespace. For regular expression matching only, backslash can also be used to inhibit delimiter interpretation of the next character. At this point, the only way to use this feature is to type ms= directly into the URL; the UI still needs to be updated. Be aware for LIKE interpretation that % needs to be written as %25. check-in: be586845 user: andygoth tags: andygoth-timeline-ms
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/timeline.c.

1227
1228
1229
1230
1231
1232
1233
1234











1235
1236
1237
1238
1239
1240
1241
....
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
  MS_EXACT,   /* Matches a single tag by exact string comparison. */
  MS_LIKE,    /* Matches tags against a list of LIKE patterns. */
  MS_GLOB,    /* Matches tags against a list of GLOB patterns. */
  MS_REGEXP   /* Matches tags against a list of regular expressions. */
} MatchStyle;

/*
** Construct the tag match expression.











*/
static const char *tagMatchExpression(
  MatchStyle matchStyle,  /* Match style code */
  const char *zTag,       /* Tag name, match pattern, or list of patterns */
  int *pCount             /* Pointer to match pattern count variable */
){
  Blob blob = BLOB_INITIALIZER;
................................................................................
    zPre = "GLOB 'sym-";
    zSuf = "'";
  }else/* if( matchStyle==MS_REGEXP )*/{
    zPre = "REGEXP '^sym-";
    zSuf = "$'";
  }

  /* The following code is glob_expr() modified to support LIKE and REGEXP, plus
   * adjust each pattern to start with "sym-" and be anchored at end.  In REGEXP
   * mode, it allows backslash to protect delimiter characters. */

  /* Convert the list of matches into an SQL expression. */
  *pCount = 0;
  blob_zero(&blob);
  while( 1 ){
    /* Skip leading delimiters. */
    for( ; fossil_isspace(*zTag) || *zTag==','; ++zTag );








|
>
>
>
>
>
>
>
>
>
>
>







 







<
<
<
<







1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
....
1273
1274
1275
1276
1277
1278
1279




1280
1281
1282
1283
1284
1285
1286
  MS_EXACT,   /* Matches a single tag by exact string comparison. */
  MS_LIKE,    /* Matches tags against a list of LIKE patterns. */
  MS_GLOB,    /* Matches tags against a list of GLOB patterns. */
  MS_REGEXP   /* Matches tags against a list of regular expressions. */
} MatchStyle;

/*
** Construct the tag match SQL expression.
**
** This function is adapted from glob_expr() to support the MS_EXACT, MS_LIKE,
** MS_GLOB, and MS_REGEXP match styles.  For MS_EXACT, the returned expression
** checks for integer match against the tag ID which is looked up directly by
** this function.  For the other modes, the returned SQL expression performs
** string comparisons against the tag names, so it is necessary to join against
** the tag table to access the "tagname" column.
** 
** Each pattern is adjusted to to start with "sym-" and be anchored at end.
** 
** In MS_REGEXP mode, backslash can be used to protect delimiter characters.
*/
static const char *tagMatchExpression(
  MatchStyle matchStyle,  /* Match style code */
  const char *zTag,       /* Tag name, match pattern, or list of patterns */
  int *pCount             /* Pointer to match pattern count variable */
){
  Blob blob = BLOB_INITIALIZER;
................................................................................
    zPre = "GLOB 'sym-";
    zSuf = "'";
  }else/* if( matchStyle==MS_REGEXP )*/{
    zPre = "REGEXP '^sym-";
    zSuf = "$'";
  }





  /* Convert the list of matches into an SQL expression. */
  *pCount = 0;
  blob_zero(&blob);
  while( 1 ){
    /* Skip leading delimiters. */
    for( ; fossil_isspace(*zTag) || *zTag==','; ++zTag );