OSDN Git Service

Thu Jan 21 15:48:03 1999 Dave Brolley <brolley@cygnus.com>
authorbrolley <brolley@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 21 Jan 1999 12:58:38 +0000 (12:58 +0000)
committerbrolley <brolley@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 21 Jan 1999 12:58:38 +0000 (12:58 +0000)
* cppexp.c (cpp_lex): Allocate token_buffer dynamically.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@24802 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cppexp.c

index 69e53eb..b8ffa87 100644 (file)
@@ -1,3 +1,7 @@
+Thu Jan 21 15:48:03 1999  Dave Brolley  <brolley@cygnus.com>
+
+       * cppexp.c (cpp_lex): Allocate token_buffer dynamically.
+
 Thu Jan 21 14:18:04 EST 1999  Andrew MacLeod  <amacleod@cygnus.com>
 
        * expr.c (MOVE_BY_PIECES_P): Define condition for deciding to use
index f8da222..bd8e663 100644 (file)
@@ -254,6 +254,10 @@ static struct token tokentab2[] = {
   {NULL, ERROR}
 };
 
+/* This is used to accumulate the value of a character literal.  It is static
+   so that it only gets allocated once per compilation.  */
+static char *token_buffer = NULL;
+
 /* Read one token.  */
 
 struct operation
@@ -323,11 +327,18 @@ cpp_lex (pfile, skip_evaluation)
        int wide_flag = 0;
        int max_chars;
        U_CHAR *ptr = tok_start;
+
+       /* We need to allocate this buffer dynamically since the size is not
+          a constant expression on all platforms.  */
+       if (token_buffer == NULL)
+         {
 #ifdef MULTIBYTE_CHARS
-       char token_buffer[MAX_LONG_TYPE_SIZE/MAX_CHAR_TYPE_SIZE + MB_CUR_MAX];
+           token_buffer = xmalloc (MAX_LONG_TYPE_SIZE/MAX_CHAR_TYPE_SIZE
+                                   + MB_CUR_MAX);
 #else
-       char token_buffer[MAX_LONG_TYPE_SIZE/MAX_CHAR_TYPE_SIZE + 1];
+           token_buffer = xmalloc (MAX_LONG_TYPE_SIZE/MAX_CHAR_TYPE_SIZE + 1);
 #endif
+         }
 
        if (*ptr == 'L')
          {