blueswir1 | 5824d65 | 2009-03-28 06:44:27 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | hxtoh() |
| 4 | { |
| 5 | flag=1 |
blueswir1 | fb21ced | 2009-03-29 09:06:43 +0000 | [diff] [blame] | 6 | while read -r str; do |
blueswir1 | 5824d65 | 2009-03-28 06:44:27 +0000 | [diff] [blame] | 7 | case $str in |
| 8 | HXCOMM*) |
| 9 | ;; |
Paolo Bonzini | 44d619b | 2017-07-07 17:46:46 +0200 | [diff] [blame] | 10 | STEXI*|ETEXI*) flag=$(($flag^1)) |
blueswir1 | 5824d65 | 2009-03-28 06:44:27 +0000 | [diff] [blame] | 11 | ;; |
| 12 | *) |
blueswir1 | 004efc9 | 2009-03-29 10:50:43 +0000 | [diff] [blame] | 13 | test $flag -eq 1 && printf "%s\n" "$str" |
blueswir1 | 5824d65 | 2009-03-28 06:44:27 +0000 | [diff] [blame] | 14 | ;; |
| 15 | esac |
| 16 | done |
| 17 | } |
| 18 | |
Paolo Bonzini | 43f187a | 2017-01-04 13:50:37 +0100 | [diff] [blame] | 19 | print_texi_heading() |
| 20 | { |
| 21 | if test "$*" != ""; then |
Markus Armbruster | de6b4f9 | 2017-10-02 16:03:00 +0200 | [diff] [blame] | 22 | title="$*" |
| 23 | printf "@subsection %s\n" "${title%:}" |
Paolo Bonzini | 43f187a | 2017-01-04 13:50:37 +0100 | [diff] [blame] | 24 | fi |
| 25 | } |
| 26 | |
blueswir1 | 5824d65 | 2009-03-28 06:44:27 +0000 | [diff] [blame] | 27 | hxtotexi() |
| 28 | { |
| 29 | flag=0 |
Jan Kiszka | 6c913ba | 2010-05-20 09:16:33 +0200 | [diff] [blame] | 30 | line=1 |
blueswir1 | fb21ced | 2009-03-29 09:06:43 +0000 | [diff] [blame] | 31 | while read -r str; do |
blueswir1 | 5824d65 | 2009-03-28 06:44:27 +0000 | [diff] [blame] | 32 | case "$str" in |
| 33 | HXCOMM*) |
| 34 | ;; |
Jan Kiszka | 6c913ba | 2010-05-20 09:16:33 +0200 | [diff] [blame] | 35 | STEXI*) |
| 36 | if test $flag -eq 1 ; then |
Daniel Shahaf | 5a1de0b | 2016-10-16 17:28:18 +0300 | [diff] [blame] | 37 | printf "line %d: syntax error: expected ETEXI, found '%s'\n" "$line" "$str" >&2 |
Jan Kiszka | 6c913ba | 2010-05-20 09:16:33 +0200 | [diff] [blame] | 38 | exit 1 |
| 39 | fi |
| 40 | flag=1 |
| 41 | ;; |
| 42 | ETEXI*) |
| 43 | if test $flag -ne 1 ; then |
Daniel Shahaf | 5a1de0b | 2016-10-16 17:28:18 +0300 | [diff] [blame] | 44 | printf "line %d: syntax error: expected STEXI, found '%s'\n" "$line" "$str" >&2 |
Jan Kiszka | 6c913ba | 2010-05-20 09:16:33 +0200 | [diff] [blame] | 45 | exit 1 |
| 46 | fi |
| 47 | flag=0 |
blueswir1 | 5824d65 | 2009-03-28 06:44:27 +0000 | [diff] [blame] | 48 | ;; |
| 49 | DEFHEADING*) |
Paolo Bonzini | 43f187a | 2017-01-04 13:50:37 +0100 | [diff] [blame] | 50 | print_texi_heading "$(expr "$str" : "DEFHEADING(\(.*\))")" |
blueswir1 | 5824d65 | 2009-03-28 06:44:27 +0000 | [diff] [blame] | 51 | ;; |
Michael Ellerman | a3adb7a | 2011-12-19 17:19:31 +1100 | [diff] [blame] | 52 | ARCHHEADING*) |
Paolo Bonzini | 43f187a | 2017-01-04 13:50:37 +0100 | [diff] [blame] | 53 | print_texi_heading "$(expr "$str" : "ARCHHEADING(\(.*\),.*)")" |
Michael Ellerman | a3adb7a | 2011-12-19 17:19:31 +1100 | [diff] [blame] | 54 | ;; |
blueswir1 | 5824d65 | 2009-03-28 06:44:27 +0000 | [diff] [blame] | 55 | *) |
Daniel Shahaf | 5a1de0b | 2016-10-16 17:28:18 +0300 | [diff] [blame] | 56 | test $flag -eq 1 && printf '%s\n' "$str" |
blueswir1 | 5824d65 | 2009-03-28 06:44:27 +0000 | [diff] [blame] | 57 | ;; |
| 58 | esac |
Jan Kiszka | 6c913ba | 2010-05-20 09:16:33 +0200 | [diff] [blame] | 59 | line=$((line+1)) |
blueswir1 | 5824d65 | 2009-03-28 06:44:27 +0000 | [diff] [blame] | 60 | done |
| 61 | } |
| 62 | |
| 63 | case "$1" in |
| 64 | "-h") hxtoh ;; |
| 65 | "-t") hxtotexi ;; |
| 66 | *) exit 1 ;; |
| 67 | esac |
blueswir1 | 5c2f8d2 | 2009-03-28 08:13:56 +0000 | [diff] [blame] | 68 | |
| 69 | exit 0 |