improved cmd/sed/sed.c

This commit is contained in:
hyung-hwan 2009-09-09 01:05:48 +00:00
parent faf8d996db
commit 2a9fabebb6
4 changed files with 292 additions and 143 deletions

View File

@ -21,6 +21,7 @@
#include <qse/cmn/mem.h> #include <qse/cmn/mem.h>
#include <qse/cmn/chr.h> #include <qse/cmn/chr.h>
#include <qse/cmn/opt.h> #include <qse/cmn/opt.h>
#include <qse/cmn/sio.h>
#include <qse/cmn/misc.h> #include <qse/cmn/misc.h>
#include <qse/cmn/stdio.h> #include <qse/cmn/stdio.h>
#include <qse/cmn/main.h> #include <qse/cmn/main.h>
@ -36,44 +37,38 @@ static qse_ssize_t in (
switch (cmd) switch (cmd)
{ {
case QSE_SED_IO_OPEN: case QSE_SED_IO_OPEN:
if (arg->path == QSE_NULL || {
arg->path[0] == QSE_T('\0')) const qse_char_t* file;
if (arg->path == QSE_NULL || arg->path[0] == QSE_T('\0'))
{ {
if (g_infile) file = (g_infile == QSE_NULL)? QSE_NULL: g_infile;
{
arg->handle = qse_fopen (g_infile, QSE_T("r"));
if (arg->handle == QSE_NULL)
{
qse_cstr_t errarg;
errarg.ptr = g_infile;
errarg.len = qse_strlen(g_infile);
qse_sed_seterror (sed, QSE_SED_EIOFIL, &errarg, QSE_NULL);
return -1;
}
}
else arg->handle = QSE_STDIN;
} }
else file = arg->path;
if (file == QSE_NULL) arg->handle = qse_sio_in;
else else
{ {
arg->handle = qse_fopen (arg->path, QSE_T("r")); arg->handle = qse_sio_open (
qse_sed_getmmgr(sed),
0,
file,
QSE_SIO_READ
);
if (arg->handle == QSE_NULL) return -1; if (arg->handle == QSE_NULL) return -1;
} }
return 1; return 1;
}
case QSE_SED_IO_CLOSE: case QSE_SED_IO_CLOSE:
if (arg->handle != QSE_STDIN) if (arg->handle != qse_sio_in) qse_sio_close (arg->handle);
qse_fclose (arg->handle);
return 0; return 0;
case QSE_SED_IO_READ: case QSE_SED_IO_READ:
{ return qse_sio_getsn (arg->handle, buf, size);
qse_cint_t c;
/* TODO: read more characters */
c = qse_fgetc (arg->handle);
if (c == QSE_CHAR_EOF) return 0;
buf[0] = c;
return 1;
}
default: default:
return -1; return -1;
@ -86,30 +81,31 @@ static qse_ssize_t out (
switch (cmd) switch (cmd)
{ {
case QSE_SED_IO_OPEN: case QSE_SED_IO_OPEN:
if (arg->path == QSE_NULL || if (arg->path == QSE_NULL || arg->path[0] == QSE_T('\0'))
arg->path[0] == QSE_T('\0'))
{ {
arg->handle = QSE_STDOUT; arg->handle = qse_sio_out;
} }
else else
{ {
arg->handle = qse_fopen (arg->path, QSE_T("w")); arg->handle = qse_sio_open (
qse_sed_getmmgr(sed),
0,
arg->path,
QSE_SIO_WRITE |
QSE_SIO_CREATE |
QSE_SIO_TRUNCATE
);
if (arg->handle == QSE_NULL) return -1; if (arg->handle == QSE_NULL) return -1;
} }
return 1; return 1;
case QSE_SED_IO_CLOSE: case QSE_SED_IO_CLOSE:
if (arg->handle != QSE_STDOUT) if (arg->handle != qse_sio_out) qse_sio_close (arg->handle);
qse_fclose (arg->handle);
return 0; return 0;
case QSE_SED_IO_WRITE: case QSE_SED_IO_WRITE:
{ return qse_sio_putsn (arg->handle, data, len);
qse_size_t i = 0;
for (i = 0; i < len; i++)
qse_fputc (data[i], arg->handle);
return len;
}
default: default:
return -1; return -1;

View File

@ -1,5 +1,5 @@
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f cou-001.awk cou.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f cou-001.awk cou.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
USSR 275 USSR 275
Canada 25 Canada 25
@ -13,7 +13,7 @@ Japan 120
Germany 61 Germany 61
England 56 England 56
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f cou-002.awk cou.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f cou-002.awk cou.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
COUNTRY AREA POP CONTINENT COUNTRY AREA POP CONTINENT
@ -31,44 +31,44 @@ England 56
TOTAL 25681 2819 TOTAL 25681 2819
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f cou-003.awk cou.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f cou-003.awk cou.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
India 1267 746 Asia India 1267 746 Asia
Japan 144 120 Asia Japan 144 120 Asia
Germany 96 61 Europe Germany 96 61 Europe
England 94 56 Europe England 94 56 Europe
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f cou-004.awk cou.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f cou-004.awk cou.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
USSR 8649 275 Asia USSR 8649 275 Asia
USA 3615 237 North America USA 3615 237 North America
Mexico 762 78 North America Mexico 762 78 North America
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f cou-005.awk cou.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f cou-005.awk cou.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Canada 3852 25 North America Canada 3852 25 North America
Brazil 3286 134 South America Brazil 3286 134 South America
Mexico 762 78 North America Mexico 762 78 North America
England 94 56 Europe England 94 56 Europe
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f cou-006.awk cou.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f cou-006.awk cou.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f cou-007.awk cou.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f cou-007.awk cou.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
USSR 8649 275 Asia USSR 8649 275 Asia
China 3705 1032 Asia China 3705 1032 Asia
India 1267 746 Asia India 1267 746 Asia
Japan 144 120 Asia Japan 144 120 Asia
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f cou-008.awk cou.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f cou-008.awk cou.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
USSR 8649 275 Asia USSR 8649 275 Asia
China 3705 1032 Asia China 3705 1032 Asia
India 1267 746 Asia India 1267 746 Asia
Japan 144 120 Asia Japan 144 120 Asia
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f cou-009.awk cou.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f cou-009.awk cou.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Canada 3852 25 North America Canada 3852 25 North America
USA 3615 237 North America USA 3615 237 North America
@ -78,22 +78,22 @@ France 211 55 Europe
Germany 96 61 Europe Germany 96 61 Europe
England 94 56 Europe England 94 56 Europe
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f cou-010.awk cou.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f cou-010.awk cou.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
USSR 8649 275 Asia USSR 8649 275 Asia
China 3705 1032 Asia China 3705 1032 Asia
India 1267 746 Asia India 1267 746 Asia
Japan 144 120 Asia Japan 144 120 Asia
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f cou-011.awk cou.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f cou-011.awk cou.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f cou-012.awk cou.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f cou-012.awk cou.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
China 3705 1032 Asia China 3705 1032 Asia
India 1267 746 Asia India 1267 746 Asia
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f cou-013.awk cou.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f cou-013.awk cou.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
USSR 8649 275 Asia USSR 8649 275 Asia
China 3705 1032 Asia China 3705 1032 Asia
@ -103,7 +103,7 @@ Japan 144 120 Asia
Germany 96 61 Europe Germany 96 61 Europe
England 94 56 Europe England 94 56 Europe
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f cou-014.awk cou.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f cou-014.awk cou.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
USSR 8649 275 Asia USSR 8649 275 Asia
China 3705 1032 Asia China 3705 1032 Asia
@ -113,7 +113,7 @@ Japan 144 120 Asia
Germany 96 61 Europe Germany 96 61 Europe
England 94 56 Europe England 94 56 Europe
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f cou-015.awk cou.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f cou-015.awk cou.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
USSR 8649 275 Asia USSR 8649 275 Asia
China 3705 1032 Asia China 3705 1032 Asia
@ -123,7 +123,7 @@ Japan 144 120 Asia
Germany 96 61 Europe Germany 96 61 Europe
England 94 56 Europe England 94 56 Europe
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f cou-016.awk cou.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f cou-016.awk cou.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
USSR 8649 275 Asia USSR 8649 275 Asia
China 3705 1032 Asia China 3705 1032 Asia
@ -133,16 +133,16 @@ Japan 144 120 Asia
Germany 96 61 Europe Germany 96 61 Europe
England 94 56 Europe England 94 56 Europe
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f cou-017.awk cou.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f cou-017.awk cou.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Canada 3852 25 North America Canada 3852 25 North America
China 3705 1032 Asia China 3705 1032 Asia
USA 3615 237 North America USA 3615 237 North America
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f cou-018.awk cou.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f cou-018.awk cou.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f cou-019.awk cou.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f cou-019.awk cou.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
cou.dat: USSR 8649 275 Asia cou.dat: USSR 8649 275 Asia
cou.dat: Canada 3852 25 North America cou.dat: Canada 3852 25 North America
@ -150,7 +150,7 @@ cou.dat: China 3705 1032 Asia
cou.dat: USA 3615 237 North America cou.dat: USA 3615 237 North America
cou.dat: Brazil 3286 134 South America cou.dat: Brazil 3286 134 South America
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f cou-020.awk cou.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f cou-020.awk cou.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
cou.dat: USSR 8649 275 Asia cou.dat: USSR 8649 275 Asia
cou.dat: Canada 3852 25 North America cou.dat: Canada 3852 25 North America
@ -158,14 +158,14 @@ cou.dat: China 3705 1032 Asia
cou.dat: USA 3615 237 North America cou.dat: USA 3615 237 North America
cou.dat: Brazil 3286 134 South America cou.dat: Brazil 3286 134 South America
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f cou-021.awk cou.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f cou-021.awk cou.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
USSR 8649000 USSR 8649000
China 3705000 China 3705000
India 1267000 India 1267000
Japan 144000 Japan 144000
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f cou-022.awk cou.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f cou-022.awk cou.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
USSR 8649 275 Asia USSR 8649 275 Asia
Canada 3852 25 NA Canada 3852 25 NA
@ -179,7 +179,7 @@ Japan 144 120 Asia
Germany 96 61 Europe Germany 96 61 Europe
England 94 56 Europe England 94 56 Europe
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f cou-023.awk cou.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f cou-023.awk cou.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
USSR 8649 275 Asia 31.7956 USSR 8649 275 Asia 31.7956
Canada 3852 25 North America 6.49013 Canada 3852 25 North America 6.49013
@ -193,42 +193,42 @@ Japan 144 120 Asia 833.333
Germany 96 61 Europe 635.417 Germany 96 61 Europe 635.417
England 94 56 Europe 595.745 England 94 56 Europe 595.745
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f cou-024.awk cou.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f cou-024.awk cou.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Total population of the 4 Asian countries is 2173 million. Total population of the 4 Asian countries is 2173 million.
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f cou-025.awk cou.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f cou-025.awk cou.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Asian population is 2173 million. Asian population is 2173 million.
European population is 172 million. European population is 172 million.
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f cou-026.awk cou.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f cou-026.awk cou.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Asia 2173 Asia 2173
Europe 172 Europe 172
North America 340 North America 340
South America 134 South America 134
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f cou-027.awk cou.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f cou-027.awk cou.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Asia 2173 Asia 2173
North America 340 North America 340
Europe 172 Europe 172
South America 134 South America 134
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f emp-001.awk emp.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f emp-001.awk emp.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Kathy 40 Kathy 40
Mark 100 Mark 100
Mary 121 Mary 121
Susie 76.5 Susie 76.5
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f emp-002.awk emp.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f emp-002.awk emp.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Beth Beth
Dan Dan
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f emp-003.awk emp.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f emp-003.awk emp.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
3 Beth 0 3 Beth 0
3 Dan 0 3 Dan 0
@ -237,7 +237,7 @@ Dan
3 Mary 22 3 Mary 22
3 Susie 18 3 Susie 18
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f emp-004.awk emp.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f emp-004.awk emp.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
1 Beth 4.00 0 1 Beth 4.00 0
2 Dan 3.74 0 2 Dan 3.74 0
@ -246,7 +246,7 @@ Dan
5 Mary 5.50 22 5 Mary 5.50 22
6 Susie 4.25 18 6 Susie 4.25 18
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f emp-005.awk emp.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f emp-005.awk emp.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
total pay for Beth is 0 total pay for Beth is 0
total pay for Dan is 0 total pay for Dan is 0
@ -255,7 +255,7 @@ total pay for Mark is 100
total pay for Mary is 121 total pay for Mary is 121
total pay for Susie is 76.5 total pay for Susie is 76.5
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f emp-006.awk emp.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f emp-006.awk emp.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
total pay for Beth is $0.00 total pay for Beth is $0.00
total pay for Dan is $0.00 total pay for Dan is $0.00
@ -264,7 +264,7 @@ total pay for Mark is $100.00
total pay for Mary is $121.00 total pay for Mary is $121.00
total pay for Susie is $76.50 total pay for Susie is $76.50
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f emp-007.awk emp.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f emp-007.awk emp.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Beth $ 0.00 Beth $ 0.00
Dan $ 0.00 Dan $ 0.00
@ -273,26 +273,26 @@ Mark $100.00
Mary $121.00 Mary $121.00
Susie $ 76.50 Susie $ 76.50
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f emp-008.awk emp.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f emp-008.awk emp.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Mark 5.00 20 Mark 5.00 20
Mary 5.50 22 Mary 5.50 22
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f emp-009.awk emp.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f emp-009.awk emp.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
$100.00 for Mark $100.00 for Mark
$121.00 for Mary $121.00 for Mary
$76.50 for Susie $76.50 for Susie
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f emp-010.awk emp.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f emp-010.awk emp.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Susie 4.25 18 Susie 4.25 18
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f emp-011.awk emp.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f emp-011.awk emp.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Susie 4.25 18 Susie 4.25 18
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f emp-012.awk emp.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f emp-012.awk emp.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Beth 4.00 0 Beth 4.00 0
Kathy 4.00 10 Kathy 4.00 10
@ -300,7 +300,7 @@ Mark 5.00 20
Mary 5.50 22 Mary 5.50 22
Susie 4.25 18 Susie 4.25 18
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f emp-013.awk emp.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f emp-013.awk emp.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Beth 4.00 0 Beth 4.00 0
Kathy 4.00 10 Kathy 4.00 10
@ -310,7 +310,7 @@ Mary 5.50 22
Mary 5.50 22 Mary 5.50 22
Susie 4.25 18 Susie 4.25 18
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f emp-014.awk emp.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f emp-014.awk emp.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Beth 4.00 0 Beth 4.00 0
Kathy 4.00 10 Kathy 4.00 10
@ -318,10 +318,10 @@ Mark 5.00 20
Mary 5.50 22 Mary 5.50 22
Susie 4.25 18 Susie 4.25 18
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f emp-015.awk emp.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f emp-015.awk emp.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f emp-016.awk emp.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f emp-016.awk emp.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
NAME RATE HOURS NAME RATE HOURS
@ -332,33 +332,33 @@ Mark 5.00 20
Mary 5.50 22 Mary 5.50 22
Susie 4.25 18 Susie 4.25 18
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f emp-017.awk emp.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f emp-017.awk emp.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
3 employees worked more than 15 hours 3 employees worked more than 15 hours
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f emp-018.awk emp.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f emp-018.awk emp.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
6 employees 6 employees
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f emp-019.awk emp.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f emp-019.awk emp.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
6 employees 6 employees
total pay is 337.5 total pay is 337.5
average pay is 56.25 average pay is 56.25
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f emp-020.awk emp.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f emp-020.awk emp.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
highest hourly rage: 5.50 for Mary highest hourly rage: 5.50 for Mary
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f emp-021.awk emp.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f emp-021.awk emp.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Beth Dan Kathy Mark Mary Susie Beth Dan Kathy Mark Mary Susie
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f emp-022.awk emp.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f emp-022.awk emp.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Susie 4.25 18 Susie 4.25 18
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f emp-023.awk emp.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f emp-023.awk emp.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Beth 4 Beth 4
Dan 3 Dan 3
@ -367,15 +367,15 @@ Mark 4
Mary 4 Mary 4
Susie 5 Susie 5
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f emp-024.awk emp.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f emp-024.awk emp.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
6 lines, 18 words, 77 characters 6 lines, 18 words, 77 characters
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f emp-025.awk emp.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f emp-025.awk emp.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
no employees are paid more than $6/hour no employees are paid more than $6/hour
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f emp-026.awk emp.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f emp-026.awk emp.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Susie 4.25 18 Susie 4.25 18
Mary 5.50 22 Mary 5.50 22
@ -384,7 +384,7 @@ Kathy 4.00 10
Dan 3.74 0 Dan 3.74 0
Beth 4.00 0 Beth 4.00 0
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f emp-027.awk emp.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f emp-027.awk emp.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Susie 4.25 18 Susie 4.25 18
Mary 5.50 22 Mary 5.50 22
@ -393,18 +393,18 @@ Kathy 4.00 10
Dan 3.74 0 Dan 3.74 0
Beth 4.00 0 Beth 4.00 0
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f adr-001.awk adr.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f adr-001.awk adr.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
James Brown 012-345-678 James Brown 012-345-678
Richie Ren 02-3473-9192 Richie Ren 02-3473-9192
Toh WeeKung 9102-1203 Toh WeeKung 9102-1203
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f adr-002.awk adr.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f adr-002.awk adr.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
James Brown Somewhere over the rainbow 012-345-678 James Brown Somewhere over the rainbow 012-345-678
Toh WeeKung Singapore 9102-1203 Toh WeeKung Singapore 9102-1203
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f unr-001.awk unr.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f unr-001.awk unr.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Beth 4 0 Beth 4 0
Dan 3.74 0 Dan 3.74 0
@ -413,7 +413,7 @@ Mark 5.00 20
Mary 5.5 22 Mary 5.5 22
Susie 4.25 18 Susie 4.25 18
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --strictnaming=off --newline=on -o- -f lang-001.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --strictnaming=off --newline=on -o- -f lang-001.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
function f (__p0) function f (__p0)
{ {
@ -426,7 +426,7 @@ BEGIN {
hello hello
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --newline=on -o- -f lang-002.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --newline=on -o- -f lang-002.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
function f (__p0) function f (__p0)
{ {
@ -939,7 +939,7 @@ my hello
my hello my hello
ERROR: CODE 15 LINE 6 COLUMN 1 - block nested too deeply ERROR: CODE 15 LINE 6 COLUMN 1 - block nested too deeply
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --newline=on -o- -f lang-003.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --newline=on -o- -f lang-003.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
function fn (__p0) function fn (__p0)
{ {
@ -954,11 +954,11 @@ BEGIN {
50 50
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --newline=on -o- -f lang-004.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --newline=on -o- -f lang-004.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
ERROR: CODE 42 LINE 3 COLUMN 9 - function 'a' redefined ERROR: CODE 42 LINE 3 COLUMN 9 - function 'a' redefined
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --implicit=off --explicit=on --newline=on -o- -f lang-005.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --implicit=off --explicit=on --newline=on -o- -f lang-005.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
function a (__p0) function a (__p0)
{ {
@ -982,11 +982,11 @@ BEGIN {
50 50
100 100
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --implicit=off --explicit=on --newline=on -o- -f lang-006.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --implicit=off --explicit=on --newline=on -o- -f lang-006.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
ERROR: CODE 43 LINE 5 COLUMN 10 - global variable 'a' redefined ERROR: CODE 43 LINE 5 COLUMN 10 - global variable 'a' redefined
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --implicit=on --explicit=on --newline=on -o- -f lang-007.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --implicit=on --explicit=on --newline=on -o- -f lang-007.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
global __g17; global __g17;
@ -1005,7 +1005,7 @@ BEGIN {
20 20
30 30
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --implicit=off --explicit=on --newline=on -o- -f lang-008.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --implicit=off --explicit=on --newline=on -o- -f lang-008.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
global x; global x;
@ -1027,7 +1027,7 @@ BEGIN {
2 2
1 1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --implicit=off --explicit=on --newline=on --strictnaming=off -o- -f lang-009.awk lang-009.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --implicit=off --explicit=on --newline=on --strictnaming=off -o- -f lang-009.awk lang-009.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
function a (__p0) function a (__p0)
{ {
@ -1044,7 +1044,7 @@ END {
} }
1000 1000
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --newline=on -o- -f lang-010.awk this is just a test </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --newline=on -o- -f lang-010.awk this is just a test </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
BEGIN { BEGIN {
print "ARGC=",ARGC; print "ARGC=",ARGC;
@ -1101,7 +1101,7 @@ ARGC [+10124.1123000000] is positive
[A ] [-000000000000000000000000000000000000000000000001] [A ] [-000000000000000000000000000000000000000000000001]
abc10 000000000000000000000000000040 g good K abc10 000000000000000000000000000040 g good K
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --newline=on -o- -f lang-011.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --newline=on -o- -f lang-011.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
BEGIN { BEGIN {
a[1,2,3] = 20; a[1,2,3] = 20;
@ -1144,7 +1144,7 @@ BEGIN {
(1,2,3) in a ==> 20 (1,2,3) in a ==> 20
(4,5) not in a (4,5) not in a
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --newline=on -o- -f lang-012.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --newline=on -o- -f lang-012.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
BEGIN { BEGIN {
OFS = " "; OFS = " ";
@ -1345,7 +1345,7 @@ a < " " : 1
-0.123 -0.123
122.877 122.877
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --newline=on -o- -f lang-013.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --newline=on -o- -f lang-013.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
BEGIN { BEGIN {
CONVFMT = "%s"; CONVFMT = "%s";
@ -1354,7 +1354,7 @@ BEGIN {
ERROR: CODE 103 LINE 3 COLUMN 2 - recursion detected in format conversion ERROR: CODE 103 LINE 3 COLUMN 2 - recursion detected in format conversion
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --newline=on -o- -f lang-014.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --newline=on -o- -f lang-014.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
BEGIN { BEGIN {
a = (10 + 20); a = (10 + 20);
@ -1365,11 +1365,11 @@ BEGIN {
30 30 30 30 30 30
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --newline=on -o- -f lang-015.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --newline=on -o- -f lang-015.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
ERROR: CODE 15 LINE 3 COLUMN 50 - block nested too deeply ERROR: CODE 15 LINE 3 COLUMN 50 - block nested too deeply
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --newline=on -o- -f lang-016.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --newline=on -o- -f lang-016.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
BEGIN { BEGIN {
printf "[[[[[%s]]]]\n",sprintf ("abc %s abc",sprintf ("def %s %s",sprintf ("%s %s %s","xyz",1.2342,"xyz"),sprintf ("ttt %s tttt",123.12))); printf "[[[[[%s]]]]\n",sprintf ("abc %s abc",sprintf ("def %s %s",sprintf ("%s %s %s","xyz",1.2342,"xyz"),sprintf ("ttt %s tttt",123.12)));
@ -1379,7 +1379,7 @@ BEGIN {
[[[[[abc def xyz 1.2342 xyz ttt 123.12 tttt abc]]]] [[[[[abc def xyz 1.2342 xyz ttt 123.12 tttt abc]]]]
[[[[ttt 123.12 tttt]]]] [[[[ttt 123.12 tttt]]]]
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --newline=on -o- -f lang-017.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --newline=on -o- -f lang-017.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
function gety () function gety ()
{ {
@ -1430,7 +1430,7 @@ END {
END OF PROGRAM END OF PROGRAM
END OF PROGRAM 2 END OF PROGRAM 2
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --call main --newline=on -o- -f lang-017.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --call main --newline=on -o- -f lang-017.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
function gety () function gety ()
{ {
@ -1479,31 +1479,31 @@ END {
0 0
2 2
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --explicit=on --newline=on -o- -f lang-018.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --explicit=on --newline=on -o- -f lang-018.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
ERROR: CODE 47 LINE 1 COLUMN 8 - duplicate global variable 'ARGV' ERROR: CODE 47 LINE 1 COLUMN 8 - duplicate global variable 'ARGV'
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --explicit=on --newline=on -o- -f lang-019.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --explicit=on --newline=on -o- -f lang-019.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
ERROR: CODE 49 LINE 1 COLUMN 15 - '+' not a valid parameter name ERROR: CODE 49 LINE 1 COLUMN 15 - '+' not a valid parameter name
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --explicit=on --newline=on -o- -f lang-020.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --explicit=on --newline=on -o- -f lang-020.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
ERROR: CODE 50 LINE 1 COLUMN 8 - '+' not a valid variable name ERROR: CODE 50 LINE 1 COLUMN 8 - '+' not a valid variable name
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --explicit=on --newline=on -o- -f lang-021.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --explicit=on --newline=on -o- -f lang-021.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
ERROR: CODE 50 LINE 3 COLUMN 8 - '+' not a valid variable name ERROR: CODE 50 LINE 3 COLUMN 8 - '+' not a valid variable name
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --newline=on -o- -f lang-022.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --newline=on -o- -f lang-022.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
ERROR: CODE 23 LINE 2 COLUMN 9 - left parenthesis expected in place of '=' ERROR: CODE 23 LINE 2 COLUMN 9 - left parenthesis expected in place of '='
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --explicit=on --newline=on -o- -f lang-023.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --explicit=on --newline=on -o- -f lang-023.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
ERROR: CODE 28 LINE 5 COLUMN 20 - colon expected in place of ';' ERROR: CODE 28 LINE 5 COLUMN 20 - colon expected in place of ';'
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --explicit=on --newline=on -o- -f lang-024.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --explicit=on --newline=on -o- -f lang-024.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
BEGIN { BEGIN {
local __l0; local __l0;
@ -1513,7 +1513,7 @@ BEGIN {
1 1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --newline=on -o- -f lang-025.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --newline=on -o- -f lang-025.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
BEGIN { BEGIN {
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiix = 20; iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiix = 20;
@ -1522,7 +1522,7 @@ BEGIN {
ERROR: CODE 78 LINE 3 COLUMN 9 - variable 'iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiix' not deletable ERROR: CODE 78 LINE 3 COLUMN 9 - variable 'iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiix' not deletable
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --newline=on -o- -f lang-026.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --newline=on -o- -f lang-026.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
BEGIN { BEGIN {
abc[20] = "abc"; abc[20] = "abc";
@ -1534,19 +1534,19 @@ BEGIN {
abc abc
ERROR: CODE 86 LINE 4 COLUMN 2 - map 'abc' not assignable with a scalar ERROR: CODE 86 LINE 4 COLUMN 2 - map 'abc' not assignable with a scalar
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --newline=on -o- -f lang-027.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --newline=on -o- -f lang-027.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
ERROR: CODE 17 LINE 2 COLUMN 1 - invalid character '<NUL>' ERROR: CODE 17 LINE 2 COLUMN 1 - invalid character '<NUL>'
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --newline=on -o- -f lang-028.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --newline=on -o- -f lang-028.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
ERROR: CODE 41 LINE 2 COLUMN 10 - intrinsic function 'substr' redefined ERROR: CODE 41 LINE 2 COLUMN 10 - intrinsic function 'substr' redefined
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --explicit=on --newline=on -o- -f lang-029.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --explicit=on --newline=on -o- -f lang-029.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
ERROR: CODE 42 LINE 9 COLUMN 9 - function 'abc' redefined ERROR: CODE 42 LINE 9 COLUMN 9 - function 'abc' redefined
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --newline=on -o- -f lang-030.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --newline=on -o- -f lang-030.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
BEGIN { BEGIN {
print (1 + 0); print (1 + 0);
@ -1598,7 +1598,7 @@ BEGIN {
0 0
0 0
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --newline=on -o- -f lang-031.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --newline=on -o- -f lang-031.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
BEGIN { BEGIN {
print match ("hhhheeeo",/e+/); print match ("hhhheeeo",/e+/);
@ -1632,7 +1632,7 @@ BEGIN {
0 -1 0 -1
-------------------------- --------------------------
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --newline=on -o- -f lang-032.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --newline=on -o- -f lang-032.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
BEGIN { BEGIN {
a = 91; a = 91;
@ -1654,7 +1654,7 @@ BEGIN {
--------------------- ---------------------
9210 9210
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --newline=on -o- -f lang-033.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --newline=on -o- -f lang-033.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
BEGIN { BEGIN {
while ((("cat lang-033.awk" | getline x) > 0)) while ((("cat lang-033.awk" | getline x) > 0))
@ -1666,7 +1666,7 @@ BEGIN {
print x print x
} }
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --newline=on --rwpipe=on -o- -f lang-034.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --newline=on --rwpipe=on -o- -f lang-034.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
BEGIN { BEGIN {
print "15" || "sort"; print "15" || "sort";
@ -1687,7 +1687,7 @@ xx: 13
xx: 14 xx: 14
xx: 15 xx: 15
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --newline=on -o- -vdatafile=lang-035.dat1 -vgroupname=lang-035 -f lang-035.awk lang-035.dat2 </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --newline=on -o- -vdatafile=lang-035.dat1 -vgroupname=lang-035 -f lang-035.awk lang-035.dat2 </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
BEGIN { BEGIN {
max_cid_vars = 100; max_cid_vars = 100;
@ -1931,7 +1931,7 @@ lease 10.218.255.151 {
uid "\001\000\033[\234\220\000"; uid "\001\000\033[\234\220\000";
} }
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --newline=on -o- -f lang-036.awk lang-036.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --newline=on -o- -f lang-036.awk lang-036.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
{ {
if (($0 ~ /^-+$/)) if (($0 ~ /^-+$/))
@ -1963,7 +1963,7 @@ pq...r AAA2
kbs ddd kbs ddd
dif cccc dif cccc
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --newline=on -o- -f lang-037.awk lang-037.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk --newline=on -o- -f lang-037.awk lang-037.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
BEGIN { BEGIN {
RS = "\n-+\n"; RS = "\n-+\n";
@ -1991,7 +1991,7 @@ pq...r AAA2
kbs ddd kbs ddd
dif cccc dif cccc
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f quicksort.awk quicksort.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f quicksort.awk quicksort.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
0.0000000000 0.0000000000
0.11111111111111111111111111111 0.11111111111111111111111111111
@ -2010,7 +2010,7 @@ dif cccc
1.E12 1.E12
99X 99X
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f quicksort2.awk quicksort2.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f quicksort2.awk quicksort2.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
0.0000000000 0.0000000000
0.11111111111111111111111111111 0.11111111111111111111111111111
@ -2029,11 +2029,11 @@ dif cccc
1.E12 1.E12
99X 99X
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f asm.awk asm.s <asm.dat 2>&1 ../../cmd/awk/.libs/qseawk -f asm.awk asm.s <asm.dat 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
549 549
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f stripcomment.awk stripcomment.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f stripcomment.awk stripcomment.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -2045,7 +2045,7 @@ int main ()
return 0; return 0;
} }
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f wordfreq.awk wordfreq.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f wordfreq.awk wordfreq.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
distinctions 1 distinctions 1
list 1 list 1
@ -2073,7 +2073,7 @@ print 2
frequencies 1 frequencies 1
case 1 case 1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f hanoi.awk </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f hanoi.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
0 54321 0 54321
1 1
@ -2204,7 +2204,7 @@ case 1
2 2
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk -f indent.awk indent.dat </dev/stdin 2>&1 ../../cmd/awk/.libs/qseawk -f indent.awk indent.dat </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
#!/bin/sh #!/bin/sh

View File

@ -36,7 +36,15 @@ print_usage()
# MAIN # # MAIN #
################### ###################
QSEAWK=${QSEAWK:=../../cmd/awk/qseawk} [ -z "${QSEAWK}" ] && {
QSEAWK=../../cmd/awk/.libs/qseawk
[ -f "${QSEAWK}" ] || QSEAWK=../../cmd/awk/qseawk
}
[ -f "${QSEAWK}" -a -x "${QSEAWK}" ] || {
echo_so "the executable '${QSEAWK}' is not found or not executable"
exit 1
}
TMPFILE="${TMPFILE:=./regress.temp}" TMPFILE="${TMPFILE:=./regress.temp}"
OUTFILE="${OUTFILE:=./regress.out}" OUTFILE="${OUTFILE:=./regress.out}"
@ -158,6 +166,7 @@ PROGS="
run_scripts() run_scripts()
{ {
local valgrind="${1}"
echo "${PROGS}" > "${TMPFILE}" echo "${PROGS}" > "${TMPFILE}"
while read prog while read prog
@ -181,8 +190,8 @@ run_scripts()
[ -z "${redinfile}" ] && redinfile="/dev/stdin" [ -z "${redinfile}" ] && redinfile="/dev/stdin"
echo_title "${QSEAWK} ${awkopts} -f ${orgscript} ${datafile} <${redinfile} 2>&1" echo_title "${valgrind} ${QSEAWK} ${awkopts} -f ${orgscript} ${datafile} <${redinfile} 2>&1"
${QSEAWK} -o "${script}.dp" ${awkopts} -f ${script} ${datafile} <${redinfile} 2>&1 ${valgrind} ${QSEAWK} -o "${script}.dp" ${awkopts} -f ${script} ${datafile} <${redinfile} 2>&1
done < "${TMPFILE}" done < "${TMPFILE}"
@ -226,6 +235,15 @@ test)
rm -f "${OUTFILE}.test" rm -f "${OUTFILE}.test"
echo_so "TEST OK" echo_so "TEST OK"
;; ;;
leakcheck)
valgrind="`which valgrind 2> /dev/null || echo ""`"
[ -z "${valgrind}" ] && {
echo_so "valgrind not found. cannot perform this test"
exit 1
}
run_scripts "${valgrind} --leak-check=full --show-reachable=yes --track-fds=yes" 2>&1 > "${OUTFILE}.test"
echo_so "Inspect the '${OUTFILE}.test' file for any memory and file descriptor leaks."
;;
*) *)
echo_so "USAGE: $0 init" echo_so "USAGE: $0 init"
echo_so " $0 test" echo_so " $0 test"

135
qse/regress/sed/regress.sh Executable file
View File

@ -0,0 +1,135 @@
#!/bin/sh
echo_so()
{
tput smso
while [ $# -gt 0 ]
do
echo -n "$1 "
shift
done
echo
tput rmso
}
echo_title()
{
echo "--------------------------------------------------------------------------------"
while [ $# -gt 0 ]
do
echo -n "$1 "
echo -n "$1 " >/dev/stderr
shift
done
echo
echo > /dev/stderr
echo "--------------------------------------------------------------------------------"
}
print_usage()
{
echo_so "Usage: $0 init"
echo_so " $0 test"
}
###################
# MAIN #
###################
[ -z "${QSESED}" ] && {
QSESED=../../cmd/sed/.libs/qsesed
[ -f "${QSESED}" ] || QSESED=../../cmd/sed/qsesed
}
[ -f "${QSESED}" -a -x "${QSESED}" ] || {
echo_so "the executable '${QSESED}' is not found or not executable"
exit 1
}
TMPFILE="${TMPFILE:=./regress.temp}"
OUTFILE="${OUTFILE:=./regress.out}"
PROGS="
001.sed/001.dat//-n
002.sed/002.dat//
003.sed/003.dat//
004.sed/004.dat//
"
[ -x "${QSESED}" ] ||
{
echo "ERROR: ${QSESED} not found"
exit 1;
}
run_scripts()
{
local valgrind="$1"
echo "${PROGS}" > "${TMPFILE}"
while read prog
do
[ -z "${prog}" ] && continue
local script="`echo ${prog} | cut -d/ -f1`"
local datafile="`echo ${prog} | cut -d/ -f2`"
local redinfile="`echo ${prog} | cut -d/ -f3`"
local options="`echo ${prog} | cut -d/ -f4`"
[ -z "${script}" ] && continue
[ -f "${script}" ] ||
{
echo_so "${script} not found"
continue
}
[ -z "${redinfile}" ] && redinfile="/dev/stdin"
echo_title "${valgrind} ${QSESED} ${options} -f ${script} ${datafile} <${redinfile} 2>&1"
${valgrind} ${QSESED} ${options} -f ${script} ${datafile} <${redinfile} 2>&1
done < "${TMPFILE}"
rm -f "${TMPFILE}"
}
case $1 in
init)
rm -f *.dp
run_scripts > "${OUTFILE}"
rm -f *.dp
echo_so "INIT OK"
;;
test)
run_scripts > "${OUTFILE}.test"
# diff -q is not supported on old platforms.
# redirect output to /dev/null instead.
diff "${OUTFILE}" "${OUTFILE}.test" > /dev/null || {
echo_so "ERROR: Difference is found between expected output and actual output."
echo_so " The expected output is stored in '${OUTFILE}'."
echo_so " The actual output is stored in '${OUTFILE}.test'."
echo_so " You may execute 'diff ${OUTFILE} ${OUTFILE}.test' for more info."
exit 1
}
rm -f "${OUTFILE}.test"
echo_so "TEST OK"
;;
leakcheck)
valgrind="`which valgrind 2> /dev/null || echo ""`"
[ -z "${valgrind}" ] && {
echo_so "valgrind not found. cannot perform this test"
exit 1
}
run_scripts "${valgrind} --leak-check=full --show-reachable=yes --track-fds=yes" 2>&1 > "${OUTFILE}.test"
echo_so "Inspect the '${OUTFILE}.test' file for any memory and file descriptor leaks."
;;
*)
echo_so "USAGE: $0 init"
echo_so " $0 test"
echo_so " $0 leakcheck"
exit 1
;;
esac
exit 0