From e0a05ba95145c0c1714b0c9a3e7eaf91a8ffc33b Mon Sep 17 00:00:00 2001 From: evans1629 Date: Wed, 13 Aug 2003 01:52:46 +0000 Subject: [PATCH] Fixed scanf %x problem. --- src/cprim.c | 20 +++++++++++++++----- src/exprNode.c | 7 +++++-- src/llerror.c | 10 ++++++---- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/cprim.c b/src/cprim.c index df3b709..b77db8c 100644 --- a/src/cprim.c +++ b/src/cprim.c @@ -81,7 +81,7 @@ static bool cprim_closeEnoughAux (cprim c1, cprim c2, bool deep) { if (c1 == c2) return TRUE; - + DPRINTF (("cprim close: %s / %s", cprim_unparse (c1), cprim_unparse (c2))); if (c1 == CTX_ANYINTEGRAL) @@ -108,8 +108,13 @@ cprim_closeEnoughAux (cprim c1, cprim c2, bool deep) if (c1 == CTX_UNSIGNEDINTEGRAL) { - if (context_getFlag (FLG_MATCHANYINTEGRAL) - || context_getFlag (FLG_IGNOREQUALS)) + /* We allow signed ints to match any integral if matchanyintegral is set */ + if (context_getFlag (FLG_MATCHANYINTEGRAL)) { + return (cprim_isAnyInt (c2) + || (cprim_isAnyChar (c2) && context_msgCharInt ())); + } + + if (context_getFlag (FLG_IGNOREQUALS)) { if (context_getFlag (FLG_IGNORESIGNS)) { @@ -134,8 +139,13 @@ cprim_closeEnoughAux (cprim c1, cprim c2, bool deep) if (c1 == CTX_SIGNEDINTEGRAL) { - if (context_getFlag (FLG_MATCHANYINTEGRAL) - || context_getFlag (FLG_IGNOREQUALS)) + /* We allow signed ints to match any integral if matchanyintegral is set */ + if (context_getFlag (FLG_MATCHANYINTEGRAL)) { + return (cprim_isAnyInt (c2) + || (cprim_isAnyChar (c2) && context_msgCharInt ())); + } + + if (context_getFlag (FLG_IGNOREQUALS)) { return (cprim_isAnyInt (c2) || (cprim_isAnyChar (c2) && context_msgCharInt ())); diff --git a/src/exprNode.c b/src/exprNode.c index f082ecd..bdd0870 100644 --- a/src/exprNode.c +++ b/src/exprNode.c @@ -1930,9 +1930,12 @@ checkScanfArgs (/*@notnull@*/ /*@dependent@*/ exprNode f, uentry fcn, case 'i': case 'd': + expecttype = ctype_makePointer (ctype_combine (ctype_int, modtype)); + /*@switchbreak@*/ break; + case 'x': case 'X': /* unsigned int */ - expecttype = ctype_makePointer (ctype_combine (ctype_int, modtype)); + expecttype = ctype_makePointer (ctype_combine (ctype_uint, modtype)); /*@switchbreak@*/ break; case 'e': @@ -2591,7 +2594,7 @@ static int f->guards = guardSet_union (f->guards, a->guards); DPRINTF (("match arg: %s / %s", ctype_unparse (ct), ctype_unparse (a->typ))); - + if (!(exprNode_matchArgType (ct, a))) { DPRINTF (("Args mismatch!")); diff --git a/src/llerror.c b/src/llerror.c index fde743b..3e6978e 100644 --- a/src/llerror.c +++ b/src/llerror.c @@ -721,25 +721,27 @@ llgentypeerroraux (char *srcFile, int srcLine, } else if (ctype_isArbitraryIntegral (ctype_realType (ut1))) { + DPRINTF (("HERE: %s", ctype_unparse (ctype_realType (ut2)))); + if (ctype_isArbitraryIntegral (ctype_realType (ut2))) { hcode = FLG_MATCHANYINTEGRAL; } - else if (ctype_match (ut2, ctype_ulint)) + else if (ctype_equal (ut2, ctype_ulint)) { hcode = FLG_LONGUNSIGNEDINTEGRAL; } - else if (ctype_match (ut2, ctype_lint)) + else if (ctype_equal (ut2, ctype_lint)) { hcode = FLG_LONGINTEGRAL; } else if (ctype_isInt (ut2)) { hcode = FLG_MATCHANYINTEGRAL; - } + } else { - ; + hcode = FLG_TYPE; } } else if (ctype_isArbitraryIntegral (ctype_realType (ut2))) -- 2.45.1