summaryrefslogtreecommitdiff
path: root/src/ctype
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-02-28 21:10:57 -0500
committerJakob Kaivo <jkk@ung.org>2019-02-28 21:10:57 -0500
commit08d8fd2767733d893380ebf5c8a4743dd371528d (patch)
treeb3aff9fe38cd3cd94d99ca51b76e3de0f34037f2 /src/ctype
parentb4409255ad7f446ad0a3386dc3669bbf270bb327 (diff)
fix ctype functions in the C/POSIX locale
Diffstat (limited to 'src/ctype')
-rw-r--r--src/ctype/iscntrl.c2
-rw-r--r--src/ctype/isgraph.c2
-rw-r--r--src/ctype/isprint.c2
-rw-r--r--src/ctype/tolower.c5
-rw-r--r--src/ctype/toupper.c6
5 files changed, 14 insertions, 3 deletions
diff --git a/src/ctype/iscntrl.c b/src/ctype/iscntrl.c
index eead7f5f..9d295d26 100644
--- a/src/ctype/iscntrl.c
+++ b/src/ctype/iscntrl.c
@@ -14,7 +14,7 @@ int iscntrl(int c)
RETURN(0, ARGUMENT(c) is not a control character);
*/
- return map[c] == 0 || (map[c] == CT_SPACE && c != ' ');
+ return map[c] & CT_CNTRL;
}
/***
diff --git a/src/ctype/isgraph.c b/src/ctype/isgraph.c
index 206a09b7..ecf88a34 100644
--- a/src/ctype/isgraph.c
+++ b/src/ctype/isgraph.c
@@ -14,7 +14,7 @@ int isgraph(int c)
RETURN(0, ARGUMENT(c) is not a graphic character);
*/
- return map[c] & ~CT_SPACE;
+ return map[c] & CT_GRAPH;
}
/***
diff --git a/src/ctype/isprint.c b/src/ctype/isprint.c
index 19847118..41ed6bcf 100644
--- a/src/ctype/isprint.c
+++ b/src/ctype/isprint.c
@@ -14,7 +14,7 @@ int isprint(int c)
RETURN(0, ARGUMENT(c) is not a printable character);
*/
- return map[c] & ~CT_SPACE || c == ' ';
+ return map[c] & CT_PRINT;
}
/***
diff --git a/src/ctype/tolower.c b/src/ctype/tolower.c
index 793de6bb..7ef5057a 100644
--- a/src/ctype/tolower.c
+++ b/src/ctype/tolower.c
@@ -1,4 +1,5 @@
#include <ctype.h>
+#include "stdio.h"
#include "limits.h"
#include "nonstd/assert.h"
#include "nonstd/ctype.h"
@@ -14,6 +15,10 @@ int tolower(int c)
RETURN_FAILURE(ARGUMENT(c), ARGUMENT(c) was not an uppercase letter or it has no equivalent lowercase letter);
*/
+ if (c == EOF) {
+ return EOF;
+ }
+
return map[c];
}
diff --git a/src/ctype/toupper.c b/src/ctype/toupper.c
index 35b7c9e2..4844a702 100644
--- a/src/ctype/toupper.c
+++ b/src/ctype/toupper.c
@@ -1,4 +1,5 @@
#include <ctype.h>
+#include "stdio.h"
#include "limits.h"
#include "nonstd/assert.h"
#include "nonstd/ctype.h"
@@ -13,6 +14,11 @@ int toupper(int c)
RETURN_SUCCESS(ARGUMENT(c) converted to uppercase);
RETURN_FAILURE(ARGUMENT(c), ARGUMENT(c) was not a lowercase letter or it has no equivalent upercase letter);
*/
+
+ if (c == EOF) {
+ return EOF;
+ }
+
return map[c];
}