revised the treatment of strings in initialisations
This commit is contained in:
parent
c8453bb3f7
commit
bb8d6b5143
1 changed files with 12 additions and 5 deletions
|
@ -514,16 +514,23 @@ init_string(tpp, ex)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
arith dim = tp->tp_size / tp->tp_up->tp_size;
|
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;
|
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 */
|
/* throw out the characters of the already prepared string */
|
||||||
do
|
while (length-- > 0)
|
||||||
C_con_ucon(long2str((long)*s++ & 0xFF, 10), (arith)1);
|
C_con_ucon(long2str((long)*s++ & 0xFF, 10), (arith)1);
|
||||||
while (--length > 0);
|
|
||||||
/* pad the allocated memory (the alignment has been calculated) */
|
/* pad the allocated memory (the alignment has been calculated) */
|
||||||
while (ntopad-- > 0)
|
while (ntopad-- > 0)
|
||||||
con_nullbyte();
|
con_nullbyte();
|
||||||
|
|
Loading…
Reference in a new issue