diff options
| author | Sean Kurtz <seankurtz75@gmail.com> | 2026-11-25 00:30:44 -0600 |
|---|---|---|
| committer | Sean Kurtz <seankurtz75@gmail.com> | 2026-11-25 00:30:44 -0600 |
| commit | 5f92e02ff71be19067a422d324beb610cacd084d (patch) | |
| tree | 1af510b0e4b9e3de95b18f476a6ebff2f109c488 /src/builtin.c | |
| parent | 7a7320b6a0d7dd6864b708b7e74fb5032a5bdf8e (diff) | |
| download | zash-chore/c23-nullptr-constexpr.tar.gz | |
C23: nullptr for null pointers, constexpr for typed constantschore/c23-nullptr-constexpr
nullptr in every place a null pointer constant was meant; NULL is gone
from src/.
constexpr where it improves on #define without costing anything: the
IGGCSI00 work-area offsets and sizes, and the scalar sizes MVS_DSN_MAX,
CSI_FIELD_LEN, CSI_WORK_MIN, PDS_DIRBLK, CSI_WORK, CSI_MAX_CALLS. A
constexpr in C is a constant expression, so it still bounds the arrays
that use it, and it now carries a type and can be checked with
static_assert. Feature switches (#if), the CSIETYPE/EBCDIC byte
constants read as octets, and the related-constant enum sets stay as
they were.
Diffstat (limited to 'src/builtin.c')
| -rw-r--r-- | src/builtin.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/builtin.c b/src/builtin.c index bf20c8e..8497a0d 100644 --- a/src/builtin.c +++ b/src/builtin.c @@ -345,7 +345,7 @@ static int b_shift(int argc, char **argv) { * signal arrived. */ static int b_read(int argc, char **argv) { - static char *default_vars[] = {"REPLY", NULL}; + static char *default_vars[] = {"REPLY", nullptr}; bool raw = false; double timeout = -1; /* seconds; negative: wait for ever */ int i = 1; @@ -374,7 +374,7 @@ static int b_read(int argc, char **argv) { } struct timeval deadline = {0}; if (timeout >= 0) { - gettimeofday(&deadline, NULL); + gettimeofday(&deadline, nullptr); deadline.tv_sec += (time_t)timeout; deadline.tv_usec += (suseconds_t)((timeout - (double)(time_t)timeout) * 1e6); @@ -422,7 +422,7 @@ static int b_read(int argc, char **argv) { if (timeout >= 0) { /* -t: give up (status > 128) if no input arrives in time. */ struct timeval now; - gettimeofday(&now, NULL); + gettimeofday(&now, nullptr); long ms = (long)(deadline.tv_sec - now.tv_sec) * 1000 + (long)(deadline.tv_usec - now.tv_usec) / 1000; struct pollfd pfd = {.fd = 0, .events = POLLIN}; @@ -556,7 +556,7 @@ static int b_getopts(int argc, char **argv) { if (v && (!parse_long(v, &ind) || ind < 1)) ind = 1; - const char *arg = ind <= nargs ? args[ind - 1] : NULL; + const char *arg = ind <= nargs ? args[ind - 1] : nullptr; if (getopts_off && (!arg || getopts_off >= strlen(arg))) getopts_off = 0; /* the arguments changed under us: start afresh */ if (getopts_off == 0) { @@ -576,8 +576,8 @@ static int b_getopts(int argc, char **argv) { char c = arg[getopts_off++]; char opt_name[2] = {c, '\0'}; const char *result = opt_name; - const char *optval = NULL; - const char *spec = c == ':' ? NULL : strchr(optstring, c); + const char *optval = nullptr; + const char *spec = c == ':' ? nullptr : strchr(optstring, c); bool took_arg = false; if (!spec) { @@ -705,7 +705,7 @@ static bool is_directory(const char *path) { * @param dest The directory asked for. * @param print Set if the result came from a non-empty CDPATH entry, in * which case `cd` prints where it went. - * @return The path to use, or NULL if CDPATH has no match. + * @return The path to use, or nullptr if CDPATH has no match. */ static const char *cdpath_search(const char *dest, bool *print) { const char *cdpath = var_get("CDPATH"); @@ -827,8 +827,8 @@ static bool is_keyword(const char *s) { */ int describe_command(const char *name, bool verbose) { cmdinfo ci; - const char *what = NULL; - const alias *al = alias_count ? alias_find(name) : NULL; + const char *what = nullptr; + const alias *al = alias_count ? alias_find(name) : nullptr; if (al) { if (verbose) { out_printf(&out1, "%s is an alias for %s\n", name, al->value); |
