help-flex
[Top][All Lists]
Advanced

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

Re: %option stdinit


From: Osamu Aoki
Subject: Re: %option stdinit
Date: Wed, 6 Mar 2002 21:47:53 -0800
User-agent: Mutt/1.3.27i

Hi, thank you for your insight but ...

On Wed, Mar 06, 2002 at 11:40:39AM -0800, John W. Millaway wrote:
> > Anyone have any thoughts on this?
> This is not a bug. The user misunderstands the purpose of %option stdinit. 

Maybe not a bug with the program but, documentation-wise, I think it is
a bug.  (FYI: I could compile these example by using `%option nostdinit'
and declaring "yyin=stdin;" in yacc source.  So please do not
misunderstand my complain.  My examples included these successful
compile sample, too.)

> The option does exactly what it is supposed to do -- It initializes
> yyin/out to stdin/out, STATICALLY. This is to FORCE static
> initialization. 

Info page states:
`stdinit'
     if unset (i.e., `%option nostdinit') initializes `yyin' and
     `yyout' to nil `FILE' pointers, instead of `stdin' and `stdout'.

It does not say anything about "STATICALLY".  Of course, I could have
looked into skelton file (That I did), I do not think that is not
something we need to do.  Documentation shall be clear on this.

If this is tha case, it should require yacc code to be changed and
mention "STATICALLY".

> The advice to this user is:  Don't use %option stdinit if your libc
> doesn't define stdin/out as compile-time constants. Flex already does
> what you want, by default, at runtime (safely).

That what I ended up doing.  But I needed to add a line to the yacc code
which was written originally for yacc/lex (Orielly book).  I do not
think "compatibility" is offered here by declaring as above. 

> On the first invocation of yylex(), flex checks if yyin and yyout are
> NULL, which they are, initially, unless %option stdinit was specified.
> If either yyin or yyout are NULL, then flex initializes them to stdin
> and stdout.

No that was not what happened. Without this option (default), program
compiles but core dump upon execution.  With this option, program does
not compile.

> In reality, there is no reason to ever use %option stdinit, unless,
> for some reason, you need them to be initialized during linking. The
> option is present for backwards compatibility, as noted in the flex
> manual.

Looks like bug was closed but is this right?  Reading comment from 
Hans-Bernhard Broeker <address@hidden> .

Regards,
Osamu

-- 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+  Osamu Aoki <address@hidden> @ Cupertino, CA USA         +
Visit Debian reference http://www.debian.org/doc/manuals/quick-reference/



reply via email to

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