File: define-from-md.awk

package info (click to toggle)
rsync 3.2.3-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 4,612 kB
  • sloc: ansic: 42,277; sh: 5,922; perl: 930; python: 825; asm: 665; makefile: 349; cpp: 289; awk: 191
file content (41 lines) | stat: -rwxr-xr-x 820 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/awk -f

# The caller must pass args: -v hfile=NAME rsync.1.md

BEGIN {
    heading = "/* DO NOT EDIT THIS FILE!  It is auto-generated from a list of values in " ARGV[1] "! */"
    if (hfile ~ /compress/) {
	define = "#define DEFAULT_DONT_COMPRESS"
	prefix = "*."
    } else {
	define = "#define DEFAULT_CVSIGNORE"
	prefix = ""
    }
    value_list = ""
}

/^    > [^ ]+$/ {
    gsub(/`/, "")
    if (value_list != "") value_list = value_list " "
    value_list = value_list prefix $2
    next
}

value_list ~ /\.gz / && hfile ~ /compress/ {
    exit
}

value_list ~ /SCCS / && hfile ~ /cvsignore/ {
    exit
}

value_list = ""

END {
    if (value_list != "")
	print heading "\n\n" define " \"" value_list "\"" > hfile
    else {
	print "Failed to find a value list in " ARGV[1] " for " hfile
	exit 1
    }
}