Skip to content

Commit

Permalink
Fix ctype.h and wctype.h
Browse files Browse the repository at this point in the history
  • Loading branch information
jart committed Jul 21, 2024
1 parent e7be5a5 commit 7ebaff3
Show file tree
Hide file tree
Showing 180 changed files with 264 additions and 92 deletions.
1 change: 1 addition & 0 deletions ctl/istream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// PERFORMANCE OF THIS SOFTWARE.

#include "istream.h"
#include "libc/ctype.h"
#include "libc/fmt/conv.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
Expand Down
1 change: 1 addition & 0 deletions ctl/istringstream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// PERFORMANCE OF THIS SOFTWARE.

#include "istringstream.h"
#include "libc/ctype.h"
#include "libc/fmt/conv.h"
#include "libc/str/str.h"

Expand Down
1 change: 1 addition & 0 deletions examples/kilo.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Contact: [email protected]");
#include "libc/calls/calls.h"
#include "libc/calls/termios.h"
#include "libc/calls/weirdtypes.h"
#include "libc/ctype.h"
#include "libc/errno.h"
#include "libc/log/log.h"
#include "libc/mem/alg.h"
Expand Down
1 change: 1 addition & 0 deletions examples/ttyinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "libc/calls/struct/sigaction.h"
#include "libc/calls/struct/sigset.h"
#include "libc/calls/termios.h"
#include "libc/ctype.h"
#include "libc/errno.h"
#include "libc/log/check.h"
#include "libc/log/log.h"
Expand Down
17 changes: 13 additions & 4 deletions examples/unbourne.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
#include "libc/calls/struct/stat.h"
#include "libc/calls/struct/tms.h"
#include "libc/calls/termios.h"
#include "libc/ctype.h"
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/fmt/conv.h"
Expand Down Expand Up @@ -11142,7 +11143,9 @@ static void exitreset() {
inps4 = 0;
}
/* from expand.c: */
{ ifsfree(); }
{
ifsfree();
}
/* from redir.c: */
{
/*
Expand All @@ -11165,9 +11168,13 @@ static void forkreset() {
}
}
/* from main.c: */
{ handler = &main_handler; }
{
handler = &main_handler;
}
/* from redir.c: */
{ redirlist = NULL; }
{
redirlist = NULL;
}
/* from trap.c: */
{
char **tp;
Expand Down Expand Up @@ -11198,7 +11205,9 @@ static void reset() {
popallfiles();
}
/* from var.c: */
{ unwindlocalvars(0); }
{
unwindlocalvars(0);
}
}

static void calcsize(union node *n) {
Expand Down
1 change: 1 addition & 0 deletions examples/whois.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/calls/calls.h"
#include "libc/calls/weirdtypes.h"
#include "libc/ctype.h"
#include "libc/errno.h"
#include "libc/log/bsd.h"
#include "libc/mem/mem.h"
Expand Down
3 changes: 2 additions & 1 deletion libc/calls/read-nt.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@
#include "libc/calls/internal.h"
#include "libc/calls/sig.internal.h"
#include "libc/calls/state.internal.h"
#include "libc/intrin/fds.h"
#include "libc/calls/struct/iovec.h"
#include "libc/calls/struct/sigset.internal.h"
#include "libc/calls/syscall_support-nt.internal.h"
#include "libc/cosmo.h"
#include "libc/ctype.h"
#include "libc/errno.h"
#include "libc/fmt/itoa.h"
#include "libc/intrin/describeflags.h"
#include "libc/intrin/dll.h"
#include "libc/intrin/fds.h"
#include "libc/intrin/nomultics.h"
#include "libc/intrin/strace.h"
#include "libc/intrin/weaken.h"
Expand Down
1 change: 1 addition & 0 deletions libc/calls/readlinkat-nt.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/calls/struct/sigset.internal.h"
#include "libc/calls/syscall_support-nt.internal.h"
#include "libc/ctype.h"
#include "libc/intrin/strace.h"
#include "libc/mem/alloca.h"
#include "libc/nt/createfile.h"
Expand Down
26 changes: 26 additions & 0 deletions libc/ctype.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef COSMOPOLITAN_CTYPE_H_
#define COSMOPOLITAN_CTYPE_H_
COSMOPOLITAN_C_START_

#define _tolower(u) (0040 | (u))
#define _toupper(u) (0137 & (u))

int isascii(int) libcesque;
int isspace(int) libcesque;
int isalpha(int) libcesque;
int isdigit(int) libcesque;
int isalnum(int) libcesque;
int isxdigit(int) libcesque;
int isprint(int) libcesque;
int islower(int) libcesque;
int isupper(int) libcesque;
int isblank(int) libcesque;
int iscntrl(int) libcesque;
int isgraph(int) libcesque;
int tolower(int) libcesque;
int ispunct(int) libcesque;
int toupper(int) libcesque;
int toascii(int) libcesque;

COSMOPOLITAN_C_END_
#endif /* COSMOPOLITAN_CTYPE_H_ */
1 change: 1 addition & 0 deletions libc/fmt/atoi.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/ctype.h"
#include "libc/fmt/conv.h"
#include "libc/str/str.h"

Expand Down
1 change: 1 addition & 0 deletions libc/fmt/atol.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/ctype.h"
#include "libc/fmt/conv.h"
#include "libc/str/str.h"

Expand Down
1 change: 1 addition & 0 deletions libc/fmt/internal.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#ifndef COSMOPOLITAN_LIBC_FMT_STRTOL_H_
#define COSMOPOLITAN_LIBC_FMT_STRTOL_H_
#include "libc/ctype.h"
#include "libc/errno.h"
#include "libc/str/str.h"

Expand Down
1 change: 1 addition & 0 deletions libc/fmt/sizetol.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/ctype.h"
#include "libc/fmt/conv.h"
#include "libc/stdckdint.h"
#include "libc/str/str.h"
Expand Down
1 change: 1 addition & 0 deletions libc/intrin/kprintf.greg.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
#include "libc/thread/tls.h"
#include "libc/thread/tls2.internal.h"
#include "libc/vga/vga.internal.h"
#include "libc/wctype.h"

#define STACK_ERROR "kprintf error: stack is about to overflow\n"

Expand Down
2 changes: 1 addition & 1 deletion libc/isystem/ctype.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef _CTYPE_H
#define _CTYPE_H
#include "libc/str/str.h"
#include "libc/ctype.h"
#endif /* _CTYPE_H */
4 changes: 1 addition & 3 deletions libc/isystem/wctype.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#ifndef _WCTYPE_H
#define _WCTYPE_H
#include "libc/calls/calls.h"
#include "libc/fmt/conv.h"
#include "libc/str/str.h"
#include "libc/wctype.h"
#endif /* _WCTYPE_H */
1 change: 1 addition & 0 deletions libc/proc/cocmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "libc/calls/calls.h"
#include "libc/calls/struct/stat.h"
#include "libc/calls/struct/timespec.h"
#include "libc/ctype.h"
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/fmt/conv.h"
Expand Down
1 change: 1 addition & 0 deletions libc/sock/inet_aton.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
│ │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/ctype.h"
#include "libc/fmt/conv.h"
#include "libc/sock/sock.h"
#include "libc/sock/struct/sockaddr.h"
Expand Down
1 change: 1 addition & 0 deletions libc/sock/inet_pton.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/ctype.h"
#include "libc/macros.internal.h"
#include "libc/sock/internal.h"
#include "libc/sock/sock.h"
Expand Down
1 change: 1 addition & 0 deletions libc/stdio/fmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
│ THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/assert.h"
#include "libc/ctype.h"
#include "libc/errno.h"
#include "libc/fmt/conv.h"
#include "libc/fmt/divmod10.internal.h"
Expand Down
1 change: 1 addition & 0 deletions libc/stdio/readpassphrase.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "libc/calls/calls.h"
#include "libc/calls/struct/sigaction.h"
#include "libc/calls/termios.h"
#include "libc/ctype.h"
#include "libc/errno.h"
#include "libc/paths.h"
#include "libc/str/str.h"
Expand Down
9 changes: 4 additions & 5 deletions libc/stdio/stdio.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#ifndef COSMOPOLITAN_LIBC_STDIO_H_
#define COSMOPOLITAN_LIBC_STDIO_H_

#define EOF -1 /* end of file */
#define WEOF -1u /* end of file (multibyte) */
#define _IOFBF 0 /* fully buffered */
#define _IOLBF 1 /* line buffered */
#define _IONBF 2 /* no buffering */
#define EOF -1 /* end of file */
#define _IOFBF 0 /* fully buffered */
#define _IOLBF 1 /* line buffered */
#define _IONBF 2 /* no buffering */

#define L_tmpnam 20
#define L_ctermid 20
Expand Down
2 changes: 1 addition & 1 deletion libc/str/isalnum.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/str/str.h"
#include "libc/ctype.h"

/**
* Returns nonzero if c is lower, alpha, or digit.
Expand Down
2 changes: 1 addition & 1 deletion libc/str/isalpha.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/str/str.h"
#include "libc/ctype.h"

/**
* Returns nonzero if c is upper or lower.
Expand Down
2 changes: 1 addition & 1 deletion libc/str/isascii.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/str/str.h"
#include "libc/ctype.h"

/**
* Returns nonzero if c is ascii.
Expand Down
2 changes: 1 addition & 1 deletion libc/str/isblank.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/str/str.h"
#include "libc/ctype.h"

/**
* Returns nonzero if c is space or tab.
Expand Down
2 changes: 1 addition & 1 deletion libc/str/iscntrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/str/str.h"
#include "libc/ctype.h"

/**
* Returns nonzero if c is C0 ASCII control code or DEL.
Expand Down
2 changes: 1 addition & 1 deletion libc/str/isdigit.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/str/str.h"
#include "libc/ctype.h"

/**
* Returns nonzero if c is decimal digit.
Expand Down
2 changes: 1 addition & 1 deletion libc/str/isgraph.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/str/str.h"
#include "libc/ctype.h"

/**
* Returns nonzero if c is printable ascii that isn't space.
Expand Down
2 changes: 1 addition & 1 deletion libc/str/islower.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/str/str.h"
#include "libc/ctype.h"

/**
* Returns nonzero if c is lowercase alpha ascii character.
Expand Down
2 changes: 1 addition & 1 deletion libc/str/isprint.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/str/str.h"
#include "libc/ctype.h"

/**
* Returns nonzero if c is printable ascii including space.
Expand Down
2 changes: 1 addition & 1 deletion libc/str/ispunct.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/str/str.h"
#include "libc/ctype.h"

/**
* Returns nonzero if ``c ∈ !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~``
Expand Down
2 changes: 1 addition & 1 deletion libc/str/isspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/str/str.h"
#include "libc/ctype.h"

/**
* Returns nonzero if c is space, \t, \r, \n, \f, or \v.
Expand Down
2 changes: 1 addition & 1 deletion libc/str/isupper.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/str/str.h"
#include "libc/ctype.h"

/**
* Returns nonzero if c is uppercase alpha ascii character.
Expand Down
2 changes: 1 addition & 1 deletion libc/str/iswalnum.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/str/str.h"
#include "libc/wctype.h"

/**
* Returns nonzero if c is lower, alpha, or digit.
Expand Down
2 changes: 1 addition & 1 deletion libc/str/iswalpha.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/str/str.h"
#include "libc/wctype.h"

/**
* Returns nonzero if c is alphabetical.
Expand Down
2 changes: 1 addition & 1 deletion libc/str/iswblank.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/str/str.h"
#include "libc/wctype.h"

/**
* Returns nonzero if c is space or tab.
Expand Down
2 changes: 1 addition & 1 deletion libc/str/iswcntrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/str/str.h"
#include "libc/wctype.h"

/**
* Returns nonzero if c is C0 or C1 control code.
Expand Down
Loading

0 comments on commit 7ebaff3

Please sign in to comment.