aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-06-04 22:53:37 +1200
committerTom Ryder <tom@sanctum.geek.nz>2017-06-04 22:53:37 +1200
commitd931bdbf786e18a9d4abd6a513dcbbdcf9539d45 (patch)
treeef91ba6c1180269f06bde4e88fc3a9c43a805899
parentMerge branch 'master' into port/bsd/freebsd (diff)
parentMore tidying for mi5(1df) (diff)
downloaddotfiles-d931bdbf786e18a9d4abd6a513dcbbdcf9539d45.tar.gz
dotfiles-d931bdbf786e18a9d4abd6a513dcbbdcf9539d45.zip
Merge branch 'master' into port/bsd/freebsd
-rw-r--r--bin/mi5.awk28
-rw-r--r--bin/xrq.awk2
-rw-r--r--man/man1/mi5.1df8
3 files changed, 19 insertions, 19 deletions
diff --git a/bin/mi5.awk b/bin/mi5.awk
index 14f2ff2b..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,27 +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
- if (substr(src, i, length(unquote)) == unquote)
- iquo = 0
- }
+ # Look for end of comment and tip flag accordingly
+ if (iquo)
+ iquo = (substr(src, i, length(unquote)) != unquote)
# Inline macro expansion
else if (imac) {
@@ -74,15 +77,13 @@ 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
}
# Look for start of comment and tip flag accordingly
- if (substr(src, i, length(quote)) == quote)
- iquo = 1
+ iquo = (substr(src, i, length(quote)) == quote)
}
# Plain text mode
@@ -112,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
diff --git a/bin/xrq.awk b/bin/xrq.awk
index 5c9f7e96..686cf677 100644
--- a/bin/xrq.awk
+++ b/bin/xrq.awk
@@ -8,7 +8,7 @@ BEGIN {
# Check we have at least one resource name
if (ARGC < 2) {
- print "xrq: Need at least one resource name" | "cat 1>&2"
+ print "xrq: Need at least one resource name" | "cat >&2"
exit(2)
}
diff --git a/man/man1/mi5.1df b/man/man1/mi5.1df
index 04889b94..6466f35d 100644
--- a/man/man1/mi5.1df
+++ b/man/man1/mi5.1df
@@ -60,10 +60,10 @@ There's no way to escape the delimiters.
.P
Inline expansions cannot span multiple lines. Use blocks for that.
.P
-Doesn't cope at all with `changequote'. The ` and ' quote delimiters are
-hardcoded. If you need to change them, you can change the "quote" and "unquote"
-vars, but if you're getting to that point then you should probably write raw
-m4.
+Doesn't cope at all with `changequote'. If you need to specify different ones
+from this tool's point of view, you can change the "quote" and "unquote" vars
+in the same way as "open" and "shut", but if you're getting to that point then
+you should probably write raw m4.
.SH SEE ALSO
m4(1)
.SH AUTHOR