aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorEli Zaretskii2022-12-06 18:13:41 +0200
committerEli Zaretskii2022-12-06 18:13:41 +0200
commit7e6d1d1c47196bf1bb5254f5c9014e25bdaf9833 (patch)
tree89770813225ea4b8332fa60db4e7a98e69f8e9e6 /lib-src
parent01a4035c869b91c153af9a9132c87adb7669ea1c (diff)
downloademacs-7e6d1d1c47196bf1bb5254f5c9014e25bdaf9833.tar.gz
emacs-7e6d1d1c47196bf1bb5254f5c9014e25bdaf9833.zip
; Fix last change in etags.c.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/etags.c47
1 files changed, 29 insertions, 18 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c
index ba0092cc637..9091257a203 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -401,7 +401,9 @@ static void invalidate_nodes (fdesc *, node **);
401static void put_entries (node *); 401static void put_entries (node *);
402static void cleanup_tags_file (char const * const, char const * const); 402static void cleanup_tags_file (char const * const, char const * const);
403 403
404#if !defined (MSDOS) && !defined (DOS_NT)
404static char *escape_shell_arg_string (char *); 405static char *escape_shell_arg_string (char *);
406#endif
405static void do_move_file (const char *, const char *); 407static void do_move_file (const char *, const char *);
406static char *concat (const char *, const char *, const char *); 408static char *concat (const char *, const char *, const char *);
407static char *skip_spaces (char *); 409static char *skip_spaces (char *);
@@ -1714,15 +1716,22 @@ process_file_name (char *file, language *lang)
1714 else 1716 else
1715 { 1717 {
1716#if MSDOS || defined (DOS_NT) 1718#if MSDOS || defined (DOS_NT)
1717 int buf_len = strlen (compr->command) + strlen (" \"\" > \"\"") + strlen (real_name) + strlen (tmp_name) + 1; 1719 int buf_len =
1718 char *cmd = xmalloc (buf_len); 1720 strlen (compr->command)
1719 snprintf (cmd, buf_len, "%s \"%s\" > \"%s\"", compr->command, real_name, tmp_name); 1721 + strlen (" \"\" > \"\"") + strlen (real_name)
1722 + strlen (tmp_name) + 1;
1723 char *cmd = xmalloc (buf_len);
1724 snprintf (cmd, buf_len, "%s \"%s\" > \"%s\"",
1725 compr->command, real_name, tmp_name);
1720#else 1726#else
1721 char *new_real_name = escape_shell_arg_string (real_name); 1727 char *new_real_name = escape_shell_arg_string (real_name);
1722 char *new_tmp_name = escape_shell_arg_string (tmp_name); 1728 char *new_tmp_name = escape_shell_arg_string (tmp_name);
1723 int buf_len = strlen (compr->command) + strlen (" > ") + strlen (new_real_name) + strlen (new_tmp_name) + 1; 1729 int buf_len =
1724 char *cmd = xmalloc (buf_len); 1730 strlen (compr->command) + strlen (" > ") + strlen (new_real_name)
1725 snprintf (cmd, buf_len, "%s %s > %s", compr->command, new_real_name, new_tmp_name); 1731 + strlen (new_tmp_name) + 1;
1732 char *cmd = xmalloc (buf_len);
1733 snprintf (cmd, buf_len, "%s %s > %s",
1734 compr->command, new_real_name, new_tmp_name);
1726#endif 1735#endif
1727 inf = (system (cmd) == -1 1736 inf = (system (cmd) == -1
1728 ? NULL 1737 ? NULL
@@ -7711,6 +7720,7 @@ etags_mktmp (void)
7711 return templt; 7720 return templt;
7712} 7721}
7713 7722
7723#if !defined (MSDOS) && !defined (DOS_NT)
7714/* 7724/*
7715 * Adds single quotes around a string, if found single quotes, escaped it. 7725 * Adds single quotes around a string, if found single quotes, escaped it.
7716 * Return a newly-allocated string. 7726 * Return a newly-allocated string.
@@ -7723,14 +7733,14 @@ static char *
7723escape_shell_arg_string (char *str) 7733escape_shell_arg_string (char *str)
7724{ 7734{
7725 char *p = str; 7735 char *p = str;
7726 int need_space = 2; /* ' at begin and end */ 7736 int need_space = 2; /* ' at begin and end */
7727 7737
7728 while (*p != '\0') 7738 while (*p != '\0')
7729 { 7739 {
7730 if (*p == '\'') 7740 if (*p == '\'')
7731 need_space += 4; /* ' to '\'', length is 4 */ 7741 need_space += 4; /* ' to '\'', length is 4 */
7732 else 7742 else
7733 need_space++; 7743 need_space++;
7734 7744
7735 p++; 7745 p++;
7736 } 7746 }
@@ -7739,18 +7749,18 @@ escape_shell_arg_string (char *str)
7739 new_str[0] = '\''; 7749 new_str[0] = '\'';
7740 new_str[need_space-1] = '\''; 7750 new_str[need_space-1] = '\'';
7741 7751
7742 int i = 1; /* skip first byte */ 7752 int i = 1; /* skip first byte */
7743 p = str; 7753 p = str;
7744 while (*p != '\0') 7754 while (*p != '\0')
7745 { 7755 {
7746 new_str[i] = *p; 7756 new_str[i] = *p;
7747 if (*p == '\'') 7757 if (*p == '\'')
7748 { 7758 {
7749 new_str[i+1] = '\\'; 7759 new_str[i+1] = '\\';
7750 new_str[i+2] = '\''; 7760 new_str[i+2] = '\'';
7751 new_str[i+3] = '\''; 7761 new_str[i+3] = '\'';
7752 i += 3; 7762 i += 3;
7753 } 7763 }
7754 7764
7755 i++; 7765 i++;
7756 p++; 7766 p++;
@@ -7759,6 +7769,7 @@ escape_shell_arg_string (char *str)
7759 new_str[need_space] = '\0'; 7769 new_str[need_space] = '\0';
7760 return new_str; 7770 return new_str;
7761} 7771}
7772#endif
7762 7773
7763static void 7774static void
7764do_move_file(const char *src_file, const char *dst_file) 7775do_move_file(const char *src_file, const char *dst_file)