1 | #! /bin/bash |
---|
2 | # |
---|
3 | # This script converts the ASCII version of the manual saved by AmiPro |
---|
4 | # into a reasonably acceptable form of Texinfo. The output of this program |
---|
5 | # is fed into another program which inserts texinfo node and menu infomation. |
---|
6 | # |
---|
7 | # $Id$ |
---|
8 | # |
---|
9 | |
---|
10 | #set -x |
---|
11 | |
---|
12 | #rm -f *.txt |
---|
13 | orig=/usr1/home/joel/tmp/doc/relnotes |
---|
14 | inputfiles=`cd $orig ; echo *.txt` |
---|
15 | |
---|
16 | for i in $inputfiles |
---|
17 | do |
---|
18 | echo $i |
---|
19 | out=`echo $i | sed -e 's/\.txt$/.texi/'` |
---|
20 | # 1. Remove <ctl>-Z and <ctl>-M |
---|
21 | # 2. Tackle paragraph style issues |
---|
22 | # 3. Directive status code lines |
---|
23 | |
---|
24 | tr -d '\032\015' <${orig}/$i | |
---|
25 | sed -e 's/<Topic Lvl 0>/@chapter /' | |
---|
26 | sed -e 's/<Topic Lvl 1>/@section /' | |
---|
27 | sed -e 's/<Topic Lvl 2>/@subsection /' | |
---|
28 | sed -e 's/<Topic Lvl 3>/@subsection /' | |
---|
29 | sed -e 's/<Body Text>//' | |
---|
30 | sed -e 's/<Directive Tbl>/@item /' | |
---|
31 | sed -e 's/<Table Title>/@itemize /' | |
---|
32 | sed -e 's/<Bullet>/@item /' | |
---|
33 | sed -e 's/<Bullet 2>/@item /' | |
---|
34 | sed -e 's/<Table Text>/@item /' | |
---|
35 | sed -e 's/<Number List>/@item /' | |
---|
36 | sed -e 's/<Time Desc>/@item /' | |
---|
37 | while read line |
---|
38 | do |
---|
39 | case $line in |
---|
40 | "<C Code Exampl>"*"{") echo "@example"; echo "$line" ; read line;; |
---|
41 | "<C Code Exampl>"*"(") echo "@example"; echo "$line" ; read line;; |
---|
42 | "<C Code Exampl>"*");") echo "$line" ; echo "@end example" ;; |
---|
43 | "<C Code Exampl>"*"}"*";") echo "$line" ; echo "@end example" ;; |
---|
44 | "<C Code Exampl>"*",") echo "$line" ; read line ;; |
---|
45 | "<C Code Exampl>"*";") echo "$line" ; read line ;; |
---|
46 | *) echo "$line" ;; |
---|
47 | esac |
---|
48 | done | |
---|
49 | sed -e 's/<C Code Exampl>//' | |
---|
50 | sed -e 's/<Directive Tbl>/@item /' | |
---|
51 | sed -e 's/<Topic>/@subheading /' | |
---|
52 | sed -e 's/<Directive>/@page\ |
---|
53 | @subsection /' | |
---|
54 | sed -e 's/<Status Codes>//' | |
---|
55 | sed -e 's/^\(SUCCESSFUL\) - \(.*\)/@code{\1} - \2@*/' | |
---|
56 | sed -e 's/^\(TASK_EXITTED\) - \(.*\)/@code{\1} - \2@*/' | |
---|
57 | sed -e 's/^\(MP_NOT_CONFIGURED\) - \(.*\)/@code{\1} - \2@*/' | |
---|
58 | sed -e 's/^\(INVALID_NAME\) - \(.*\)/@code{\1} - \2@*/' | |
---|
59 | sed -e 's/^\(INVALID_ID\) - \(.*\)/@code{\1} - \2@*/' | |
---|
60 | sed -e 's/^\(TOO_MANY\) - \(.*\)/@code{\1} - \2@*/' | |
---|
61 | sed -e 's/^\(TIMEOUT\) - \(.*\)/@code{\1} - \2@*/' | |
---|
62 | sed -e 's/^\(OBJECT_WAS_DELETED\) - \(.*\)/@code{\1} - \2@*/' | |
---|
63 | sed -e 's/^\(INVALID_SIZE\) - \(.*\)/@code{\1} - \2@*/' | |
---|
64 | sed -e 's/^\(INVALID_ADDRESS\) - \(.*\)/@code{\1} - \2@*/' | |
---|
65 | sed -e 's/^\(INVALID_NUMBER\) - \(.*\)/@code{\1} - \2@*/' | |
---|
66 | sed -e 's/^\(NOT_DEFINED\) - \(.*\)/@code{\1} - \2@*/' | |
---|
67 | sed -e 's/^\(RESOURCE_IN_USE\) - \(.*\)/@code{\1} - \2@*/' | |
---|
68 | sed -e 's/^\(UNSATISFIED\) - \(.*\)/@code{\1} - \2@*/' | |
---|
69 | sed -e 's/^\(INCORRRECT_STATE\) - \(.*\)/@code{\1} - \2@*/' | |
---|
70 | sed -e 's/^\(ALREADY_SUSPENDED\) - \(.*\)/@code{\1} - \2@*/' | |
---|
71 | sed -e 's/^\(ILLEGAL_ON_SELF\) - \(.*\)/@code{\1} - \2@*/' | |
---|
72 | sed -e 's/^\(ILLEGAL_ON_REMOTE_OBJECT\) - \(.*\)/@code{\1} - \2@*/' | |
---|
73 | sed -e 's/^\(CALLED_FROM_ISR\) - \(.*\)/@code{\1} - \2@*/' | |
---|
74 | sed -e 's/^\(INVALID_PRIORITY\) - \(.*\)/@code{\1} - \2@*/' | |
---|
75 | sed -e 's/^\(INVALID_TIME_OF_DAY\) - \(.*\)/@code{\1} - \2@*/' | |
---|
76 | sed -e 's/^\(INVALID_NODE\) - \(.*\)/@code{\1} - \2@*/' | |
---|
77 | sed -e 's/^\(NOT_CONFIGURED\) - \(.*\)/@code{\1} - \2@*/' | |
---|
78 | sed -e 's/^\(NOT_OWNER_OF_RESOURCE\) - \(.*\)/@code{\1} - \2@*/' | |
---|
79 | sed -e 's/^\(NOT_IMPLEMENTED\) - \(.*\)/@code{\1} - \2@*/' | |
---|
80 | sed -e 's/^\(INTERNAL_ERROR\) - \(.*\)/@code{\1} - \2@*/' | |
---|
81 | sed -e 's/^\(NO_MEMORY\) - \(.*\)/@code{\1} - \2@*/' | |
---|
82 | cat >$out |
---|
83 | done |
---|