On Tue, Apr 11, 2006 at 06:15:32PM +0200, Leopold Toetsch wrote:
> 
> On Apr 7, 2006, at 19:38, Nicholas Clark wrote:
> 
> >>-        STRING *fill = CONST_STRING(interpreter, info->flags & 
> >>FLAG_ZERO ? "0" : " ");
> 
> >
> >I think that this change is masking the true bug,
> 
> No. Above replaced line was definitely bogus. CONST_STRING is a macro 
> that takes *one* string constant and it has likely to be own it's own 
> line.

Ah. Thanks for the explanation.

One literal string constant?

find . -type f | grep -v text-base | xargs grep CONST_STR | grep -v '")'
finds
./src/library.c:            *prefix_str = CONST_STRING(interpreter, pwd);

which smells fishy:

    if (!VTABLE_elements(interpreter, config_hash)) {
        const char *pwd = ".";
        char *ret;

        if (prefix_str) {
            *prefix_str = CONST_STRING(interpreter, pwd);
            return NULL;
        }
        ret = mem_sys_allocate(3);
        strcpy(ret, pwd);
        return ret;
    }


> and the generated .str files. Improvements to that utility are welcome 
> to prevent such errors.

If it's supposed to only ever be a literal "" string constant, Chip suggested
a neat trick that we're now using in Perl 5 - in the macro get the C
pre-processor to append "" to the argument. The only thing that that's valid
for is a literal string.

Nicholas Clark

Reply via email to