чување af9976b41e5b3169212f2cacb43501847c84bf29
родитељ 90b714c682de9076dd35a327ea09ce385eae508c
Аутор: Страхиња Радић <contact@strahinja.org>
Датум: Wed, 3 Mar 2021 19:29:09 +0100
Added the --msdos option
Signed-off-by: Страхиња Радић <contact@strahinja.org>
Diffstat:
измењених датотека: 4, додавања: 32(+), брисања: 9(-)
diff --git a/README b/README
@@ -53,7 +53,7 @@ $ su
block in do_view_action() function includes:
csv)
- table -n "${MC_EXT_FILENAME}"
+ table -m -n "${MC_EXT_FILENAME}"
;;
You also need to edit extension file (Command->Edit extension file) or just
@@ -74,7 +74,7 @@ $ su
## CSV
csv)
- table "${FILE_PATH}" && exit 5
+ table -m "${FILE_PATH}" && exit 5
exit 1;;
@@ -87,7 +87,7 @@ $ su
" CSV
fileviewer *.csv
- \ table %c
+ \ table -m %c
[1]: https://github.com/apenwarr/redo
diff --git a/index.html b/index.html
@@ -144,7 +144,7 @@ case "${filetype}" in</pre>
<pre>
csv)
- table -n "${MC_EXT_FILENAME}"
+ table -m -n "${MC_EXT_FILENAME}"
;;</pre>
<p>You also need to edit extension file (Command->Edit extension
@@ -167,7 +167,7 @@ shell/.csv
<pre>
## CSV
csv)
- table "${FILE_PATH}" && exit 5
+ table -m "${FILE_PATH}" && exit 5
exit 1;;</pre>
<h2>Configuring vifm</h2>
@@ -179,7 +179,7 @@ csv)
<pre>
" CSV
fileviewer *.csv
- \ table %c</pre>
+ \ table -m %c</pre>
<h2>Changelog</h2>
diff --git a/table.1.in b/table.1.in
@@ -32,6 +32,7 @@ table \- Command line utility to format and display CSV.
.OP "\-c \fR|\fP \-\-columns=" cols
.OP "\-d \fR|\fP \-\-delim=" delim
.OP "\-f \fR|\fP \-\-format=" format
+.OP "\-m \fR|\fP \-\-msdos"
.OP "\-n \fR|\fP \-\-no\-ansi"
.OP "\-s \fR|\fP \-\-symbols=" set
.OP "\-t \fR|\fP \-\-expand-tabs"
@@ -124,6 +125,14 @@ $ table -f 1:5:5:1 -c 50 -s aa examples/quotes-english.csv
Print this usage information screen.
.
.TP
+.B \-m
+.TQ
+.B \-\-msdos
+.br
+Ignore carriage return (\\r) characters in input. The default behavior is to
+treat them as part of the text, which can produce unexpected results.
+.
+.TP
.B \-n
.TQ
.B \-\-no\-ansi
diff --git a/table.c b/table.c
@@ -65,8 +65,9 @@ ucs4_t delimiter = ',';
ULONG* format = NULL;
size_t format_size = 0;
ULONG format_value = 0;
-BOOL handle_ansi = TRUE;
BOOL border_mode = FALSE;
+BOOL handle_ansi = TRUE;
+BOOL msdos = FALSE;
BOOL expand_tabs = FALSE;
int
@@ -81,8 +82,8 @@ usage()
{
printf("Usage: %s [-b|--border-mode] [-c <cols>|--columns=<cols>] [-d"
" <delim>|--delimiter=<delim>] [-f <format>|--format=<format>]"
- " [-h|--help] [-n|--no-ansi] [-s <set>|--symbols=<set>] "
- "[-t|--expand-tabs] [-v|--version]\n",
+ " [-h|--help] [-m|--msdos] [-n|--no-ansi]"
+ " [-s <set>|--symbols=<set>] [-t|--expand-tabs] [-v|--version]\n",
PROGRAMNAME);
return 0;
}
@@ -361,6 +362,11 @@ main(int argc, char** argv)
arg += strlen("format=");
set_format(arg, &format, &format_size);
}
+ else if (startswith(arg, "msdos"))
+ {
+ arg += strlen("msdos");
+ msdos = TRUE;
+ }
else if (startswith(arg, "no-ansi"))
{
arg += strlen("no-ansi");
@@ -401,6 +407,9 @@ main(int argc, char** argv)
case 'h':
return usage();
break;
+ case 'm':
+ msdos = TRUE;
+ break;
case 'n':
handle_ansi = FALSE;
break;
@@ -598,6 +607,11 @@ main(int argc, char** argv)
}
colno++;
}
+ else if (uch == '\r' && msdos)
+ {
+ pline++;
+ colno++;
+ }
else if (uch == '\t' && expand_tabs)
{
while (within_column(column_start))