From: Steven R. Loomis Date: Mon, 17 Sep 2012 22:24:17 +0000 (+0000) Subject: ICU-9586 print out status of gendict during build X-Git-Tag: milestone-59-0-1~3554 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a29d76d39089efa2680c4ccd9bd77638b4a0a809;p=icu ICU-9586 print out status of gendict during build X-SVN-Rev: 32398 --- diff --git a/icu4c/source/i18n/udat.cpp b/icu4c/source/i18n/udat.cpp index 16d52e4d77f..6b811cd07b0 100644 --- a/icu4c/source/i18n/udat.cpp +++ b/icu4c/source/i18n/udat.cpp @@ -138,7 +138,7 @@ udat_open(UDateFormatStyle timeStyle, return (UDateFormat*)fmt; } // else fall through. } - if(timeStyle != UDAT_IGNORE) { + if(timeStyle != UDAT_PATTERN) { if(locale == 0) { fmt = DateFormat::createDateTimeInstance((DateFormat::EStyle)dateStyle, (DateFormat::EStyle)timeStyle); diff --git a/icu4c/source/i18n/unicode/udat.h b/icu4c/source/i18n/unicode/udat.h index c5bf9d68c20..15af7da2f3b 100644 --- a/icu4c/source/i18n/unicode/udat.h +++ b/icu4c/source/i18n/unicode/udat.h @@ -167,9 +167,16 @@ typedef enum UDateFormatStyle { /** No style */ UDAT_NONE = -1, - /** for internal API use only */ - UDAT_IGNORE = -2 + /** + * Use the pattern given in the parameter to udat_open + * @see udat_open + * @draft ICU 50 + */ + UDAT_PATTERN = -2, + + /** @internal alias to UDAT_PATTERN */ + UDAT_IGNORE = UDAT_PATTERN, } UDateFormatStyle; /* Cannot use #ifndef U_HIDE_DRAFT_API for UDateFormatContextType and UDateFormatContextValue @@ -581,9 +588,12 @@ udat_toCalendarDateField(UDateFormatField field); * @param timeStyle The style used to format times; one of UDAT_FULL, UDAT_LONG, * UDAT_MEDIUM, UDAT_SHORT, UDAT_DEFAULT, or UDAT_NONE (relative time styles * are not currently supported). + * When the pattern parameter is used, pass in UDAT_PATTERN for both timeStyle and dateStyle. * @param dateStyle The style used to format dates; one of UDAT_FULL, UDAT_LONG, * UDAT_MEDIUM, UDAT_SHORT, UDAT_DEFAULT, UDAT_FULL_RELATIVE, UDAT_LONG_RELATIVE, - * UDAT_MEDIUM_RELATIVE, UDAT_SHORT_RELATIVE, or UDAT_NONE. As currently implemented, + * UDAT_MEDIUM_RELATIVE, UDAT_SHORT_RELATIVE, or UDAT_NONE. + * When the pattern parameter is used, pass in UDAT_PATTERN for both timeStyle and dateStyle. + * As currently implemented, * relative date formatting only affects a limited range of calendar days before or * after the current date, based on the CLDR <field type="day">/<relative> data: For * example, in English, "Yesterday", "Today", and "Tomorrow". Outside of this range, diff --git a/icu4c/source/tools/gendict/gendict.cpp b/icu4c/source/tools/gendict/gendict.cpp index b95fb2404b1..f50f1c350c9 100644 --- a/icu4c/source/tools/gendict/gendict.cpp +++ b/icu4c/source/tools/gendict/gendict.cpp @@ -35,6 +35,49 @@ #include #include +#include "putilimp.h" +UDate startTime = -1.0; + +static int elapsedTime() { + return (int)uprv_floor((uprv_getRawUTCtime()-startTime)/1000.0); +} + +#if U_PLATFORM_IMPLEMENTS_POSIX && !U_PLATFORM_HAS_WIN32_API +#include + +const char *wToolname="gendict"; +const char *wOutname="(some file)"; + +const int firstSeconds = 5; /* seconds between notices*/ +const int nextSeconds = 15; /* seconds between notices*/ + +static void alarm_fn(int /*n*/) { + printf("%s: still writing\t%s (%ds)\t...\n", wToolname, wOutname, elapsedTime()); + + alarm(nextSeconds); // reset the alarm +} + +static void install_watchdog(const char *toolName, const char *outFileName) { + wToolname=toolName; + wOutname=outFileName; + + if(startTime<0) { // uninitialized + startTime = uprv_getRawUTCtime(); + } + signal(SIGALRM, &alarm_fn); + + alarm(firstSeconds); // set the alarm +} + +#else +static void install_watchdog(const char*, const char*) { + // not implemented +} +#endif + + + + U_NAMESPACE_USE static char *progName; @@ -255,6 +298,9 @@ int main(int argc, char **argv) { const char *outFileName = argv[2]; const char *wordFileName = argv[1]; + // set up the watchdog + install_watchdog(progName, outFileName); + if (options[ARG_ICUDATADIR].doesOccur) { u_setDataDirectory(options[ARG_ICUDATADIR].value); } @@ -424,7 +470,7 @@ int main(int argc, char **argv) { exit(U_INTERNAL_PROGRAM_ERROR); } - puts("gendict: tool completed successfully."); + printf("%s: done writing\t%s (%ds).\n", progName, outFileName, elapsedTime()); #ifdef TEST_GENDICT if (isBytesTrie) {