Skip to content

Commit

Permalink
Fixed failure when temporary directory is created under ${RUNAWK_TMPD…
Browse files Browse the repository at this point in the history
…IR}.

Improve regression test for this case.
  • Loading branch information
cheusov committed Nov 7, 2012
1 parent 7a691ae commit 6a0aa4c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
23 changes: 17 additions & 6 deletions examples/demo_tmpfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,24 @@
# This demo generates temporary file names and outputs them to stdout

BEGIN {
tmpfile1 = tmpfile()
tmpfile2 = tmpfile()
tmpfile3 = tmpfile()
tmpfile1 = tmpfile()
tmpfile2 = tmpfile()
tmpsubdir = tmpfile()

print tmpfile1
print tmpfile2
print tmpfile3
print "file 1" > tmpfile1

print "file 2" > tmpfile2

system("mkdir " tmpsubdir)

tmpfile3 = tmpsubdir "/file3"
print "file 3" > tmpfile3

close(tmpfile1)
close(tmpfile2)
close(tmpfile3)

system("cat " tmpfile1 " " tmpfile2 " " tmpfile3)

exitnow(0)
}
1 change: 0 additions & 1 deletion runawk/file_hier.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ void file_hier (
if (0 == lstat (buffer, &sb)){
if (S_ISDIR (sb.st_mode)){
file_hier (buffer, proc_file, proc_dir);
proc_dir (buffer);
}else{
proc_file (buffer);
}
Expand Down
2 changes: 1 addition & 1 deletion runawk/runawk.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ static dynarray_t includes;
static void remove_file (const char *fn)
{
if (unlink (fn)){
fprintf (stderr, "rm(\"%s\") failed: %s\n", fn, strerror (errno));
fprintf (stderr, "unlink(\"%s\") failed: %s\n", fn, strerror (errno));
}
}

Expand Down
6 changes: 3 additions & 3 deletions test/test.out
Original file line number Diff line number Diff line change
Expand Up @@ -969,9 +969,9 @@ $1=12
NF=0
--------------------------------------------------
------ args: ../examples/demo_tmpfile
/tmp/awk.XXXX/0
/tmp/awk.XXXX/1
/tmp/awk.XXXX/2
file 1
file 2
file 3
--------------------------------------------------
------ args: ../examples/demo_trim ../examples/demo_trim.in
trim_l("Van Der Graaf Generator ")="Van Der Graaf Generator "
Expand Down

0 comments on commit 6a0aa4c

Please sign in to comment.