** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
** MA 02111-1307, USA.
**
-** For information on splint: splint@cs.virginia.edu
-** To report a bug: splint-bug@cs.virginia.edu
+** For information on splint: info@splint.org
+** To report a bug: splint-bug@splint.org
** For more information: http://www.splint.org
*/
/*
if (ctype_isFixedArray (t1))
{
+
int nelements = long_toInt (ctype_getArraySize (t1));
llassert (multiVal_isString (mval));
slit = multiVal_forceString (mval);
- len = cstring_length (slit);
+
+ len = cstring_lengthExpandEscapes (slit);
+
if (len == nelements)
{
+ mstring temp;
+
+ temp = cstring_expandEscapes(slit);
+
+ if (temp[len-1] == '\0')
+ {
+ voptgenerror
+ (FLG_STRINGLITNOROOMFINALNULL,
+ message ("String literal with %d character%& "
+ "is assigned to %s (no room for final null terminator): %s",
+ len + 1,
+ ctype_unparse (t1),
+ exprNode_unparse (e2)),
+ e2->loc);
+ }
+ else
+ {
+
+
voptgenerror
(FLG_STRINGLITNOROOM,
message ("String literal with %d character%& "
"is assigned to %s (no room for null terminator): %s",
- cstring_length (slit),
+ len + 1,
ctype_unparse (t1),
exprNode_unparse (e2)),
- e2->loc);
+ e2->loc);
+ }
}
else if (len > nelements)
{
voptgenerror
(FLG_STRINGLITTOOLONG,
- message ("Stirng literal with %d character%& (counting null terminator) "
+ message ("String literal with %d character%& (counting null terminator) "
"is assigned to %s (insufficient storage available): %s",
- cstring_length (slit),
+ len + 1,
ctype_unparse (t1),
exprNode_unparse (e2)),
e2->loc);
voptgenerror
(FLG_STRINGLITSMALLER,
message ("String literal with %d character%& is assigned to %s (possible waste of storage): %s",
- cstring_length (slit),
+ len + 1,
ctype_unparse (t1),
exprNode_unparse (e2)),
e2->loc);
if (exprNode_isDefined (val) && val->kind == XPR_INITBLOCK)
{
exprNodeList vals = exprData_getArgs (val->edata);
-
+
DPRINTF (("Check one init: %s", exprNodeList_unparse (vals)));
DPRINTF (("Type: %s", ctype_unparse (t1)));
{
int nelements = long_toInt (ctype_getArraySize (t1));
+ DPRINTF (("Checked array: %s / %d",
+ ctype_unparse (t1), nelements));
+
if (exprNode_isStringLiteral (val))
{
exprNode_checkStringLiteralLength (t1, val);