X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/729e4ab9bc6618bc3d8a898e575df7f4019e29ca..f59164e3d128c7675a4d3934206346a3384e53a5:/icuSources/tools/toolutil/writesrc.c diff --git a/icuSources/tools/toolutil/writesrc.c b/icuSources/tools/toolutil/writesrc.c index 59d6e057..6db9087e 100644 --- a/icuSources/tools/toolutil/writesrc.c +++ b/icuSources/tools/toolutil/writesrc.c @@ -1,7 +1,7 @@ /* ******************************************************************************* * -* Copyright (C) 2005-2010, International Business Machines +* Copyright (C) 2005-2012, 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, @@ -66,30 +71,30 @@ usrc_createWithHeader(const char *path, const char *filename, const char *header } U_CAPI FILE * U_EXPORT2 -usrc_create(const char *path, const char *filename) { - const char *header= +usrc_create(const char *path, const char *filename, const char *generator) { + static 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 on: %s\n" + " * machine-generated by: %s\n" " */\n\n"; - return usrc_createWithHeader(path, filename, header); + return usrc_createWithHeader(path, filename, generator, header); } U_CAPI FILE * U_EXPORT2 -usrc_createTextData(const char *path, const char *filename) { - const char *header= +usrc_createTextData(const char *path, const char *filename, const char *generator) { + static const char *header= "# Copyright (C) 1999-%s, International Business Machines\n" "# Corporation and others. All Rights Reserved.\n" "#\n" "# file name: %s\n" "#\n" - "# machine-generated on: %s\n" + "# machine-generated by: %s\n" "#\n\n"; - return usrc_createWithHeader(path, filename, header); + return usrc_createWithHeader(path, filename, generator, header); } U_CAPI void U_EXPORT2 @@ -216,3 +221,42 @@ usrc_writeUTrie2Struct(FILE *f, fputs(postfix, f); } } + +U_CAPI void U_EXPORT2 +usrc_writeArrayOfMostlyInvChars(FILE *f, + const char *prefix, + const char *p, int32_t length, + const char *postfix) { + int32_t i, col; + int prev2, prev, c; + + if(prefix!=NULL) { + fprintf(f, prefix, (long)length); + } + prev2=prev=-1; + for(i=col=0; i0) { + /* Break long lines. Try to break at interesting places, to minimize revision diffs. */ + if( + /* Very long line. */ + col>=32 || + /* Long line, break after terminating NUL. */ + (col>=24 && prev2>=0x20 && prev==0) || + /* Medium-long line, break before non-NUL, non-character byte. */ + (col>=16 && (prev==0 || prev>=0x20) && 0