The C standard defines EOF as:
... an integer constant expression, with type int and a negative value...
This means a conforming implemenetation could define this as a one of the
printable characters. This won't be a problem for ASCII.
A specific test case has been added for EOF.
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4240)
*/
#include <string.h>
+#include <stdio.h>
#include "internal/ctype.h"
#include "openssl/ebcdic.h"
#ifdef CHARSET_EBCDIC
int ossl_toascii(int c)
{
- if (c < -128 || c > 256)
+ if (c < -128 || c > 256 || c == EOF)
return c;
/*
* Adjust negatively signed characters.
int ossl_fromascii(int c)
{
- if (c < -128 || c > 256)
+ if (c < -128 || c > 256 || c == EOF)
return c;
if (c < 0)
c += 256;
&& TEST_int_eq(ossl_tolower(case_change[n].l), case_change[n].l);
}
+static int test_ctype_eof(void)
+{
+ return test_ctype_chars(EOF);
+}
+
int setup_tests(void)
{
ADD_ALL_TESTS(test_ctype_chars, 128);
ADD_ALL_TESTS(test_ctype_toupper, OSSL_NELEM(case_change));
ADD_ALL_TESTS(test_ctype_tolower, OSSL_NELEM(case_change));
+ ADD_TEST(test_ctype_eof);
return 1;
}