Slightly improved version. int ncmp[3] = { 100, 5, 2 }; // fixed data
if (sys_locale) { SWBuf locale; StringList localelist = LocaleMgr::getSystemLocaleMgr()->getAvailableLocales(); StringList::iterator it; // length-limited match for (int i = 0; i < 3; ++i) { for (it = localelist.begin(); it != localelist.end(); ++it) { locale = *it; if (!strncmp(sys_locale, locale.c_str(), ncmp[i])) { LocaleMgr::getSystemLocaleMgr()-> setDefaultLocaleName(locale.c_str()); return g_strdup(locale.c_str()); } } } } The improvement is the elimination of the 1st pass using just strcmp(), instead leaving it as a 3-pass test using only strncmp(), but with the 1st pass employing an absurdly long potential match length, having the contextual effect of using strcmp(). I just like smaller code, especially when one section nearly duplicates another. _______________________________________________ sword-devel mailing list: sword-devel@crosswire.org http://www.crosswire.org/mailman/listinfo/sword-devel Instructions to unsubscribe/change your settings at above page