On Sat, Nov 8, 2008 at 9:22 PM, chromatic <[EMAIL PROTECTED]> wrote:

> On Wednesday 05 November 2008 14:31:21 [EMAIL PROTECTED] wrote:
>
> > Modified:
> >    trunk/compilers/pirc/new/pir.l
> >    trunk/compilers/pirc/new/pirlexer.c
> >    trunk/compilers/pirc/new/pirlexer.h
> >
> > Log:
> > [pirc] add support for braced arguments in macro expansion.
> >
> > Modified: trunk/compilers/pirc/new/pir.l
> >
> ===========================================================================
> >=== --- trunk/compilers/pirc/new/pir.l (original)
> > +++ trunk/compilers/pirc/new/pir.l    Wed Nov  5 14:31:19 2008
> > @@ -610,6 +610,12 @@
> >                                 yy_switch_to_buffer(lexer->buffer,
> > yyscanner); }
> >
> > +<MACROEXPAND>"{"[^}]*"}"     { /* a braced argument; match ANYTHING up
> to
> > the closing brace. */
> > +                               yylval->sval =
> > dupstrn(yyget_extra(yyscanner), +
>
> We have strdup, str_dup, and dupstrn; any thoughts on standardizing on one
> or
> two?  (I like the idea of using an _n variant wherever possible.)
>
> -- c
>

1) strdup is a C library function, but not C89.
2) str_dup is the IMCC version that does the same (and I'm trying to get rid
of that)
3) dupstrn is pirc's solution; it has dupstr and dupstrn, taking a 3rd
argument, "n".

You're right, it's better to use *some* standard, but I shouldn't use 1) as
it's not C89 (AFAIK), 2) is IMCC-specific, so I chose 3), as it was the best
solution at the time I needed it (pirc didn't link to libparrot yet, and
moreover, it's a imcc-specific function, and I don't want to introduce
dependencies on something that I'm trying to replace).

Maybe there should be a configure test: if the platform has a strdup, use
that, otherwise use some built-in or so (possibly a macro, as strdup is
really really easy)

_n variant: do you mean dupstr_n?

kjs

Reply via email to