Skip to content

Commit

Permalink
Merge pull request #3204 from grondo/issue#3199
Browse files Browse the repository at this point in the history
Allow fallback to ascii f prefix for F58 FLUIDs with FLUX_F58_FORCE_ASCII
  • Loading branch information
mergify[bot] committed Sep 11, 2020
2 parents 284ec80 + 908d664 commit 2433e36
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/common/libutil/fluid.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,10 @@ static int b58revenc (char *buf, int bufsz, fluid_t id)
static inline int is_utf8_locale (void)
{
/* Assume if MB_CUR_MAX > 1, this locale can handle wide characters
* and therefore will properly handle UTF-8.
* and therefore will properly handle UTF-8, but allow ascii encoding
* to be enforced if FLUX_F58_FORCE_ASCII is set.
*/
if (MB_CUR_MAX > 1)
if (MB_CUR_MAX > 1 && !getenv ("FLUX_F58_FORCE_ASCII"))
return 1;
return 0;
}
Expand Down
9 changes: 9 additions & 0 deletions src/common/libutil/test/fluid.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ void test_f58 (void)
tp++;
}

if (setenv ("FLUX_F58_FORCE_ASCII", "1", 1) < 0)
BAIL_OUT ("Failed to setenv FLUX_F58_FORCE_ASCII");
ok (fluid_encode (buf, sizeof (buf), f58_tests->id, type) == 0,
"fluid_encode with FLUX_F58_FORCE_ASCII works");
is (buf, f58_tests->f58_alt,
"fluid_encode with FLUX_F58_FORCE_ASCII used ascii prefix");
if (unsetenv ("FLUX_F58_FORCE_ASCII") < 0)
BAIL_OUT ("Failed to unsetenv FLUX_F58_FORCE_ASCII");

ok (fluid_encode (buf, 1, 1, type) < 0 && errno == EOVERFLOW,
"fluid_encode (buf, 1, 1, F58) returns EOVERFLOW");
errno = 0;
Expand Down

0 comments on commit 2433e36

Please sign in to comment.