| @@ -1,16 +1,16 @@ | | | @@ -1,16 +1,16 @@ |
1 | #! /bin/sh | | 1 | #! /bin/sh |
2 | | | 2 | |
3 | # $NetBSD: mkoptions.sh,v 1.7 2024/04/06 14:20:27 kre Exp $ | | 3 | # $NetBSD: mkoptions.sh,v 1.8 2024/04/16 23:30:19 christos Exp $ |
4 | | | 4 | |
5 | # | | 5 | # |
6 | # It would be more sensible to generate 2 .h files, one which | | 6 | # It would be more sensible to generate 2 .h files, one which |
7 | # is for everyone to use, defines the "variables" and (perhaps) generates | | 7 | # is for everyone to use, defines the "variables" and (perhaps) generates |
8 | # the externs (though they could just be explicit in options.h) | | 8 | # the externs (though they could just be explicit in options.h) |
9 | # and one just for options.c which generates the initialisation. | | 9 | # and one just for options.c which generates the initialisation. |
10 | # | | 10 | # |
11 | # But then I'd have to deal with making the Makefile handle that properly... | | 11 | # But then I'd have to deal with making the Makefile handle that properly... |
12 | # (this is simpler there, and it just means a bit more sh compile time.) | | 12 | # (this is simpler there, and it just means a bit more sh compile time.) |
13 | | | 13 | |
14 | set -f | | 14 | set -f |
15 | IFS=' ' # blank, tab (no newline) | | 15 | IFS=' ' # blank, tab (no newline) |
16 | export LC_ALL=C # for sort consistency | | 16 | export LC_ALL=C # for sort consistency |
| @@ -42,28 +42,28 @@ exec 6> "${O_FILE}" | | | @@ -42,28 +42,28 @@ exec 6> "${O_FILE}" |
42 | printf ' */\n\n' | | 42 | printf ' */\n\n' |
43 | | | 43 | |
44 | printf '#ifdef DEFINE_OPTIONS\n' | | 44 | printf '#ifdef DEFINE_OPTIONS\n' |
45 | printf 'struct optent optlist[] = {\n' | | 45 | printf 'struct optent optlist[] = {\n' |
46 | } >"${OF}" | | 46 | } >"${OF}" |
47 | | | 47 | |
48 | FIRST=true | | 48 | FIRST=true |
49 | | | 49 | |
50 | ${SED:-sed} <"${IF}" \ | | 50 | ${SED:-sed} <"${IF}" \ |
51 | -e '/^$/d' \ | | 51 | -e '/^$/d' \ |
52 | -e '/^#/d' \ | | 52 | -e '/^#/d' \ |
53 | -e '/^[ ]*\//d' \ | | 53 | -e '/^[ ]*\//d' \ |
54 | -e '/^[ ]*\*/d' \ | | 54 | -e '/^[ ]*\*/d' \ |
55 | -e '/^[ ]*;/d' | | | 55 | -e '/^[ ]*;/d' | |
56 | sort -b -k2,2f -k2,2 | | | 56 | sort -k2b,2f -k2b,2 | |
57 | while read line | | 57 | while read line |
58 | do | | 58 | do |
59 | # Look for comments in various styles, and ignore them | | 59 | # Look for comments in various styles, and ignore them |
60 | # (these should generally be already removed by sed above) | | 60 | # (these should generally be already removed by sed above) |
61 | | | 61 | |
62 | case "${line}" in | | 62 | case "${line}" in |
63 | '') continue;; | | 63 | '') continue;; |
64 | /*) continue;; | | 64 | /*) continue;; |
65 | \**) continue;; | | 65 | \**) continue;; |
66 | \;*) continue;; | | 66 | \;*) continue;; |
67 | \#*) continue;; | | 67 | \#*) continue;; |
68 | esac | | 68 | esac |
69 | | | 69 | |