crossroads

Git mirror of https://crossroads.e-tunity.com/
git clone git://git.finwo.net/app/crossroads
Log | Files | Refs

e-txt2c (1499B)


      1 #!/bin/sh
      2 
      3 VER=1.04
      4 
      5 # ChangeLog:
      6 # 1.04  Call to e-copyright removed.
      7 # 1.03  -V shows more info
      8 # 1.02	In the text file, ' is changed to \' and \ is changed to \\
      9 # 1.01	-V flag implemented
     10 # 1.00	First version
     11 
     12 # e-txt2c: development tool
     13 # just write up your usage in a file "usage.txt", then run
     14 # 	e-txt2c DEFINENAME < usage.txt > usage.h
     15 # then include usage.h in your program and refer to define DEFINENAME
     16 # to address the string
     17 
     18 # check args
     19 if [ "$1" = "-V" ] ; then
     20     echo $VER TXT to C-string Translator
     21     exit 0
     22 fi
     23 
     24 if [ -z "$1" ] ; then
     25 	cat << ENDUSAGE 1>&2
     26 Usage: e-txt2c DEFINENAME <input.txt >output.h
     27 E.g., when writing up your usage() function, just put your text in usage.txt.
     28 Then run "e-txt2c USAGETEXT <usage.txt >usage.h" and include usage.h. Refer
     29 to your text using the define symbol USAGETEXT. Typically this is a rule
     30 in a Makefile, as in:
     31 	# my "main.c" includes "usage.h", so it is dependent on that
     32 	main.o: main.c usage.h
     33 
     34 	# how to make usage.h
     35 	usage.h: usage.txt
     36 		e-txt2c USAGETEXT <usage.txt >usage.h
     37 
     38 ENDUSAGE
     39 	exit 1
     40 fi
     41 
     42 cat << ENDWARNING
     43 
     44 /*
     45  * Warning: this file is auto-generated from an input file by e-txt2c.
     46  * Don't modify this, your changes will be overwritten (probably during
     47  * the next "make").
     48  * To change this text, find the sources, edit the text input, and
     49  * re-make the program.
     50  */
     51 
     52 ENDWARNING
     53 
     54 echo "#define $1 \\"
     55 
     56 sed \
     57 	-e 's:\\:\\\\:g' \
     58 	-e "s:':\\\':g" \
     59 	-e 's:":\\":g' \
     60  	-e 's:^:  ":'    \
     61 	-e 's:$:\\n" \\:'
     62 
     63 echo '  ""'