Philip Hazel writes:
> On Thu, 2 Mar 2000, Malcolm Beattie wrote:
>
> > Off the top of my head, how about
> > foo = "something;something else;and another" separator ;
> > or similar? The disadvantage is that it looks a bit ugly (you have to
> > look at the end to see what the separator is). The advantage is that it
> > ought to be completely backward compatible since presumably nothing has
> > ever looked passed the final quote before.
>
> But you don't have to use quotes! You could always say
>
> local_domains = a:b:c
>
> and with the new change I've proposed you can now say
>
> local_domains = a:\
> b:\
> c
That's nothing to do with the separator issue though. The comment I was
replying to was asking if anyone could think of a way to avoid having
to double colons in places like URLs and IPv6 addresses. I came up with
foo = "..." separator <char>
as a backward-compatible way of letting you do that. You couldn't pull
the same trick without requiring quotes because the string might well
*really* end in "separator <char>".
> Another objection is that it complicates things no end. Every single
> string option would have to store its separator as well as its data.
Pity. I hadn't looked into how you do the parsing. On the other hand,
could you not simply store the separator as the first character of
every option string? Then you could have something like:
#define OPT_SEPARATOR(str) *(str)
#define OPT_VALUE(str) (str + 1)
It's not like you need a structure with a separately allocated chunk of
data somewhere. Or maybe there are lots of places which handle option
strings and "normal" strings together and it wouldn't be obvious which
to add OPT_VALUE() to? Maybe I ought to read the source...:-)
--Malcolm
--
Malcolm Beattie <mbeattie@???>
Unix Systems Programmer
Oxford University Computing Services