From: Michael Ow Date: Thu, 14 Jul 2011 17:13:48 +0000 (+0000) Subject: ICU-8671 Update pkgdata to allow for space separated items when generating common... X-Git-Tag: milestone-59-0-1~4646 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4fe319b158e71c8e0b916f19fe70a22b35472648;p=icu ICU-8671 Update pkgdata to allow for space separated items when generating common data file. X-SVN-Rev: 30343 --- diff --git a/icu4c/source/tools/toolutil/pkg_gencmn.c b/icu4c/source/tools/toolutil/pkg_gencmn.c index 59f4d79ee47..d6cf05c5ba1 100644 --- a/icu4c/source/tools/toolutil/pkg_gencmn.c +++ b/icu4c/source/tools/toolutil/pkg_gencmn.c @@ -92,6 +92,7 @@ static uint32_t fileMax = 0; static char *symPrefix = NULL; +#define LINE_BUFFER_SIZE 512 /* prototypes --------------------------------------------------------------- */ static void @@ -115,12 +116,21 @@ U_CAPI void U_EXPORT2 createCommonDataFile(const char *destDir, const char *name, const char *entrypointName, const char *type, const char *source, const char *copyRight, const char *dataFile, uint32_t max_size, UBool sourceTOC, UBool verbose, char *gencmnFileName) { static char buffer[4096]; - char line[512]; - char *s; + char *line; + char *linePtr; + char *s = NULL; UErrorCode errorCode=U_ZERO_ERROR; uint32_t i, fileOffset, basenameOffset, length, nread; FileStream *in, *file; + line = (char *)uprv_malloc(sizeof(char) * LINE_BUFFER_SIZE); + if (line == NULL) { + fprintf(stderr, "gencmn: unable to allocate memory for line buffer of size %d\n", LINE_BUFFER_SIZE); + exit(U_MEMORY_ALLOCATION_ERROR); + } + + linePtr = line; + maxSize = max_size; if (destDir == NULL) { @@ -155,11 +165,19 @@ createCommonDataFile(const char *destDir, const char *name, const char *entrypoi } /* read the list of files and get their lengths */ - while(T_FileStream_readLine(in, line, sizeof(line))!=NULL) { - /* remove trailing newline characters */ - s=line; + while((s != NULL && *s != 0) || T_FileStream_readLine(in, line, LINE_BUFFER_SIZE)!=NULL) { + /* remove trailing newline characters and parse space separated items */ + if (s != NULL && *s != 0) { + line=s; + } else { + s=line; + } while(*s!=0) { - if(*s=='\r' || *s=='\n') { + if(*s==' ') { + *s=0; + ++s; + break; + } else if(*s=='\r' || *s=='\n') { *s=0; break; } @@ -184,6 +202,10 @@ createCommonDataFile(const char *destDir, const char *name, const char *entrypoi addFile(getLongPathname(line), name, source, sourceTOC, verbose); } + if (linePtr) { + uprv_free(linePtr); + } + if(in!=T_FileStream_stdin()) { T_FileStream_close(in); }