diff options
author | wkj <devnull@localhost> | 2004-05-17 03:22:35 +0000 |
---|---|---|
committer | wkj <devnull@localhost> | 2004-05-17 03:22:35 +0000 |
commit | aa83d77271f0d2be72067058f78abd1780f3b69e (patch) | |
tree | 14a24e73abb43ad0b7340a1623e077a733b0be33 /src/cmd/index/deroman | |
parent | a7eb134e8717c2ea831066891314cf74fa4a6ad3 (diff) | |
download | plan9port-aa83d77271f0d2be72067058f78abd1780f3b69e.tar.gz plan9port-aa83d77271f0d2be72067058f78abd1780f3b69e.tar.bz2 plan9port-aa83d77271f0d2be72067058f78abd1780f3b69e.zip |
More troff bits; if you want them elsewhere, feel free to repo copy them.
Diffstat (limited to 'src/cmd/index/deroman')
-rw-r--r-- | src/cmd/index/deroman | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/cmd/index/deroman b/src/cmd/index/deroman new file mode 100644 index 00000000..5129e511 --- /dev/null +++ b/src/cmd/index/deroman @@ -0,0 +1,18 @@ +awk ' # deroman +# Input: string (tab) [arab or roman] +# Output: string (tab) [arab] + +# Roman numeral n is replaced by arab n-1000 (e.g., iii -> -997) +BEGIN { FS = OFS = "\t" + # set a["i"] = 1, a["ii"] = 2, ... + s = "i ii iii iv v vi vii viii ix x" + s = s " xi xii xiii xiv xv xvi xvii xviii xix xx" + s = s " xxi xxii xxiii xxiv xxv xxvi xxvii xxviii xxix xxx" + n = split(s, b, " ") + for (i = 1; i <= n; i++) a[b[i]] = i + } +$2~/^[ivxlc]+$/ { if ($2 in a) $2 = -1000 + a[$2] + else print "deroman: bad number: " $0 | "cat 1>&2" + } + { print } +' $* |