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/unparse.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/unparse.c')
| -rw-r--r-- | src/unparse.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/unparse.c b/src/unparse.c index d775128..6a4e9cd 100644 --- a/src/unparse.c +++ b/src/unparse.c @@ -27,7 +27,7 @@ static void put_node(strbuf *sb, const node *n); static void put_lit(strbuf *sb, const char *s, size_t len, bool quoted) { bool need = quoted && !len; for (size_t i = 0; i < len && quoted && !need; i++) - need = strchr(" \t\n;&|<>()$`\\\"'*?[#~=%", s[i]) != NULL; + need = strchr(" \t\n;&|<>()$`\\\"'*?[#~=%", s[i]) != nullptr; if (!need) { sb_put(sb, s, len); return; @@ -76,7 +76,7 @@ static void put_param(strbuf *sb, const param *pm) { /** * @brief Append the parts of one word. * @param sb Destination. - * @param p First part, or NULL. + * @param p First part, or nullptr. * @param raw The parts are an arithmetic expression: literal text is * written as is (it was never shell-quoted). */ @@ -114,7 +114,7 @@ static void put_parts(strbuf *sb, const wpart *p, bool raw) { /** * @brief Append a list of words separated by spaces. * @param sb Destination. - * @param w First word, or NULL. + * @param w First word, or nullptr. * @param first Whether nothing precedes the list on this command (no * leading space is wanted then). * @return false if anything was written, else `first` unchanged. @@ -135,7 +135,7 @@ static bool put_words(strbuf *sb, const word *w, bool first) { /** * @brief Append a command's redirections. * @param sb Destination. - * @param r First redirection, or NULL. + * @param r First redirection, or nullptr. */ static void put_redirs(strbuf *sb, const redir *r) { static const char *const ops[] = { @@ -163,7 +163,7 @@ static void put_redirs(strbuf *sb, const redir *r) { /** * @brief Append a command list that sits inside a compound command. * @param sb Destination. - * @param n The list, or NULL for an empty one. + * @param n The list, or nullptr for an empty one. */ static void put_body(strbuf *sb, const node *n) { if (n) @@ -220,7 +220,7 @@ static void put_cond(strbuf *sb, const cond *c) { /** * @brief Append the text of one command. * @param sb Destination. - * @param n The command. Must not be NULL. + * @param n The command. Must not be nullptr. */ static void put_node(strbuf *sb, const node *n) { switch (n->kind) { @@ -338,7 +338,7 @@ static void put_node(strbuf *sb, const node *n) { /** * @brief Rebuild the text of a command. - * @param n The command, or NULL. + * @param n The command, or nullptr. * @return Heap-allocated text. The caller frees it. */ char *node_text(const node *n) { |
