On Sat, 10 Nov 2001, Mike Breuer wrote:
> Unpropper grammar notwithstanding,
...[1]
> this is basically the same issue that has been discussed very
> recently. half_chop() calls any_one_arg() which converts the passed
> arguments to lower case. If you don't want this behavior, you'll need
> to parse the arguments yourself. Something like this:
Or, perhaps, write a generalized parsing function, something like this:
/*
* split(string, token, delimiter, preserveCase) ==> char *
* A genearlized string tokenizer. Mailer Code(tm) -dak
*/
char *split(char *orig, char *arg, char sep, bool pcase)
{
if (!orig) {
log("SYSERR: split() called with NULL pointer!");
*arg = '\0';
return (NULL);
}
skip_spaces(&orig);
/* SPECIAL CASE: A separator of " or ' means "group on quotes" */
if (sep == '"' || sep == '\'') {
if (*orig == '"') {
sep = '"';
orig++;
} else if (*orig == '\'') {
sep = '\'';
orig++;
} else sep = 0;
}
while (*orig && (sep ? *orig != sep : isspace(*orig))) {
if (*arg == open_sep) depth++;
*(arg++) = (pcase ? *orig : LOWER(*orig));
orig++;
}
*arg = '\0';
return (orig);
}
You could then redefine one_argument() and friends in terms of this:
#define one_argument(argument, first_arg) \
do argument = split(argument, first_arg, 0, FALSE); \
while (fill_word(first_arg))
#define one_word(argument, first_arg) \
do argument = split(argument, first_arg, '"', FALSE); \
while (fill_word(first_arg))
#define any_one_arg(argument, first_arg) \
split(argument, first_arg, 0, FALSE)
for backwards compatability. With split(), you can choose to preserve the
case when desired by simply using TRUE as the last argument to the
function.
-dak
[1] !
--
+---------------------------------------------------------------+
| FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
| Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
+---------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/06/01 PST