summaryrefslogtreecommitdiff
path: root/locale/programs/record-status.h
AgeCommit message (Collapse)Author
2018-01-01Update copyright dates with scripts/update-copyrights.Joseph Myers
* All files with FSF copyright notices: Update copyright dates using scripts/update-copyrights. * locale/programs/charmap-kw.h: Regenerated. * locale/programs/locfile-kw.h: Likewise.
2017-10-25localedef: Add --no-warnings/--warnings optionCarlos O'Donell
From localedef --help: Output control: ... --no-warnings=<warnings> Comma-separated list of warnings to disable; supported warnings are: ascii, intcurrsym ... --warnings=<warnings> Comma-separated list of warnings to enable; supported warnings are: ascii, intcurrsym Locales using SHIFT_JIS and SHIFT_JISX0213 character maps are not ASCII compatible. In order to build locales using these character maps, and have localedef exit with a status of 0, we add new option to localedef to disable or enable specific warnings. The options are --no-warnings and --warnings, to disable and enable specific warnings respectively. The options take a comma-separated list of warning names. The warning names are taken directly from the generated warning. When a warning that can be disabled is issued it will print something like this: foo is not defined [--no-warnings=foo] For the initial implementation we add two controllable warnings; first 'ascii' which is used by the localedata installation makefile target to install SHIFT_JIS and SHIFT_JISX0213-using locales without error; second 'intcurrsym' which allows a program to use a non-standard international currency symbol without triggering a warning. The 'intcurrsym' is useful in the future if country codes are added that are not in our current ISO 4217 list, and the user wants to avoid the warning. Having at least two warnings to control gives an example for how the changes can be extended to more warnings if required in the future. These changes allow ja_JP.SHIFT_JIS and ja_JP.SHIFT_JISX0213 to be compiled without warnings using --no-warnings=ascii. The localedata/Makefile $(INSTALL-SUPPORTED-LOCALES) target is adjusted to automatically add `--no-warnings=ascii` for such charmaps, and likewise localedata/gen-locale.sh is adjusted with similar logic. v2: Bring verbose, be_quiet, and all warning control booleans into record-status.c, and compile this object file to be used by locale, iconv, and localedef. Any users include record-status.h. v3: Fix an instance of boolean coercion in set_warning(). Signed-off-by: Carlos O'Donell <carlos@redhat.com>
2017-10-13locale: Fix localedef exit code (Bug 22292)Carlos O'Donell
The error and warning handling in localedef, locale, and iconv is a bit of a mess. We use ugly constructs like this: WITH_CUR_LOCALE (error (1, errno, gettext ("\ cannot read character map directory `%s'"), directory)); to issue errors, and read error_message_count directly from the error API to detect errors. The problem with that is that the code also uses error to print warnings, and informative messages. All of this leads to problems where just having warnings will produce an exit status as-if errors had been seen. To fix this situation I have adopted the following high-level changes: * All errors are counted distinctly. * All warnings are counted distinctly. * All informative messages are not counted. * Increasing verbosity cannot generate *more* errors, and it previously did for errors conditional on verbose, this is now fixed. * Increasing verbosity *can* generate *more* warnings. * Making the output quiet cannot generate *fewer* errors, and it previously did for errors conditional on be_quiet, this is now fixed. * Each of error, warning, and informative message has it's own function to call defined in record-status.h, and they are: record_error, record_warning, and record_verbose. * The record_error function always records an error, but conditional on be_quiet may not print it. * The record_warning function always records a warning, but conditional on be_quiet may not print it. * The record_verbose function only prints the verbose message if verbose is true and be_quiet is false. This has allowed the following fix: * Previously any warnings were being treated as errors because they incremented error_message_count, but now we properly return an exit status of 1 if there are warnings but output was generated. All of this allows localedef to correctly decide if errors, or warnings were present, and produce the correct exit code. The locale and iconv programs now also use record-status.h and we have removed the WITH_CUR_LOCALE hack, and instead have internal push_locale/pop_locale functions centralized in the record routines. Signed-off-by: Carlos O'Donell <carlos@redhat.com>