opnsense-src/contrib/one-true-awk/testdir/T.csv
Warner Losh daf917daba Merge one true awk from 2024-01-22 for the Awk Second Edition support
This brings in Unicode support, CSV support and a number of bug fixes.
They are described in _The AWK Programming Language_, Second Edition, by
Al Aho, Brian Kernighan, and Peter Weinberger (Addison-Wesley, 2024,
ISBN-13 978-0138269722, ISBN-10 0138269726).

Sponsored by:		Netflix

(cherry picked from commit f32a6403d34654ac6e61182d09abb5e85850e1ee)
2024-03-11 22:53:18 -06:00

1.5 KiB
Executable file

1#!/bin/sh
2echo T.csv: tests of csv field splitting, no embedded newlines
3awk=${awk-../a.out}
4$awk '
5BEGIN {
6}
7NF == 0 || $1 ~ /^#/ {
8next
9}
10$1 ~ /try/ { # new test
11nt++
12prog = $0
13nt2 = 0
14while (getline > 0) {
15if (NF == 0) # blank line terminates a sequence
16break
17input = $1
18input, prog)
19else
20nt, ++nt2)
21system(test output run)
22}
23tt += nt2
24}
25' <<\!!!!
26# General format:
27# try program as rest of line
28# $1 $2 $3 output1 (\t for tab, \n for newline,
29# ... terminated by blank line
30a [a]
31a [ a]
32,a [][a]
33, a [ ][ a]
34a,b [a][b]
35a,b,c [a][b][c]
36a''b [a''b]
37,, [][][]
38a, [a][]
39, [][]
40!!!!