The branch, master has been updated via 5496eda5 Turn help-from-md into an awk script. from 353dec11 Avoid -e option to sed for BSD.
https://git.samba.org/?p=rsync.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 5496eda5d18afb67fdae4e482a97516cab1e0267 Author: Wayne Davison <wa...@opencoder.net> Date: Mon Jun 15 18:14:08 2020 -0700 Turn help-from-md into an awk script. ----------------------------------------------------------------------- Summary of changes: Makefile.in | 2 +- help-from-md | 32 -------------------------------- help-from-md.awk | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 33 deletions(-) delete mode 100755 help-from-md create mode 100755 help-from-md.awk Changeset truncated at 500 lines: diff --git a/Makefile.in b/Makefile.in index a0681c89..5e5038d7 100644 --- a/Makefile.in +++ b/Makefile.in @@ -104,7 +104,7 @@ options.o: latest-year.h help-rsync.h help-rsyncd.h flist.o: rounding.h help-rsync.h help-rsyncd.h: rsync.1.md - ./help-from-md "$(srcdir)/$<" $@ + awk -f $(srcdir)/help-from-md.awk -v helpfile=$@ $(srcdir)/$< rounding.h: rounding.c rsync.h proto.h @for r in 0 1 3; do \ diff --git a/help-from-md b/help-from-md deleted file mode 100755 index a5b61577..00000000 --- a/help-from-md +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -if [[ "$#" != 2 ]]; then - echo "Usage: $0 MD_FILE HELP_FILE.h" - exit 1 -fi - -mdfile="$1" -helpfile="$2" -newfile="$helpfile.new" -findfile="${helpfile/./\\.}" - -sed '1,/^\[comment\].*'"$findfile"'/d' <"$mdfile" | \ - sed '1,/^```/d' | \ - sed '/^```/,$d' | \ - sed 's/"/\\"/g' | \ - sed 's/^/ rprintf(F,"/' | \ - sed 's/$/\\n");/' >"$newfile" - -if [[ ! -s "$newfile" ]]; then - rm "$newfile" - echo "Discarding empty output for $helpfile file from $mdfile" - exit 1 -fi - -(cat <<EOT -/* DO NOT EDIT THIS FILE! It is auto-generated from the option list in $mdfile! */ - -EOT -cat "$newfile" -) >"$helpfile" -rm "$newfile" diff --git a/help-from-md.awk b/help-from-md.awk new file mode 100755 index 00000000..ca358c89 --- /dev/null +++ b/help-from-md.awk @@ -0,0 +1,40 @@ +#!/usr/bin/awk -f + +# The caller must set -v helpfile=help-NAME.h and pass arg NAME.NUM.md + +BEGIN { + heading = "/* DO NOT EDIT THIS FILE! It is auto-generated from the option list in " ARGV[1] "! */" + findcomment = helpfile + 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 > helpfile + else { + print "Failed to find " helpfile " section in " ARGV[1] + exit 1 + } +} -- The rsync repository. _______________________________________________ rsync-cvs mailing list rsync-cvs@lists.samba.org https://lists.samba.org/mailman/listinfo/rsync-cvs