Line
Link Here
|
0 |
-- libs/icu/icu-4.4/tools/pkgdata/pkgdata.cpp |
0 |
++ libs/icu/icu-4.4/tools/pkgdata/pkgdata.cpp |
Lines 95-100
Link Here
|
95 |
#endif |
95 |
#endif |
96 |
|
96 |
|
97 |
#define LARGE_BUFFER_MAX_SIZE 2048 |
97 |
#define LARGE_BUFFER_MAX_SIZE 2048 |
|
|
98 |
#define MEDIUM_BUFFER_MAX_SIZE 1024 |
98 |
#define SMALL_BUFFER_MAX_SIZE 512 |
99 |
#define SMALL_BUFFER_MAX_SIZE 512 |
99 |
|
100 |
|
100 |
static void loadLists(UPKGOptions *o, UErrorCode *status); |
101 |
static void loadLists(UPKGOptions *o, UErrorCode *status); |
Lines 561-602
Link Here
|
561 |
char gencFilePath[SMALL_BUFFER_MAX_SIZE] = ""; |
562 |
char gencFilePath[SMALL_BUFFER_MAX_SIZE] = ""; |
562 |
char version_major[10] = ""; |
563 |
char version_major[10] = ""; |
563 |
UBool reverseExt = FALSE; |
564 |
UBool reverseExt = FALSE; |
|
|
565 |
unsigned currentBufferSize = MEDIUM_BUFFER_MAX_SIZE; |
564 |
|
566 |
|
565 |
/* Initialize pkgdataFlags */ |
567 |
/* Initialize pkgdataFlags */ |
566 |
pkgDataFlags = (char**)uprv_malloc(sizeof(char*) * PKGDATA_FLAGS_SIZE); |
568 |
pkgDataFlags = (char**)uprv_malloc(sizeof(char*) * PKGDATA_FLAGS_SIZE); |
567 |
if (pkgDataFlags != NULL) { |
569 |
#if !defined(WINDOWS_WITH_MSVC) || defined(USING_CYGWIN) |
568 |
for (int32_t i = 0; i < PKGDATA_FLAGS_SIZE; i++) { |
570 |
/* If we run out of space, allocate more */ |
569 |
pkgDataFlags[i] = (char*)uprv_malloc(sizeof(char) * SMALL_BUFFER_MAX_SIZE); |
571 |
do { |
570 |
if (pkgDataFlags[i] != NULL) { |
572 |
#endif |
571 |
pkgDataFlags[i][0] = 0; |
573 |
if (pkgDataFlags != NULL) { |
572 |
} else { |
574 |
for (int32_t i = 0; i < PKGDATA_FLAGS_SIZE; i++) { |
573 |
fprintf(stderr,"Error allocating memory for pkgDataFlags.\n"); |
575 |
pkgDataFlags[i] = (char*)uprv_malloc(sizeof(char) * currentBufferSize); |
574 |
return -1; |
576 |
if (pkgDataFlags[i] != NULL) { |
|
|
577 |
pkgDataFlags[i][0] = 0; |
578 |
} else { |
579 |
fprintf(stderr,"Error allocating memory for pkgDataFlags.\n"); |
580 |
return -1; |
581 |
} |
575 |
} |
582 |
} |
|
|
583 |
} else { |
584 |
fprintf(stderr,"Error allocating memory for pkgDataFlags.\n"); |
585 |
return -1; |
576 |
} |
586 |
} |
577 |
} else { |
|
|
578 |
fprintf(stderr,"Error allocating memory for pkgDataFlags.\n"); |
579 |
return -1; |
580 |
} |
581 |
|
587 |
|
582 |
if(o->verbose) { |
588 |
if(o->verbose) { |
583 |
fprintf(stdout, "# pkgDataFlags="); |
589 |
fprintf(stdout, "# pkgDataFlags="); |
584 |
for(int32_t i=0;i<PKGDATA_FLAGS_SIZE && pkgDataFlags[i][0];i++) { |
590 |
for(int32_t i=0;i<PKGDATA_FLAGS_SIZE && pkgDataFlags[i][0];i++) { |
585 |
fprintf(stdout, "%c \"%s\"", (i>0)?',':' ',pkgDataFlags[i]); |
591 |
fprintf(stdout, "%c \"%s\"", (i>0)?',':' ',pkgDataFlags[i]); |
586 |
} |
592 |
} |
587 |
fprintf(stdout, "\n"); |
593 |
fprintf(stdout, "\n"); |
588 |
} |
594 |
} |
589 |
|
595 |
|
590 |
#ifndef WINDOWS_WITH_MSVC |
596 |
#ifndef WINDOWS_WITH_MSVC |
591 |
/* Read in options file. */ |
597 |
/* Read in options file. */ |
592 |
if(o->verbose) { |
598 |
if(o->verbose) { |
593 |
fprintf(stdout, "# Reading options file %s\n", o->options); |
599 |
fprintf(stdout, "# Reading options file %s\n", o->options); |
594 |
} |
600 |
} |
595 |
parseFlagsFile(o->options, pkgDataFlags, SMALL_BUFFER_MAX_SIZE, (int32_t)PKGDATA_FLAGS_SIZE, &status); |
601 |
parseFlagsFile(o->options, pkgDataFlags, currentBufferSize, (int32_t)PKGDATA_FLAGS_SIZE, &status); |
596 |
if (U_FAILURE(status)) { |
602 |
if (status == U_BUFFER_OVERFLOW_ERROR) { |
597 |
fprintf(stderr,"Unable to open or read \"%s\" option file. status = %s\n", o->options, u_errorName(status)); |
603 |
for (int32_t i = 0; i < PKGDATA_FLAGS_SIZE; i++) { |
598 |
return -1; |
604 |
uprv_free(pkgDataFlags[i]); |
599 |
} |
605 |
} |
|
|
606 |
currentBufferSize *= 2; |
607 |
} else if (U_FAILURE(status)) { |
608 |
fprintf(stderr,"Unable to open or read \"%s\" option file. status = %s\n", o->options, u_errorName(status)); |
609 |
return -1; |
610 |
} |
611 |
} while (status == U_BUFFER_OVERFLOW_ERROR); |
600 |
|
612 |
|
601 |
/* Get the version major number. */ |
613 |
/* Get the version major number. */ |
602 |
if (o->version != NULL) { |
614 |
if (o->version != NULL) { |