~kevin8t8/mutt

mutt/txt2c.sh -rwxr-xr-x 625 bytes
d5a18cca — Vincent Lefevre Updated French translation. 22 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/sh

txt2c_fallback () {
	# consumes stdin

	# declaration
	echo "unsigned char $1[] = "

	# initializer - filter out unwanted characters, then convert problematic
	# or odd-looking sequences.  The result is a sequence of quote-bounded
	# C strings, which the compiler concatenates into a single C string.
	tr -c '\011\012\015\040[!-~]' '?' |
	sed \
	    -e 's/\\/\\\\/g' \
	    -e 's/"/\\"/g' \
	    -e 's/??/\\?\\?/g' \
	    -e 's/	/\\t/g' \
	    -e 's/
/\\r/g' \
	    -e 's/^/	"/g' \
	    -e 's/$/\\n"/g'
	echo ";"
}

if ./txt2c test </dev/null >/dev/null 2>&1; then
    ./txt2c "$1"
else
    txt2c_fallback "$1"
fi