diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 16:14:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 16:14:31 +0000 |
commit | 2d5707c7479eacb3b1ad98e01b53f56a88f8fb78 (patch) | |
tree | d9c334e83692851c02e3e1b8e65570c97bc82481 /help-from-md.awk | |
parent | Initial commit. (diff) | |
download | rsync-2d5707c7479eacb3b1ad98e01b53f56a88f8fb78.tar.xz rsync-2d5707c7479eacb3b1ad98e01b53f56a88f8fb78.zip |
Adding upstream version 3.2.7.upstream/3.2.7
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-x | help-from-md.awk | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/help-from-md.awk b/help-from-md.awk new file mode 100755 index 0000000..1900797 --- /dev/null +++ b/help-from-md.awk @@ -0,0 +1,40 @@ +#!/usr/bin/awk -f + +# The caller must pass args: -v hfile=help-NAME.h NAME.NUM.md + +BEGIN { + heading = "/* DO NOT EDIT THIS FILE! It is auto-generated from the option list in " ARGV[1] "! */" + findcomment = hfile + sub("\\.", "\\.", findcomment) + findcomment = "\\[comment\\].*" findcomment + backtick_cnt = 0 + prints = "" +} + +/^```/ { + backtick_cnt++ + next +} + +foundcomment { + if (backtick_cnt > 1) exit + if (backtick_cnt == 1) { + gsub(/"/, "\\\"") + prints = prints "\n rprintf(F,\"" $0 "\\n\");" + } + next +} + +$0 ~ findcomment { + foundcomment = 1 + backtick_cnt = 0 +} + +END { + if (foundcomment && backtick_cnt > 1) + print heading "\n" prints > hfile + else { + print "Failed to find " hfile " section in " ARGV[1] + exit 1 + } +} |