aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-06-04 22:28:20 +1200
committerTom Ryder <tom@sanctum.geek.nz>2017-06-04 22:28:20 +1200
commit0baaec5d7e47ef29ddbc89a435ef4c05bdd619a1 (patch)
tree3dd5b082147e1fd9c8d21e8f63d647bc21d6ec4a /bin
parentRemove unneeded FD ID (diff)
downloaddotfiles-0baaec5d7e47ef29ddbc89a435ef4c05bdd619a1.tar.gz
dotfiles-0baaec5d7e47ef29ddbc89a435ef4c05bdd619a1.zip
More tidying for mi5(1df)
Diffstat (limited to 'bin')
-rw-r--r--bin/mi5.awk22
1 files changed, 12 insertions, 10 deletions
diff --git a/bin/mi5.awk b/bin/mi5.awk
index 6042a46c..fad03035 100644
--- a/bin/mi5.awk
+++ b/bin/mi5.awk
@@ -17,6 +17,9 @@ BEGIN {
unquote = "'"
if (!length(dnl))
dnl = "dnl"
+
+ # We do not start in a block
+ bmac = 0
}
# Fatal error function
@@ -42,26 +45,27 @@ NF == 1 && $1 == shut && bmac-- {
# and trailing whitespace
bmac && NF {
gsub(/(^ +| +$)/, "")
- print $0 "dnl"
+ print $0 dnl
}
# If not in a block, look for inlines to process
!bmac {
- # We'll parse one variable into another...
+ # We'll parse one variable into another.
src = $0
dst = ""
+ # Start off neither quoting nor macroing.
+ iquo = imac = 0
+
# Crude and slow, clansman. Your parser was no better than that of a clumsy
# child.
for (i = 1; i <= length(src); ) {
# Inline macro expansion: commented
- if (iquo) {
-
- # Look for end of comment and tip flag accordingly
+ # Look for end of comment and tip flag accordingly
+ if (iquo)
iquo = (substr(src, i, length(unquote)) != unquote)
- }
# Inline macro expansion
else if (imac) {
@@ -73,8 +77,7 @@ bmac && NF {
continue
if (substr(src, j, length(shut)) == shut) {
dst = dst quote
- i = j
- i += length(shut)
+ i = j + length(shut)
imac = 0
continue
}
@@ -110,8 +113,7 @@ bmac && NF {
}
# If we got down here, we can just add the next character and move on
- dst = dst substr(src, i, 1)
- i += 1
+ dst = dst substr(src, i++, 1)
}
# If we're still in a macro expansion or quote by this point, something's