From 5b99bfd6792ab9229bb5b1d9048833d21b22ecef Mon Sep 17 00:00:00 2001 From: evans1629 Date: Tue, 27 Jul 2004 21:27:51 +0000 Subject: [PATCH] Fixed -help bug. --- src/Headers/flags.h | 1 + src/flags.c | 44 ++++++++++++++++++++++++++++++++++++---- src/help.c | 4 ++++ src/nameChecks.c | 2 +- test/ansireserved.expect | 16 +++++++-------- test/tests2.5/Makefile | 30 +++++++++++++-------------- 6 files changed, 69 insertions(+), 28 deletions(-) diff --git a/src/Headers/flags.h b/src/Headers/flags.h index dcf4e26..d4e0160 100644 --- a/src/Headers/flags.h +++ b/src/Headers/flags.h @@ -95,6 +95,7 @@ extern bool flagcode_hasArgument (flagcode p_f) /*@*/ ; extern bool flags_isModeName (cstring p_s) /*@*/ ; extern /*@only@*/ cstring describeModes (void) /*@modifies g_messagestream@*/ ; +extern /*@only@*/ cstring describeMode (/*@observer@*/ cstring mode) /*@*/ ; extern void summarizeErrors (void) /*@modifies g_messagestream@*/ ; extern bool flagcode_isNameChecksFlag (flagcode p_f) /*@*/ ; diff --git a/src/flags.c b/src/flags.c index bc1597f..c26a6c6 100644 --- a/src/flags.c +++ b/src/flags.c @@ -705,6 +705,40 @@ printFlagManual (bool html) } end_allFlags ; } +cstring +describeMode (cstring mode) +{ + cstringSList sflags = sortedFlags (); + cstring res = message ("Predefined mode %s sets: ", mode); + + llassert (flags_isModeName (mode)); + + context_setMode (mode); + + cstringSList_elements (sflags, flagname) + { + flagcode code = flags_identifyFlag (flagname); + fflag currentflag = flags[code]; + + if (mstring_isDefined (currentflag.desc) && flagcode_isModeFlag (code)) + { + if (context_getFlag (code)) + { + res = message ("%q\n +%s", res, cstring_fromChars (currentflag.flag)); + } + else + { + res = message ("%q\n -%s", res, cstring_fromChars (currentflag.flag)); + } + } + } end_cstringSList_elements; + + cstringSList_free (sflags); + + res = cstring_appendChar (res, '\n'); + return (res); +} + cstring describeFlagCode (flagcode flag) { @@ -716,6 +750,11 @@ describeFlagCode (flagcode flag) return (cstring_makeLiteral ("")); } + if (flagcode_isModeName (flag)) + { + return (cstring_makeLiteral ("")); + } + context_resetAllFlags (); f = flags[flag]; @@ -850,10 +889,7 @@ describeFlag (cstring flagname) if (flags_isModeName (flagname)) { cstring_free (oflagname); - - return - (message ("%s: predefined mode (see Manual for information)", - flagname)); + return describeMode (flagname); } else { diff --git a/src/help.c b/src/help.c index 4f4deb7..443f50c 100644 --- a/src/help.c +++ b/src/help.c @@ -524,6 +524,10 @@ void help_processFlags (int argc, char **argv) { printMaintainer (); } + else if (flags_isModeName (thisarg)) + { + llmsg (describeMode (thisarg)); + } else if (mstring_equal (thisarg, "flags")) { if (i + 1 < argc) diff --git a/src/nameChecks.c b/src/nameChecks.c index 20e8fa5..5566114 100644 --- a/src/nameChecks.c +++ b/src/nameChecks.c @@ -1487,7 +1487,7 @@ checkAnsiName (uentry ue) message ("Name %s is reserved for future library extensions. " "Functions that begin with \"mem\" or \"wcs\" and a " - "lowercase letter letter may be added to . (ISO:7.26.11)", + "lowercase letter may be added to . (ISO:7.26.11)", name), uentry_whereLast (ue)); } diff --git a/test/ansireserved.expect b/test/ansireserved.expect index 283e89a..6154b15 100644 --- a/test/ansireserved.expect +++ b/test/ansireserved.expect @@ -11,8 +11,8 @@ ansireserved.c:5:5: Name atan2f is reserved for future library extensions. The names of all existing functions in suffixed with 'f' or 'l' may be added to . (ISO:7.26.1) ansireserved.c:7:13: Name wcst is reserved for future library extensions. - Functions that begin with "mem" or "wcs" and a lowercase letter letter may - be added to . (ISO:7.26.11) + Functions that begin with "mem" or "wcs" and a lowercase letter may be + added to . (ISO:7.26.11) ansireserved.c:11:5: Name isaFish is reserved for future library extensions. Functions beginning with "is" or "to" and a lowercase letter may be added to . (ISO99:7.26.2) @@ -33,8 +33,8 @@ ansireserved.c:5:5: Name atan2f is reserved for future library extensions. The names of all existing functions in suffixed with 'f' or 'l' may be added to . (ISO:7.26.1) ansireserved.c:7:13: Name wcst is reserved for future library extensions. - Functions that begin with "mem" or "wcs" and a lowercase letter letter may - be added to . (ISO:7.26.11) + Functions that begin with "mem" or "wcs" and a lowercase letter may be + added to . (ISO:7.26.11) ansireserved.c:11:5: Name isaFish is reserved for future library extensions. Functions beginning with "is" or "to" and a lowercase letter may be added to . (ISO99:7.26.2) @@ -43,8 +43,8 @@ ansireserved.c:13:20: Name powl is reserved for future library extensions. The names of all existing functions in suffixed with 'f' or 'l' may be added to . (ISO:7.26.1) ansireserved.c:15:22: Name memory is reserved for future library extensions. - Functions that begin with "mem" or "wcs" and a lowercase letter letter may - be added to . (ISO:7.26.11) + Functions that begin with "mem" or "wcs" and a lowercase letter may be + added to . (ISO:7.26.11) ansireserved.c:16:20: Name wctomb is reserved for the standard library Finished checking --- 11 code warnings, as expected @@ -67,8 +67,8 @@ ansireserved.c:5:5: Name atan2f is reserved for future library extensions. The names of all existing functions in suffixed with 'f' or 'l' may be added to . (ISO:7.26.1) ansireserved.c:7:13: Name wcst is reserved for future library extensions. - Functions that begin with "mem" or "wcs" and a lowercase letter letter may - be added to . (ISO:7.26.11) + Functions that begin with "mem" or "wcs" and a lowercase letter may be + added to . (ISO:7.26.11) ansireserved.c:11:5: Name isaFish is reserved for future library extensions. Functions beginning with "is" or "to" and a lowercase letter may be added to . (ISO99:7.26.2) diff --git a/test/tests2.5/Makefile b/test/tests2.5/Makefile index b2b6d1e..cc2de35 100644 --- a/test/tests2.5/Makefile +++ b/test/tests2.5/Makefile @@ -6,41 +6,41 @@ SPLINT = splint all: testalt boolt uconstants badcomment hoof boolbad booltest ull baz immutable impabsmodule testalt: - ${SPLINT} -dump newlint.lcd testalt.c + -${SPLINT} -dump newlint.lcd testalt.c boolt: - ${SPLINT} -expect 1 +partial +booltype pan_bool_t +booltrue PAN_TRUE +boolfalse PAN_FALSE boolt.c + -${SPLINT} -expect 1 +partial +booltype pan_bool_t +booltrue PAN_TRUE +boolfalse PAN_FALSE boolt.c uconstants: - ${SPLINT} uconstants.c -expect 2 + -${SPLINT} uconstants.c -expect 2 badcomment: - ${SPLINT} badcomment.c -expect 3 + -${SPLINT} badcomment.c -expect 3 hoof: - ${SPLINT} hoof.c -expect 1 - ${SPLINT} hoof.c +ignorequals + -${SPLINT} hoof.c -expect 1 + -${SPLINT} hoof.c +ignorequals ignorecmd: - ${SPLINT} +ignorecommand -we + -${SPLINT} +ignorecommand -we booltest: - ${SPLINT} booltest.c -booltype bool -expect 2 - ${SPLINT} booltest.c -booltype bool +boolint - ${SPLINT} booltest.c -booltype bool -predboolint -expect 1 + -${SPLINT} booltest.c -booltype bool -expect 2 + -${SPLINT} booltest.c -booltype bool +boolint + -${SPLINT} booltest.c -booltype bool -predboolint -expect 1 boolbad: - ${SPLINT} -weak -booltype BOOLEAN -booltrue TRUE -boolfalse FALSE boolbad.c + -${SPLINT} -weak -booltype BOOLEAN -booltrue TRUE -boolfalse FALSE boolbad.c ull: - ${SPLINT} ull.c + -${SPLINT} ull.c baz: - ${SPLINT} baz.h bimbim.h -I. + -${SPLINT} baz.h bimbim.h -I. immutable: - ${SPLINT} immutable.c testimmutable.c -expect 2 + -${SPLINT} immutable.c testimmutable.c -expect 2 impabsmodule: - ${SPLINT} +impabstract impabsmodule.c -expect 2 + -${SPLINT} +impabstract impabsmodule.c -expect 2 -- 2.45.0