Convert spaces to tabs in watch.c

This commit is contained in:
Nipunn Koorapati 2020-07-13 03:24:53 +00:00 committed by Craig Small
parent 9c4ad4c419
commit 5d155068ce

50
watch.c
View File

@ -83,7 +83,7 @@ static int line_wrap = 1;
#define MAX_ANSIBUF 100 #define MAX_ANSIBUF 100
static void __attribute__ ((__noreturn__)) static void __attribute__ ((__noreturn__))
usage(FILE * out) usage(FILE * out)
{ {
fputs(USAGE_HEADER, out); fputs(USAGE_HEADER, out);
fprintf(out, fprintf(out,
@ -185,12 +185,12 @@ static int set_ansi_attribute(const int attrib)
case 27: /* unset inversed */ case 27: /* unset inversed */
attributes &= ~A_REVERSE; attributes &= ~A_REVERSE;
break; break;
case 39: case 39:
fg_col = 0; fg_col = 0;
break; break;
case 49: case 49:
bg_col = 0; bg_col = 0;
break; break;
default: default:
if (attrib >= 30 && attrib <= 37) { /* set foreground color */ if (attrib >= 30 && attrib <= 37) { /* set foreground color */
fg_col = attrib - 30 + 1; fg_col = attrib - 30 + 1;
@ -201,7 +201,7 @@ static int set_ansi_attribute(const int attrib)
} }
} }
attrset(attributes | COLOR_PAIR(bg_col * nr_of_colors + fg_col + 1)); attrset(attributes | COLOR_PAIR(bg_col * nr_of_colors + fg_col + 1));
return 1; return 1;
} }
static void process_ansi(FILE * fp) static void process_ansi(FILE * fp)
@ -235,14 +235,14 @@ static void process_ansi(FILE * fp)
* attributes to apply, but typically there are between 1 and 3. * attributes to apply, but typically there are between 1 and 3.
*/ */
/* Special case of <ESC>[m */ /* Special case of <ESC>[m */
if (buf[0] == '\0') if (buf[0] == '\0')
set_ansi_attribute(0); set_ansi_attribute(0);
for (endptr = numstart = buf; *endptr != '\0'; numstart = endptr + 1) { for (endptr = numstart = buf; *endptr != '\0'; numstart = endptr + 1) {
if (!set_ansi_attribute(strtol(numstart, &endptr, 10))) if (!set_ansi_attribute(strtol(numstart, &endptr, 10)))
break; break;
} }
} }
static void __attribute__ ((__noreturn__)) do_exit(int status) static void __attribute__ ((__noreturn__)) do_exit(int status)
@ -379,7 +379,7 @@ static void output_header(char *restrict command, double interval)
char *ts = ctime(&t); char *ts = ctime(&t);
char *header; char *header;
char *right_header; char *right_header;
int max_host_name_len = (int) sysconf(_SC_HOST_NAME_MAX); int max_host_name_len = (int) sysconf(_SC_HOST_NAME_MAX);
char hostname[max_host_name_len + 1]; char hostname[max_host_name_len + 1];
int command_columns = 0; /* not including final \0 */ int command_columns = 0; /* not including final \0 */
@ -415,7 +415,7 @@ static void output_header(char *restrict command, double interval)
mvaddstr(0, width - rhlen - 4, "... "); mvaddstr(0, width - rhlen - 4, "... ");
} else { } else {
#ifdef WITH_WATCH8BIT #ifdef WITH_WATCH8BIT
command_columns = wcswidth(wcommand, -1); command_columns = wcswidth(wcommand, -1);
if (width < rhlen + hlen + command_columns) { if (width < rhlen + hlen + command_columns) {
/* print truncated */ /* print truncated */
int available = width - rhlen - hlen; int available = width - rhlen - hlen;
@ -431,14 +431,14 @@ static void output_header(char *restrict command, double interval)
mvaddwstr(0, hlen, wcommand); mvaddwstr(0, hlen, wcommand);
} }
#else #else
command_columns = strlen(command); command_columns = strlen(command);
if (width < rhlen + hlen + command_columns) { if (width < rhlen + hlen + command_columns) {
/* print truncated */ /* print truncated */
mvaddnstr(0, hlen, command, width - rhlen - hlen - 4); mvaddnstr(0, hlen, command, width - rhlen - hlen - 4);
mvaddstr(0, width - rhlen - 4, "... "); mvaddstr(0, width - rhlen - 4, "... ");
} else { } else {
mvaddnstr(0, hlen, command, width - rhlen - hlen); mvaddnstr(0, hlen, command, width - rhlen - hlen);
} }
#endif /* WITH_WATCH8BIT */ #endif /* WITH_WATCH8BIT */
} }
} }