From 8a34f7839eb66f9ab8eeceb94877144401fcb581 Mon Sep 17 00:00:00 2001 From: Mihail Groza Date: Wed, 15 Mar 2017 18:47:22 +0000 Subject: [PATCH] Some consistency changes to library & headers flags. Setting +nolib didn't disabled standard headers, causing unexpected behaviour or forcing user to add +skip-std-headers. Also, setting any of the POSIX libs ({posix,unix}[strict]) didn't enabled POSIX headers, causing unexpected behaviour or forcing user to add +skip-posix-headers. (This also is a code/documentation conflict, as the manual says posix headers are skipped by default, which is false). Modified behaviour by setting the standard and POSIX headers skipping in relation to the usage of standard and POSIX libraries. This has the side-effect that if a user specifies a header skipping flag prior to a library flag, the header skipping flag will be discarded. This behavioural change should be documented in the manual (but sadly is not, for now). --- src/context.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/context.c b/src/context.c index f343dbb..fe6f103 100644 --- a/src/context.c +++ b/src/context.c @@ -587,6 +587,11 @@ flagcode context_getLibrary (void) void context_setLibrary (flagcode code) { gc.library = code; + + /* what if these any of these flags has already been explicitly set? + * we're changing them without any warning to the user ... */ + gc.flags[FLG_SKIPSTDHEADERS] = context_usingStdLibrary (); + gc.flags[FLG_SKIPPOSIXHEADERS] = context_usingPosixLibrary (); } /*@observer@*/ cstring context_selectedLibrary (void) @@ -3684,15 +3689,19 @@ context_userSetFlag (flagcode f, bool b) if (flagcode_isLibraryFlag (f)) { - if (gc.library != FLG_STDLIB - && gc.library != f) - { - llerror_flagWarning - (message ("Selecting library %s after library %s was " - "selected (only one library may be used)", - flagcode_unparse (f), - flagcode_unparse (gc.library))); - } + static bool libSet = FALSE; + if (!libSet) + { + libSet = TRUE; + } + else + { + llerror_flagWarning + (message ("Selecting library %s after library %s was " + "selected (only one library may be used)", + flagcode_unparse (f), + flagcode_unparse (gc.library))); + } if (f == FLG_UNIXLIB) { @@ -3702,12 +3711,12 @@ context_userSetFlag (flagcode f, bool b) (cstring_makeLiteral ("Selecting unix library. Unix library is " "based on the Single Unix Specification, Version 2. Not all " - "Unix implementations are consistend with this specification. " + "Unix implementations are consistent with this specification. " "Use -warnunixlib to suppress this message.")); } } - gc.library = f; + context_setLibrary (f); } if (flagcode_isNameChecksFlag (f) && b && !context_maybeSet (FLG_NAMECHECKS)) -- 2.11.4.GIT