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_ext.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_ext.c')
| -rw-r--r-- | src/builtin_ext.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/builtin_ext.c b/src/builtin_ext.c index 9b0ee9c..f693552 100644 --- a/src/builtin_ext.c +++ b/src/builtin_ext.c @@ -144,7 +144,7 @@ int builtin_whence(int argc, char **argv) { } const char *path = var_get("PATH"); const char *full = strchr(argv[i], '/') - ? (access(argv[i], X_OK) == 0 ? argv[i] : NULL) + ? (access(argv[i], X_OK) == 0 ? argv[i] : nullptr) : path_search(argv[i], path ? path : "", true); if (full) out_printf(&out1, "%s\n", full); @@ -278,7 +278,7 @@ typedef struct limit { char opt; /**< Option letter. */ int resource; /**< RLIMIT_* value. */ const char *name; /**< Description for `ulimit -a`. */ - const char *unit; /**< Unit name for `ulimit -a`, or NULL. */ + const char *unit; /**< Unit name for `ulimit -a`, or nullptr. */ unsigned scale; /**< Bytes (or items) per unit shown to the user. */ } limit; @@ -297,7 +297,7 @@ static const limit limits[] = { {'m', RLIMIT_RSS, "max memory size", "kbytes", 1024}, #endif #ifdef RLIMIT_NOFILE - {'n', RLIMIT_NOFILE, "open files", NULL, 1}, + {'n', RLIMIT_NOFILE, "open files", nullptr, 1}, #endif #ifdef RLIMIT_STACK {'s', RLIMIT_STACK, "stack size", "kbytes", 1024}, @@ -306,7 +306,7 @@ static const limit limits[] = { {'t', RLIMIT_CPU, "cpu time", "seconds", 1}, #endif #ifdef RLIMIT_NPROC - {'u', RLIMIT_NPROC, "max user processes", NULL, 1}, + {'u', RLIMIT_NPROC, "max user processes", nullptr, 1}, #endif #ifdef RLIMIT_AS {'v', RLIMIT_AS, "virtual memory", "kbytes", 1024}, @@ -349,7 +349,7 @@ int builtin_ulimit(int argc, char **argv) { bool hard = false; bool soft = false; bool all = false; - const limit *l = NULL; + const limit *l = nullptr; int i = 1; for (; i < argc && argv[i][0] == '-' && argv[i][1]; i++) { for (const char *p = argv[i] + 1; *p; p++) { @@ -360,7 +360,7 @@ int builtin_ulimit(int argc, char **argv) { } else if (*p == 'a') { all = true; } else { - const limit *found = NULL; + const limit *found = nullptr; for (size_t k = 0; k < ARRAY_LEN(limits); k++) { if (limits[k].opt == *p) found = &limits[k]; @@ -476,7 +476,7 @@ static int tag_print(const char *path) { */ int builtin_tag(int argc, char **argv) { char mode = 'p'; - const char *codeset = NULL; + const char *codeset = nullptr; int i = 1; for (; i < argc && argv[i][0] == '-' && argv[i][1]; i++) { if (!strcmp(argv[i], "--")) { @@ -487,7 +487,7 @@ int builtin_tag(int argc, char **argv) { if (strchr("ptmbr", *p)) { mode = *p; } else if (*p == 'c') { - codeset = p[1] ? p + 1 : (i + 1 < argc ? argv[++i] : NULL); + codeset = p[1] ? p + 1 : (i + 1 < argc ? argv[++i] : nullptr); if (!codeset) { sh_warn("tag: -c: code set required"); return 2; @@ -510,7 +510,7 @@ int builtin_tag(int argc, char **argv) { status |= tag_print(argv[i]); continue; } - int rc = mode == 'r' ? sys_tag_set(argv[i], NULL, 0) + int rc = mode == 'r' ? sys_tag_set(argv[i], nullptr, 0) : mode == 'b' ? sys_tag_set(argv[i], "BINARY", 0) : sys_tag_set(argv[i], codeset, mode == 't'); if (rc < 0) { |
