From bb8d6b5143dcca098f37cd66722d5a0109215b9a Mon Sep 17 00:00:00 2001 From: erikb Date: Fri, 4 Apr 1986 09:54:50 +0000 Subject: [PATCH] revised the treatment of strings in initialisations --- lang/cem/cemcom/ival.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lang/cem/cemcom/ival.c b/lang/cem/cemcom/ival.c index 201c50287..b47cd0ad4 100644 --- a/lang/cem/cemcom/ival.c +++ b/lang/cem/cemcom/ival.c @@ -514,16 +514,23 @@ init_string(tpp, ex) } else { arith dim = tp->tp_size / tp->tp_up->tp_size; + extern char options[]; + if (length > dim) { + if (options['R']) + too_many_initialisers(ex); + else { /* don't take the null byte into account */ + if (length > dim + 1) + expr_warning(ex, + "too many initialisers"); + length = dim; + } + } ntopad = align(dim, word_align) - length; - if (length > dim) - expr_error(ex, - "too many characters in initialiser string"); } /* throw out the characters of the already prepared string */ - do + while (length-- > 0) C_con_ucon(long2str((long)*s++ & 0xFF, 10), (arith)1); - while (--length > 0); /* pad the allocated memory (the alignment has been calculated) */ while (ntopad-- > 0) con_nullbyte(); -- 2.34.1