From ecd4d00f1bdf184163cc44ed8261d9f11ca9aae0 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Wed, 12 Aug 2020 11:02:56 -0400 Subject: remove all generated nonstd/ headers --- src/_assert.h | 51 ++++++++ src/_nonstd.h | 22 ++++ src/ctype/_ctype.h | 2 +- src/ctype/isalnum.c | 2 +- src/ctype/isalpha.c | 2 +- src/ctype/isblank.c | 2 +- src/ctype/iscntrl.c | 2 +- src/ctype/isdigit.c | 2 +- src/ctype/isgraph.c | 2 +- src/ctype/islower.c | 2 +- src/ctype/isprint.c | 2 +- src/ctype/ispunct.c | 2 +- src/ctype/isspace.c | 2 +- src/ctype/isupper.c | 2 +- src/ctype/isxdigit.c | 2 +- src/ctype/tolower.c | 2 +- src/ctype/toupper.c | 2 +- src/errno/__errno.c | 2 +- src/fnmatch/fnmatch.c | 2 +- src/glob/glob.c | 2 +- src/locale/__load_locale.c | 239 ++++++++++++++++++++++++++++++++++++++ src/locale/_locale.h | 65 +++++++++++ src/locale/localeconv.c | 3 +- src/locale/setlocale.c | 3 +- src/nonstd/ASSERT_NONNULL.c | 14 --- src/nonstd/ASSERT_NONZERO.c | 14 --- src/nonstd/ASSERT_NOOVERLAP.c | 9 -- src/nonstd/ASSERT_REPRESENTABLE.c | 21 ---- src/nonstd/LIBC_INTERNAL.c | 17 --- src/nonstd/__libc.c | 10 +- src/nonstd/__libc_per_thread.c | 4 +- src/nonstd/__load_locale.c | 4 - src/nonstd/_locale.h | 235 ------------------------------------- src/nonstd/locale-internal.ref | 2 - src/nonstd/locale-limits.ref | 2 - src/nonstd/locale-locale.ref | 2 - src/nonstd/struct_locale_t.c | 57 --------- src/stdio/__stdio.c | 5 + src/stdio/feof.c | 2 +- src/stdio/ferror.c | 2 +- src/stdio/fileno.c | 2 +- src/stdio/popen.c | 2 +- src/stdio/setvbuf.c | 12 +- src/string/memchr.c | 2 +- src/string/memcmp.c | 2 +- src/string/memcpy.c | 2 +- src/string/memmove.c | 2 +- src/string/memset.c | 2 +- src/string/strcat.c | 9 +- src/string/strchr.c | 2 +- src/string/strcmp.c | 2 +- src/string/strcoll.c | 2 +- src/string/strcpy.c | 2 +- src/string/strcspn.c | 2 +- src/string/strlen.c | 2 +- src/string/strncat.c | 2 +- src/string/strncmp.c | 2 +- src/string/strncpy.c | 2 +- src/string/strpbrk.c | 2 +- src/string/strrchr.c | 2 +- src/string/strspn.c | 2 +- src/string/strstr.c | 2 +- src/string/strtok.c | 2 +- src/string/strxfrm.c | 2 +- src/sys/stat/stat.c | 2 +- src/sys/utsname/uname.c | 2 +- src/termios/cfgetispeed.c | 2 +- src/termios/cfgetospeed.c | 2 +- src/termios/cfsetispeed.c | 2 +- src/termios/cfsetospeed.c | 2 +- src/time/gmtime.c | 2 +- src/time/localtime.c | 2 +- src/time/strftime.c | 5 +- src/unistd/confstr.c | 2 +- src/unistd/getcwd.c | 2 +- src/unistd/getgroups.c | 2 +- src/unistd/pipe.c | 2 +- src/unistd/unlink.c | 2 +- src/unistd/write.c | 2 +- src/wchar/fgetwc.c | 1 - src/wchar/fgetws.c | 2 +- src/wchar/fwide.c | 2 +- src/wchar/wcscmp.c | 2 +- src/wchar/wcscspn.c | 2 +- src/wchar/wcsncmp.c | 2 +- src/wchar/wmemchr.c | 2 +- src/wchar/wmemmove.c | 2 +- src/wctype/iswalnum.c | 2 +- src/wctype/iswalpha.c | 2 +- src/wctype/iswblank.c | 2 +- src/wctype/iswcntrl.c | 2 +- src/wctype/iswctype.c | 2 +- src/wctype/iswdigit.c | 2 +- src/wctype/iswgraph.c | 2 +- src/wctype/iswlower.c | 2 +- src/wctype/iswprint.c | 2 +- src/wctype/iswpunct.c | 2 +- src/wctype/iswspace.c | 2 +- src/wctype/iswupper.c | 2 +- src/wctype/iswxdigit.c | 2 +- src/wctype/towctrans.c | 2 +- src/wctype/towlower.c | 2 +- src/wctype/towupper.c | 2 +- src/wctype/wctrans.c | 2 +- src/wctype/wctype.c | 2 +- 105 files changed, 491 insertions(+), 477 deletions(-) create mode 100644 src/_assert.h create mode 100644 src/_nonstd.h create mode 100644 src/locale/__load_locale.c create mode 100644 src/locale/_locale.h delete mode 100644 src/nonstd/ASSERT_NONNULL.c delete mode 100644 src/nonstd/ASSERT_NONZERO.c delete mode 100644 src/nonstd/ASSERT_NOOVERLAP.c delete mode 100644 src/nonstd/ASSERT_REPRESENTABLE.c delete mode 100644 src/nonstd/LIBC_INTERNAL.c delete mode 100644 src/nonstd/__load_locale.c delete mode 100644 src/nonstd/_locale.h delete mode 100644 src/nonstd/locale-internal.ref delete mode 100644 src/nonstd/locale-limits.ref delete mode 100644 src/nonstd/locale-locale.ref delete mode 100644 src/nonstd/struct_locale_t.c diff --git a/src/_assert.h b/src/_assert.h new file mode 100644 index 00000000..2d27edfb --- /dev/null +++ b/src/_assert.h @@ -0,0 +1,51 @@ +#ifndef ___ASSERT_H__ +#define ___ASSERT_H__ + +#ifndef NDEBUG +#define ASSERT_NONNULL(__ptr) do { \ + if (!__ptr) { \ + struct __constraint_info _ci = {0}; \ + _ci.func = __func__; \ + __libc.stdlib.constraint_handler("Undefined behavior: " \ + "Parameter " #__ptr " can not be NULL", &_ci, EFAULT); \ + } \ +} while (0) + +#define ASSERT_NONZERO(__n) do { \ + if (!__n) { \ + struct __constraint_info _ci = {0}; \ + _ci.func = __func__; \ + __libc.stdlib.constraint_handler("Undefined behavior: " \ + "Parameter " #__n " can not be 0", &_ci, ERANGE); \ + } \ +} while (0) + +#define ASSERT_NOOVERLAP(__x, __y, __s) do { \ + /* TODO */ \ +} while (0) + +#define ASSERT_REPRESENTABLE(_n, _min, _max, _type, _sentinel) do { \ + if (_sentinel && (_n != _sentinel && (_n < _min || _n > _max))) { \ + struct __constraint_info _ci = {0}; \ + _ci.func = __func__; \ + __libc.stdlib.constraint_handler("Undefined behavior: " \ + "Paramater " #_n " must be representable as a " #_type \ + "or be equal to " #_sentinel, &_ci, ERANGE); \ + } else if (_n < _min || _n > _max) { \ + struct __constraint_info _ci = {0}; \ + _ci.func = __func__; \ + __libc.stdlib.constraint_handler("Undefined behavior: " \ + "Parameter " #_n " must be representable as a " #_type, \ + &_ci, ERANGE); \ + } \ + } while (0) +#else + +#define ASSERT_REPRESENTABLE(_n, _min, _max, _type, _sentinel) +#define ASSERT_NOOVERLAP(__x, __y, __s) +#define ASSERT_NONNULL(x) +#define ASSERT_NONZERO(n) + +#endif + +#endif diff --git a/src/_nonstd.h b/src/_nonstd.h new file mode 100644 index 00000000..247579cd --- /dev/null +++ b/src/_nonstd.h @@ -0,0 +1,22 @@ +#ifndef ___NONSTD_H__ +#define ___NONSTD_H__ + +typedef enum { + /* errno.h */ + ERRNO, + + /* locale.h */ + THREAD_LOCALE, + GLOBAL_LOCALE, + LCONV, + LOAD_LOCALE, + + /* [w]ctype.h */ + CTYPE, + TOLOWER, + TOUPPER, +} LIBC_INTERNAL; + +void *__libc(LIBC_INTERNAL __variable); + +#endif diff --git a/src/ctype/_ctype.h b/src/ctype/_ctype.h index fa584da6..f64553c1 100644 --- a/src/ctype/_ctype.h +++ b/src/ctype/_ctype.h @@ -1,7 +1,7 @@ #ifndef ___CTYPE_H__ #define ___CTYPE_H__ -#include "nonstd/internal.h" +#include "../_nonstd.h" typedef enum { CT_ALPHA = (1 << 0), diff --git a/src/ctype/isalnum.c b/src/ctype/isalnum.c index 6b0d7388..67ade0a2 100644 --- a/src/ctype/isalnum.c +++ b/src/ctype/isalnum.c @@ -1,6 +1,6 @@ #include #include "limits.h" -#include "nonstd/assert.h" +#include "../_assert.h" /** test whether a character is alphanumeric **/ diff --git a/src/ctype/isalpha.c b/src/ctype/isalpha.c index c399dc1c..b87817c8 100644 --- a/src/ctype/isalpha.c +++ b/src/ctype/isalpha.c @@ -1,6 +1,6 @@ #include #include "limits.h" -#include "nonstd/assert.h" +#include "../_assert.h" /** test whether a character is alphabetic **/ diff --git a/src/ctype/isblank.c b/src/ctype/isblank.c index aed70f98..d22d2315 100644 --- a/src/ctype/isblank.c +++ b/src/ctype/isblank.c @@ -2,7 +2,7 @@ #include "limits.h" #include "locale.h" #include "_ctype.h" -#include "nonstd/assert.h" +#include "../_assert.h" /** test whether a character is blank **/ diff --git a/src/ctype/iscntrl.c b/src/ctype/iscntrl.c index 679d3d24..ef28ff20 100644 --- a/src/ctype/iscntrl.c +++ b/src/ctype/iscntrl.c @@ -1,6 +1,6 @@ #include #include "limits.h" -#include "nonstd/assert.h" +#include "../_assert.h" #include "_ctype.h" /** test whether a character is a control character */ diff --git a/src/ctype/isdigit.c b/src/ctype/isdigit.c index f4f80c1b..0f91a7d3 100644 --- a/src/ctype/isdigit.c +++ b/src/ctype/isdigit.c @@ -1,6 +1,6 @@ #include #include "limits.h" -#include "nonstd/assert.h" +#include "../_assert.h" /** test whether a character is a digit **/ diff --git a/src/ctype/isgraph.c b/src/ctype/isgraph.c index d041e840..a6490d8f 100644 --- a/src/ctype/isgraph.c +++ b/src/ctype/isgraph.c @@ -1,6 +1,6 @@ #include #include "limits.h" -#include "nonstd/assert.h" +#include "../_assert.h" #include "_ctype.h" /** test whether a character is graphic **/ diff --git a/src/ctype/islower.c b/src/ctype/islower.c index b2e0b678..35c8236d 100644 --- a/src/ctype/islower.c +++ b/src/ctype/islower.c @@ -1,6 +1,6 @@ #include #include "limits.h" -#include "nonstd/assert.h" +#include "../_assert.h" #include "_ctype.h" /** test whether a character is a lowercase letter **/ diff --git a/src/ctype/isprint.c b/src/ctype/isprint.c index 4a426fe1..c3deaebd 100644 --- a/src/ctype/isprint.c +++ b/src/ctype/isprint.c @@ -1,6 +1,6 @@ #include #include "limits.h" -#include "nonstd/assert.h" +#include "../_assert.h" #include "_ctype.h" /** test whether a character is printable **/ diff --git a/src/ctype/ispunct.c b/src/ctype/ispunct.c index e55dac2e..12d0cf16 100644 --- a/src/ctype/ispunct.c +++ b/src/ctype/ispunct.c @@ -1,6 +1,6 @@ #include #include "limits.h" -#include "nonstd/assert.h" +#include "../_assert.h" #include "_ctype.h" /** test whether a character is punctuation **/ diff --git a/src/ctype/isspace.c b/src/ctype/isspace.c index 16cb0c24..fb913c49 100644 --- a/src/ctype/isspace.c +++ b/src/ctype/isspace.c @@ -1,6 +1,6 @@ #include #include "limits.h" -#include "nonstd/assert.h" +#include "../_assert.h" #include "_ctype.h" /** test whether a character is white-space **/ diff --git a/src/ctype/isupper.c b/src/ctype/isupper.c index d0d58eaa..ff07ff59 100644 --- a/src/ctype/isupper.c +++ b/src/ctype/isupper.c @@ -1,6 +1,6 @@ #include #include "limits.h" -#include "nonstd/assert.h" +#include "../_assert.h" #include "_ctype.h" /** test whether a character is an uppercase letter **/ diff --git a/src/ctype/isxdigit.c b/src/ctype/isxdigit.c index 543774a3..9f9e0b91 100644 --- a/src/ctype/isxdigit.c +++ b/src/ctype/isxdigit.c @@ -1,6 +1,6 @@ #include #include "limits.h" -#include "nonstd/assert.h" +#include "../_assert.h" #include "_ctype.h" /** test whether a character is a hexadecimal digit **/ diff --git a/src/ctype/tolower.c b/src/ctype/tolower.c index 0994071b..4512ef36 100644 --- a/src/ctype/tolower.c +++ b/src/ctype/tolower.c @@ -1,7 +1,7 @@ #include #include "stdio.h" #include "limits.h" -#include "nonstd/assert.h" +#include "../_assert.h" #include "_ctype.h" /** convert an uppercase letter to lowercase **/ diff --git a/src/ctype/toupper.c b/src/ctype/toupper.c index e40e4a73..897d059e 100644 --- a/src/ctype/toupper.c +++ b/src/ctype/toupper.c @@ -1,7 +1,7 @@ #include #include "stdio.h" #include "limits.h" -#include "nonstd/assert.h" +#include "../_assert.h" #include "_ctype.h" /** convert a lowercase letter to uppercase **/ diff --git a/src/errno/__errno.c b/src/errno/__errno.c index c46c86c7..99061185 100644 --- a/src/errno/__errno.c +++ b/src/errno/__errno.c @@ -1,5 +1,5 @@ #include -#include "nonstd/internal.h" +#include "../_nonstd.h" int *__errno(void) { diff --git a/src/fnmatch/fnmatch.c b/src/fnmatch/fnmatch.c index 2f330951..97c17071 100644 --- a/src/fnmatch/fnmatch.c +++ b/src/fnmatch/fnmatch.c @@ -1,5 +1,5 @@ #include -#include "nonstd/assert.h" +#include "../_assert.h" int fnmatch(const char * pattern, const char * string, int flags) { diff --git a/src/glob/glob.c b/src/glob/glob.c index e3b7525f..153f8046 100644 --- a/src/glob/glob.c +++ b/src/glob/glob.c @@ -6,7 +6,7 @@ #include "fnmatch.h" #include "errno.h" #include "unistd.h" -#include "nonstd/assert.h" +#include "../_assert.h" int glob(const char * restrict pattern, int flags, int (*errfunc) (const char * epath, int eerrno), glob_t * restrict pglob) { diff --git a/src/locale/__load_locale.c b/src/locale/__load_locale.c new file mode 100644 index 00000000..d79bb4e4 --- /dev/null +++ b/src/locale/__load_locale.c @@ -0,0 +1,239 @@ +#include "locale.h" +#include "limits.h" +#include "stdio.h" +#include "string.h" + +#include "_locale.h" +#include "../ctype/_ctype.h" + +#define LC_COLLATE_MASK (1<<0) +#define LC_CTYPE_MASK (1<<1) +#define LC_MONETARY_MASK (1<<2) +#define LC_NUMERIC_MASK (1<<3) +#define LC_TIME_MASK (1<<4) +#define LC_MESSAGES_MASK (1<<5) +#define LC_ALL_MASK (0xff) + +#define setall(_map, _input, _mask) do { \ + size_t _i; \ + for (_i = 0; _i < sizeof(_input) - 1; _i++) { \ + _map[(int)_input[_i]] |= _mask; \ + } \ +} while (0) + +char * __load_locale(struct __locale_t *loc, int mask, const char *name) +{ + if (name == NULL) { + name = ""; + } + + char localepath[FILENAME_MAX] = "/lib/locale/"; + strcat(localepath, name); + + FILE *localefile = fopen(localepath, "rb"); + if (localefile == NULL && strcmp(name, "C") && strcmp(name, "POSIX")) { + return NULL; + } + + if (mask & LC_COLLATE_MASK) { + strcpy(loc->collate, name); + + if (localefile == NULL) { + /* TODO: POSIX/C locale collation */ + } else { + /* read from file */ + loc->lc_collate = NULL; + } + } + + if (mask & LC_CTYPE_MASK) { + strcpy(loc->ctype, name); + + if (localefile == NULL) { + char upper[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + char lower[] = "abcdefghijklmnopqrstuvwxyz"; + char digit[] = "0123456789"; + char xdigit[] = "0123456789ABCDEFabcdef"; + char space[] = " \f\n\r\t\v"; + char punct[] = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"; + char blank[] = " \t"; + size_t i; + + memset(loc->lc_ctype.ctattr, 0, sizeof(loc->lc_ctype.ctattr)); + + for (i = 0; i < 32; i++) { + loc->lc_ctype.ctattr[i] = CT_CNTRL; + } + loc->lc_ctype.ctattr[127] = CT_CNTRL; + + setall(loc->lc_ctype.ctattr, upper, CT_UPPER); + setall(loc->lc_ctype.ctattr, upper, CT_ALPHA); + setall(loc->lc_ctype.ctattr, lower, CT_LOWER); + setall(loc->lc_ctype.ctattr, lower, CT_ALPHA); + setall(loc->lc_ctype.ctattr, digit, CT_DIGIT); + setall(loc->lc_ctype.ctattr, xdigit, CT_XDIGIT); + setall(loc->lc_ctype.ctattr, space, CT_SPACE); + setall(loc->lc_ctype.ctattr, punct, CT_PUNCT); + setall(loc->lc_ctype.ctattr, blank, CT_BLANK); + + for (i = 0; i < CHAR_MAX; i++) { + if (loc->lc_ctype.ctattr[i] & + (CT_UPPER | CT_ALPHA | CT_LOWER | + CT_DIGIT | CT_XDIGIT | CT_PUNCT)) { + loc->lc_ctype.ctattr[i] |= CT_GRAPH; + loc->lc_ctype.ctattr[i] |= CT_PRINT; + } + } + + loc->lc_ctype.ctattr[' '] |= CT_PRINT; + + for (i = 0; i < UCHAR_MAX; i++) { + loc->lc_ctype.ctoupper[i] = i; + loc->lc_ctype.ctolower[i] = i; + } + + for (i = 0; i < sizeof(upper); i++) { + loc->lc_ctype.ctolower[(int)upper[i]] = lower[i]; + loc->lc_ctype.ctoupper[(int)lower[i]] = upper[i]; + } + } else { + /* read from file */ + /* + loc->lc_ctype.ctattr + loc->lc_ctype.ctoupper + loc->lc_ctype.ctolower + */ + } + } + + if (mask & LC_MONETARY_MASK) { + strcpy(loc->monetary, name); + + if (localefile == NULL) { + loc->mn.mon_decimal_point = ""; + loc->mn.mon_thousands_sep = ""; + loc->mn.mon_grouping = ""; + loc->mn.positive_sign = ""; + loc->mn.negative_sign = ""; + loc->mn.currency_symbol = ""; + loc->mn.frac_digits = CHAR_MAX; + loc->mn.p_cs_precedes = CHAR_MAX; + loc->mn.n_cs_precedes = CHAR_MAX; + loc->mn.p_sep_by_space = CHAR_MAX; + loc->mn.n_sep_by_space = CHAR_MAX; + loc->mn.p_sign_posn = CHAR_MAX; + loc->mn.n_sign_posn = CHAR_MAX; + loc->mn.int_curr_symbol = ""; + loc->mn.int_frac_digits = CHAR_MAX; + + #if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ + loc->mn.int_p_cs_precedes = CHAR_MAX; + loc->mn.int_n_cs_precedes = CHAR_MAX; + loc->mn.int_p_sep_by_space = CHAR_MAX; + loc->mn.int_n_sep_by_space = CHAR_MAX; + loc->mn.int_p_sign_posn = CHAR_MAX; + loc->mn.int_n_sign_posn = CHAR_MAX; + #else + loc->mn.__int_p_cs_precedes = CHAR_MAX; + loc->mn.__int_n_cs_precedes = CHAR_MAX; + loc->mn.__int_p_sep_by_space = CHAR_MAX; + loc->mn.__int_n_sep_by_space = CHAR_MAX; + loc->mn.__int_p_sign_posn = CHAR_MAX; + loc->mn.__int_n_sign_posn = CHAR_MAX; + #endif + } else { + /* + loc->mn.monetary fields; + */ + } + } + + if (mask & LC_NUMERIC_MASK) { + strcpy(loc->numeric, name); + + if (localefile == NULL) { + loc->mn.decimal_point = "."; + loc->mn.thousands_sep = ""; + loc->mn.grouping = ""; + } else { + /* + loc->mn.numeric fields + */ + } + } + + if (mask & LC_TIME_MASK) { + strcpy(loc->time, name); + + if (localefile == NULL) { + memset(&loc->lc_time, 0, sizeof(loc->lc_time)); + + loc->lc_time.d_t_fmt = "%a %b %e %H:%M:%S %Y"; + loc->lc_time.d_fmt = "%m/%d/%y"; + loc->lc_time.t_fmt = "%H:%M:%S"; + loc->lc_time.am_pm[0] = "AM"; + loc->lc_time.am_pm[1] = "PM"; + loc->lc_time.t_fmt_ampm = "%I:%M:%S %p"; + loc->lc_time.day[0] = "Sunday"; + loc->lc_time.day[1] = "Monday"; + loc->lc_time.day[2] = "Tuesday"; + loc->lc_time.day[3] = "Wednesday"; + loc->lc_time.day[4] = "Thursday"; + loc->lc_time.day[5] = "Friday"; + loc->lc_time.day[6] = "Saturday"; + loc->lc_time.abday[0] = "Sun"; + loc->lc_time.abday[1] = "Mon"; + loc->lc_time.abday[2] = "Tue"; + loc->lc_time.abday[3] = "Wed"; + loc->lc_time.abday[4] = "Thu"; + loc->lc_time.abday[5] = "Fri"; + loc->lc_time.abday[6] = "Sat"; + loc->lc_time.mon[0] = "January"; + loc->lc_time.mon[1] = "February"; + loc->lc_time.mon[2] = "March"; + loc->lc_time.mon[3] = "April"; + loc->lc_time.mon[4] = "May"; + loc->lc_time.mon[5] = "June"; + loc->lc_time.mon[6] = "July"; + loc->lc_time.mon[7] = "August"; + loc->lc_time.mon[8] = "September"; + loc->lc_time.mon[9] = "October"; + loc->lc_time.mon[10] = "November"; + loc->lc_time.mon[11] = "December"; + loc->lc_time.abmon[0] = "Jan"; + loc->lc_time.abmon[1] = "Feb"; + loc->lc_time.abmon[2] = "Mar"; + loc->lc_time.abmon[3] = "Apr"; + loc->lc_time.abmon[4] = "May"; + loc->lc_time.abmon[5] = "Jun"; + loc->lc_time.abmon[6] = "Jul"; + loc->lc_time.abmon[7] = "Aug"; + loc->lc_time.abmon[8] = "Sep"; + loc->lc_time.abmon[9] = "Oct"; + loc->lc_time.abmon[10] = "Nov"; + loc->lc_time.abmon[11] = "Dec"; + } else { + /* read from file */ + /* loc->lc_time */ + } + } + + if (mask & LC_MESSAGES_MASK) { + strcpy(loc->messages, name); + + if (localefile == NULL) { + loc->lc_messages.yesexpr = "^[yY]"; + loc->lc_messages.noexpr = "^[nN]"; + } else { + /* read */ + loc->lc_messages.yesexpr = NULL; + loc->lc_messages.noexpr = NULL; + } + } + + return (char*)name; +} + +/* +STDC(0) +*/ diff --git a/src/locale/_locale.h b/src/locale/_locale.h new file mode 100644 index 00000000..bed7e0f5 --- /dev/null +++ b/src/locale/_locale.h @@ -0,0 +1,65 @@ +#ifndef ___LOCALE_H__ +#define ___LOCALE_H__ + +#include +#include + +struct __locale_t { + char all[UCHAR_MAX]; + + char ctype[UCHAR_MAX]; + struct { + unsigned int ctattr[UCHAR_MAX + 1]; + unsigned char ctoupper[UCHAR_MAX + 1]; + unsigned char ctolower[UCHAR_MAX + 1]; + } lc_ctype; + + char collate[UCHAR_MAX]; + struct collation { + char * sequence; + int weight; + } *lc_collate; + + char messages[UCHAR_MAX]; + struct { + char *yesexpr; + char *noexpr; + } lc_messages; + + char monetary[UCHAR_MAX]; + char numeric[UCHAR_MAX]; + struct lconv mn; + + char time[UCHAR_MAX]; + struct { + char *abday[7]; + char *day[7]; + char *abmon[12]; + char *mon[12]; + char *d_t_fmt; + char *d_fmt; + char *t_fmt; + char *am_pm[2]; + char *t_fmt_ampm; + struct { + char direction; + int offset; + int start_year; + int start_month; + int start_day; + int end_year; + int end_month; + int end_day; + char *era_name; + char *era_format; + } era; + char *era_d_fmt; + char *era_t_fmt; + char *era_d_t_fmt; + char *alt_digits; + } lc_time; +}; + +char * __load_locale(struct __locale_t *, int, const char *); + +#endif diff --git a/src/locale/localeconv.c b/src/locale/localeconv.c index f08eb872..e63402e2 100644 --- a/src/locale/localeconv.c +++ b/src/locale/localeconv.c @@ -1,5 +1,6 @@ #include -#include "nonstd/locale.h" +#include "_locale.h" +#include "../_nonstd.h" /** return locale-specific information **/ struct lconv * localeconv(void) diff --git a/src/locale/setlocale.c b/src/locale/setlocale.c index 56043e61..068bf858 100644 --- a/src/locale/setlocale.c +++ b/src/locale/setlocale.c @@ -1,7 +1,8 @@ #include #include "string.h" #include "stdlib.h" -#include "nonstd/locale.h" +#include "_locale.h" +#include "../_nonstd.h" #include "LC_ALL_MASK.c" #include "LC_COLLATE_MASK.c" diff --git a/src/nonstd/ASSERT_NONNULL.c b/src/nonstd/ASSERT_NONNULL.c deleted file mode 100644 index 26a6138e..00000000 --- a/src/nonstd/ASSERT_NONNULL.c +++ /dev/null @@ -1,14 +0,0 @@ -#include - -#ifndef NDEBUG -#define ASSERT_NONNULL(__ptr) do { \ - if (!__ptr) { \ - struct __constraint_info _ci = {0}; \ - _ci.func = __func__; \ - __libc.stdlib.constraint_handler("Undefined behavior: " \ - "Parameter " #__ptr " can not be NULL", &_ci, EFAULT); \ - } \ - } while (0) -#else -#define ASSERT_NONNULL(x) -#endif diff --git a/src/nonstd/ASSERT_NONZERO.c b/src/nonstd/ASSERT_NONZERO.c deleted file mode 100644 index e48e775a..00000000 --- a/src/nonstd/ASSERT_NONZERO.c +++ /dev/null @@ -1,14 +0,0 @@ -#include - -#ifndef NDEBUG -#define ASSERT_NONZERO(__n) do { \ - if (!__n) { \ - struct __constraint_info _ci = {0}; \ - _ci.func = __func__; \ - __libc.stdlib.constraint_handler("Undefined behavior: " \ - "Parameter " #__n " can not be 0", &_ci, ERANGE); \ - } \ - } while (0) -#else -#define ASSERT_NONZERO(n) -#endif diff --git a/src/nonstd/ASSERT_NOOVERLAP.c b/src/nonstd/ASSERT_NOOVERLAP.c deleted file mode 100644 index 7173752d..00000000 --- a/src/nonstd/ASSERT_NOOVERLAP.c +++ /dev/null @@ -1,9 +0,0 @@ -#include - -#ifndef NDEBUG -#define ASSERT_NOOVERLAP(__x, __y, __s) do { \ - /* TODO */ \ - } while (0) -#else -#define ASSERT_NOOVERLAP(__x, __y, __s) -#endif diff --git a/src/nonstd/ASSERT_REPRESENTABLE.c b/src/nonstd/ASSERT_REPRESENTABLE.c deleted file mode 100644 index 0067d9b4..00000000 --- a/src/nonstd/ASSERT_REPRESENTABLE.c +++ /dev/null @@ -1,21 +0,0 @@ -#include - -#ifndef NDEBUG -#define ASSERT_REPRESENTABLE(_n, _min, _max, _type, _sentinel) do { \ - if (_sentinel && (_n != _sentinel && (_n < _min || _n > _max))) { \ - struct __constraint_info _ci = {0}; \ - _ci.func = __func__; \ - __libc.stdlib.constraint_handler("Undefined behavior: " \ - "Paramater " #_n " must be representable as a " #_type \ - "or be equal to " #_sentinel, &_ci, ERANGE); \ - } else if (_n < _min || _n > _max) { \ - struct __constraint_info _ci = {0}; \ - _ci.func = __func__; \ - __libc.stdlib.constraint_handler("Undefined behavior: " \ - "Parameter " #_n " must be representable as a " #_type, \ - &_ci, ERANGE); \ - } \ - } while (0) -#else -#define ASSERT_REPRESENTABLE(_n, _min, _max, _type, _sentinel) -#endif diff --git a/src/nonstd/LIBC_INTERNAL.c b/src/nonstd/LIBC_INTERNAL.c deleted file mode 100644 index a00a0c98..00000000 --- a/src/nonstd/LIBC_INTERNAL.c +++ /dev/null @@ -1,17 +0,0 @@ -#include - -typedef enum { - /* errno.h */ - ERRNO, - - /* locale.h */ - THREAD_LOCALE, - GLOBAL_LOCALE, - LCONV, - LOAD_LOCALE, - - /* [w]ctype.h */ - CTYPE, - TOLOWER, - TOUPPER, -} LIBC_INTERNAL; diff --git a/src/nonstd/__libc.c b/src/nonstd/__libc.c index 752dcab0..9000dd46 100644 --- a/src/nonstd/__libc.c +++ b/src/nonstd/__libc.c @@ -1,10 +1,8 @@ #include "sys/types.h" -#include -#include "nonstd/locale.h" +#include "../_nonstd.h" +#include "../locale/_locale.h" #include "../stdio/_stdio.h" -#include "_locale.h" - void *__libc(LIBC_INTERNAL variable) { extern void *__libc_per_thread(LIBC_INTERNAL __variable); @@ -59,10 +57,6 @@ void *__libc(LIBC_INTERNAL variable) r = &(((struct __locale_t*)r)->mn); break; - case LOAD_LOCALE: - r = (void*)(__load_locale); - break; - default: break; } diff --git a/src/nonstd/__libc_per_thread.c b/src/nonstd/__libc_per_thread.c index 15156c6e..38c7c610 100644 --- a/src/nonstd/__libc_per_thread.c +++ b/src/nonstd/__libc_per_thread.c @@ -1,6 +1,6 @@ -#include "nonstd/internal.h" +#include "../_nonstd.h" #include "locale.h" -#include "nonstd/locale.h" +#include "../locale/_locale.h" #if defined __STDC_VERSION__ && 201112L <= __STDC_VERSION__ && !defined __STDC_NO_THREADS__ #define THREAD_LOCAL static _Thread_local diff --git a/src/nonstd/__load_locale.c b/src/nonstd/__load_locale.c deleted file mode 100644 index 2233e6b8..00000000 --- a/src/nonstd/__load_locale.c +++ /dev/null @@ -1,4 +0,0 @@ -#include - -#define __load_locale(_loc, _mask, _name) \ - ((char * (*)(struct __locale_t *, int, const char *))__libc(LOAD_LOCALE))(_loc, _mask, _name) diff --git a/src/nonstd/_locale.h b/src/nonstd/_locale.h deleted file mode 100644 index be692e87..00000000 --- a/src/nonstd/_locale.h +++ /dev/null @@ -1,235 +0,0 @@ -#include -#include -#include -#include - -#include "nonstd/locale.h" -#include "../ctype/_ctype.h" - -#define LC_COLLATE_MASK (1<<0) -#define LC_CTYPE_MASK (1<<1) -#define LC_MONETARY_MASK (1<<2) -#define LC_NUMERIC_MASK (1<<3) -#define LC_TIME_MASK (1<<4) -#define LC_MESSAGES_MASK (1<<5) -#define LC_ALL_MASK (0xff) - -#define setall(_map, _input, _mask) do { \ - size_t _i; \ - for (_i = 0; _i < sizeof(_input) - 1; _i++) { \ - _map[(int)_input[_i]] |= _mask; \ - } \ -} while (0) - -static char * (__load_locale)(struct __locale_t *loc, int mask, const char *name) -{ - if (name == NULL) { - name = ""; - } - - char localepath[FILENAME_MAX] = "/lib/locale/"; - strcat(localepath, name); - - FILE *localefile = fopen(localepath, "rb"); - if (localefile == NULL && strcmp(name, "C") && strcmp(name, "POSIX")) { - return NULL; - } - - if (mask & LC_COLLATE_MASK) { - strcpy(loc->collate, name); - - if (localefile == NULL) { - /* TODO: POSIX/C locale collation */ - } else { - /* read from file */ - loc->lc_collate = NULL; - } - } - - if (mask & LC_CTYPE_MASK) { - strcpy(loc->ctype, name); - - if (localefile == NULL) { - char upper[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - char lower[] = "abcdefghijklmnopqrstuvwxyz"; - char digit[] = "0123456789"; - char xdigit[] = "0123456789ABCDEFabcdef"; - char space[] = " \f\n\r\t\v"; - char punct[] = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"; - char blank[] = " \t"; - size_t i; - - memset(loc->lc_ctype.ctattr, 0, sizeof(loc->lc_ctype.ctattr)); - - for (i = 0; i < 32; i++) { - loc->lc_ctype.ctattr[i] = CT_CNTRL; - } - loc->lc_ctype.ctattr[127] = CT_CNTRL; - - setall(loc->lc_ctype.ctattr, upper, CT_UPPER); - setall(loc->lc_ctype.ctattr, upper, CT_ALPHA); - setall(loc->lc_ctype.ctattr, lower, CT_LOWER); - setall(loc->lc_ctype.ctattr, lower, CT_ALPHA); - setall(loc->lc_ctype.ctattr, digit, CT_DIGIT); - setall(loc->lc_ctype.ctattr, xdigit, CT_XDIGIT); - setall(loc->lc_ctype.ctattr, space, CT_SPACE); - setall(loc->lc_ctype.ctattr, punct, CT_PUNCT); - setall(loc->lc_ctype.ctattr, blank, CT_BLANK); - - for (i = 0; i < CHAR_MAX; i++) { - if (loc->lc_ctype.ctattr[i] & - (CT_UPPER | CT_ALPHA | CT_LOWER | - CT_DIGIT | CT_XDIGIT | CT_PUNCT)) { - loc->lc_ctype.ctattr[i] |= CT_GRAPH; - loc->lc_ctype.ctattr[i] |= CT_PRINT; - } - } - - loc->lc_ctype.ctattr[' '] |= CT_PRINT; - - for (i = 0; i < UCHAR_MAX; i++) { - loc->lc_ctype.ctoupper[i] = i; - loc->lc_ctype.ctolower[i] = i; - } - - for (i = 0; i < sizeof(upper); i++) { - loc->lc_ctype.ctolower[(int)upper[i]] = lower[i]; - loc->lc_ctype.ctoupper[(int)lower[i]] = upper[i]; - } - } else { - /* read from file */ - /* - loc->lc_ctype.ctattr - loc->lc_ctype.ctoupper - loc->lc_ctype.ctolower - */ - } - } - - if (mask & LC_MONETARY_MASK) { - strcpy(loc->monetary, name); - - if (localefile == NULL) { - loc->mn.mon_decimal_point = ""; - loc->mn.mon_thousands_sep = ""; - loc->mn.mon_grouping = ""; - loc->mn.positive_sign = ""; - loc->mn.negative_sign = ""; - loc->mn.currency_symbol = ""; - loc->mn.frac_digits = CHAR_MAX; - loc->mn.p_cs_precedes = CHAR_MAX; - loc->mn.n_cs_precedes = CHAR_MAX; - loc->mn.p_sep_by_space = CHAR_MAX; - loc->mn.n_sep_by_space = CHAR_MAX; - loc->mn.p_sign_posn = CHAR_MAX; - loc->mn.n_sign_posn = CHAR_MAX; - loc->mn.int_curr_symbol = ""; - loc->mn.int_frac_digits = CHAR_MAX; - - #if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ - loc->mn.int_p_cs_precedes = CHAR_MAX; - loc->mn.int_n_cs_precedes = CHAR_MAX; - loc->mn.int_p_sep_by_space = CHAR_MAX; - loc->mn.int_n_sep_by_space = CHAR_MAX; - loc->mn.int_p_sign_posn = CHAR_MAX; - loc->mn.int_n_sign_posn = CHAR_MAX; - #else - loc->mn.__int_p_cs_precedes = CHAR_MAX; - loc->mn.__int_n_cs_precedes = CHAR_MAX; - loc->mn.__int_p_sep_by_space = CHAR_MAX; - loc->mn.__int_n_sep_by_space = CHAR_MAX; - loc->mn.__int_p_sign_posn = CHAR_MAX; - loc->mn.__int_n_sign_posn = CHAR_MAX; - #endif - } else { - /* - loc->mn.monetary fields; - */ - } - } - - if (mask & LC_NUMERIC_MASK) { - strcpy(loc->numeric, name); - - if (localefile == NULL) { - loc->mn.decimal_point = "."; - loc->mn.thousands_sep = ""; - loc->mn.grouping = ""; - } else { - /* - loc->mn.numeric fields - */ - } - } - - if (mask & LC_TIME_MASK) { - strcpy(loc->time, name); - - if (localefile == NULL) { - memset(&loc->lc_time, 0, sizeof(loc->lc_time)); - - loc->lc_time.d_t_fmt = "%a %b %e %H:%M:%S %Y"; - loc->lc_time.d_fmt = "%m/%d/%y"; - loc->lc_time.t_fmt = "%H:%M:%S"; - loc->lc_time.am_pm[0] = "AM"; - loc->lc_time.am_pm[1] = "PM"; - loc->lc_time.t_fmt_ampm = "%I:%M:%S %p"; - loc->lc_time.day[0] = "Sunday"; - loc->lc_time.day[1] = "Monday"; - loc->lc_time.day[2] = "Tuesday"; - loc->lc_time.day[3] = "Wednesday"; - loc->lc_time.day[4] = "Thursday"; - loc->lc_time.day[5] = "Friday"; - loc->lc_time.day[6] = "Saturday"; - loc->lc_time.abday[0] = "Sun"; - loc->lc_time.abday[1] = "Mon"; - loc->lc_time.abday[2] = "Tue"; - loc->lc_time.abday[3] = "Wed"; - loc->lc_time.abday[4] = "Thu"; - loc->lc_time.abday[5] = "Fri"; - loc->lc_time.abday[6] = "Sat"; - loc->lc_time.mon[0] = "January"; - loc->lc_time.mon[1] = "February"; - loc->lc_time.mon[2] = "March"; - loc->lc_time.mon[3] = "April"; - loc->lc_time.mon[4] = "May"; - loc->lc_time.mon[5] = "June"; - loc->lc_time.mon[6] = "July"; - loc->lc_time.mon[7] = "August"; - loc->lc_time.mon[8] = "September"; - loc->lc_time.mon[9] = "October"; - loc->lc_time.mon[10] = "November"; - loc->lc_time.mon[11] = "December"; - loc->lc_time.abmon[0] = "Jan"; - loc->lc_time.abmon[1] = "Feb"; - loc->lc_time.abmon[2] = "Mar"; - loc->lc_time.abmon[3] = "Apr"; - loc->lc_time.abmon[4] = "May"; - loc->lc_time.abmon[5] = "Jun"; - loc->lc_time.abmon[6] = "Jul"; - loc->lc_time.abmon[7] = "Aug"; - loc->lc_time.abmon[8] = "Sep"; - loc->lc_time.abmon[9] = "Oct"; - loc->lc_time.abmon[10] = "Nov"; - loc->lc_time.abmon[11] = "Dec"; - } else { - /* read from file */ - /* loc->lc_time */ - } - } - - if (mask & LC_MESSAGES_MASK) { - strcpy(loc->messages, name); - - if (localefile == NULL) { - loc->lc_messages.yesexpr = "^[yY]"; - loc->lc_messages.noexpr = "^[nN]"; - } else { - /* read */ - loc->lc_messages.yesexpr = NULL; - loc->lc_messages.noexpr = NULL; - } - } - - return (char*)name; -} diff --git a/src/nonstd/locale-internal.ref b/src/nonstd/locale-internal.ref deleted file mode 100644 index d795ee8f..00000000 --- a/src/nonstd/locale-internal.ref +++ /dev/null @@ -1,2 +0,0 @@ -#include -REFERENCE() diff --git a/src/nonstd/locale-limits.ref b/src/nonstd/locale-limits.ref deleted file mode 100644 index 705296b4..00000000 --- a/src/nonstd/locale-limits.ref +++ /dev/null @@ -1,2 +0,0 @@ -#include -REFERENCE() diff --git a/src/nonstd/locale-locale.ref b/src/nonstd/locale-locale.ref deleted file mode 100644 index 98478b9f..00000000 --- a/src/nonstd/locale-locale.ref +++ /dev/null @@ -1,2 +0,0 @@ -#include -REFERENCE() diff --git a/src/nonstd/struct_locale_t.c b/src/nonstd/struct_locale_t.c deleted file mode 100644 index 3479e22f..00000000 --- a/src/nonstd/struct_locale_t.c +++ /dev/null @@ -1,57 +0,0 @@ -#include - -struct __locale_t { - char all[UCHAR_MAX]; - - char ctype[UCHAR_MAX]; - struct { - unsigned int ctattr[UCHAR_MAX + 1]; - unsigned char ctoupper[UCHAR_MAX + 1]; - unsigned char ctolower[UCHAR_MAX + 1]; - } lc_ctype; - - char collate[UCHAR_MAX]; - struct collation { - char * sequence; - int weight; - } *lc_collate; - - char messages[UCHAR_MAX]; - struct { - char *yesexpr; - char *noexpr; - } lc_messages; - - char monetary[UCHAR_MAX]; - char numeric[UCHAR_MAX]; - struct lconv mn; - - char time[UCHAR_MAX]; - struct { - char *abday[7]; - char *day[7]; - char *abmon[12]; - char *mon[12]; - char *d_t_fmt; - char *d_fmt; - char *t_fmt; - char *am_pm[2]; - char *t_fmt_ampm; - struct { - char direction; - int offset; - int start_year; - int start_month; - int start_day; - int end_year; - int end_month; - int end_day; - char *era_name; - char *era_format; - } era; - char *era_d_fmt; - char *era_t_fmt; - char *era_d_t_fmt; - char *alt_digits; - } lc_time; -}; diff --git a/src/stdio/__stdio.c b/src/stdio/__stdio.c index d607bde6..2360020f 100644 --- a/src/stdio/__stdio.c +++ b/src/stdio/__stdio.c @@ -1,2 +1,7 @@ #include "_stdio.h" + struct __stdio __stdio; + +/* +STDC(0) +*/ diff --git a/src/stdio/feof.c b/src/stdio/feof.c index 9524d8c6..8b2455bd 100644 --- a/src/stdio/feof.c +++ b/src/stdio/feof.c @@ -1,6 +1,6 @@ #include #include "_stdio.h" -#include "nonstd/assert.h" +#include "../_assert.h" /** test for end-of-file **/ int feof(FILE *stream) diff --git a/src/stdio/ferror.c b/src/stdio/ferror.c index 9d427e1f..d4e014d4 100644 --- a/src/stdio/ferror.c +++ b/src/stdio/ferror.c @@ -1,5 +1,5 @@ #include -#include "nonstd/assert.h" +#include "../_assert.h" #include "_stdio.h" /** tests the file stream error indicator **/ diff --git a/src/stdio/fileno.c b/src/stdio/fileno.c index 8292001d..969f572c 100644 --- a/src/stdio/fileno.c +++ b/src/stdio/fileno.c @@ -1,6 +1,6 @@ #include #include "_stdio.h" -#include "nonstd/assert.h" +#include "../_assert.h" int fileno(FILE * stream) { diff --git a/src/stdio/popen.c b/src/stdio/popen.c index 04918003..0e0fc663 100644 --- a/src/stdio/popen.c +++ b/src/stdio/popen.c @@ -5,7 +5,7 @@ #include "sys/types.h" #include "unistd.h" -#include "nonstd/assert.h" +#include "../_assert.h" #include "_stdio.h" #ifdef __STDC_VERSION__ diff --git a/src/stdio/setvbuf.c b/src/stdio/setvbuf.c index e5800288..ecf038fd 100644 --- a/src/stdio/setvbuf.c +++ b/src/stdio/setvbuf.c @@ -16,11 +16,19 @@ int setvbuf(FILE *stream, char *buf, int mode, size_t size) stream->buffering = mode; stream->bsize = size; + if (mode == _IONBF) { + /* maybe free buffer */ + return 0; + } + if (buf != NULL) { stream->buf = buf; stream->buftype = SUPPLIED; - } else if (mode != _IONBF) { - stream->buf = calloc(size, sizeof(char)); + } else if (size <= BUFSIZ) { + stream->buf = stream->ibuf; + stream->buftype = INTERNAL; + } else { + stream->buf = malloc(size); stream->buftype = ALLOCED; } diff --git a/src/string/memchr.c b/src/string/memchr.c index 97f6b257..9b795e9b 100644 --- a/src/string/memchr.c +++ b/src/string/memchr.c @@ -1,5 +1,5 @@ #include -#include "nonstd/assert.h" +#include "../_assert.h" /** search memory **/ void * memchr(const void *s, int c, size_t n) diff --git a/src/string/memcmp.c b/src/string/memcmp.c index 64dcb464..f0c1e2da 100644 --- a/src/string/memcmp.c +++ b/src/string/memcmp.c @@ -1,5 +1,5 @@ #include -#include "nonstd/assert.h" +#include "../_assert.h" /** compare memory regions **/ int memcmp(const void *s1, const void *s2, size_t n) diff --git a/src/string/memcpy.c b/src/string/memcpy.c index f53fe5d8..43ac292e 100644 --- a/src/string/memcpy.c +++ b/src/string/memcpy.c @@ -1,5 +1,5 @@ #include -#include "nonstd/assert.h" +#include "../_assert.h" /** copy memory **/ void * memcpy(void * restrict s1, const void * restrict s2, size_t n) diff --git a/src/string/memmove.c b/src/string/memmove.c index 33000e0e..ec8e785d 100644 --- a/src/string/memmove.c +++ b/src/string/memmove.c @@ -1,5 +1,5 @@ #include -#include "nonstd/assert.h" +#include "../_assert.h" /** move memory **/ void * memmove(void *s1, const void *s2, size_t n) diff --git a/src/string/memset.c b/src/string/memset.c index 1f3d14ff..2fdb8551 100644 --- a/src/string/memset.c +++ b/src/string/memset.c @@ -1,5 +1,5 @@ #include -#include "nonstd/assert.h" +#include "../_assert.h" /** fill memory **/ void * memset(void *s, int c, size_t n) diff --git a/src/string/strcat.c b/src/string/strcat.c index 9526cd59..75364ad3 100644 --- a/src/string/strcat.c +++ b/src/string/strcat.c @@ -1,9 +1,10 @@ #include -#include "nonstd/assert.h" +#include "../_assert.h" /** concatenate strings **/ char * strcat(char * restrict s1, const char * restrict s2) { + size_t i = 0; ASSERT_NONNULL(s1); ASSERT_NONNULL(s2); ASSERT_NOOVERLAP(s1, s2, strlen(s1) + strlen(s2)); @@ -11,7 +12,11 @@ char * strcat(char * restrict s1, const char * restrict s2) /* RETURN_ALWAYS(ARGUMENT(s1)); */ - return strncat(s1, s2, strlen(s2)); + while (s1[i] != '\0') { + i++; + } + + return strcpy(s1 + i, s2); } /*** diff --git a/src/string/strchr.c b/src/string/strchr.c index 874db9be..2ee80c9b 100644 --- a/src/string/strchr.c +++ b/src/string/strchr.c @@ -1,5 +1,5 @@ #include -#include "nonstd/assert.h" +#include "../_assert.h" /** string search **/ char * strchr(const char *s, int c) diff --git a/src/string/strcmp.c b/src/string/strcmp.c index ed089c77..fdceeb67 100644 --- a/src/string/strcmp.c +++ b/src/string/strcmp.c @@ -1,5 +1,5 @@ #include -#include "nonstd/assert.h" +#include "../_assert.h" /** compare strings **/ int strcmp(const char *s1, const char *s2) diff --git a/src/string/strcoll.c b/src/string/strcoll.c index 8707ba73..afdf868e 100644 --- a/src/string/strcoll.c +++ b/src/string/strcoll.c @@ -1,6 +1,6 @@ #include #include "stdlib.h" -#include "nonstd/assert.h" +#include "../_assert.h" /** collate strings **/ int strcoll(const char *s1, const char *s2) diff --git a/src/string/strcpy.c b/src/string/strcpy.c index cf4eeb21..915701d9 100644 --- a/src/string/strcpy.c +++ b/src/string/strcpy.c @@ -1,5 +1,5 @@ #include -#include "nonstd/assert.h" +#include "../_assert.h" /** copy string **/ char * strcpy(char * restrict s1, const char * restrict s2) diff --git a/src/string/strcspn.c b/src/string/strcspn.c index 4bbdee2e..5ae42e04 100644 --- a/src/string/strcspn.c +++ b/src/string/strcspn.c @@ -1,5 +1,5 @@ #include -#include "nonstd/assert.h" +#include "../_assert.h" /** count non-matching characters **/ size_t strcspn(const char *s1, const char *s2) diff --git a/src/string/strlen.c b/src/string/strlen.c index 89ccbfcc..3405b252 100644 --- a/src/string/strlen.c +++ b/src/string/strlen.c @@ -1,5 +1,5 @@ #include -#include "nonstd/assert.h" +#include "../_assert.h" /** find string length **/ size_t strlen(const char *s) diff --git a/src/string/strncat.c b/src/string/strncat.c index 34800069..17ed6b40 100644 --- a/src/string/strncat.c +++ b/src/string/strncat.c @@ -1,5 +1,5 @@ #include -#include "nonstd/assert.h" +#include "../_assert.h" /** concatenate bounded string **/ char * strncat(char * restrict s1, const char * restrict s2, size_t n) diff --git a/src/string/strncmp.c b/src/string/strncmp.c index 23c8104e..f5647d33 100644 --- a/src/string/strncmp.c +++ b/src/string/strncmp.c @@ -1,5 +1,5 @@ #include -#include "nonstd/assert.h" +#include "../_assert.h" /** compare bound strings **/ int strncmp(const char *s1, const char *s2, size_t n) diff --git a/src/string/strncpy.c b/src/string/strncpy.c index ee632d69..290d36c3 100644 --- a/src/string/strncpy.c +++ b/src/string/strncpy.c @@ -1,5 +1,5 @@ #include -#include "nonstd/assert.h" +#include "../_assert.h" /** copy bounded string **/ char * strncpy(char * restrict s1, const char * restrict s2, size_t n) diff --git a/src/string/strpbrk.c b/src/string/strpbrk.c index 0b88b999..e5dfc52d 100644 --- a/src/string/strpbrk.c +++ b/src/string/strpbrk.c @@ -1,5 +1,5 @@ #include -#include "nonstd/assert.h" +#include "../_assert.h" /** count matching characters **/ char * strpbrk(const char *s1, const char *s2) diff --git a/src/string/strrchr.c b/src/string/strrchr.c index 0427aa66..fe40c5db 100644 --- a/src/string/strrchr.c +++ b/src/string/strrchr.c @@ -1,5 +1,5 @@ #include -#include "nonstd/assert.h" +#include "../_assert.h" /** search string from end **/ char * strrchr(const char *s, int c) diff --git a/src/string/strspn.c b/src/string/strspn.c index e67461a5..677d43c2 100644 --- a/src/string/strspn.c +++ b/src/string/strspn.c @@ -1,5 +1,5 @@ #include -#include "nonstd/assert.h" +#include "../_assert.h" /** count matching characters **/ size_t strspn(const char *s1, const char *s2) diff --git a/src/string/strstr.c b/src/string/strstr.c index 898db1be..7aaad5ad 100644 --- a/src/string/strstr.c +++ b/src/string/strstr.c @@ -1,5 +1,5 @@ #include -#include "nonstd/assert.h" +#include "../_assert.h" /** search for substring **/ char * strstr(const char *s1, const char *s2) diff --git a/src/string/strtok.c b/src/string/strtok.c index ed44e9f2..b4d77305 100644 --- a/src/string/strtok.c +++ b/src/string/strtok.c @@ -1,5 +1,5 @@ #include -#include "nonstd/assert.h" +#include "../_assert.h" /** split string into tokens **/ char * strtok(char * restrict s1, const char * restrict s2) diff --git a/src/string/strxfrm.c b/src/string/strxfrm.c index b6ec62b6..4c640a26 100644 --- a/src/string/strxfrm.c +++ b/src/string/strxfrm.c @@ -1,5 +1,5 @@ #include -#include "nonstd/assert.h" +#include "../_assert.h" /** transform string **/ size_t strxfrm(char * restrict s1, const char * restrict s2, size_t n) diff --git a/src/sys/stat/stat.c b/src/sys/stat/stat.c index c5079295..2c2d02d2 100644 --- a/src/sys/stat/stat.c +++ b/src/sys/stat/stat.c @@ -1,7 +1,7 @@ #include "sys/types.h" #include #include "stdlib.h" -#include "nonstd/assert.h" +#include "../../_assert.h" int stat(const char * restrict path, struct stat * restrict buf) { diff --git a/src/sys/utsname/uname.c b/src/sys/utsname/uname.c index 50b53e11..e5a4b83e 100644 --- a/src/sys/utsname/uname.c +++ b/src/sys/utsname/uname.c @@ -1,6 +1,6 @@ #include #include "string.h" -#include "nonstd/assert.h" +#include "../../_assert.h" # define __PLATFORM__ "x86" diff --git a/src/termios/cfgetispeed.c b/src/termios/cfgetispeed.c index d7fd9aa1..6ba31775 100644 --- a/src/termios/cfgetispeed.c +++ b/src/termios/cfgetispeed.c @@ -1,5 +1,5 @@ #include -#include "nonstd/assert.h" +#include "../_assert.h" speed_t cfgetispeed(const struct termios *termios_p) { diff --git a/src/termios/cfgetospeed.c b/src/termios/cfgetospeed.c index 870f6b35..7ccab1f2 100644 --- a/src/termios/cfgetospeed.c +++ b/src/termios/cfgetospeed.c @@ -1,5 +1,5 @@ #include -#include "nonstd/assert.h" +#include "../_assert.h" speed_t cfgetospeed(const struct termios *termios_p) { diff --git a/src/termios/cfsetispeed.c b/src/termios/cfsetispeed.c index f2452171..3fbf0836 100644 --- a/src/termios/cfsetispeed.c +++ b/src/termios/cfsetispeed.c @@ -1,6 +1,6 @@ #include #include "errno.h" -#include "nonstd/assert.h" +#include "../_assert.h" int cfsetispeed(struct termios *termios_p, speed_t speed) { diff --git a/src/termios/cfsetospeed.c b/src/termios/cfsetospeed.c index af99a0bb..62558b08 100644 --- a/src/termios/cfsetospeed.c +++ b/src/termios/cfsetospeed.c @@ -1,6 +1,6 @@ #include #include "errno.h" -#include "nonstd/assert.h" +#include "../_assert.h" int cfsetospeed(struct termios *termios_p, speed_t speed) { diff --git a/src/time/gmtime.c b/src/time/gmtime.c index a844d097..a193fb99 100644 --- a/src/time/gmtime.c +++ b/src/time/gmtime.c @@ -1,5 +1,5 @@ #include -#include "nonstd/assert.h" +#include "../_assert.h" # define SEC_PER_MIN (60L) # define MIN_PER_HR (60L) diff --git a/src/time/localtime.c b/src/time/localtime.c index b09f84a5..80ac9bfa 100644 --- a/src/time/localtime.c +++ b/src/time/localtime.c @@ -1,5 +1,5 @@ #include -#include "nonstd/assert.h" +#include "../_assert.h" /** convert arithmetic time to broken down time **/ diff --git a/src/time/strftime.c b/src/time/strftime.c index 9d9f10e1..4d306789 100644 --- a/src/time/strftime.c +++ b/src/time/strftime.c @@ -1,8 +1,9 @@ #include #include "stdio.h" -#include "nonstd/assert.h" +#include "../_assert.h" #include "locale.h" -#include "nonstd/locale.h" +#include "../locale/_locale.h" +#include "../_nonstd.h" /** convert time to a formatted string **/ diff --git a/src/unistd/confstr.c b/src/unistd/confstr.c index 0cf00319..c6fd1523 100644 --- a/src/unistd/confstr.c +++ b/src/unistd/confstr.c @@ -2,7 +2,7 @@ #include #include "errno.h" #include "string.h" -#include "nonstd/assert.h" +#include "../_assert.h" size_t confstr(int name, char *buf, size_t len) { diff --git a/src/unistd/getcwd.c b/src/unistd/getcwd.c index 7a37a7c2..61f9c573 100644 --- a/src/unistd/getcwd.c +++ b/src/unistd/getcwd.c @@ -1,6 +1,6 @@ #include "sys/types.h" #include -#include "nonstd/assert.h" +#include "../_assert.h" #include "../_syscall.h" char * getcwd(char *buf, size_t size) diff --git a/src/unistd/getgroups.c b/src/unistd/getgroups.c index b7df2896..5e7b3ff5 100644 --- a/src/unistd/getgroups.c +++ b/src/unistd/getgroups.c @@ -3,7 +3,7 @@ #include #include "errno.h" #include "../_syscall.h" -#include "nonstd/assert.h" +#include "../_assert.h" int getgroups(int gidsetsize, gid_t grouplist[]) { diff --git a/src/unistd/pipe.c b/src/unistd/pipe.c index 26e97dea..394b1846 100644 --- a/src/unistd/pipe.c +++ b/src/unistd/pipe.c @@ -1,7 +1,7 @@ #include "stddef.h" #include "sys/types.h" #include -#include "nonstd/assert.h" +#include "../_assert.h" #include "../_syscall.h" int pipe(int fildes[2]) diff --git a/src/unistd/unlink.c b/src/unistd/unlink.c index f658872d..0ce396bf 100644 --- a/src/unistd/unlink.c +++ b/src/unistd/unlink.c @@ -1,7 +1,7 @@ #include "stddef.h" #include "sys/types.h" #include -#include "nonstd/assert.h" +#include "../_assert.h" #include "../_syscall.h" int unlink(const char *path) diff --git a/src/unistd/write.c b/src/unistd/write.c index 6982a359..a58bdc78 100644 --- a/src/unistd/write.c +++ b/src/unistd/write.c @@ -1,7 +1,7 @@ #include "stddef.h" #include "sys/types.h" #include -#include "nonstd/assert.h" +#include "../_assert.h" #include "../_syscall.h" ssize_t write(int fildes, const void *buf, size_t nbyte) diff --git a/src/wchar/fgetwc.c b/src/wchar/fgetwc.c index e5bedd04..8d725b6e 100644 --- a/src/wchar/fgetwc.c +++ b/src/wchar/fgetwc.c @@ -5,7 +5,6 @@ #if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 199506L #include "../unistd/read.c" -#include "../stdio/getc_unlocked.c" #endif wint_t fgetwc(FILE * stream) diff --git a/src/wchar/fgetws.c b/src/wchar/fgetws.c index 5262a79d..40d41cec 100644 --- a/src/wchar/fgetws.c +++ b/src/wchar/fgetws.c @@ -1,6 +1,6 @@ #include #include "stdio.h" -#include "nonstd/assert.h" +#include "../_assert.h" wchar_t * fgetws(wchar_t * restrict s, int n, FILE * restrict stream) { diff --git a/src/wchar/fwide.c b/src/wchar/fwide.c index 13c4d5f0..17da898b 100644 --- a/src/wchar/fwide.c +++ b/src/wchar/fwide.c @@ -1,7 +1,7 @@ #include #include "stdio.h" #include "../stdio/_stdio.h" -#include "nonstd/assert.h" +#include "../_assert.h" int fwide(FILE * stream, int mode) { diff --git a/src/wchar/wcscmp.c b/src/wchar/wcscmp.c index d07d9a10..67ef7432 100644 --- a/src/wchar/wcscmp.c +++ b/src/wchar/wcscmp.c @@ -1,5 +1,5 @@ #include -#include "nonstd/assert.h" +#include "../_assert.h" int wcscmp(const wchar_t * s1, const wchar_t * s2) { diff --git a/src/wchar/wcscspn.c b/src/wchar/wcscspn.c index 0c300a4a..1c4f5cf2 100644 --- a/src/wchar/wcscspn.c +++ b/src/wchar/wcscspn.c @@ -1,5 +1,5 @@ #include -#include "nonstd/assert.h" +#include "../_assert.h" size_t wcscspn(const wchar_t * s1, const wchar_t * s2) { diff --git a/src/wchar/wcsncmp.c b/src/wchar/wcsncmp.c index d41899f4..06edf836 100644 --- a/src/wchar/wcsncmp.c +++ b/src/wchar/wcsncmp.c @@ -1,5 +1,5 @@ #include -#include "nonstd/assert.h" +#include "../_assert.h" int wcsncmp(const wchar_t * s1, const wchar_t * s2, size_t n) { diff --git a/src/wchar/wmemchr.c b/src/wchar/wmemchr.c index b6d9ac7b..28ad085d 100644 --- a/src/wchar/wmemchr.c +++ b/src/wchar/wmemchr.c @@ -1,5 +1,5 @@ #include -#include "nonstd/assert.h" +#include "../_assert.h" wchar_t * wmemchr(const wchar_t * s, wchar_t c, size_t n) { diff --git a/src/wchar/wmemmove.c b/src/wchar/wmemmove.c index 75b58f87..7667e3c4 100644 --- a/src/wchar/wmemmove.c +++ b/src/wchar/wmemmove.c @@ -1,6 +1,6 @@ #include #include "stdlib.h" -#include "nonstd/assert.h" +#include "../_assert.h" wchar_t * wmemmove(wchar_t * s1, const wchar_t * s2, size_t n) { diff --git a/src/wctype/iswalnum.c b/src/wctype/iswalnum.c index dafc242e..42f0df4a 100644 --- a/src/wctype/iswalnum.c +++ b/src/wctype/iswalnum.c @@ -1,6 +1,6 @@ #include #include "limits.h" -#include "nonstd/assert.h" +#include "../_assert.h" #include "wchar.h" /** test whether a wide character is alphanumeric **/ diff --git a/src/wctype/iswalpha.c b/src/wctype/iswalpha.c index 6fcc275f..0d3e6d57 100644 --- a/src/wctype/iswalpha.c +++ b/src/wctype/iswalpha.c @@ -1,6 +1,6 @@ #include #include "wchar.h" -#include "nonstd/assert.h" +#include "../_assert.h" /** test whether a wide character is alphabetic **/ int iswalpha(wint_t wc) diff --git a/src/wctype/iswblank.c b/src/wctype/iswblank.c index b6a44d3c..753f9b41 100644 --- a/src/wctype/iswblank.c +++ b/src/wctype/iswblank.c @@ -1,5 +1,5 @@ #include -#include "nonstd/assert.h" +#include "../_assert.h" /** test whether a wide character is blank **/ int iswblank(wint_t wc) diff --git a/src/wctype/iswcntrl.c b/src/wctype/iswcntrl.c index 7859148a..acec5785 100644 --- a/src/wctype/iswcntrl.c +++ b/src/wctype/iswcntrl.c @@ -1,6 +1,6 @@ #include #include "wchar.h" -#include "nonstd/assert.h" +#include "../_assert.h" /** test whether a wide character is a control character */ int iswcntrl(wint_t wc) diff --git a/src/wctype/iswctype.c b/src/wctype/iswctype.c index fd24051a..db05e919 100644 --- a/src/wctype/iswctype.c +++ b/src/wctype/iswctype.c @@ -1,6 +1,6 @@ #include #include "wchar.h" -#include "nonstd/assert.h" +#include "../_assert.h" /** test whether a wide character is part of a character class **/ int iswctype(wint_t wc, wctype_t desc) diff --git a/src/wctype/iswdigit.c b/src/wctype/iswdigit.c index 1ccdf84d..7dc13755 100644 --- a/src/wctype/iswdigit.c +++ b/src/wctype/iswdigit.c @@ -1,6 +1,6 @@ #include #include "wchar.h" -#include "nonstd/assert.h" +#include "../_assert.h" /** test whether a wide character is a digit **/ int iswdigit(wint_t wc) diff --git a/src/wctype/iswgraph.c b/src/wctype/iswgraph.c index f20ad02c..dba00813 100644 --- a/src/wctype/iswgraph.c +++ b/src/wctype/iswgraph.c @@ -1,6 +1,6 @@ #include #include "wchar.h" -#include "nonstd/assert.h" +#include "../_assert.h" /** test whether a wide character is graphic **/ int iswgraph(wint_t wc) diff --git a/src/wctype/iswlower.c b/src/wctype/iswlower.c index 739c36e8..5bd19e2e 100644 --- a/src/wctype/iswlower.c +++ b/src/wctype/iswlower.c @@ -1,6 +1,6 @@ #include #include "wchar.h" -#include "nonstd/assert.h" +#include "../_assert.h" /** test whether a character is a lowercase letter **/ int iswlower(wint_t wc) diff --git a/src/wctype/iswprint.c b/src/wctype/iswprint.c index 11bf9033..51730c5e 100644 --- a/src/wctype/iswprint.c +++ b/src/wctype/iswprint.c @@ -1,6 +1,6 @@ #include #include "wchar.h" -#include "nonstd/assert.h" +#include "../_assert.h" /** test whether a wide character is printable **/ int iswprint(wint_t wc) diff --git a/src/wctype/iswpunct.c b/src/wctype/iswpunct.c index 5ffdbe85..5896f8bb 100644 --- a/src/wctype/iswpunct.c +++ b/src/wctype/iswpunct.c @@ -1,6 +1,6 @@ #include #include "wchar.h" -#include "nonstd/assert.h" +#include "../_assert.h" /** test whether a wide character is punctuation **/ int iswpunct(wint_t wc) diff --git a/src/wctype/iswspace.c b/src/wctype/iswspace.c index 60bf723a..feb22b5e 100644 --- a/src/wctype/iswspace.c +++ b/src/wctype/iswspace.c @@ -1,6 +1,6 @@ #include #include "wchar.h" -#include "nonstd/assert.h" +#include "../_assert.h" /** test whether a wide character is white-space **/ int iswspace(wint_t wc) diff --git a/src/wctype/iswupper.c b/src/wctype/iswupper.c index 27fe2359..b56e4214 100644 --- a/src/wctype/iswupper.c +++ b/src/wctype/iswupper.c @@ -1,6 +1,6 @@ #include #include "wchar.h" -#include "nonstd/assert.h" +#include "../_assert.h" /** test whether a wide character is an uppercase letter **/ int iswupper(wint_t wc) diff --git a/src/wctype/iswxdigit.c b/src/wctype/iswxdigit.c index b544b285..2b255a40 100644 --- a/src/wctype/iswxdigit.c +++ b/src/wctype/iswxdigit.c @@ -1,6 +1,6 @@ #include #include "wchar.h" -#include "nonstd/assert.h" +#include "../_assert.h" /** test whether a wide character is a hexadecimal digit **/ int iswxdigit(wint_t wc) diff --git a/src/wctype/towctrans.c b/src/wctype/towctrans.c index 9ea0c8a6..0b083cad 100644 --- a/src/wctype/towctrans.c +++ b/src/wctype/towctrans.c @@ -1,6 +1,6 @@ #include #include "wchar.h" -#include "nonstd/assert.h" +#include "../_assert.h" wint_t towctrans(wint_t wc, wctrans_t desc) { diff --git a/src/wctype/towlower.c b/src/wctype/towlower.c index 8e5254d8..fe0c632e 100644 --- a/src/wctype/towlower.c +++ b/src/wctype/towlower.c @@ -1,7 +1,7 @@ #include #include "wchar.h" #include "stdlib.h" -#include "nonstd/assert.h" +#include "../_assert.h" /** convert a wide uppercase letter to lowercase **/ wint_t towlower(wint_t wc) diff --git a/src/wctype/towupper.c b/src/wctype/towupper.c index 1310e109..0f1a40be 100644 --- a/src/wctype/towupper.c +++ b/src/wctype/towupper.c @@ -1,6 +1,6 @@ #include #include "wchar.h" -#include "nonstd/assert.h" +#include "../_assert.h" /** convert a wide lowercase letter to uppercase **/ wint_t towupper(wint_t wc) diff --git a/src/wctype/wctrans.c b/src/wctype/wctrans.c index fac15545..4380467e 100644 --- a/src/wctype/wctrans.c +++ b/src/wctype/wctrans.c @@ -1,6 +1,6 @@ #include #include "string.h" -#include "nonstd/assert.h" +#include "../_assert.h" #include "_wctype.h" /** lookup character translation **/ diff --git a/src/wctype/wctype.c b/src/wctype/wctype.c index 96e5dd1b..c2ec3460 100644 --- a/src/wctype/wctype.c +++ b/src/wctype/wctype.c @@ -1,6 +1,6 @@ #include #include "string.h" -#include "nonstd/assert.h" +#include "../_assert.h" #include "_wctype.h" /** lookup character class **/ -- cgit v1.2.1