*** empty log message ***
This commit is contained in:
parent
d4aeb27b90
commit
f73fdd1276
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: misc.c,v 1.43 2006-11-29 02:54:15 bacon Exp $
|
||||
* $Id: misc.c,v 1.44 2006-12-04 07:17:12 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <ase/awk/awk_i.h>
|
||||
@ -839,6 +839,11 @@ ase_char_t* ase_awk_strxntok (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO: verify the following statement... */
|
||||
if (delim_mode == __DELIM_SPACES &&
|
||||
delim_len == 1 &&
|
||||
delim[0] != ASE_T(' ')) delim_mode = __DELIM_NOSPACES;
|
||||
}
|
||||
|
||||
if (delim_mode == __DELIM_NULL)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: rec.c,v 1.8 2006-11-29 02:54:16 bacon Exp $
|
||||
* $Id: rec.c,v 1.9 2006-12-04 07:17:12 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <ase/awk/awk_i.h>
|
||||
@ -10,7 +10,8 @@ static int __recomp_record_fields (
|
||||
const ase_char_t* str, ase_size_t len);
|
||||
|
||||
int ase_awk_setrec (
|
||||
ase_awk_run_t* run, ase_size_t idx, const ase_char_t* str, ase_size_t len)
|
||||
ase_awk_run_t* run, ase_size_t idx,
|
||||
const ase_char_t* str, ase_size_t len)
|
||||
{
|
||||
ase_awk_val_t* v;
|
||||
int errnum;
|
||||
|
15
ase/test/awk/cou-001.out
Normal file
15
ase/test/awk/cou-001.out
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
print $1,$3;
|
||||
}
|
||||
|
||||
USSR 275
|
||||
Canada 25
|
||||
China 1032
|
||||
USA 237
|
||||
Brazil 134
|
||||
India 746
|
||||
Mexico 78
|
||||
France 55
|
||||
Japan 120
|
||||
Germany 61
|
||||
England 56
|
29
ase/test/awk/cou-002.out
Normal file
29
ase/test/awk/cou-002.out
Normal file
@ -0,0 +1,29 @@
|
||||
BEGIN {
|
||||
__global7 = " ";
|
||||
printf ("%10s %6s %5s %s\n\n","COUNTRY","AREA","POP","CONTINENT");
|
||||
}
|
||||
|
||||
{
|
||||
printf ("%10s %6d %5d %s\n",$1,$2,$3,$4);
|
||||
area = (area + $2);
|
||||
pop = (pop + $3);
|
||||
}
|
||||
|
||||
END {
|
||||
printf ("\n%10s %6d %5d\n","TOTAL",area,pop);
|
||||
}
|
||||
COUNTRY AREA POP CONTINENT
|
||||
|
||||
USSR 8649 275 Asia
|
||||
Canada 3852 25 North America
|
||||
China 3705 1032 Asia
|
||||
USA 3615 237 North America
|
||||
Brazil 3286 134 South America
|
||||
India 1267 746 Asia
|
||||
Mexico 762 78 North America
|
||||
France 211 55 Europe
|
||||
Japan 144 120 Asia
|
||||
Germany 96 61 Europe
|
||||
England 94 56 Europe
|
||||
|
||||
TOTAL 25681 2819
|
6
ase/test/awk/cou-003.out
Normal file
6
ase/test/awk/cou-003.out
Normal file
@ -0,0 +1,6 @@
|
||||
(($3 / $2) >= 0.5)
|
||||
|
||||
India 1267 746 Asia
|
||||
Japan 144 120 Asia
|
||||
Germany 96 61 Europe
|
||||
England 94 56 Europe
|
5
ase/test/awk/cou-004.out
Normal file
5
ase/test/awk/cou-004.out
Normal file
@ -0,0 +1,5 @@
|
||||
($0 >= "M")
|
||||
|
||||
USSR 8649 275 Asia
|
||||
USA 3615 237 North America
|
||||
Mexico 762 78 North America
|
6
ase/test/awk/cou-005.out
Normal file
6
ase/test/awk/cou-005.out
Normal file
@ -0,0 +1,6 @@
|
||||
($1 < $4)
|
||||
|
||||
Canada 3852 25 North America
|
||||
Brazil 3286 134 South America
|
||||
Mexico 762 78 North America
|
||||
England 94 56 Europe
|
5
ase/test/awk/cou-006.out
Normal file
5
ase/test/awk/cou-006.out
Normal file
@ -0,0 +1,5 @@
|
||||
($2 < $3)
|
||||
|
||||
India 1267 746 Asia
|
||||
Mexico 762 78 North America
|
||||
France 211 55 Europe
|
6
ase/test/awk/cou-007.out
Normal file
6
ase/test/awk/cou-007.out
Normal file
@ -0,0 +1,6 @@
|
||||
/Asia/
|
||||
|
||||
USSR 8649 275 Asia
|
||||
China 3705 1032 Asia
|
||||
India 1267 746 Asia
|
||||
Japan 144 120 Asia
|
6
ase/test/awk/cou-008.out
Normal file
6
ase/test/awk/cou-008.out
Normal file
@ -0,0 +1,6 @@
|
||||
($4 !~ /Asia/)
|
||||
|
||||
USSR 8649 275 Asia
|
||||
China 3705 1032 Asia
|
||||
India 1267 746 Asia
|
||||
Japan 144 120 Asia
|
9
ase/test/awk/cou-009.out
Normal file
9
ase/test/awk/cou-009.out
Normal file
@ -0,0 +1,9 @@
|
||||
($4 + /Asia/)
|
||||
|
||||
Canada 3852 25 North America
|
||||
USA 3615 237 North America
|
||||
Brazil 3286 134 South America
|
||||
Mexico 762 78 North America
|
||||
France 211 55 Europe
|
||||
Germany 96 61 Europe
|
||||
England 94 56 Europe
|
6
ase/test/awk/cou-010.out
Normal file
6
ase/test/awk/cou-010.out
Normal file
@ -0,0 +1,6 @@
|
||||
($0 !~ /Asia/)
|
||||
|
||||
USSR 8649 275 Asia
|
||||
China 3705 1032 Asia
|
||||
India 1267 746 Asia
|
||||
Japan 144 120 Asia
|
2
ase/test/awk/cou-011.out
Normal file
2
ase/test/awk/cou-011.out
Normal file
@ -0,0 +1,2 @@
|
||||
($2 + /^[0-9]+$/)
|
||||
|
1
ase/test/awk/cou-012.awk
Normal file
1
ase/test/awk/cou-012.awk
Normal file
@ -0,0 +1 @@
|
||||
$4 == "Asia" && $3 > 500
|
4
ase/test/awk/cou-012.out
Normal file
4
ase/test/awk/cou-012.out
Normal file
@ -0,0 +1,4 @@
|
||||
(($4 == "Asia") && ($3 > 500))
|
||||
|
||||
China 3705 1032 Asia
|
||||
India 1267 746 Asia
|
1
ase/test/awk/cou-013.awk
Normal file
1
ase/test/awk/cou-013.awk
Normal file
@ -0,0 +1 @@
|
||||
$4 == "Asia" || $4 == "Europe"
|
9
ase/test/awk/cou-013.out
Normal file
9
ase/test/awk/cou-013.out
Normal file
@ -0,0 +1,9 @@
|
||||
(($4 == "Asia") || ($4 == "Europe"))
|
||||
|
||||
USSR 8649 275 Asia
|
||||
China 3705 1032 Asia
|
||||
India 1267 746 Asia
|
||||
France 211 55 Europe
|
||||
Japan 144 120 Asia
|
||||
Germany 96 61 Europe
|
||||
England 94 56 Europe
|
1
ase/test/awk/cou-014.awk
Normal file
1
ase/test/awk/cou-014.awk
Normal file
@ -0,0 +1 @@
|
||||
$4 ~ /^(Asia|Europe)$/
|
9
ase/test/awk/cou-014.out
Normal file
9
ase/test/awk/cou-014.out
Normal file
@ -0,0 +1,9 @@
|
||||
($4 !~ /^(Asia|Europe)$/)
|
||||
|
||||
USSR 8649 275 Asia
|
||||
China 3705 1032 Asia
|
||||
India 1267 746 Asia
|
||||
France 211 55 Europe
|
||||
Japan 144 120 Asia
|
||||
Germany 96 61 Europe
|
||||
England 94 56 Europe
|
1
ase/test/awk/cou-015.awk
Normal file
1
ase/test/awk/cou-015.awk
Normal file
@ -0,0 +1 @@
|
||||
/Asia/ || /Europe/
|
9
ase/test/awk/cou-015.out
Normal file
9
ase/test/awk/cou-015.out
Normal file
@ -0,0 +1,9 @@
|
||||
(/Asia/ || /Europe/)
|
||||
|
||||
USSR 8649 275 Asia
|
||||
China 3705 1032 Asia
|
||||
India 1267 746 Asia
|
||||
France 211 55 Europe
|
||||
Japan 144 120 Asia
|
||||
Germany 96 61 Europe
|
||||
England 94 56 Europe
|
1
ase/test/awk/cou-016.awk
Normal file
1
ase/test/awk/cou-016.awk
Normal file
@ -0,0 +1 @@
|
||||
/Asia|Europe/
|
9
ase/test/awk/cou-016.out
Normal file
9
ase/test/awk/cou-016.out
Normal file
@ -0,0 +1,9 @@
|
||||
/Asia|Europe/
|
||||
|
||||
USSR 8649 275 Asia
|
||||
China 3705 1032 Asia
|
||||
India 1267 746 Asia
|
||||
France 211 55 Europe
|
||||
Japan 144 120 Asia
|
||||
Germany 96 61 Europe
|
||||
England 94 56 Europe
|
1
ase/test/awk/cou-017.awk
Normal file
1
ase/test/awk/cou-017.awk
Normal file
@ -0,0 +1 @@
|
||||
/Canada/, /USA/
|
5
ase/test/awk/cou-017.out
Normal file
5
ase/test/awk/cou-017.out
Normal file
@ -0,0 +1,5 @@
|
||||
/Canada/,/USA/
|
||||
|
||||
Canada 3852 25 North America
|
||||
China 3705 1032 Asia
|
||||
USA 3615 237 North America
|
1
ase/test/awk/cou-018.awk
Normal file
1
ase/test/awk/cou-018.awk
Normal file
@ -0,0 +1 @@
|
||||
/Eurpoe/, /Africa/
|
2
ase/test/awk/cou-018.out
Normal file
2
ase/test/awk/cou-018.out
Normal file
@ -0,0 +1,2 @@
|
||||
/Eurpoe/,/Africa/
|
||||
|
1
ase/test/awk/cou-019.awk
Normal file
1
ase/test/awk/cou-019.awk
Normal file
@ -0,0 +1 @@
|
||||
FNR == 1, FNR == 5 { print FILENAME ": " $0; }
|
9
ase/test/awk/cou-019.out
Normal file
9
ase/test/awk/cou-019.out
Normal file
@ -0,0 +1,9 @@
|
||||
(__global6 == 1),(__global6 == 5) {
|
||||
print ((__global5 ~ ": ") ~ $0);
|
||||
}
|
||||
|
||||
cou-en.data: USSR 8649 275 Asia
|
||||
cou-en.data: Canada 3852 25 North America
|
||||
cou-en.data: China 3705 1032 Asia
|
||||
cou-en.data: USA 3615 237 North America
|
||||
cou-en.data: Brazil 3286 134 South America
|
1
ase/test/awk/cou-020.awk
Normal file
1
ase/test/awk/cou-020.awk
Normal file
@ -0,0 +1 @@
|
||||
FNR <= 5 { print FILENAME ": " $0; }
|
9
ase/test/awk/cou-020.out
Normal file
9
ase/test/awk/cou-020.out
Normal file
@ -0,0 +1,9 @@
|
||||
(__global6 <= 5) {
|
||||
print ((__global5 ~ ": ") ~ $0);
|
||||
}
|
||||
|
||||
cou-en.data: USSR 8649 275 Asia
|
||||
cou-en.data: Canada 3852 25 North America
|
||||
cou-en.data: China 3705 1032 Asia
|
||||
cou-en.data: USA 3615 237 North America
|
||||
cou-en.data: Brazil 3286 134 South America
|
1
ase/test/awk/cou-021.awk
Normal file
1
ase/test/awk/cou-021.awk
Normal file
@ -0,0 +1 @@
|
||||
$4 == "Asia" { print $1, 1000 * $2; }
|
8
ase/test/awk/cou-021.out
Normal file
8
ase/test/awk/cou-021.out
Normal file
@ -0,0 +1,8 @@
|
||||
($4 == "Asia") {
|
||||
print $1,(1000 * $2);
|
||||
}
|
||||
|
||||
USSR 8649000
|
||||
China 3705000
|
||||
India 1267000
|
||||
Japan 144000
|
6
ase/test/awk/cou-022.awk
Normal file
6
ase/test/awk/cou-022.awk
Normal file
@ -0,0 +1,6 @@
|
||||
BEGIN { FS = "\t"; OFS = "\t"; }
|
||||
#BEGIN { FS = OFS = "\t"; }
|
||||
$4 == "North America" { $4 = "NA"; }
|
||||
$4 == "South America" { $4 = "SA"; }
|
||||
{ print; }
|
||||
|
28
ase/test/awk/cou-022.out
Normal file
28
ase/test/awk/cou-022.out
Normal file
@ -0,0 +1,28 @@
|
||||
BEGIN {
|
||||
__global7 = " ";
|
||||
__global13 = " ";
|
||||
}
|
||||
|
||||
($4 == "North America") {
|
||||
$4 = "NA";
|
||||
}
|
||||
|
||||
($4 == "South America") {
|
||||
$4 = "SA";
|
||||
}
|
||||
|
||||
{
|
||||
print;
|
||||
}
|
||||
|
||||
USSR 8649 275 Asia
|
||||
Canada 3852 25 NA
|
||||
China 3705 1032 Asia
|
||||
USA 3615 237 NA
|
||||
Brazil 3286 134 SA
|
||||
India 1267 746 Asia
|
||||
Mexico 762 78 NA
|
||||
France 211 55 Europe
|
||||
Japan 144 120 Asia
|
||||
Germany 96 61 Europe
|
||||
England 94 56 Europe
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
names = ((names $1) " ");
|
||||
names = ((names ~ $1) ~ " ");
|
||||
}
|
||||
|
||||
END {
|
||||
|
Loading…
Reference in New Issue
Block a user