diff options
Diffstat (limited to 'test/readdir0.awk')
-rw-r--r-- | test/readdir0.awk | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/test/readdir0.awk b/test/readdir0.awk index c98ac674..2b7674a4 100644 --- a/test/readdir0.awk +++ b/test/readdir0.awk @@ -1,4 +1,9 @@ +# NOTE: This program is not a generalized parser for the output of 'ls'. +# It's job is to read the output of ls from the gawk source code directory, +# where we know there are no symbolic links, nor are there files with +# spaces in their file names, etc. BEGIN { + # analyze results from readdir extension while ((getline x < extout) > 0) { numrec++ if ((split(x, f, "/") == 3) && (f[3] == "u")) @@ -11,12 +16,29 @@ BEGIN { } } -{ - ino = $1 - name = $NF - type = substr($2, 1, 1) - if (type == "-") - type = "f" +BEGIN { + for (i = 1; (getline < dirlist) > 0; i++) { + # inode number is $1, filename is read of record + inode = $1 + $1 = "" + $0 = $0 + sub(/^ */, "") + names[i] = $0 + ino[names[i]] = inode + } + close(dirlist) + + for (j = 1; (getline < longlist) > 0; j++) { + type_let = substr($0, 1, 1) + if (type_let == "-") + type_let = "f" + type[$NF] = type_let + } + close(longlist) - printf "%s/%s/%s\n", ino, name, (ftype_unknown ? "u" : type) + if (i != j) + printf("mismatch: %d from `ls -afi' and %d from `ls -lna'\n", i, j) > "/dev/stderr" + + for (i = 1; i in names; i++) + printf("%s/%s/%s\n", ino[names[i]], names[i], (ftype_unknown ? "u" : type[names[i]])) } |