aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/etags.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c
index 65b9fae8d5a..ea99ed9f396 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -1427,14 +1427,19 @@ main (int argc, char **argv)
1427 if (CTAGS) 1427 if (CTAGS)
1428 if (append_to_tagfile || update) 1428 if (append_to_tagfile || update)
1429 { 1429 {
1430 char *cmd = xmalloc (2 * strlen (tagfile) + sizeof "sort -u -o..");
1431 /* Maybe these should be used: 1430 /* Maybe these should be used:
1432 setenv ("LC_COLLATE", "C", 1); 1431 setenv ("LC_COLLATE", "C", 1);
1433 setenv ("LC_ALL", "C", 1); */ 1432 setenv ("LC_ALL", "C", 1); */
1434 char *z = stpcpy (cmd, "sort -u -o "); 1433 char *cmd = xmalloc (8 * strlen (tagfile) + sizeof "sort -u -o '' ''");
1435 z = stpcpy (z, tagfile); 1434 char *z = stpcpy (cmd, "sort -u -o '");
1436 *z++ = ' '; 1435 char *escaped_tagfile = z;
1437 strcpy (z, tagfile); 1436 for (; *tagfile; *z++ = *tagfile++)
1437 if (*tagfile == '\'')
1438 z = stpcpy (z, "'\\'");
1439 ptrdiff_t escaped_tagfile_len = z - escaped_tagfile;
1440 z = stpcpy (z, "' '");
1441 z = mempcpy (z, escaped_tagfile, escaped_tagfile_len);
1442 strcpy (z, "'");
1438 return system (cmd); 1443 return system (cmd);
1439 } 1444 }
1440 return EXIT_SUCCESS; 1445 return EXIT_SUCCESS;
@@ -6396,7 +6401,8 @@ mercury_decl (char *s, size_t pos)
6396 size_t origpos; 6401 size_t origpos;
6397 origpos = pos; 6402 origpos = pos;
6398 6403
6399 while (s + pos != NULL && (c_isalnum (s[pos]) || s[pos] == '_')) ++pos; 6404 while (c_isalnum (s[pos]) || s[pos] == '_')
6405 pos++;
6400 6406
6401 unsigned char decl_type_length = pos - origpos; 6407 unsigned char decl_type_length = pos - origpos;
6402 char buf[decl_type_length + 1]; 6408 char buf[decl_type_length + 1];
@@ -6440,9 +6446,9 @@ mercury_decl (char *s, size_t pos)
6440 so this is the hard case. */ 6446 so this is the hard case. */
6441 if (strcmp (buf, "solver") == 0) 6447 if (strcmp (buf, "solver") == 0)
6442 { 6448 {
6443 ++pos; 6449 do
6444 while (s + pos != NULL && (c_isalnum (s[pos]) || s[pos] == '_')) 6450 pos++;
6445 ++pos; 6451 while (c_isalnum (s[pos]) || s[pos] == '_');
6446 6452
6447 decl_type_length = pos - origpos; 6453 decl_type_length = pos - origpos;
6448 char buf2[decl_type_length + 1]; 6454 char buf2[decl_type_length + 1];
@@ -6492,7 +6498,6 @@ mercury_decl (char *s, size_t pos)
6492 while (c_isalnum (s[pos]) 6498 while (c_isalnum (s[pos])
6493 || s[pos] == '_' 6499 || s[pos] == '_'
6494 || (s[pos] == '.' /* A module dot. */ 6500 || (s[pos] == '.' /* A module dot. */
6495 && s + pos + 1 != NULL
6496 && (c_isalnum (s[pos + 1]) || s[pos + 1] == '_') 6501 && (c_isalnum (s[pos + 1]) || s[pos + 1] == '_')
6497 && (module_dot_pos = pos))) /* Record module dot position. 6502 && (module_dot_pos = pos))) /* Record module dot position.
6498 Erase module from name. */ 6503 Erase module from name. */
@@ -6536,10 +6541,10 @@ mercury_decl (char *s, size_t pos)
6536 } 6541 }
6537 else if (is_mercury_quantifier && s[pos] == '[') /* :- some [T] pred/func. */ 6542 else if (is_mercury_quantifier && s[pos] == '[') /* :- some [T] pred/func. */
6538 { 6543 {
6539 for (++pos; s + pos != NULL && s[pos] != ']'; ++pos) {} 6544 char *close_bracket = strchr (s + pos + 1, ']');
6540 if (s + pos == NULL) return null_pos; 6545 if (!close_bracket)
6541 ++pos; 6546 return null_pos;
6542 pos = skip_spaces (s + pos) - s; 6547 pos = skip_spaces (close_bracket + 1) - s;
6543 mercury_pos_t position = mercury_decl (s, pos); 6548 mercury_pos_t position = mercury_decl (s, pos);
6544 position.totlength += pos - origpos; 6549 position.totlength += pos - origpos;
6545 return position; 6550 return position;