File: gen-ent

package info (click to toggle)
elinks 0.18.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 23,352 kB
  • sloc: ansic: 156,569; cpp: 30,139; sh: 7,719; python: 4,031; perl: 2,183; pascal: 1,670; makefile: 995; javascript: 904; yacc: 295; lisp: 125; awk: 79; ruby: 70
file content (28 lines) | stat: -rwxr-xr-x 641 bytes parent folder | download | duplicates (9)
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
#!/bin/sh

echo
echo Generating entity table.

sed -n '/^[^#]/,$p' < entities.txt | while read line; do \
		name=$(echo "$line" | cut -f 1); \
		code=$(echo "$line" | cut -f 3); \
		desc=$(echo "$line" | cut -f 4 | sed 's/# //'); \
		test "$code" = "0x????" && continue
		printf "\t{ %-12s %s }, /* %-46s */\n" \
			"\"$name\"," "$code" "$desc"; \
	done | LC_ALL=C sort > tmp
N=`cat tmp | wc -l`

cat > ../src/intl/entity.inc <<EOF
/* Automatically generated by gen-ent */

static const struct entity { char *s; unicode_val_T c; } entities [$(expr $N + 1)] = {
$(cat tmp)
	{ NULL, 0 }
};

#define N_ENTITIES $N
EOF
rm -f tmp
echo Done.
echo