|
Packit Service |
f629e6 |
# strftime.awk ; test the strftime code
|
|
Packit Service |
f629e6 |
#
|
|
Packit Service |
f629e6 |
# input is the output of `date', see Makefile.in
|
|
Packit Service |
f629e6 |
|
|
Packit Service |
f629e6 |
BEGIN {
|
|
Packit Service |
f629e6 |
maxtries = 10
|
|
Packit Service |
f629e6 |
# On DOS/Windows, DATECMD is set by the Makefile to point to
|
|
Packit Service |
f629e6 |
# Unix-like 'date' command.
|
|
Packit Service |
f629e6 |
datecmd = DATECMD
|
|
Packit Service |
f629e6 |
if (datecmd == "")
|
|
Packit Service |
f629e6 |
datecmd = "date"
|
|
Packit Service |
f629e6 |
fmt = "%a %b %e %H:%M:%S %Z %Y"
|
|
Packit Service |
f629e6 |
|
|
Packit Service |
f629e6 |
# loop until before equals after, thereby protecting
|
|
Packit Service |
f629e6 |
# against a race condition where the seconds field might have
|
|
Packit Service |
f629e6 |
# incremented between running date and strftime
|
|
Packit Service |
f629e6 |
i = 0
|
|
Packit Service |
f629e6 |
while (1) {
|
|
Packit Service |
f629e6 |
if (++i > maxtries) {
|
|
Packit Service |
f629e6 |
printf "Warning: this system is so slow that after %d attempts, we could never get two sequential invocations of strftime to give the same result!\n", maxtries > "/dev/stderr"
|
|
Packit Service |
f629e6 |
break
|
|
Packit Service |
f629e6 |
}
|
|
Packit Service |
f629e6 |
before = strftime(fmt)
|
|
Packit Service |
f629e6 |
datecmd | getline sd
|
|
Packit Service |
f629e6 |
after = strftime(fmt)
|
|
Packit Service |
f629e6 |
close(datecmd)
|
|
Packit Service |
f629e6 |
if (before == after) {
|
|
Packit Service |
f629e6 |
if (i > 1)
|
|
Packit Service |
f629e6 |
printf "Notice: it took %d loops to get the before and after strftime values to match\n", i > "/dev/stderr"
|
|
Packit Service |
f629e6 |
break
|
|
Packit Service |
f629e6 |
}
|
|
Packit Service |
f629e6 |
}
|
|
Packit Service |
f629e6 |
print sd > "strftime.ok"
|
|
Packit Service |
f629e6 |
print after > OUTPUT
|
|
Packit Service |
f629e6 |
}
|