# HG changeset patch # User Matti Hamalainen # Date 1709544027 -7200 # Node ID ac63db65b917c4acf94542163447577ea2f36f5f # Parent 63d100185adf22dffd99214fdaa8002ccdf564c7 Implement -Wextra for some extra warnings. diff -r 63d100185adf -r ac63db65b917 src/mkloc.c --- a/src/mkloc.c Mon Mar 04 11:07:12 2024 +0200 +++ b/src/mkloc.c Mon Mar 04 11:20:27 2024 +0200 @@ -30,9 +30,11 @@ WARN_NONE = 0x0000, WARN_MARKER_INVALID = 0x0001, WARN_MARKER_MISSING = 0x0002, - WARN_AUTHORS = 0x0004, - WARN_TIMESTAMPS = 0x0008, - WARN_ALL = 0xffff + WARN_AUTHORS_MISSING = 0x0004, + WARN_TIMESTAMPS_MISSING = 0x0008, + + WARN_EXTRA = 0x1000, + WARN_ALL = 0x0fff }; @@ -91,7 +93,8 @@ { 18,'t', "type-prefix", "Prepend labels with type prefix", OPT_NONE }, { 19,'X', "markers", "Location markers ('" LOC_MARKERS "')", OPT_ARGREQ }, { 22,'W', "warnings", "Output warnings about: " - "none, all, timestamps, authors", OPT_ARGREQ }, + "none, all, timestamps, authors, extra\n" + "(NOTE: 'all' does NOT include 'extra')", OPT_ARGREQ }, { 23, 0, "warn-loc", "Output warnings to loc file instead of stderr", OPT_NONE }, }; @@ -265,11 +268,14 @@ else switch (tolower(optArg[0])) { - case 't': - optWarnings |= WARN_TIMESTAMPS; + case 'a': + optWarnings |= WARN_AUTHORS_MISSING; break; - case 'c': - optWarnings |= WARN_AUTHORS; + case 't': + optWarnings |= WARN_TIMESTAMPS_MISSING; + break; + case 'e': + optWarnings |= WARN_EXTRA; break; default: THERR("Invalid argument to -W: '%s'\n", optArg); @@ -736,11 +742,45 @@ (loc->flags & LOCF_M_PCITY) == 0 && (loc->flags & LOCF_T_SHRINE) == 0) { - if ((optWarnings & WARN_TIMESTAMPS) && !loc->valid) + if ((optWarnings & WARN_TIMESTAMPS_MISSING) && !loc->valid) printLocWarning(&first, outFile, loc, "No timestamp"); - if ((optWarnings & WARN_AUTHORS) && loc->nauthors == 0) + if ((optWarnings & WARN_AUTHORS_MISSING) && loc->nauthors == 0) printLocWarning(&first, outFile, loc, "No authors listed"); + + if (optWarnings & WARN_EXTRA) + { + if (loc->valid) + { + const char *msg = NULL; + switch (loc->added.accuracy) + { + case TS_ACC_DEFAULT: + msg = "Addition timestamp 'default'."; + break; +/* + case TS_ACC_GUESSTIMATE: + msg = "Addition timestamp 'approximate'."; + break; +*/ + } + if (msg != NULL) + printLocWarning(&first, outFile, loc, msg); + } + + if (loc->nauthors > 0) + { + int flags = 0; + for (int nauthor = 0; nauthor < loc->nauthors; nauthor++) + { + flags |= loc->authors[nauthor].flags; + } + if ((flags & AUTHOR_ORIG) == 0) + { + printLocWarning(&first, outFile, loc, "Primary author not set"); + } + } + } } }