From 90b2bf6959066e8e839fa690bf406f96ac3843ba Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Thu, 16 Apr 2015 15:22:30 +0000 Subject: [PATCH] ICU-11642 add -q options to gencfu,gencnval,gendict,makeconv,genbrk X-SVN-Rev: 37343 --- icu4c/source/tools/genbrk/genbrk.cpp | 8 ++++++-- icu4c/source/tools/gencfu/gencfu.cpp | 13 +++++++++++-- icu4c/source/tools/gencnval/gencnval.c | 16 ++++++++++++---- icu4c/source/tools/gendict/gendict.cpp | 10 +++++++--- icu4c/source/tools/makeconv/makeconv.c | 14 ++++++++++---- 5 files changed, 46 insertions(+), 15 deletions(-) diff --git a/icu4c/source/tools/genbrk/genbrk.cpp b/icu4c/source/tools/genbrk/genbrk.cpp index 72c6cffe7b5..789d2ed12ab 100644 --- a/icu4c/source/tools/genbrk/genbrk.cpp +++ b/icu4c/source/tools/genbrk/genbrk.cpp @@ -1,6 +1,6 @@ /* ********************************************************************** -* Copyright (C) 2002-2009, International Business Machines +* Copyright (C) 2002-2015, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * @@ -56,6 +56,7 @@ static UOption options[]={ UOPTION_ICUDATADIR, /* 5 */ UOPTION_DESTDIR, /* 6 */ UOPTION_COPYRIGHT, /* 7 */ + UOPTION_QUIET, /* 8 */ }; void usageAndDie(int retCode) { @@ -66,6 +67,7 @@ void usageAndDie(int retCode) { "\t-V or --version show a version message\n" "\t-c or --copyright include a copyright notice\n" "\t-v or --verbose turn on verbose output\n" + "\t-q or --quiet do not display warnings and progress\n" "\t-i or --icudatadir directory for locating any needed intermediate data files,\n" "\t followed by path, defaults to %s\n" "\t-d or --destdir destination directory, followed by the path\n", @@ -338,7 +340,9 @@ int main(int argc, char **argv) { u_cleanup(); - printf("genbrk: tool completed successfully.\n"); + if(!options[8].doesOccur) { + printf("genbrk: tool completed successfully.\n"); + } return 0; #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ diff --git a/icu4c/source/tools/gencfu/gencfu.cpp b/icu4c/source/tools/gencfu/gencfu.cpp index 37bb1dad33c..0942f854651 100644 --- a/icu4c/source/tools/gencfu/gencfu.cpp +++ b/icu4c/source/tools/gencfu/gencfu.cpp @@ -1,6 +1,6 @@ /* ********************************************************************** -* Copyright (C) 2009-2011, International Business Machines +* Copyright (C) 2009-2015, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * @@ -56,6 +56,7 @@ static UOption options[]={ UOPTION_ICUDATADIR, /* 6 */ UOPTION_DESTDIR, /* 7 */ UOPTION_COPYRIGHT, /* 8 */ + UOPTION_QUIET, /* 9 */ }; void usageAndDie(int retCode) { @@ -66,6 +67,7 @@ void usageAndDie(int retCode) { "\t-V or --version show a version message\n" "\t-c or --copyright include a copyright notice\n" "\t-v or --verbose turn on verbose output\n" + "\t-q or --quiet do not display warnings and progress\n" "\t-i or --icudatadir directory for locating any needed intermediate data files,\n" "\t followed by path, defaults to %s\n" "\t-d or --destdir destination directory, followed by the path\n", @@ -174,6 +176,11 @@ int main(int argc, char **argv) { copyright = U_COPYRIGHT_STRING; } + UBool quiet = FALSE; + if (options[9].doesOccur) { + quiet = TRUE; + } + #if UCONFIG_NO_REGULAR_EXPRESSIONS || UCONFIG_NO_NORMALIZATION || UCONFIG_NO_FILE_IO // spoof detection data file parsing is dependent on regular expressions. // TODO: have the tool return an error status. Requires fixing the ICU data build @@ -290,7 +297,9 @@ int main(int argc, char **argv) { delete [] confusables; delete [] wsConfsables; u_cleanup(); - printf("gencfu: tool completed successfully.\n"); + if (!quiet) { + printf("gencfu: tool completed successfully.\n"); + } return 0; #endif // UCONFIG_NO_REGULAR_EXPRESSIONS } diff --git a/icu4c/source/tools/gencnval/gencnval.c b/icu4c/source/tools/gencnval/gencnval.c index 5fe446f4ea9..4f5da6a8d29 100644 --- a/icu4c/source/tools/gencnval/gencnval.c +++ b/icu4c/source/tools/gencnval/gencnval.c @@ -1,7 +1,7 @@ /* ******************************************************************************* * -* Copyright (C) 1999-2012, International Business Machines +* Copyright (C) 1999-2015 International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* @@ -135,6 +135,7 @@ static uint16_t aliasListsSize = 0; /* Were the standard tags declared before the aliases. */ static UBool standardTagsUsed = FALSE; static UBool verbose = FALSE; +static UBool quiet = FALSE; static int lineNum = 1; static UConverterAliasOptions tableOptions = { @@ -203,7 +204,8 @@ enum VERBOSE, COPYRIGHT, DESTDIR, - SOURCEDIR + SOURCEDIR, + QUIET }; static UOption options[]={ @@ -212,7 +214,8 @@ static UOption options[]={ UOPTION_VERBOSE, UOPTION_COPYRIGHT, UOPTION_DESTDIR, - UOPTION_SOURCEDIR + UOPTION_SOURCEDIR, + UOPTION_QUIET }; extern int @@ -242,6 +245,7 @@ main(int argc, char* argv[]) { "options:\n" "\t-h or -? or --help this usage text\n" "\t-v or --verbose prints out extra information about the alias table\n" + "\t-q or --quiet do not display warnings and progress\n" "\t-c or --copyright include a copyright notice\n" "\t-d or --destdir destination directory, followed by the path\n" "\t-s or --sourcedir source directory, followed by the path\n", @@ -253,6 +257,10 @@ main(int argc, char* argv[]) { verbose = TRUE; } + if(options[QUIET].doesOccur) { + quiet = TRUE; + } + if(argc>=2) { path=argv[1]; } else { @@ -929,7 +937,7 @@ createOneAliasList(uint16_t *aliasArrLists, uint32_t tag, uint32_t converter, ui value = aliasList->aliases[aliasNum] + offset; } else { value = 0; - if (tag != 0) { /* Only show the warning when it's not the leftover tag. */ + if (tag != 0 && !quiet) { /* Only show the warning when it's not the leftover tag. */ fprintf(stderr, "%s: warning: tag %s does not have a default alias for %s\n", path, GET_TAG_STR(tags[tag].tag), diff --git a/icu4c/source/tools/gendict/gendict.cpp b/icu4c/source/tools/gendict/gendict.cpp index 7c429068623..18d6debe921 100644 --- a/icu4c/source/tools/gendict/gendict.cpp +++ b/icu4c/source/tools/gendict/gendict.cpp @@ -1,6 +1,6 @@ /* ********************************************************************** -* Copyright (C) 2002-2014, International Business Machines +* Copyright (C) 2002-2015, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * @@ -55,6 +55,7 @@ static UOption options[]={ { "uchars", NULL, NULL, NULL, '\1', UOPT_NO_ARG, 0}, /* 6 */ { "bytes", NULL, NULL, NULL, '\1', UOPT_NO_ARG, 0}, /* 7 */ { "transform", NULL, NULL, NULL, '\1', UOPT_REQUIRES_ARG, 0}, /* 8 */ + UOPTION_QUIET, /* 9 */ }; enum arguments { @@ -65,7 +66,8 @@ enum arguments { ARG_COPYRIGHT, ARG_UCHARS, ARG_BYTES, - ARG_TRANSFORM + ARG_TRANSFORM, + ARG_QUIET }; // prints out the standard usage method describing command line arguments, @@ -79,6 +81,7 @@ static void usageAndDie(UErrorCode retCode) { "\t-V or --version show a version message\n" "\t-c or --copyright include a copyright notice\n" "\t-v or --verbose turn on verbose output\n" + "\t-q or --quiet do not display warnings and progress\n" "\t-i or --icudatadir directory for locating any needed intermediate data files,\n" // TODO: figure out if we need this option "\t followed by path, defaults to %s\n" "\t--uchars output a UCharsTrie (mutually exclusive with -b!)\n" @@ -255,6 +258,7 @@ int main(int argc, char **argv) { } UBool verbose = options[ARG_VERBOSE].doesOccur; + UBool quiet = options[ARG_QUIET].doesOccur; if (argc < 3) { fprintf(stderr, "input and output file must both be specified.\n"); @@ -444,7 +448,7 @@ int main(int argc, char **argv) { exit(U_INTERNAL_PROGRAM_ERROR); } - printf("%s: done writing\t%s (%ds).\n", progName, outFileName, elapsedTime()); + if (!quiet) { printf("%s: done writing\t%s (%ds).\n", progName, outFileName, elapsedTime()); } #ifdef TEST_GENDICT if (isBytesTrie) { diff --git a/icu4c/source/tools/makeconv/makeconv.c b/icu4c/source/tools/makeconv/makeconv.c index 4eabcba51f5..a4a500da55e 100644 --- a/icu4c/source/tools/makeconv/makeconv.c +++ b/icu4c/source/tools/makeconv/makeconv.c @@ -1,7 +1,7 @@ /* ******************************************************************************** * - * Copyright (C) 1998-2014, International Business Machines + * Copyright (C) 1998-2015, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************** @@ -76,6 +76,7 @@ extern const UConverterStaticData * ucnv_converterStaticData[UCNV_NUMBER_OF_SUPP * Global - verbosity */ UBool VERBOSE = FALSE; +UBool QUIET = FALSE; UBool SMALL = FALSE; UBool IGNORE_SISO_CHECK = FALSE; @@ -174,6 +175,8 @@ enum { OPT_VERBOSE, OPT_SMALL, OPT_IGNORE_SISO_CHECK, + OPT_QUIET, + OPT_COUNT }; @@ -185,7 +188,8 @@ static UOption options[]={ UOPTION_DESTDIR, UOPTION_VERBOSE, { "small", NULL, NULL, NULL, '\1', UOPT_NO_ARG, 0 }, - { "ignore-siso-check", NULL, NULL, NULL, '\1', UOPT_NO_ARG, 0 } + { "ignore-siso-check", NULL, NULL, NULL, '\1', UOPT_NO_ARG, 0 }, + UOPTION_QUIET, }; int main(int argc, char* argv[]) @@ -231,7 +235,8 @@ int main(int argc, char* argv[]) "\t-V or --version show a version message\n" "\t-c or --copyright include a copyright notice\n" "\t-d or --destdir destination directory, followed by the path\n" - "\t-v or --verbose Turn on verbose output\n", + "\t-v or --verbose Turn on verbose output\n" + "\t-q or --quiet do not display warnings and progress\n", argv[0]); fprintf(stdfile, "\t --small Generate smaller .cnv files. They will be\n" @@ -253,6 +258,7 @@ int main(int argc, char* argv[]) haveCopyright = options[OPT_COPYRIGHT].doesOccur; destdir = options[OPT_DESTDIR].value; VERBOSE = options[OPT_VERBOSE].doesOccur; + QUIET = options[OPT_QUIET].doesOccur; SMALL = options[OPT_SMALL].doesOccur; if (options[OPT_IGNORE_SISO_CHECK].doesOccur) { @@ -361,7 +367,7 @@ int main(int argc, char* argv[]) { p++; /* If found separtor, don't include it in compare */ } - if(uprv_stricmp(p,data.staticData.name)) + if(uprv_stricmp(p,data.staticData.name) && !QUIET) { fprintf(stderr, "Warning: %s%s claims to be '%s'\n", cnvName, CONVERTER_FILE_EXTENSION, -- 2.40.0