чување 5c30e5c6c1a962e3099ef88e71e7caf19561925b
родитељ bfd20a4ca71953b1b4d8ddf41a6a9eaecbac26ba
Аутор: Страхиња Радић <contact@strahinja.org>
Датум: Fri, 7 Apr 2023 19:02:11 +0200
table.c(set_delimiter): Remove redundant testing for '/"; table.1.in: Clarify processing of -d arguments
Signed-off-by: Страхиња Радић <contact@strahinja.org>
Diffstat:
измењених датотека: 2, додавања: 31(+), брисања: 15(-)
diff --git a/table.1.in b/table.1.in
@@ -8,11 +8,20 @@
.RS \\$1
.sp 1
..
+.de CDSN
+.EX
+.RS \\$1
+.sp 1
+..
.de CDE
.sp 1
.RE
.EE
..
+.de CDEN
+.RE
+.EE
+..
.
.TH TABLE "1" "%DATE%" "%VERSION%" "General Commands Manual"
.SH NAME
@@ -87,11 +96,27 @@ Set maximum table width in columns (default 80).
.BI \-\-delimiter= delim
.br
Set field delimiter (default ","). First line of the input determines the number
-of table columns. Special characters, like ";", need to be quoted:
+of table columns. The first character of
+.I delim
+becomes the delimiter. Special characters, like ";", need to be quoted or
+escaped:
.
.CDS 12
-$ table -d ';'
-.CDE
+$ table -d';'
+.CDEN
+.
+.IP
+or
+.
+.CDSN 12
+$ table -d\\;
+.CDEN
+.
+.IP
+In the examples above, "'" and "\\" are parsed by the shell and are not passed
+to
+.BR table ,
+so are not considered as "first characters" for the assignment.
.
.TP
.BI \-f " format"
diff --git a/table.c b/table.c
@@ -231,21 +231,12 @@ int
set_delimiter(u8* arg, u32* delimiter)
{
size_t delimiter_len = 0;
- u8* parg = arg;
u32 uch;
- while (parg && *parg)
- {
- u8_char_to_u32(&uch, parg, &delimiter_len);
- if (uch != (u32)L'"' && uch != (u32)L'\'')
- {
- *delimiter = uch;
- return 0;
- }
- parg += delimiter_len;
- }
+ u8_char_to_u32(&uch, arg, &delimiter_len);
+ *delimiter = uch;
- return -1;
+ return 0;
}
int