php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #1600 flex-generated parsers don't use const if __STDC__ is not true
Submitted: 1999-06-25 22:51 UTC Modified: 1999-06-26 14:02 UTC
From: alanc at soar dot berkeley dot edu Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 3.0.9 OS: Solaris 2.6
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: alanc at soar dot berkeley dot edu
New email:
PHP Version: OS:

 

 [1999-06-25 22:51 UTC] alanc at soar dot berkeley dot edu
language-scanner.c & configuration parser.c contain the following code (generated by flex):

#if __STDC__
#define YY_USE_CONST
#endif  /* __STDC__ */

#ifdef YY_USE_CONST
#define yyconst const
#else
#define yyconst
#endif

Unfortunately, not all compilers that support the const keyword define __STDC__ to a true value.
For instance, Sun's C compiler only defines __STDC__ to be true if the compiler is invoked with
-Xc (strict ANSI compliance mode, no non-ANSI features allowed).  The following patch works around
this behavior, and generates a libmodphp.a that makes the large parser tables read-only so they
can be shared between http processes and lowers the per-process memory requirements:
diff -crwb php-3.0.9/configure.in php-3.0.9-mine/configure.in
*** php-3.0.9/configure.in      Thu Jun  3 05:03:05 1999
--- php-3.0.9-mine/configure.in Fri Jun 25 18:20:00 1999
***************
*** 36,41 ****
--- 36,50 ----
        CFLAGS=`echo $CFLAGS | sed -e 's/-g//'`
  fi
  
+ dnl Make flex scanners use const if they can, even if __STDC__ is not
+ dnl true, for compilers like Sun's that only set __STDC__ true in
+ dnl "limit-to-ANSI-standard" mode, not in "ANSI-compatible" mode
+ AC_C_CONST
+ if test $ac_cv_c_const = yes; then
+    LEX_CFLAGS="-DYY_USE_CONST"
+ fi
+ AC_SUBST(LEX_CFLAGS)
+ 
  dnl check for -R, etc. switch
  AC_MSG_CHECKING(if compiler supports -R)
  AC_CACHE_VAL(php_cv_cc_dashr,[

diff -crwb php-3.0.9/Makefile.in php-3.0.9-mine/Makefile.in
*** php-3.0.9/Makefile.in       Thu Jun  3 07:05:10 1999
--- php-3.0.9-mine/Makefile.in  Fri Jun 25 18:23:27 1999
***************
*** 52,57 ****
--- 52,58 ----
  APXS = @APXS@
  APXS_LDFLAGS = @PHP_LIBS@ @APXS_LDFLAGS@ @LIBS@
  WARNING_LEVEL = @WARNING_LEVEL@
+ LEX_CFLAGS = -w$(WARNING_LEVEL) @LEX_CFLAGS@
  
  SOURCE = language-parser.tab.c language-scanner.c main.c php3_hash.c operators
.c \
         variables.c token_cache.c stack.c internal_functions.c \
***************
*** 141,147 ****
        bison -p php -v -d $(srcdir)/language-parser.y -o language-parser.tab.c
  
  language-scanner.o:
!       $(CC) $(CFLAGS) -w$(WARNING_LEVEL) -c language-scanner.c
  
  language-scanner.c:  $(srcdir)/language-scanner.lex
        flex -Pphp -olanguage-scanner.c -i $(srcdir)/language-scanner.lex
--- 142,148 ----
        bison -p php -v -d $(srcdir)/language-parser.y -o language-parser.tab.c
  
  language-scanner.o:
!       $(CC) $(CFLAGS) $(LEX_CFLAGS) -c language-scanner.c
  
  language-scanner.c:  $(srcdir)/language-scanner.lex
        flex -Pphp -olanguage-scanner.c -i $(srcdir)/language-scanner.lex
***************
*** 150,156 ****
        bison -p cfg -v -d $(srcdir)/configuration-parser.y -o configuration-par
ser.tab.c
  
  configuration-scanner.o:
!       $(CC) $(CFLAGS) -w$(WARNING_LEVEL) -c configuration-scanner.c
  
  configuration-scanner.c:      $(srcdir)/configuration-scanner.lex
        flex -Pcfg -oconfiguration-scanner.c -i $(srcdir)/configuration-scanner.
lex
--- 151,157 ----
        bison -p cfg -v -d $(srcdir)/configuration-parser.y -o configuration-par
ser.tab.c
  
  configuration-scanner.o:
!       $(CC) $(CFLAGS) $(LEX_CFLAGS) -c configuration-scanner.c
  
  configuration-scanner.c:      $(srcdir)/configuration-scanner.lex
        flex -Pcfg -oconfiguration-scanner.c -i $(srcdir)/configuration-scanner.
lex


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-06-26 14:02 UTC] sas at cvs dot php dot net
Thanks for the patch. Will be in 3.0.11.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Mon Jun 15 00:00:02 2026 UTC