Skip to content

Commit

Permalink
bugfix #415
Browse files Browse the repository at this point in the history
  • Loading branch information
gagolews committed Apr 7, 2021
1 parent 0040045 commit b413535
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: stringi
Version: 1.5.4
Date: 2021-03-02
Date: 2021-04-07
Title: Character String Processing Facilities
Description: A multitude of character string/text/natural language
processing tools: pattern searching (e.g., with 'Java'-like regular
Expand Down
5 changes: 4 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
* [INTERNAL] #414: Use `LEVELS(x)` macro instead of accessing `(x)->sxpinfo.gp`
directly (@lukaszdaniel).

* [BUGFIX] #415: `locale=''` was not equivalent to `locale=NULL`
in `stri_opts_collator()`.

* ... (to do) ..., for example:
#25 (locate-capture groups),
#31 (sub_index),
Expand All @@ -24,7 +27,7 @@
## 1.5.3 (2020-09-04) **CRAN**

* [DOCUMENTATION] stringi home page has moved to https://stringi.gagolewski.com
and now includes the comprehensive reference manual.
and now includes a comprehensive reference manual.

* [NEW FEATURE] #400: `%s$%` and `%stri$%` are now binary operators
that call base R's `sprintf()`.
Expand Down
4 changes: 2 additions & 2 deletions src/stri_collator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ UCollator* stri__ucol_open(SEXP opts_collator)

if (narg <= 0) { // no custom settings - use default Collator
UErrorCode status = U_ZERO_ERROR;
UCollator* col = ucol_open(NULL, &status);
UCollator* col = ucol_open(uloc_getDefault(), &status);
STRI__CHECKICUSTATUS_RFERROR(status, {/* do nothing special on err */}) // error() allowed here
return col;
}
Expand All @@ -93,7 +93,7 @@ UCollator* stri__ucol_open(SEXP opts_collator)
UColAttributeValue opt_STRENGTH = UCOL_DEFAULT_STRENGTH;
UColAttributeValue opt_NUMERIC_COLLATION = UCOL_DEFAULT;
// USearchAttributeValue opt_OVERLAP = USEARCH_OFF;
const char* opt_LOCALE = NULL;
const char* opt_LOCALE = uloc_getDefault();

for (R_len_t i=0; i<narg; ++i) {
if (STRING_ELT(names, i) == NA_STRING)
Expand Down
8 changes: 8 additions & 0 deletions src/stri_prepare_arg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,9 @@ const char* stri__prepare_arg_string_1_notNA(SEXP x, const char* argname)
*
* @version 0.5-1 (Marek Gagolewski, 2015-01-01)
* "@keyword=value" may use default locale from now; also, loc is trimmed
*
* @version 1.5.4 (Marek Gagolewski, 2021-04-07)
* BUGFIX: locale='' is the default
*/
const char* stri__prepare_arg_locale(SEXP loc, const char* argname, bool allowdefault, bool allowna)
{
Expand All @@ -1159,6 +1162,11 @@ const char* stri__prepare_arg_locale(SEXP loc, const char* argname, bool allowde
if (allowna) return NULL;
else Rf_error(MSG__ARG_EXPECTED_NOT_NA, argname); // Rf_error allowed here
}
if (strlen((const char*)CHAR(STRING_ELT(loc, 0))) == 0) {
UNPROTECT(1);
if (allowdefault) return uloc_getDefault();
else Rf_error(MSG__LOCALE_INCORRECT_ID); // Rf_error allowed here
}

UErrorCode err = U_ZERO_ERROR;
char buf[ULOC_FULLNAME_CAPACITY];
Expand Down

0 comments on commit b413535

Please sign in to comment.