diff options
author | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2014-04-13 14:30:56 -0400 |
---|---|---|
committer | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2014-04-13 14:30:56 -0400 |
commit | 94e3f93395de538d73826e128281a3ea9591a5a9 (patch) | |
tree | 45257e4b024537c5e0e5a3037a99ea9765583c99 /test/readdir0.awk | |
parent | c4300d657ba49db0b6d0f0884f41a29622edc58b (diff) | |
parent | a4b59faf911743b30f2e6e979c4f9c1ea0669ac3 (diff) | |
download | egawk-94e3f93395de538d73826e128281a3ea9591a5a9.tar.gz egawk-94e3f93395de538d73826e128281a3ea9591a5a9.tar.bz2 egawk-94e3f93395de538d73826e128281a3ea9591a5a9.zip |
Merge branch 'master' into select
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]])) } |