summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2005-08-12 16:05:48 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2005-08-12 16:05:48 +0000
commit3badd553f24defd43f2d3e43f50b529f0ac1fd3a (patch)
tree8085d76f457dfb32b923e9837f41ba8f7b1014e9
parent4d288c2946b56e4c3a9707ed11a70e16d4a4d968 (diff)
downloadmailutils-3badd553f24defd43f2d3e43f50b529f0ac1fd3a.tar.gz
mailutils-3badd553f24defd43f2d3e43f50b529f0ac1fd3a.tar.bz2
Make handling of quotes consistent with shell
rules. In particular, single quotes need not be quoted, and are not removed when appearing within a doubly-quoted string.
-rw-r--r--mailbox/argcv.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/mailbox/argcv.c b/mailbox/argcv.c
index 91b3219e1..9722978ac 100644
--- a/mailbox/argcv.c
+++ b/mailbox/argcv.c
@@ -167,7 +167,7 @@ argcv_quoted_length (const char *str, int *quote)
len++;
*quote = 1;
}
- else if (*str == '"' || *str == '\'')
+ else if (*str == '"')
{
len += 2;
*quote = 1;
@@ -275,7 +275,7 @@ argcv_quote_copy (char *dst, const char *src)
{
for (; *src; src++)
{
- if (*src == '"' || *src == '\'')
+ if (*src == '"')
{
*dst++ = '\\';
*dst++ = *src;
@@ -329,6 +329,8 @@ argcv_get_n (const char *command, int len, const char *delim, const char *cmnt,
for (i = 0; i < *argc; i++)
{
int n;
+ int unquote;
+
argcv_scan (len, command, delim, cmnt, &start, &end, &save);
if ((command[start] == '"' || command[end] == '\'')
@@ -336,12 +338,19 @@ argcv_get_n (const char *command, int len, const char *delim, const char *cmnt,
{
start++;
end--;
+ unquote = 0;
}
+ else
+ unquote = 1;
+
n = end - start + 1;
(*argv)[i] = calloc (n+1, sizeof (char));
if ((*argv)[i] == NULL)
return ENOMEM;
- argcv_unquote_copy ((*argv)[i], &command[start], n);
+ if (unquote)
+ argcv_unquote_copy ((*argv)[i], &command[start], n);
+ else
+ memcpy ((*argv)[i], &command[start], n);
(*argv)[i][n] = 0;
}
(*argv)[i] = NULL;

Return to:

Send suggestions and report system problems to the System administrator.