From: erikb Date: Fri, 4 Apr 1986 09:54:50 +0000 (+0000) Subject: revised the treatment of strings in initialisations X-Git-Tag: release-5-5~5321 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=bb8d6b5143dcca098f37cd66722d5a0109215b9a;p=ack.git revised the treatment of strings in initialisations --- 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();