OSDN Git Service

Remove change of Oct 4.
[pf3gnuchains/gcc-fork.git] / gcc / bi-lexer.c
index 954638a..0ec0b1d 100644 (file)
@@ -1,5 +1,5 @@
 /* Lexer for scanner of bytecode definition file.
-   Copyright (C) 1993 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1995 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -15,33 +15,27 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with GNU CC; see the file COPYING.  If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
 
 #include <stdio.h>
+#include "hconfig.h"
 #include "bi-parser.h"
 
-extern char *malloc ();
-extern char *realloc ();
 
-
-/* Current read buffer and point */
-static char *buffer = NULL;
-static char *inpoint = NULL;
-
-
-/* Safely allocate NBYTES bytes of memory. Reuturns pointer to block of
-   memory. */
+/* Safely allocate NBYTES bytes of memory.  Returns pointer to block of
+   memory.  */
 
 static char *
 xmalloc (nbytes)
      int nbytes;
 {
-  char *tmp = malloc (nbytes);
+  char *tmp = (char *) malloc (nbytes);
 
   if (!tmp)
     {
       fprintf (stderr, "can't allocate %d bytes (out of virtual memory)\n", nbytes);
-      exit (1);
+      exit (FATAL_EXIT_CODE);
     }
 
   return tmp;
@@ -49,19 +43,21 @@ xmalloc (nbytes)
 
 
 /* Safely reallocate BLOCK so its size becomes NBYTES.
-   The block returned may be different from the one supplied. */
+   The block returned may be different from the one supplied.  */
 
 static char *
 xrealloc (block, nbytes)
      char *block;
      int nbytes;
 {
-  char *tmp = realloc (block, nbytes);
+  char *tmp = (block
+              ? (char *) realloc (block, nbytes)
+              : (char *) malloc (nbytes));
 
   if (!tmp)
     {
       fprintf (stderr, "can't reallocate %d bytes (out of virtual memory)\n", nbytes);
-      exit (1);
+      exit (FATAL_EXIT_CODE);
     }
 
   return tmp;
@@ -72,7 +68,7 @@ xrealloc (block, nbytes)
    purposes here, a sequence of characters that starts with the regexp
    ``[^ #\t\n(),]'' and is then followed by the regexp ``[^#(),]*''. Any
    character is accepted if preceded by a backslash, "\\".  It is assumed
-   that the first character has already been checked by the main loop. */
+   that the first character has already been checked by the main loop.  */
 
 static char *
 scan_string ()
@@ -92,7 +88,7 @@ scan_string ()
          int previous_point_index = point - buffer;
 
          buffer_size = (!buffer_size ? 32 : buffer_size * 2);
-         if (buffer)
+         if (!buffer)
            buffer = xmalloc (buffer_size);
          else
            buffer = xrealloc (buffer, buffer_size);