Improve the NSTR differentiation idiom.
[rsync.git] / define-from-md.awk
blob9f7f2bf3b0c87d2578f27ff69b0ed265b2886be3
1 #!/usr/bin/awk -f
3 # The caller must pass args: -v hfile=NAME rsync.1.md
5 BEGIN {
6 heading = "/* DO NOT EDIT THIS FILE! It is auto-generated from a list of values in " ARGV[1] "! */"
7 if (hfile ~ /compress/) {
8 define = "#define DEFAULT_DONT_COMPRESS"
9 prefix = "*."
10 } else {
11 define = "#define DEFAULT_CVSIGNORE"
12 prefix = ""
14 value_list = ""
17 /^ > [^ ]+$/ {
18 gsub(/`/, "")
19 if (value_list != "") value_list = value_list " "
20 value_list = value_list prefix $2
21 next
24 value_list ~ /\.gz / && hfile ~ /compress/ {
25 exit
28 value_list ~ /SCCS / && hfile ~ /cvsignore/ {
29 exit
32 value_list = ""
34 END {
35 if (value_list != "")
36 print heading "\n\n" define " \"" value_list "\"" > hfile
37 else {
38 print "Failed to find a value list in " ARGV[1] " for " hfile
39 exit 1