emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fix the sscanf usage in etags


From: Masatake YAMATO
Subject: Re: fix the sscanf usage in etags
Date: Wed, 09 Aug 2006 23:10:42 +0900 (JST)

> Masatake YAMATO skrev:
> > This is the file what I got trouble without my patch.
> > 
> 
> ...
> 
> > // 7.4: string literal in #line directive shall be a character string
> > //      literal.
> > //E t_6_062.cpp(21): warning: ill formed #line directive: 123 L"wide"
> > #line 123 L"wide"
> > 
> 
> I don't know if etags supports wide characters at all.  A line directive like 
> that is not allowed by ANSI-C as the comment says.

I see. In this case, etags should ignore the line.
The problem I found was that etags crashed when `#line 123 L"wide"' was given
as input. If the crashing can be suppressed, it is enough.

> We can switch places between \" and %n and check for ":
> 
>         if (sscanf (lbp->buffer, "#line %d %n\"", &lno, &start) >= 1
>             && lbp->buffer[start] == '"')
>           {
>             char *endp = lbp->buffer + ++start;

This works fine.
I tested with:

const char * buffer = "#line 123                                      
L\"wide\"";
const char * buffer = "#line 123 L\"wide\"";
const char * buffer = "#line 123L\"wide\"";

Masatake YAMATO




reply via email to

[Prev in Thread] Current Thread [Next in Thread]