aboutsummaryrefslogtreecommitdiff
path: root/gcc/cppexp.c
diff options
context:
space:
mode:
authorDave Brolley <brolley@cygnus.com>1999-01-21 12:58:38 +0000
committerDave Brolley <brolley@gcc.gnu.org>1999-01-21 07:58:38 -0500
commit939b4a73dbf5ef563c9567c68c6d8e56708f964d (patch)
treef42deb9d3da9ac29ad8111541b0e060cae6e636b /gcc/cppexp.c
parentfbe1758db29ec4459a0a9bce7827597d37b6523a (diff)
downloadgcc-939b4a73dbf5ef563c9567c68c6d8e56708f964d.zip
gcc-939b4a73dbf5ef563c9567c68c6d8e56708f964d.tar.gz
gcc-939b4a73dbf5ef563c9567c68c6d8e56708f964d.tar.bz2
cppexp.c (cpp_lex): Allocate token_buffer dynamically.
Thu Jan 21 15:48:03 1999 Dave Brolley <brolley@cygnus.com> * cppexp.c (cpp_lex): Allocate token_buffer dynamically. From-SVN: r24802
Diffstat (limited to 'gcc/cppexp.c')
-rw-r--r--gcc/cppexp.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/gcc/cppexp.c b/gcc/cppexp.c
index f8da222..bd8e663 100644
--- a/gcc/cppexp.c
+++ b/gcc/cppexp.c
@@ -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')
{