lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 1 | #!/usr/bin/awk -f |
| 2 | # |
| 3 | # Usage: awk -f separate.awk foo.SUSv4.in |
| 4 | # Input: http://www.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html#tag_13_77_03_06 |
| 5 | # Output: foo-$CODE.SUSv4.syms, foo.SUSv4.syms |
| 6 | # |
| 7 | # Copyright (C) 2010 Bernhard Reutner-Fischer |
| 8 | # Public domain |
| 9 | |
| 10 | function get_code(line) |
| 11 | { |
| 12 | sub("\\]\\[.*", "", line) |
| 13 | sub("\\[", "", line) |
| 14 | sub(" ", "", line) |
| 15 | return line |
| 16 | } |
| 17 | BEGIN{ |
| 18 | code="";# feature set; XSI, OB XSI, CX, etc |
| 19 | |
| 20 | } |
| 21 | /\[Option Start\]/{ |
| 22 | code = get_code($0) |
| 23 | next |
| 24 | } |
| 25 | /\[Option End\]/{ code = ""; next; } |
| 26 | /.*/ { |
| 27 | if (!hdrname) { |
| 28 | split(FILENAME, fparts, ".") |
| 29 | hdrname = fparts[1] |
| 30 | stdname = fparts[2] |
| 31 | if (fparts[3] != "in") { |
| 32 | print "inputfilename may not be ok, exiting." |
| 33 | exit(1) |
| 34 | } |
| 35 | } |
| 36 | if (code) { |
| 37 | fname = hdrname "-" code "." stdname ".syms" |
| 38 | } else { |
| 39 | fname = hdrname "." stdname ".syms" |
| 40 | } |
| 41 | sub("^*", "", $0) |
| 42 | if (file[code]) { |
| 43 | print $0 >> fname |
| 44 | } else { |
| 45 | print $0 > fname |
| 46 | file[code] = 1 |
| 47 | } |
| 48 | } |