summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2005-06-29 19:50:05 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2005-06-29 19:50:05 +0000
commit7090df05d0073065f56d1970e20cc2470be6241d (patch)
tree52b1ed3544f21b48a47c26e84d06f91d65d8c2a5
parente9cf710c9cd2d580cede554e8ebd6ae29b452658 (diff)
downloadmailutils-7090df05d0073065f56d1970e20cc2470be6241d.tar.gz
mailutils-7090df05d0073065f56d1970e20cc2470be6241d.tar.bz2
(argcv_scan): Improved scanning.
-rw-r--r--mailbox/argcv.c48
1 files changed, 18 insertions, 30 deletions
diff --git a/mailbox/argcv.c b/mailbox/argcv.c
index feefd7710..d736add16 100644
--- a/mailbox/argcv.c
+++ b/mailbox/argcv.c
@@ -40,7 +40,6 @@ argcv_scan (int len, const char *command, const char *delim, const char* cmnt,
int *start, int *end, int *save)
{
int i = 0;
- int expect_delim;
for (;;)
{
@@ -54,46 +53,35 @@ argcv_scan (int len, const char *command, const char *delim, const char* cmnt,
i++;
*start = i;
- switch (command[i])
+ if (!isdelim (command[i], delim))
{
- case '"':
- case '\'':
- while (++i < len
- && (command[i] != command[*start]
- || command[i-1] == '\\'))
- ;
- if (i < len) /* found matching quote */
- break;
- /*FALLTHRU*/ default:
- if (isdelim (command[i], delim))
- break;
- /* Skip until next whitespace character or end of line. Honor
- escaped whitespace. */
- expect_delim = 0;
- while (++i < len)
+ while (i < len)
{
- if (expect_delim)
+ if (command[i] == '\\')
{
- if (command[i-1] != '\\' && command[i] == expect_delim)
- expect_delim = 0;
- else
- continue;
+ if (++i == len)
+ break;
+ i++;
+ continue;
}
- if (command[i-1] != '\\')
+ if (command[i] == '\'' || command[i] == '"')
{
- if (command[i] == '\'' || command[i] == '"')
- expect_delim = command[i];
- else if (isws (command[i]) || isdelim (command[i], delim))
- break;
+ int j;
+ for (j = i+1; j < len && command[j] != command[i]; j++)
+ if (command[j] == '\\')
+ j++;
+ if (j < len)
+ i = j+1;
+ else
+ i++;
}
+ else if (isws (command[i]) || isdelim (command[i], delim))
+ break;
else
i++; /* skip the escaped character */
}
- if (expect_delim)
- i--;
i--;
- break;
}
*end = i;

Return to:

Send suggestions and report system problems to the System administrator.