diff options
Diffstat (limited to 'contrib/sendmail/libsm/lowercase.c')
-rw-r--r-- | contrib/sendmail/libsm/lowercase.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/contrib/sendmail/libsm/lowercase.c b/contrib/sendmail/libsm/lowercase.c index 8448eee5ad40..430d2ac79039 100644 --- a/contrib/sendmail/libsm/lowercase.c +++ b/contrib/sendmail/libsm/lowercase.c @@ -15,10 +15,11 @@ #include <sm/string.h> #include <sm/heap.h> #if USE_EAI -# include <sm/ixlen.h> +# include <sm/limits.h> # include <unicode/ucasemap.h> # include <unicode/ustring.h> # include <unicode/uchar.h> +# include <sm/ixlen.h> /* ** ASCIISTR -- check whether a string is printable ASCII @@ -42,6 +43,38 @@ asciistr(str) str++; return ch == '\0'; } + +/* +** ASCIINSTR -- check whether a string is printable ASCII up to len +** +** Parameters: +** str -- string +** len -- length to check +** +** Returns: +** TRUE iff printable ASCII +*/ + +bool +asciinstr(str, len) + const char *str; + size_t len; +{ + unsigned char ch; + int n; + + if (str == NULL) + return true; + SM_REQUIRE(len < INT_MAX); + n = 0; + while (n < len && (ch = (unsigned char)*str) != '\0' + && ch >= 32 && ch < 127) + { + n++; + str++; + } + return n == len || ch == '\0'; +} #endif /* USE_EAI */ /* |