]> git.saurik.com Git - bison.git/commitdiff
* src/system.h: We don't need nor want bcopy.
authorAkim Demaille <akim@epita.fr>
Sun, 30 Dec 2001 21:06:22 +0000 (21:06 +0000)
committerAkim Demaille <akim@epita.fr>
Sun, 30 Dec 2001 21:06:22 +0000 (21:06 +0000)
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.

ChangeLog
configure.in
lib/Makefile.am
lib/strndup.c [deleted file]
lib/xstrndup.c [new file with mode: 0644]
src/parse-skel.y
src/scan-skel.l
src/system.h

index 57c917243ddfff4ef49488f40480a1c9ff250285..54b7fd8b0b9eb210e35b182f6acd3adc31ac9a24 100644 (file)
--- a/ChangeLog
+++ b/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>
 
        * src/skeleton.h: New.
index 2cad57616b92b1657c65288f6c3e922b78b8cdb7..6211eee4172a91bd9ed598c1982dced2fdb0e9ea 100644 (file)
@@ -87,8 +87,8 @@ AC_FUNC_ALLOCA
 AC_FUNC_OBSTACK
 AC_FUNC_ERROR_AT_LINE
 AC_CHECK_FUNCS(mkstemp setlocale)
-AC_CHECK_DECLS([stpcpy, strchr, strndup, strspn, strnlen, memchr])
-AC_REPLACE_FUNCS(stpcpy strchr strndup strnlen strspn memchr)
+AC_CHECK_DECLS([stpcpy, strchr, strspn, strnlen, memchr])
+AC_REPLACE_FUNCS(stpcpy strchr strnlen strspn memchr)
 jm_FUNC_MALLOC
 jm_FUNC_REALLOC
 jm_PREREQ_QUOTEARG
index 637f4deed3e175da254fe38627b75057f1db320a..cec735c3f74e8a10ffb58ab3c4259e855730e30f 100644 (file)
@@ -38,7 +38,7 @@ libbison_a_SOURCES = \
   getopt.h getopt.c getopt1.c \
   hash.h hash.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_DEPENDENCIES = $(libbison_a_LIBADD)
diff --git a/lib/strndup.c b/lib/strndup.c
deleted file mode 100644 (file)
index 136e51c..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/* Copyright (C) 1996, 1997, 1998, 2000 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
-   under the terms of the GNU General Public License as published by the
-   Free Software Foundation; either version 2, or (at your option) any
-   later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software Foundation,
-   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <stdio.h>
-#include <sys/types.h>
-
-#if defined _LIBC || defined STDC_HEADERS
-# include <stdlib.h>
-# include <string.h>
-#else
-char *malloc ();
-#endif
-
-#ifndef HAVE_DECL_STRNLEN
-"this configure-time declaration test was not run"
-#endif
-#if !HAVE_DECL_STRNLEN
-size_t strnlen ();
-#endif
-
-#undef __strndup
-#undef strndup
-
-#ifndef weak_alias
-# define __strndup strndup
-#endif
-
-char *
-__strndup (const char *s, size_t n)
-{
-  size_t len = strnlen (s, n);
-  char *new = malloc (len + 1);
-
-  if (new == NULL)
-    return NULL;
-
-  new[len] = '\0';
-  return (char *) memcpy (new, s, len);
-}
-#ifdef weak_alias
-weak_alias (__strndup, strndup)
-#endif
diff --git a/lib/xstrndup.c b/lib/xstrndup.c
new file mode 100644 (file)
index 0000000..594a6c9
--- /dev/null
@@ -0,0 +1,51 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+
+   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
+   Free Software Foundation; either version 2, or (at your option) any
+   later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if STDC_HEADERS || HAVE_STRING_H
+# include <string.h>
+#else
+# include <strings.h>
+#endif
+
+#include <sys/types.h>
+
+#include "xalloc.h"
+
+#ifndef HAVE_DECL_STRNLEN
+"this configure-time declaration test was not run"
+#endif
+#if !HAVE_DECL_STRNLEN
+size_t strnlen ();
+#endif
+
+char *xstrndup (const char *s, size_t n);
+
+char *
+xstrndup (const char *s, size_t n)
+{
+  size_t len = strnlen (s, n);
+  char *new = xmalloc (len + 1);
+
+  if (new == NULL)
+    return NULL;
+
+  new[len] = '\0';
+  return (char *) memcpy (new, s, len);
+}
index 372320de2208a917a1b3b276d3bf2b3823a77e9a..0d56dcfe1126afdac6809f55afefbe88489ec8bc 100644 (file)
@@ -21,6 +21,7 @@
 
 %debug
 %defines
+%verbose
 %error-verbose
 
 %{
@@ -47,8 +48,8 @@ static int yyerror PARAMS ((const char* error));
 
 %union
 {
-  charmuscle;
-  charstring;
+  char *muscle;
+  char *string;
   char character;
   int yacc;
 }
index 71577d7e6aa3281f0655d82989e7bb319dce771f..0bb71d196f33fcbbdfc56495244ebe83ed975835 100644 (file)
    02111-1307, USA.  */
 
 %{
-
 #include "system.h"
 #include "skeleton.h"
 #include "parse-skel.h"
-
 %}
 
 %option nounput
 "%%{actions}"  { return ACTIONS; }
 "%%{tokendef}" { return TOKENS; }
 
-"%%{"[a-zA-Z][0-9a-zA-Z_-]+"}" { /* Muscle.  */
-  size_t len = strlen (yytext);
-  yylval.string = (char*) malloc (len - 3);
-  strncpy (yylval.string, yytext + 3, len - 4);
-  yylval.string[len - 4] = 0;
+  /* Muscle.  */
+"%%{"[a-zA-Z][0-9a-zA-Z_-]+"}" {
+  yylval.muscle = xstrndup (yytext + 3, yyleng - 4);
   return MUSCLE;
 }
 
-"%%\"".*"\"" { /* String.  */
-  size_t len = strlen (yytext);
-  yylval.string = (char*) malloc (len - 3);
-  strncpy (yylval.string, yytext + 3, len - 4);
-  yylval.string[len - 4] = 0;
+  /* String.  */
+"%%\"".*"\"" {
+  yylval.string = xstrndup (yytext + 3, yyleng - 4);
   return STRING;
 }
 
-<<EOF>> { /* End of file.  */
-  return 0;
-}
-
-"\n" { /* End of line.  */
+  /* End of line.  */
+"\n" {
   return '\n';
 }
 
-. { /* Character.  */
+  /* Plain Character.  */
+. {
   yylval.character = *yytext;
   return CHARACTER;
 }
index efaf554db1e10c6016f346b93c3bffb6668d1619..b1d15424b7a1f2ebfaa82847ec2d634e53846529 100644 (file)
 
 #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
 # include <stdlib.h>
 #endif
@@ -62,9 +52,6 @@
 # if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H)
 #  include <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 */
 # include <strings.h>
 /* memory.h and strings.h conflict on some systems.  */
@@ -102,6 +89,9 @@ char *alloca ();
 
 # include "xalloc.h"
 
+/* From xstrndup.c.  */
+char *xstrndup PARAMS ((const char *s, size_t n));
+
 /*---------------------.
 | Missing prototypes.  |
 `---------------------*/
@@ -319,4 +309,4 @@ do {                                                \
 #  include <dmalloc.h>
 # endif /* WITH_DMALLOC */
 
-#endif  /* BISON_SYSTEM_H */
+#endif  /* BISON_SYSTEM_H */