]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - progs/tabs.c
ncurses 6.2 - patch 20210418
[ncurses.git] / progs / tabs.c
index 8a3bc108fe8dfda35b53b77cde9af50850ad7973..4a6eb2415e7c973d0ce13d7eb3f93fbfa19055d1 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 2008-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -39,9 +39,9 @@
 #include <progs.priv.h>
 #include <tty_settings.h>
 
-MODULE_ID("$Id: tabs.c,v 1.42 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: tabs.c,v 1.47 2021/04/03 23:00:00 tom Exp $")
 
-static void usage(void) GCC_NORETURN;
+static GCC_NORETURN void usage(void);
 
 const char *_nc_progname;
 static int max_cols;
@@ -75,7 +75,7 @@ do_tabs(int *tab_list)
            }
        }
        if (stop <= max_cols) {
-           tputs(tparm(set_tab, stop), 1, putch);
+           tputs(TIPARM_1(set_tab, stop), 1, putch);
            last = stop;
        } else {
            break;
@@ -146,7 +146,6 @@ static void
 print_ruler(int *tab_list)
 {
     int last = 0;
-    int stop;
     int n;
 
     /* first print a readable ruler */
@@ -164,7 +163,8 @@ print_ruler(int *tab_list)
 
     /* now, print '*' for each stop */
     for (n = 0, last = 0; (tab_list[n] > 0) && (last < max_cols); ++n) {
-       stop = tab_list[n];
+       int stop = tab_list[n];
+
        while (++last < stop) {
            if (last <= max_cols) {
                putchar('-');
@@ -210,11 +210,11 @@ static char *
 trimmed_tab_list(const char *source)
 {
     char *result = strdup(source);
-    int ch, j, k, last;
-
     if (result != 0) {
+       int j, k, last;
+
        for (j = k = last = 0; result[j] != 0; ++j) {
-           ch = UChar(result[j]);
+           int ch = UChar(result[j]);
            if (isspace(ch)) {
                if (last == '\0') {
                    continue;
@@ -304,9 +304,11 @@ legal_tab_list(const char *tab_list)
 
     if (tab_list != 0 && *tab_list != '\0') {
        if (comma_is_needed(tab_list)) {
-           int n, ch;
+           int n;
+
            for (n = 0; tab_list[n] != '\0'; ++n) {
-               ch = UChar(tab_list[n]);
+               int ch = UChar(tab_list[n]);
+
                if (!(isdigit(ch) || ch == ',' || ch == '+')) {
                    fprintf(stderr,
                            "%s: unexpected character found '%c'\n",