diff options
Diffstat (limited to 'src/expand.c')
| -rw-r--r-- | src/expand.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/expand.c b/src/expand.c index 515a7b1..943d2bf 100644 --- a/src/expand.c +++ b/src/expand.c @@ -60,7 +60,7 @@ static const char empty_string[] = ""; /** * @brief Append a finished field to the argument vector. * @param x Expansion state. - * @param s The field (scratch memory), or NULL to terminate the vector. + * @param s The field (scratch memory), or nullptr to terminate the vector. */ static void field_add(expansion *x, const char *s) { if (x->argc + 1 >= x->cap) { @@ -295,7 +295,7 @@ static size_t expand_tilde(expansion *x, const char *s, size_t n, bool assign, } else { const struct passwd *pw = getpwnam(arena_strndup(&scratch, s + 1, e - 1)); - home = pw ? pw->pw_dir : NULL; + home = pw ? pw->pw_dir : nullptr; } if (!home) return 0; @@ -397,7 +397,7 @@ static void expand_all_params(expansion *x, char which, bool quoted) { * @param c The parameter character. * @param buf Work space for numbers. * @param size Size of `buf`. - * @return The value, or NULL if it is unset (`$!` before any `&`). + * @return The value, or nullptr if it is unset (`$!` before any `&`). */ static const char *special_value(char c, char *buf, size_t size) { switch (c) { @@ -410,19 +410,19 @@ static const char *special_value(char c, char *buf, size_t size) { return fmt_int(shellparam.n, buf); case '!': if (!last_bg_pid) - return NULL; + return nullptr; snprintf(buf, size, "%ld", (long)last_bg_pid); return buf; case '-': return option_letters(); default: - return NULL; + return nullptr; } } /** * @brief Current value of a parameter of any kind. - * @return The value, or NULL if the parameter is unset. + * @return The value, or nullptr if the parameter is unset. */ static const char *param_value(const param *pm, char *buf, size_t size) { switch (pm->type) { @@ -431,11 +431,11 @@ static const char *param_value(const param *pm, char *buf, size_t size) { case PT_POS: if (pm->pos == 0) return arg0; - return pm->pos <= shellparam.n ? shellparam.p[pm->pos - 1] : NULL; + return pm->pos <= shellparam.n ? shellparam.p[pm->pos - 1] : nullptr; case PT_SPECIAL: return special_value(pm->special, buf, size); } - return NULL; + return nullptr; } /** @@ -523,7 +523,7 @@ static void expand_param(expansion *x, const param *pm, bool quoted) { return; } val = shellparam.n ? join_params(pm->special == '*' ? ifs_first : ' ') - : NULL; + : nullptr; } else { val = param_value(pm, buf, sizeof buf); } @@ -668,7 +668,7 @@ static void expand_word(expansion *x, const wpart *p) { * * @param list The words. * @param argc Receives the number of fields. - * @return A NULL-terminated vector in scratch memory. + * @return A nullptr-terminated vector in scratch memory. */ char **expand_words(const word *list, int *argc) { expansion x = {.mode = X_FIELDS}; @@ -684,7 +684,7 @@ char **expand_words(const word *list, int *argc) { field_end(&x); x.sep = SEP_NONE; } - field_add(&x, NULL); + field_add(&x, nullptr); *argc = x.argc - 1; return x.argv; } @@ -731,7 +731,7 @@ char *expand_assign(const word *w) { emit_assign_lit(&x, p->u.lit.s, p->u.lit.len, false, !p->next); } else { wpart one = *p; - one.next = NULL; + one.next = nullptr; expand_parts(&x, &one); } } |
