| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: column.c,v 1.21 2008/07/21 14:19:21 lukem Exp $ */ | | 1 | /* $NetBSD: column.c,v 1.22 2020/08/27 01:52:04 simonb Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1989, 1993, 1994 | | 4 | * Copyright (c) 1989, 1993, 1994 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -29,27 +29,27 @@ | | | @@ -29,27 +29,27 @@ |
29 | * SUCH DAMAGE. | | 29 | * SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include <sys/cdefs.h> | | 32 | #include <sys/cdefs.h> |
33 | #ifndef lint | | 33 | #ifndef lint |
34 | __COPYRIGHT("@(#) Copyright (c) 1989, 1993, 1994\ | | 34 | __COPYRIGHT("@(#) Copyright (c) 1989, 1993, 1994\ |
35 | The Regents of the University of California. All rights reserved."); | | 35 | The Regents of the University of California. All rights reserved."); |
36 | #endif /* not lint */ | | 36 | #endif /* not lint */ |
37 | | | 37 | |
38 | #ifndef lint | | 38 | #ifndef lint |
39 | #if 0 | | 39 | #if 0 |
40 | static char sccsid[] = "@(#)column.c 8.4 (Berkeley) 5/4/95"; | | 40 | static char sccsid[] = "@(#)column.c 8.4 (Berkeley) 5/4/95"; |
41 | #endif | | 41 | #endif |
42 | __RCSID("$NetBSD: column.c,v 1.21 2008/07/21 14:19:21 lukem Exp $"); | | 42 | __RCSID("$NetBSD: column.c,v 1.22 2020/08/27 01:52:04 simonb Exp $"); |
43 | #endif /* not lint */ | | 43 | #endif /* not lint */ |
44 | | | 44 | |
45 | #include <sys/types.h> | | 45 | #include <sys/types.h> |
46 | #include <sys/ioctl.h> | | 46 | #include <sys/ioctl.h> |
47 | | | 47 | |
48 | #include <ctype.h> | | 48 | #include <ctype.h> |
49 | #include <err.h> | | 49 | #include <err.h> |
50 | #include <termios.h> | | 50 | #include <termios.h> |
51 | #include <limits.h> | | 51 | #include <limits.h> |
52 | #include <stdio.h> | | 52 | #include <stdio.h> |
53 | #include <stdlib.h> | | 53 | #include <stdlib.h> |
54 | #include <string.h> | | 54 | #include <string.h> |
55 | #include <unistd.h> | | 55 | #include <unistd.h> |
| @@ -236,27 +236,27 @@ maketbl(void) | | | @@ -236,27 +236,27 @@ maketbl(void) |
236 | DEFCOLS * sizeof(*lens)); | | 236 | DEFCOLS * sizeof(*lens)); |
237 | maxcols += DEFCOLS; | | 237 | maxcols += DEFCOLS; |
238 | } | | 238 | } |
239 | t->list = ecalloc(coloff, sizeof(*(t->list))); | | 239 | t->list = ecalloc(coloff, sizeof(*(t->list))); |
240 | t->len = ecalloc(coloff, sizeof(*(t->len))); | | 240 | t->len = ecalloc(coloff, sizeof(*(t->len))); |
241 | for (t->cols = coloff; --coloff >= 0;) { | | 241 | for (t->cols = coloff; --coloff >= 0;) { |
242 | t->list[coloff] = cols[coloff]; | | 242 | t->list[coloff] = cols[coloff]; |
243 | t->len[coloff] = strlen(cols[coloff]); | | 243 | t->len[coloff] = strlen(cols[coloff]); |
244 | if (t->len[coloff] > lens[coloff]) | | 244 | if (t->len[coloff] > lens[coloff]) |
245 | lens[coloff] = t->len[coloff]; | | 245 | lens[coloff] = t->len[coloff]; |
246 | } | | 246 | } |
247 | } | | 247 | } |
248 | for (cnt = 0, t = tbl; cnt < entries; ++cnt, ++t) { | | 248 | for (cnt = 0, t = tbl; cnt < entries; ++cnt, ++t) { |
249 | for (coloff = 0; coloff < t->cols - 1; ++coloff) | | 249 | for (coloff = 0; coloff < t->cols - 1; ++coloff) |
250 | (void)printf("%s%*s", t->list[coloff], | | 250 | (void)printf("%s%*s", t->list[coloff], |
251 | lens[coloff] - t->len[coloff] + 2, " "); | | 251 | lens[coloff] - t->len[coloff] + 2, " "); |
252 | (void)printf("%s\n", t->list[coloff]); | | 252 | (void)printf("%s\n", t->list[coloff]); |
253 | } | | 253 | } |
254 | free(tbl); | | 254 | free(tbl); |
255 | free(cols); | | 255 | free(cols); |
256 | free(lens); | | 256 | free(lens); |
257 | } | | 257 | } |
258 | | | 258 | |
259 | #define DEFNUM 1000 | | 259 | #define DEFNUM 1000 |
260 | | | 260 | |
261 | static void | | 261 | static void |
262 | input(FILE *fp) | | 262 | input(FILE *fp) |