aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorEli Zaretskii2022-07-01 16:17:40 +0300
committerEli Zaretskii2022-07-01 16:17:40 +0300
commit8a098f6517157ebe2364f08008b44ab49c2d1115 (patch)
treef30311ac3cbbbd53ed46d4a9881d5f4549459f45 /lib-src
parent474f5b21b43efd4c2f60bfdfa385c8b522bf12c8 (diff)
downloademacs-8a098f6517157ebe2364f08008b44ab49c2d1115.tar.gz
emacs-8a098f6517157ebe2364f08008b44ab49c2d1115.zip
Fix quoting of file names in 'ctags'
* lib-src/etags.c (main) [WINDOWSNT || MSDOS]: Quote file names according to the rules of the system shells.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/etags.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c
index 9a60714ecab..ef112579264 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -1431,6 +1431,16 @@ main (int argc, char **argv)
1431 setenv ("LC_COLLATE", "C", 1); 1431 setenv ("LC_COLLATE", "C", 1);
1432 setenv ("LC_ALL", "C", 1); */ 1432 setenv ("LC_ALL", "C", 1); */
1433 char *cmd = xmalloc (8 * strlen (tagfile) + sizeof "sort -u -o '' ''"); 1433 char *cmd = xmalloc (8 * strlen (tagfile) + sizeof "sort -u -o '' ''");
1434#if defined WINDOWSNT || defined MSDOS
1435 /* Quote "like this". No need to escape the quotes in the file name,
1436 since it is not allowed in file names on these systems. */
1437 char *z = stpcpy (cmd, "sort -u -o \"");
1438 z = stpcpy (z, tagfile);
1439 z = stpcpy (z, "\" \"");
1440 z = stpcpy (z, tagfile);
1441 stpcpy (z, "\"");
1442#else
1443 /* Quote 'like this', and escape the apostrophe in the file name. */
1434 char *z = stpcpy (cmd, "sort -u -o '"); 1444 char *z = stpcpy (cmd, "sort -u -o '");
1435 char *escaped_tagfile = z; 1445 char *escaped_tagfile = z;
1436 for (; *tagfile; *z++ = *tagfile++) 1446 for (; *tagfile; *z++ = *tagfile++)
@@ -1440,6 +1450,7 @@ main (int argc, char **argv)
1440 z = stpcpy (z, "' '"); 1450 z = stpcpy (z, "' '");
1441 z = mempcpy (z, escaped_tagfile, escaped_tagfile_len); 1451 z = mempcpy (z, escaped_tagfile, escaped_tagfile_len);
1442 strcpy (z, "'"); 1452 strcpy (z, "'");
1453#endif
1443 return system (cmd); 1454 return system (cmd);
1444 } 1455 }
1445 return EXIT_SUCCESS; 1456 return EXIT_SUCCESS;