Bug 899722 Part 2: Backport upstream r32937 to fix symbol collision w/ truncate on BSD r=norbert r=waldo

See http://bugs.icu-project.org/trac/ticket/10290
This commit is contained in:
Landry Breuil 2013-08-14 13:04:41 +02:00
parent 4826869196
commit 521f931c7e
3 changed files with 117 additions and 6 deletions

View File

@ -0,0 +1,110 @@
Bug 899722 Part 2 - Backport upstream r32937 to fix symbol collision w/ truncate on BSD r=norbert
http://bugs.icu-project.org/trac/ticket/10290
diff --git a/intl/icu/source/tools/genrb/derb.c b/intl/icu/source/tools/genrb/derb.c
--- a/intl/icu/source/tools/genrb/derb.c
+++ b/intl/icu/source/tools/genrb/derb.c
@@ -49,17 +49,17 @@
#define DERB_VERSION "1.0"
#define DERB_DEFAULT_TRUNC 80
static UConverter *defaultConverter = 0;
static const int32_t indentsize = 4;
static int32_t truncsize = DERB_DEFAULT_TRUNC;
-static UBool truncate = FALSE;
+static UBool opt_truncate = FALSE;
static const char *getEncodingName(const char *encoding);
static void reportError(const char *pname, UErrorCode *status, const char *when);
static UChar *quotedString(const UChar *string);
static void printOutBundle(FILE *out, UConverter *converter, UResourceBundle *resource, int32_t indent, const char *pname, UErrorCode *status);
static void printString(FILE *out, UConverter *converter, const UChar *str, int32_t len);
static void printCString(FILE *out, UConverter *converter, const char *str, int32_t len);
static void printIndent(FILE *out, UConverter *converter, int32_t indent);
@@ -147,24 +147,24 @@ main(int argc, char* argv[]) {
encoding = options[2].value;
}
if (options[3].doesOccur) {
tostdout = 1;
}
if(options[4].doesOccur) {
- truncate = TRUE;
+ opt_truncate = TRUE;
if(options[4].value != NULL) {
truncsize = atoi(options[4].value); /* user defined printable size */
} else {
truncsize = DERB_DEFAULT_TRUNC; /* we'll use default omitting size */
}
} else {
- truncate = FALSE;
+ opt_truncate = FALSE;
}
if(options[5].doesOccur) {
verbose = TRUE;
}
if (options[6].doesOccur) {
outputDir = options[6].value;
@@ -468,17 +468,17 @@ static void printHex(FILE *out, UConvert
printString(out, converter, hex, (int32_t)(sizeof(hex)/sizeof(*hex)));
}
static void printOutAlias(FILE *out, UConverter *converter, UResourceBundle *parent, Resource r, const char *key, int32_t indent, const char *pname, UErrorCode *status) {
static const UChar cr[] = { '\n' };
int32_t len = 0;
const UChar* thestr = res_getAlias(&(parent->fResData), r, &len);
UChar *string = quotedString(thestr);
- if(truncate && len > truncsize) {
+ if(opt_truncate && len > truncsize) {
char msg[128];
printIndent(out, converter, indent);
sprintf(msg, "// WARNING: this resource, size %li is truncated to %li\n",
(long)len, (long)truncsize/2);
printCString(out, converter, msg, -1);
len = truncsize;
}
if(U_SUCCESS(*status)) {
@@ -512,17 +512,17 @@ static void printOutBundle(FILE *out, UC
switch(ures_getType(resource)) {
case URES_STRING :
{
int32_t len=0;
const UChar* thestr = ures_getString(resource, &len, status);
UChar *string = quotedString(thestr);
/* TODO: String truncation */
- if(truncate && len > truncsize) {
+ if(opt_truncate && len > truncsize) {
char msg[128];
printIndent(out, converter, indent);
sprintf(msg, "// WARNING: this resource, size %li is truncated to %li\n",
(long)len, (long)(truncsize/2));
printCString(out, converter, msg, -1);
len = truncsize/2;
}
printIndent(out, converter, indent);
@@ -571,17 +571,17 @@ static void printOutBundle(FILE *out, UC
}
printString(out, converter, cr, (int32_t)(sizeof(cr) / sizeof(*cr)));
break;
}
case URES_BINARY :
{
int32_t len = 0;
const int8_t *data = (const int8_t *)ures_getBinary(resource, &len, status);
- if(truncate && len > truncsize) {
+ if(opt_truncate && len > truncsize) {
char msg[128];
printIndent(out, converter, indent);
sprintf(msg, "// WARNING: this resource, size %li is truncated to %li\n",
(long)len, (long)(truncsize/2));
printCString(out, converter, msg, -1);
len = truncsize;
}
if(U_SUCCESS(*status)) {

View File

@ -54,7 +54,7 @@ static UConverter *defaultConverter = 0;
static const int32_t indentsize = 4;
static int32_t truncsize = DERB_DEFAULT_TRUNC;
static UBool truncate = FALSE;
static UBool opt_truncate = FALSE;
static const char *getEncodingName(const char *encoding);
static void reportError(const char *pname, UErrorCode *status, const char *when);
@ -152,14 +152,14 @@ main(int argc, char* argv[]) {
}
if(options[4].doesOccur) {
truncate = TRUE;
opt_truncate = TRUE;
if(options[4].value != NULL) {
truncsize = atoi(options[4].value); /* user defined printable size */
} else {
truncsize = DERB_DEFAULT_TRUNC; /* we'll use default omitting size */
}
} else {
truncate = FALSE;
opt_truncate = FALSE;
}
if(options[5].doesOccur) {
@ -473,7 +473,7 @@ static void printOutAlias(FILE *out, UConverter *converter, UResourceBundle *pa
int32_t len = 0;
const UChar* thestr = res_getAlias(&(parent->fResData), r, &len);
UChar *string = quotedString(thestr);
if(truncate && len > truncsize) {
if(opt_truncate && len > truncsize) {
char msg[128];
printIndent(out, converter, indent);
sprintf(msg, "// WARNING: this resource, size %li is truncated to %li\n",
@ -517,7 +517,7 @@ static void printOutBundle(FILE *out, UConverter *converter, UResourceBundle *re
UChar *string = quotedString(thestr);
/* TODO: String truncation */
if(truncate && len > truncsize) {
if(opt_truncate && len > truncsize) {
char msg[128];
printIndent(out, converter, indent);
sprintf(msg, "// WARNING: this resource, size %li is truncated to %li\n",
@ -576,7 +576,7 @@ static void printOutBundle(FILE *out, UConverter *converter, UResourceBundle *re
{
int32_t len = 0;
const int8_t *data = (const int8_t *)ures_getBinary(resource, &len, status);
if(truncate && len > truncsize) {
if(opt_truncate && len > truncsize) {
char msg[128];
printIndent(out, converter, indent);
sprintf(msg, "// WARNING: this resource, size %li is truncated to %li\n",

View File

@ -41,5 +41,6 @@ svn info $1 > ${icu_dir}/SVN-INFO
patch -d ${icu_dir}/../../ -p1 < ${icu_dir}/../icu-patches/bug-724533
patch -d ${icu_dir}/../../ -p1 < ${icu_dir}/../icu-patches/bug-853706
patch -d ${icu_dir}/../../ -p1 < ${icu_dir}/../icu-patches/bug-899722
patch -d ${icu_dir}/../../ -p1 < ${icu_dir}/../icu-patches/bug-899722-2
hg addremove ${icu_dir}