mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-19 17:23:02 +00:00
* src/system.h: We don't need nor want bcopy.
Throw away MS-DOS crap: we don't need getpid. * configure.in: We don't need strndup. It was even causing problems: because Flex includes the headers *before* us, _GNU_SOURCE is not defined by config.h, and therefore strndup was not visible. * lib/xstrndup.c: New. * src/scan-skel.l: Use it. Be sure to initialize yylval.muscle member when scanning a MUSCLE. * src/parse-skel.y: Use %directives instead of #defines.
This commit is contained in:
14
ChangeLog
14
ChangeLog
@@ -1,3 +1,17 @@
|
|||||||
|
2001-12-30 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
|
* src/system.h: We don't need nor want bcopy.
|
||||||
|
Throw away MS-DOS crap: we don't need getpid.
|
||||||
|
* configure.in: We don't need strndup. It was even causing
|
||||||
|
problems: because Flex includes the headers *before* us,
|
||||||
|
_GNU_SOURCE is not defined by config.h, and therefore strndup was
|
||||||
|
not visible.
|
||||||
|
* lib/xstrndup.c: New.
|
||||||
|
* src/scan-skel.l: Use it.
|
||||||
|
Be sure to initialize yylval.muscle member when scanning a MUSCLE.
|
||||||
|
* src/parse-skel.y: Use %directives instead of #defines.
|
||||||
|
|
||||||
|
|
||||||
2001-12-30 Akim Demaille <akim@epita.fr>
|
2001-12-30 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* src/skeleton.h: New.
|
* src/skeleton.h: New.
|
||||||
|
|||||||
@@ -87,8 +87,8 @@ AC_FUNC_ALLOCA
|
|||||||
AC_FUNC_OBSTACK
|
AC_FUNC_OBSTACK
|
||||||
AC_FUNC_ERROR_AT_LINE
|
AC_FUNC_ERROR_AT_LINE
|
||||||
AC_CHECK_FUNCS(mkstemp setlocale)
|
AC_CHECK_FUNCS(mkstemp setlocale)
|
||||||
AC_CHECK_DECLS([stpcpy, strchr, strndup, strspn, strnlen, memchr])
|
AC_CHECK_DECLS([stpcpy, strchr, strspn, strnlen, memchr])
|
||||||
AC_REPLACE_FUNCS(stpcpy strchr strndup strnlen strspn memchr)
|
AC_REPLACE_FUNCS(stpcpy strchr strnlen strspn memchr)
|
||||||
jm_FUNC_MALLOC
|
jm_FUNC_MALLOC
|
||||||
jm_FUNC_REALLOC
|
jm_FUNC_REALLOC
|
||||||
jm_PREREQ_QUOTEARG
|
jm_PREREQ_QUOTEARG
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ libbison_a_SOURCES = \
|
|||||||
getopt.h getopt.c getopt1.c \
|
getopt.h getopt.c getopt1.c \
|
||||||
hash.h hash.c \
|
hash.h hash.c \
|
||||||
quote.h quote.c quotearg.h quotearg.c \
|
quote.h quote.c quotearg.h quotearg.c \
|
||||||
xalloc.h xmalloc.c xstrdup.c
|
xalloc.h xmalloc.c xstrdup.c xstrndup.c
|
||||||
|
|
||||||
libbison_a_LIBADD = @LIBOBJS@ @ALLOCA@
|
libbison_a_LIBADD = @LIBOBJS@ @ALLOCA@
|
||||||
libbison_a_DEPENDENCIES = $(libbison_a_LIBADD)
|
libbison_a_DEPENDENCIES = $(libbison_a_LIBADD)
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
/* Copyright (C) 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
|
/* Copyright (C) 2001 Free Software Foundation, Inc.
|
||||||
|
|
||||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
|
||||||
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it
|
This program is free software; you can redistribute it and/or modify it
|
||||||
under the terms of the GNU General Public License as published by the
|
under the terms of the GNU General Public License as published by the
|
||||||
@@ -17,20 +14,20 @@
|
|||||||
along with this program; if not, write to the Free Software Foundation,
|
along with this program; if not, write to the Free Software Foundation,
|
||||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#if HAVE_CONFIG_H
|
||||||
# include "config.h"
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#if STDC_HEADERS || HAVE_STRING_H
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#if defined _LIBC || defined STDC_HEADERS
|
|
||||||
# include <stdlib.h>
|
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
#else
|
#else
|
||||||
char *malloc ();
|
# include <strings.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "xalloc.h"
|
||||||
|
|
||||||
#ifndef HAVE_DECL_STRNLEN
|
#ifndef HAVE_DECL_STRNLEN
|
||||||
"this configure-time declaration test was not run"
|
"this configure-time declaration test was not run"
|
||||||
#endif
|
#endif
|
||||||
@@ -38,18 +35,13 @@ char *malloc ();
|
|||||||
size_t strnlen ();
|
size_t strnlen ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#undef __strndup
|
char *xstrndup (const char *s, size_t n);
|
||||||
#undef strndup
|
|
||||||
|
|
||||||
#ifndef weak_alias
|
|
||||||
# define __strndup strndup
|
|
||||||
#endif
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
__strndup (const char *s, size_t n)
|
xstrndup (const char *s, size_t n)
|
||||||
{
|
{
|
||||||
size_t len = strnlen (s, n);
|
size_t len = strnlen (s, n);
|
||||||
char *new = malloc (len + 1);
|
char *new = xmalloc (len + 1);
|
||||||
|
|
||||||
if (new == NULL)
|
if (new == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -57,6 +49,3 @@ __strndup (const char *s, size_t n)
|
|||||||
new[len] = '\0';
|
new[len] = '\0';
|
||||||
return (char *) memcpy (new, s, len);
|
return (char *) memcpy (new, s, len);
|
||||||
}
|
}
|
||||||
#ifdef weak_alias
|
|
||||||
weak_alias (__strndup, strndup)
|
|
||||||
#endif
|
|
||||||
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
%debug
|
%debug
|
||||||
%defines
|
%defines
|
||||||
|
%verbose
|
||||||
%error-verbose
|
%error-verbose
|
||||||
|
|
||||||
%{
|
%{
|
||||||
@@ -47,8 +48,8 @@ static int yyerror PARAMS ((const char* error));
|
|||||||
|
|
||||||
%union
|
%union
|
||||||
{
|
{
|
||||||
char* muscle;
|
char *muscle;
|
||||||
char* string;
|
char *string;
|
||||||
char character;
|
char character;
|
||||||
int yacc;
|
int yacc;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,11 +20,9 @@
|
|||||||
02111-1307, USA. */
|
02111-1307, USA. */
|
||||||
|
|
||||||
%{
|
%{
|
||||||
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "skeleton.h"
|
#include "skeleton.h"
|
||||||
#include "parse-skel.h"
|
#include "parse-skel.h"
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%option nounput
|
%option nounput
|
||||||
@@ -49,31 +47,25 @@
|
|||||||
"%%{actions}" { return ACTIONS; }
|
"%%{actions}" { return ACTIONS; }
|
||||||
"%%{tokendef}" { return TOKENS; }
|
"%%{tokendef}" { return TOKENS; }
|
||||||
|
|
||||||
"%%{"[a-zA-Z][0-9a-zA-Z_-]+"}" { /* Muscle. */
|
/* Muscle. */
|
||||||
size_t len = strlen (yytext);
|
"%%{"[a-zA-Z][0-9a-zA-Z_-]+"}" {
|
||||||
yylval.string = (char*) malloc (len - 3);
|
yylval.muscle = xstrndup (yytext + 3, yyleng - 4);
|
||||||
strncpy (yylval.string, yytext + 3, len - 4);
|
|
||||||
yylval.string[len - 4] = 0;
|
|
||||||
return MUSCLE;
|
return MUSCLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
"%%\"".*"\"" { /* String. */
|
/* String. */
|
||||||
size_t len = strlen (yytext);
|
"%%\"".*"\"" {
|
||||||
yylval.string = (char*) malloc (len - 3);
|
yylval.string = xstrndup (yytext + 3, yyleng - 4);
|
||||||
strncpy (yylval.string, yytext + 3, len - 4);
|
|
||||||
yylval.string[len - 4] = 0;
|
|
||||||
return STRING;
|
return STRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
<<EOF>> { /* End of file. */
|
/* End of line. */
|
||||||
return 0;
|
"\n" {
|
||||||
}
|
|
||||||
|
|
||||||
"\n" { /* End of line. */
|
|
||||||
return '\n';
|
return '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
. { /* Character. */
|
/* Plain Character. */
|
||||||
|
. {
|
||||||
yylval.character = *yytext;
|
yylval.character = *yytext;
|
||||||
return CHARACTER;
|
return CHARACTER;
|
||||||
}
|
}
|
||||||
|
|||||||
18
src/system.h
18
src/system.h
@@ -26,16 +26,6 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#ifdef MSDOS
|
|
||||||
# include <io.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
# include <stdlib.h>
|
|
||||||
# include <process.h>
|
|
||||||
# define getpid _getpid
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if HAVE_STDLIB_H
|
#if HAVE_STDLIB_H
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -62,9 +52,6 @@
|
|||||||
# if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H)
|
# if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H)
|
||||||
# include <memory.h>
|
# include <memory.h>
|
||||||
# endif /* not STDC_HEADERS and HAVE_MEMORY_H */
|
# endif /* not STDC_HEADERS and HAVE_MEMORY_H */
|
||||||
# ifndef bcopy
|
|
||||||
# define bcopy(src, dst, num) memcpy((dst), (src), (num))
|
|
||||||
# endif
|
|
||||||
#else /* not STDC_HEADERS and not HAVE_STRING_H */
|
#else /* not STDC_HEADERS and not HAVE_STRING_H */
|
||||||
# include <strings.h>
|
# include <strings.h>
|
||||||
/* memory.h and strings.h conflict on some systems. */
|
/* memory.h and strings.h conflict on some systems. */
|
||||||
@@ -102,6 +89,9 @@ char *alloca ();
|
|||||||
|
|
||||||
# include "xalloc.h"
|
# include "xalloc.h"
|
||||||
|
|
||||||
|
/* From xstrndup.c. */
|
||||||
|
char *xstrndup PARAMS ((const char *s, size_t n));
|
||||||
|
|
||||||
/*---------------------.
|
/*---------------------.
|
||||||
| Missing prototypes. |
|
| Missing prototypes. |
|
||||||
`---------------------*/
|
`---------------------*/
|
||||||
@@ -319,4 +309,4 @@ do { \
|
|||||||
# include <dmalloc.h>
|
# include <dmalloc.h>
|
||||||
# endif /* WITH_DMALLOC */
|
# endif /* WITH_DMALLOC */
|
||||||
|
|
||||||
#endif /* BISON_SYSTEM_H */
|
#endif /* ! BISON_SYSTEM_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user