From: Wayne Davison Date: Mon, 15 Jun 2020 01:49:38 +0000 (-0700) Subject: Add a warning header to the generated help-*.h files. X-Git-Tag: v3.2.0pre2~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=775f64f4b8a9afdd73e1e4e8aba06944e58d1d14;p=thirdparty%2Frsync.git Add a warning header to the generated help-*.h files. --- diff --git a/Makefile.in b/Makefile.in index f6dd515b..a0681c89 100644 --- a/Makefile.in +++ b/Makefile.in @@ -104,14 +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 - @sed -e '1,/^\[comment\].*$@/d' \ - -e '1,/^```/d' \ - -e '/^```/,$$d' \ - -e 's/"/\\"/g' \ - -e 's/^/ rprintf(F,"/' \ - -e 's/$$/\\n");/' \ - <"$(srcdir)/$<" >$@ - @if ! test -s $@; then rm -f $@ ; echo "The Makefile generated an empty file: $@" ; exit 1 ; fi + ./help-from-md "$(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 new file mode 100755 index 00000000..21f49cd2 --- /dev/null +++ b/help-from-md @@ -0,0 +1,33 @@ +#!/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 -e '1,/^\[comment\].*'"$findfile"'/d' \ + -e '1,/^```/d' \ + -e '/^```/,$d' \ + -e 's/"/\\"/g' \ + -e 's/^/ rprintf(F,"/' \ + -e 's/$/\\n");/' \ + <"$mdfile" >"$newfile" + +if [[ ! -s "$newfile" ]]; then + rm "$newfile" + echo "Discarding empty output for $helpfile file from $mdfile" + exit 1 +fi + +(cat <"$helpfile" +rm "$newfile"