#include "uresimp.h"
#include "uassert.h"
#include "ubrkimpl.h"
+#include "charstr.h"
// *****************************************************************************
// class BreakIterator
{
char fnbuff[256];
char ext[4]={'\0'};
- char actualLocale[ULOC_FULLNAME_CAPACITY];
+ CharString actualLocale;
int32_t size;
const UChar* brkfname = NULL;
UResourceBundle brkRulesStack;
// Use the string if we found it
if (U_SUCCESS(status) && brkfname) {
- uprv_strncpy(actualLocale,
- ures_getLocaleInternal(brkName, &status),
- sizeof(actualLocale)/sizeof(actualLocale[0]));
+ actualLocale.append(ures_getLocaleInternal(brkName, &status), -1, status);
UChar* extStart=u_strchr(brkfname, 0x002e);
int len = 0;
// If there is a result, set the valid locale and actual locale, and the kind
if (U_SUCCESS(status) && result != NULL) {
U_LOCALE_BASED(locBased, *(BreakIterator*)result);
- locBased.setLocaleIDs(ures_getLocaleByType(b, ULOC_VALID_LOCALE, &status), actualLocale);
+ locBased.setLocaleIDs(ures_getLocaleByType(b, ULOC_VALID_LOCALE, &status),
+ actualLocale.data());
result->setBreakType(kind);
}
void LocaleBased::setLocaleIDs(const char* validID, const char* actualID) {
if (validID != 0) {
- uprv_strcpy(valid, validID);
+ uprv_strncpy(valid, validID, ULOC_FULLNAME_CAPACITY);
+ valid[ULOC_FULLNAME_CAPACITY-1] = 0; // always terminate
}
if (actualID != 0) {
- uprv_strcpy(actual, actualID);
+ uprv_strncpy(actual, actualID, ULOC_FULLNAME_CAPACITY);
+ actual[ULOC_FULLNAME_CAPACITY-1] = 0; // always terminate
}
}
/**
* Macro to declare a locale LocaleBased wrapper object for the given
* object, which must have two members named `validLocale' and
- * `actualLocale'.
+ * `actualLocale' of size ULOC_FULLNAME_CAPACITY
*/
#define U_LOCALE_BASED(varname, objname) \
LocaleBased varname((objname).validLocale, (objname).actualLocale);