From de830ac709b2d6aca7999a8b9a24d0c3738e72eb Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Sat, 17 Dec 2011 04:58:41 +0000 Subject: [PATCH] ICU-8972 machine-generated file with generator name rather than date (deterministic output) X-SVN-Rev: 31140 --- icu4c/source/common/uchar_props_data.h | 2 +- icu4c/source/tools/toolutil/ppucd.h | 3 +++ icu4c/source/tools/toolutil/writesrc.c | 31 +++++++++++++++++++++----- icu4c/source/tools/toolutil/writesrc.h | 15 +++++++++---- 4 files changed, 40 insertions(+), 11 deletions(-) diff --git a/icu4c/source/common/uchar_props_data.h b/icu4c/source/common/uchar_props_data.h index ab27225d349..35262edc817 100644 --- a/icu4c/source/common/uchar_props_data.h +++ b/icu4c/source/common/uchar_props_data.h @@ -4,7 +4,7 @@ * * file name: uchar_props_data.h * - * machine-generated on: 2011-12-05 + * machine-generated by: icu/tools/src/unicode/c/genprops/corepropswriter.cpp */ #ifndef INCLUDED_FROM_UCHAR_C diff --git a/icu4c/source/tools/toolutil/ppucd.h b/icu4c/source/tools/toolutil/ppucd.h index dbf95c31cfb..371a8e94eea 100644 --- a/icu4c/source/tools/toolutil/ppucd.h +++ b/icu4c/source/tools/toolutil/ppucd.h @@ -103,6 +103,9 @@ public: */ LineType readLine(UErrorCode &errorCode); + /** Returns the number of the line read by readLine(). */ + int32_t getLineNumber() const { return lineNumber; } + /** Returns the line's next field, or NULL. */ const char *nextField(); diff --git a/icu4c/source/tools/toolutil/writesrc.c b/icu4c/source/tools/toolutil/writesrc.c index fc19e380dc0..15ffb32ff3b 100644 --- a/icu4c/source/tools/toolutil/writesrc.c +++ b/icu4c/source/tools/toolutil/writesrc.c @@ -1,7 +1,7 @@ /* ******************************************************************************* * -* Copyright (C) 2005-2010, International Business Machines +* Copyright (C) 2005-2011, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* @@ -25,7 +25,8 @@ #include "writesrc.h" static FILE * -usrc_createWithHeader(const char *path, const char *filename, const char *header) { +usrc_createWithHeader(const char *path, const char *filename, + const char *generator, const char *header) { char buffer[1024]; const char *p; char *q; @@ -54,8 +55,12 @@ usrc_createWithHeader(const char *path, const char *filename, const char *header time(&t); lt=localtime(&t); strftime(year, sizeof(year), "%Y", lt); - strftime(buffer, sizeof(buffer), "%Y-%m-%d", lt); - fprintf(f, header, year, filename, buffer); + if(generator==NULL) { + strftime(buffer, sizeof(buffer), "%Y-%m-%d", lt); + fprintf(f, header, year, filename, buffer); + } else { + fprintf(f, header, year, filename, generator); + } } else { fprintf( stderr, @@ -76,7 +81,21 @@ usrc_create(const char *path, const char *filename) { " *\n" " * machine-generated on: %s\n" " */\n\n"; - return usrc_createWithHeader(path, filename, header); + return usrc_createWithHeader(path, filename, NULL, header); +} + +U_CAPI FILE * U_EXPORT2 +usrc_createFromGenerator(const char *path, const char *filename, const char *generator) { + const char *header= + "/*\n" + " * Copyright (C) 1999-%s, International Business Machines\n" + " * Corporation and others. All Rights Reserved.\n" + " *\n" + " * file name: %s\n" + " *\n" + " * machine-generated by: %s\n" + " */\n\n"; + return usrc_createWithHeader(path, filename, generator, header); } U_CAPI FILE * U_EXPORT2 @@ -89,7 +108,7 @@ usrc_createTextData(const char *path, const char *filename) { "#\n" "# machine-generated on: %s\n" "#\n\n"; - return usrc_createWithHeader(path, filename, header); + return usrc_createWithHeader(path, filename, NULL, header); } U_CAPI void U_EXPORT2 diff --git a/icu4c/source/tools/toolutil/writesrc.h b/icu4c/source/tools/toolutil/writesrc.h index 9085d75d393..0344412977b 100644 --- a/icu4c/source/tools/toolutil/writesrc.h +++ b/icu4c/source/tools/toolutil/writesrc.h @@ -1,7 +1,7 @@ /* ******************************************************************************* * -* Copyright (C) 2005-2010, International Business Machines +* Copyright (C) 2005-2011, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* @@ -24,14 +24,21 @@ #include "utrie2.h" /** - * Creates a source text file and write a header comment with the ICU copyright. - * Writes a C/Java-style comment. + * Creates a source text file and writes a header comment with the ICU copyright. + * Writes a C/Java-style comment with the generation date. */ U_CAPI FILE * U_EXPORT2 usrc_create(const char *path, const char *filename); /** - * Creates a source text file and write a header comment with the ICU copyright. + * Creates a source text file and writes a header comment with the ICU copyright. + * Writes a C/Java-style comment with the generator name. + */ +U_CAPI FILE * U_EXPORT2 +usrc_createFromGenerator(const char *path, const char *filename, const char *generator); + +/** + * Creates a source text file and writes a header comment with the ICU copyright. * Writes the comment with # lines, as used in scripts and text data. */ U_CAPI FILE * U_EXPORT2