Mail Archives: djgpp-workers/2002/02/20/05:43:35
The following code is part of the command-line parsing code of bison 1.32/33.
/* Under plain DOS, there is no difference on the case. This can be
troublesome when looking for `.tab' etc. */
#ifdef MSDOS
# if defined (__DJGPP__)
/* Windows 9X and successors are case sensitive. */
# define AS_FILE_NAME(File) ((pathconf ((File), _PC_NAME_MAX) > 12) ? (File) : (strlwr (File), (File)))
# else
# define AS_FILE_NAME(File) (strlwr (File), (File))
# endif
#else
# define AS_FILE_NAME(File) (File)
#endif
It works OK as long as some kind of windows is used as dpmi server.
As soon as cwsdpmi is used, bison dies with an error=0004.
The reason is that strlwr() does not check if the passed pointer
is a NULL pointer. In this case the while-loop derefences a NULL pointer
producing the SIGSEGV. This is the reason why for certain combinations
of command-line options bison 1.32/33 breaks on plain dos.
The small patch below will fix this for strlwr and strupr (suffers from the
same bug).
Regards,
Guerrero, Juan Manuel
diff -auprNU3 djgpp.orig/src/libc/compat/string/strlwr.c djgpp/src/libc/compat/string/strlwr.c
--- djgpp.orig/src/libc/compat/string/strlwr.c Thu Jun 3 19:27:34 1999
+++ djgpp/src/libc/compat/string/strlwr.c Wed Feb 20 11:17:34 2002
@@ -7,6 +7,8 @@ char *
strlwr(char *_s)
{
char *rv = _s;
+ if (!_s)
+ return rv;
while (*_s)
{
*_s = tolower((unsigned char)*_s);
diff -auprNU3 djgpp.orig/src/libc/compat/string/strlwr.txh djgpp/src/libc/compat/string/strlwr.txh
--- djgpp.orig/src/libc/compat/string/strlwr.txh Sun Sep 27 17:21:10 1998
+++ djgpp/src/libc/compat/string/strlwr.txh Wed Feb 20 10:15:38 2002
@@ -14,7 +14,7 @@ case letters.
@subheading Return Value
-The string.
+@var{string}
@subheading Portability
diff -auprNU3 djgpp.orig/src/libc/compat/string/strupr.c djgpp/src/libc/compat/string/strupr.c
--- djgpp.orig/src/libc/compat/string/strupr.c Thu Jun 3 19:27:34 1999
+++ djgpp/src/libc/compat/string/strupr.c Wed Feb 20 11:17:34 2002
@@ -7,6 +7,8 @@ char *
strupr(char *_s)
{
char *rv = _s;
+ if (!_s)
+ return rv;
while (*_s)
{
*_s = toupper((unsigned char)*_s);
- Raw text -