diff options
| author | Baptiste Daroussin <bapt@FreeBSD.org> | 2026-01-14 13:37:49 +0100 |
|---|---|---|
| committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2026-01-14 13:37:49 +0100 |
| commit | c5a1e08b52b2f6c05e0116d46277904b711b6bdb (patch) | |
| tree | a6ad7350d1b1100356ca59616d22c51dd29743eb /progs/tabs.c | |
| parent | 24fa7a5107c5b75d1c197accf0305be64bc72882 (diff) | |
Vendor import ncurses 6.6vendor/ncurses/6.6vendor/ncurses
Diffstat (limited to 'progs/tabs.c')
| -rw-r--r-- | progs/tabs.c | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/progs/tabs.c b/progs/tabs.c index a630b044e0cc..1716e2b44afc 100644 --- a/progs/tabs.c +++ b/progs/tabs.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020-2022,2023 Thomas E. Dickey * + * Copyright 2020-2023,2024 Thomas E. Dickey * * Copyright 2008-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -39,7 +39,7 @@ #include <progs.priv.h> #include <tty_settings.h> -MODULE_ID("$Id: tabs.c,v 1.53 2023/11/04 20:46:09 tom Exp $") +MODULE_ID("$Id: tabs.c,v 1.56 2024/12/07 22:10:45 tom Exp $") static GCC_NORETURN void usage(void); @@ -78,7 +78,7 @@ ansi_clear_tabs(void) { bool result = FALSE; if (VALID_STRING(clear_all_tabs)) { - char *param = skip_csi(clear_all_tabs); + const char *param = skip_csi(clear_all_tabs); if (!strcmp(param, "3g")) result = TRUE; } @@ -86,7 +86,7 @@ ansi_clear_tabs(void) } static void -do_tabs(int *tab_list) +do_tabs(const int *tab_list) { int last = 1; int stop; @@ -147,7 +147,7 @@ decode_tabs(const char *tab_list, int margin) "%s: tab-stops are not in increasing order: %d %d\n", _nc_progname, value, result[n - 1]); free(result); - result = 0; + result = NULL; break; } ++n; @@ -159,7 +159,7 @@ decode_tabs(const char *tab_list, int margin) } } - if (result != 0) { + if (result != NULL) { /* * If there is only one value, then it is an option such as "-8". */ @@ -229,7 +229,7 @@ print_ruler(const int *const tab_list, const char *new_line) * ruler. */ static void -write_tabs(int *tab_list, const char *new_line) +write_tabs(const int *tab_list, const char *new_line) { int stop; @@ -250,7 +250,7 @@ static char * trimmed_tab_list(const char *source) { char *result = strdup(source); - if (result != 0) { + if (result != NULL) { int j, k, last; for (j = k = last = 0; result[j] != 0; ++j) { @@ -280,7 +280,7 @@ comma_is_needed(const char *source) { bool result = FALSE; - if (source != 0) { + if (source != NULL) { size_t len = strlen(source); if (len != 0) result = (source[len - 1] != ','); @@ -303,7 +303,7 @@ add_to_tab_list(char **append, const char *value) char *result = *append; char *copied = trimmed_tab_list(value); - if (copied != 0 && *copied != '\0') { + if (copied != NULL && *copied != '\0') { const char *comma = ","; size_t need = 1 + strlen(copied); @@ -313,15 +313,15 @@ add_to_tab_list(char **append, const char *value) comma = ""; need += strlen(comma); - if (*append != 0) + if (*append != NULL) need += strlen(*append); result = malloc(need); - if (result == 0) + if (result == NULL) failed("add_to_tab_list"); *result = '\0'; - if (*append != 0) { + if (*append != NULL) { _nc_STRCPY(result, *append, need); free(*append); } @@ -402,7 +402,7 @@ legal_tab_list(const char *tab_list) { bool result = TRUE; - if (tab_list != 0 && *tab_list != '\0') { + if (tab_list != NULL && *tab_list != '\0') { if (comma_is_needed(tab_list)) { int n; @@ -433,7 +433,7 @@ skip_list(char *value) while (*value != '\0' && (isdigit(UChar(*value)) || isspace(UChar(*value)) || - strchr("+,", UChar(*value)) != 0)) { + strchr("+,", UChar(*value)) != NULL)) { ++value; } return value; @@ -445,7 +445,6 @@ usage(void) #define DATA(s) s "\n" static const char msg[] = { - DATA("Usage: tabs [options] [tabstop-list]") DATA("") DATA("Options:") DATA(" -0 reset tabs") @@ -468,9 +467,11 @@ usage(void) DATA("or 1,+10,+10 which is the same.") }; #undef DATA + FILE *fp = stderr; fflush(stdout); - fputs(msg, stderr); + fprintf(fp, "Usage: %s [options] [tabstop-list]\n", _nc_progname); + fputs(msg, fp); ExitProgram(EXIT_FAILURE); } @@ -482,9 +483,9 @@ main(int argc, char *argv[]) bool no_op = FALSE; bool change_tty = FALSE; int n, ch; - NCURSES_CONST char *term_name = 0; - char *append = 0; - const char *tab_list = 0; + NCURSES_CONST char *term_name = NULL; + char *append = NULL; + const char *tab_list = NULL; const char *new_line = "\n"; int margin = -1; TTY tty_settings; @@ -492,7 +493,7 @@ main(int argc, char *argv[]) _nc_progname = _nc_rootname(argv[0]); - if ((term_name = getenv("TERM")) == 0) + if ((term_name = getenv("TERM")) == NULL) term_name = "ansi+tabs"; /* cannot use getopt, since some options are two-character */ @@ -616,11 +617,11 @@ main(int argc, char *argv[]) } break; default: - if (append != 0) { + if (append != NULL) { if (tab_list != (const char *) append) { /* one of the predefined options was used */ free(append); - append = 0; + append = NULL; } } tab_list = add_to_tab_list(&append, option); @@ -682,7 +683,7 @@ main(int argc, char *argv[]) list = decode_tabs(tab_list, margin); - if (list != 0) { + if (list != NULL) { if (!no_op) do_tabs(list); if (debug) { @@ -703,7 +704,7 @@ main(int argc, char *argv[]) } rc = EXIT_SUCCESS; } - if (append != 0) + if (append != NULL) free(append); ExitProgram(rc); } |
