X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/9d88c94317aeac5dd26c1dbe8c2112dbe855d2b5..73c04bcfe1096173b00431f0cdc742894b15eef0:/icuSources/common/ures_cnv.c?ds=sidebyside diff --git a/icuSources/common/ures_cnv.c b/icuSources/common/ures_cnv.c index 9326ef12..c9729019 100644 --- a/icuSources/common/ures_cnv.c +++ b/icuSources/common/ures_cnv.c @@ -1,7 +1,7 @@ /* ******************************************************************************* * -* Copyright (C) 1997-2004, International Business Machines +* Copyright (C) 1997-2006, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* @@ -27,51 +27,49 @@ U_CAPI UResourceBundle * U_EXPORT2 ures_openU(const UChar *myPath, const char *localeID, - UErrorCode *status) { - char path[2048]; + UErrorCode *status) +{ + char pathBuffer[1024]; int32_t length; + char *path = pathBuffer; if(status==NULL || U_FAILURE(*status)) { return NULL; } if(myPath==NULL) { - *status=U_ILLEGAL_ARGUMENT_ERROR; - return NULL; + path = NULL; } - - length=u_strlen(myPath); - if(length>=sizeof(path)) { - *status=U_ILLEGAL_ARGUMENT_ERROR; - return NULL; - } else if(uprv_isInvariantUString(myPath, length)) { - /* - * the invariant converter is sufficient for package and tree names - * and is more efficient - */ - u_UCharsToChars(myPath, path, length+1); /* length+1 to include the NUL */ - } else { -#if !UCONFIG_NO_CONVERSION - /* use the default converter to support variant-character paths */ - UConverter *cnv=u_getDefaultConverter(status); - if(U_FAILURE(*status)) { - return NULL; - } - - length=ucnv_fromUChars(cnv, path, (int32_t)sizeof(path), myPath, length, status); - u_releaseDefaultConverter(cnv); - if(U_FAILURE(*status)) { - return NULL; - } - if(length>=sizeof(path)) { - /* not NUL-terminated - path too long */ + else { + length=u_strlen(myPath); + if(length>=sizeof(pathBuffer)) { *status=U_ILLEGAL_ARGUMENT_ERROR; return NULL; - } + } else if(uprv_isInvariantUString(myPath, length)) { + /* + * the invariant converter is sufficient for package and tree names + * and is more efficient + */ + u_UCharsToChars(myPath, path, length+1); /* length+1 to include the NUL */ + } else { +#if !UCONFIG_NO_CONVERSION + /* use the default converter to support variant-character paths */ + UConverter *cnv=u_getDefaultConverter(status); + length=ucnv_fromUChars(cnv, path, (int32_t)sizeof(pathBuffer), myPath, length, status); + u_releaseDefaultConverter(cnv); + if(U_FAILURE(*status)) { + return NULL; + } + if(length>=sizeof(pathBuffer)) { + /* not NUL-terminated - path too long */ + *status=U_ILLEGAL_ARGUMENT_ERROR; + return NULL; + } #else - /* the default converter is not available */ - *status=U_UNSUPPORTED_ERROR; - return NULL; + /* the default converter is not available */ + *status=U_UNSUPPORTED_ERROR; + return NULL; #endif + } } return ures_open(path, localeID, status);