2 The **tabular** utility reads files containing tabular data sequentially and pretty prints them as a table.
3 The file operands are processed in command-line order. If the file is a single dash (‘-’) or absent, **tabular**
4 reads from the standard input. The separator character(s) of each column in the data set can be specified at run-time,
5 which defaults to `','`.
9 * Compiled with security hardening flags.
10 * Static analysis integrated using clang's `scan-build` using checkers `alpha.security`, `alpha.core.CastSize`,
11 `alpha.core.CastToStruct`, `alpha.core.IdenticalExpr`, `alpha.core.PointerArithm`, `alpha.core.PointerSub`,
12 `alpha.core.SizeofPtr`, `alpha.core.TestAfterDivZero`, `alpha.unix`.
13 * Follows [FreeBSD coding style](https://www.freebsd.org/cgi/man.cgi?query=style&sektion=9).
14 * [RFC4180](https://datatracker.ietf.org/doc/html/rfc4180) compliant:
15 * handles `\n`, `\r` and `\r\n` as new line
16 * if double-quotes are used to enclose fields it handles double quotes appearing inside a field only if
17 escaped by preceding it with another double quote. For example `"x""y"` is equivalent to `x"y`
18 * handles the precence of the separator character inside a quoted field.
20 * C99 compliant *and* may be built in an environment which provides POSIX.1-2001 system interfaces.
21 * Self-contained, no external dependencies
22 * Easy to compile and uses POSIX make.
25 * Input lines are limited to `LINE_MAX` bytes in lenght.
26 * Only single character separators are allowed for now.
27 * The program presumes the locale is UTF-8.
30 The only dependency is a toolchain supporting the following flags:
33 CFLAGS = -std=c99 -O2 -Wall -Wextra -Wpedantic \
34 -Walloca -Wcast-qual -Wconversion -Wformat=2 -Wformat-security \
35 -Wnull-dereference -Wstack-protector -Wvla -Warray-bounds \
36 -Wbad-function-cast -Wconversion -Wshadow -Wstrict-overflow=4 -Wundef \
37 -Wstrict-prototypes -Wswitch-default -Wfloat-equal -Wimplicit-fallthrough \
38 -Wpointer-arith -Wswitch-enum \
40 -fstack-protector-strong -fPIE -fstack-clash-protection
42 LDFLAGS = -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -Wl,-z,separate-code
45 Otherwise you can just remove the security flags and compile it with
47 CFLAGS = -std=c99 -O2 -Wall -Wextra -Wpedantic
51 or pass your own flags to make
53 make CC=gcc CFLAGS=... LDFLAGS=...
57 Clone this repository then
60 $ make PREFIX=/usr install
63 This will install the compiled binary under `PREFIX` (`/usr/bin`) in this case, if not specified `PREFIX` will default
64 to `/usr/local`. For staged installs, `DESTDIR` is also supported. As the binary does not have any dependency it does
65 not have to be installed before use.
68 **tabular** receives as input one or more files to print as a table. The files however, can be omitted, in this case
69 the program takes the input from the standard input until `EOF` or `^D` is reached. If a file is a single dash (‘-’),
70 **tabular** reads from standard input.
72 The options are as follows:
74 * **-s** Specify a character to be used to delimit the columns and each field. If omitted `','` is used.
77 Example CSVs are taken from [https://people.sc.fsu.edu/~jburkardt/data/csv/csv.html](https://people.sc.fsu.edu/~jburkardt/data/csv/csv.html)
81 John,Doe,120 jefferson st.,Riverside, NJ, 08075
82 Jack,McGinnis,220 hobo Av.,Phila, PA,09119
83 "John ""Da Man""",Repici,120 Jefferson St.,Riverside, NJ,08075
84 Stephen,Tyler,"7452 Terrace ""At the Plaza"" road",SomeTown,SD, 91234
85 ,Blankman,,SomeTown, SD, 00298
86 "Joan ""the bone"", Anne",Jet,"9th, at Terrace plc",Desert City,CO,00123
88 $ tabular addresses.csv
89 John Doe 120 jefferson st. Riverside NJ 08075
90 Jack McGinnis 220 hobo Av. Phila PA 09119
91 John "Da Man" Repici 120 Jefferson St. Riverside NJ 08075
92 Stephen Tyler 7452 Terrace "At the Plaza" road SomeTown SD 91234
93 Blankman SomeTown SD 00298
94 Joan "the bone", Anne Jet 9th, at Terrace plc Desert City CO 00123
98 $ tabular tally_cab.csv - addresses.csv <<EOF
103 Distance (miles) "Fare ($)"
114 John Doe 120 jefferson st. Riverside NJ 08075
115 Jack McGinnis 220 hobo Av. Phila PA 09119
116 John "Da Man" Repici 120 Jefferson St. Riverside NJ 08075
117 Stephen Tyler 7452 Terrace "At the Plaza" road SomeTown SD 91234
118 Blankman SomeTown SD 00298
119 Joan "the bone", Anne Jet 9th, at Terrace plc Desert City CO 00123
123 $ cat names.csv | tabular -s ';'
125 23434 Norris, Chuck 24
126 34343 Bond, James "master" 57
130 Static analysis on the code base is done by using clang's static analyzer run through `scan-build.sh` which wraps the
131 `scan-build` utility. The checkers used are part of the
132 [Experimental Checkers](https://releases.llvm.org/12.0.0/tools/clang/docs/analyzer/checkers.html#alpha-checkers)
133 (aka *alpha* checkers):
136 * `alpha.core.CastSize`
137 * `alpha.core.CastToStruct`
138 * `alpha.core.IdenticalExpr`
139 * `alpha.core.PointerArithm`
140 * `alpha.core.PointerSub`
141 * `alpha.core.SizeofPtr`
142 * `alpha.core.TestAfterDivZero`
146 Send patches on the [mailing list](https://www.freelists.org/list/tabular-dev), report bugs using [git-bug](https://github.com/MichaelMure/git-bug/).
149 BSD 2-Clause FreeBSD License, see LICENSE.