X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/f2e710b193928f3e70f48580276498a2debe809b..c61294eca5edf4f245c2d8818bf53d3bdc3d80c1:/sbr/utils.c diff --git a/sbr/utils.c b/sbr/utils.c index 59ab7c72..610f7904 100644 --- a/sbr/utils.c +++ b/sbr/utils.c @@ -328,7 +328,10 @@ nmh_strcasestr (const char *s1, const char *s2) { int nmh_init(const char *argv0, int read_context) { - setlocale(LC_ALL, ""); + if (! setlocale(LC_ALL, "")) { + admonish(NULL, "setlocale failed, check your LC_ALL, LC_CTYPE, and " + "LANG environment variables"); + } invo_name = r1bindex ((char *) argv0, '/'); @@ -365,3 +368,24 @@ upcase (const char *str) { return up; } + + +/* + * Scan for any 8-bit characters. Return 1 if they exist. + * + * Scan up until the given endpoint (but not the actual endpoint itself). + * If the endpoint is NULL, scan until a '\0' is reached. + */ + +int +contains8bit(const char *start, const char *end) +{ + if (! start) + return 0; + + while (*start != '\0' && (!end || (start < end))) + if (! isascii((unsigned char) *start++)) + return 1; + + return 0; +}