чување b36ae9356b39aa132c062b38d8df074152f5021f
родитељ 6f96792eebfa8cd08f60dc2bc9c220d464103087
Аутор: Страхиња Радић <contact@strahinja.org>
Датум: Mon, 29 May 2023 07:46:29 +0200
Use only the first pathname, print a warning when multiple; improve manpage
Signed-off-by: Страхиња Радић <contact@strahinja.org>
Diffstat:
| M | table.1.in | | | 44 | ++++++++++++++++++++++++++++++++++++++++++-- |
| M | table.c | | | 17 | +++++++++++++++-- |
измењених датотека: 2, додавања: 57(+), брисања: 4(-)
diff --git a/table.1.in b/table.1.in
@@ -59,6 +59,7 @@ is a synonym for
.OP "\-q \fR|\fP \-\-quotes=" behavior
.OP "\-s \fR|\fP \-\-symbols=" set
.OP "\-t \fR|\fP \-\-expand-tabs"
+.RI [ pathname ]
.YS
.
.SH COPYRIGHT
@@ -77,6 +78,19 @@ It parses the given file or standard input as
and prints out a table using Unicode characters for box
drawing.
.
+.PP
+When specifying multiple
+.I pathname
+arguments,
+.B table
+prints a warning to stderr.
+Only the first such argument is processed.
+If
+.I pathname
+is omitted,
+.B table
+reads standard input.
+.
.SH OPTIONS
.
.TP
@@ -136,6 +150,13 @@ to
.BR table ,
so are not considered as "first characters" for the assignment.
.
+.IP
+Note that the
+.B \-b
+parameter takes precedence: if it is present,
+.B \-d
+is ignored.
+.
.TP
.BI \-f " format"
.TQ
@@ -185,7 +206,7 @@ The default behavior is to print header cells left-aligned.
.TQ
.B \-\-help
.br
-Print this usage information screen.
+Print the usage information screen.
.
.TP
.B \-m
@@ -282,7 +303,26 @@ _
.TQ
.B \-\-expand\-tabs
.br
-Expand tabs to spaces. Default behavior is to output tab characters as-is.
+Expand tabs to spaces, honoring standard modulo 8 tab stops.
+Default behavior is to output tab characters as-is.
+.
+.IP
+Note that the
+.B \-d
+parameter takes precedence, unless
+.B \-b
+is also used: if the delimiter is set to the
+.SM TAB
+character (0x09),
+.B \-t
+is ignored.
+When
+.B \-b
+is used in addition,
+.B \-t
+is honored and
+.B \-d
+ignored.
.
.TP
.B \-v
diff --git a/table.c b/table.c
@@ -103,11 +103,22 @@ usage()
" [-H|--align-header] [-h|--help] [-m|--msdos] [-n|--no-ansi]"
" [-p|--pause] [-q <behavior>|--quotes=<behavior>]"
" [-s <set>|--symbols=<set>] [-t|--expand-tabs]"
- " [-v|--version]\n",
+ " [-v|--version] [pathname]\n",
PROGRAMNAME);
return 0;
}
+void
+warning(char* fmt, ...)
+{
+ char buf[BUFSIZE];
+ va_list args;
+ va_start(args, fmt);
+ vsnprintf(buf, sizeof(buf), (const char*)fmt, args);
+ va_end(args);
+ fprintf(stderr, "%s: %s\n", PROGRAMNAME, buf);
+}
+
int
error(int code, char* fmt, ...)
{
@@ -775,6 +786,8 @@ do_arg:
return error(EINVAL, "Invalid argument: '%s'",
arg);
}
+ else if (filename)
+ warning("Additional argument ignored: '%s'", arg);
else
filename = arg;
cmd = CMD_NONE;
@@ -1003,7 +1016,7 @@ do_line:
continue_line:
u8_char_to_u32(&uch, pline, &ch_len);
- if (uch == (u32)L'\e' && *(pline+1) == '[')
+ if (uch == (u32)L'\e' && *(pline + 1) == '[')
{
in_sgr = 1;
if (!no_ansi)