Add a utility to extract a message catalogs

This commit is contained in:
Přemysl Eric Janouch 2014-07-14 20:39:01 +02:00
parent b58ee27362
commit cc4ca46cc3
3 changed files with 23 additions and 2 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
# Build files # Build files
/zyklonb /zyklonb
/kike /kike
/kike.msg
# Qt Creator files # Qt Creator files
/ZyklonB.* /ZyklonB.*

View File

@ -1,12 +1,14 @@
SHELL = /bin/sh SHELL = /bin/sh
CC = clang CC = clang
CFLAGS = -ggdb -Wall -Wextra -std=c99 # -Wunused-function is pretty annoying here, as everything is static and not
# all parts of common.c are used in all the executables
CFLAGS = -ggdb -Wall -Wextra -std=c99 -Wno-unused-function
# -lpthread is only there for debugging (gdb & errno) # -lpthread is only there for debugging (gdb & errno)
LDFLAGS = `pkg-config --libs libssl` -lpthread LDFLAGS = `pkg-config --libs libssl` -lpthread
.PHONY: all clean .PHONY: all clean
targets = zyklonb kike targets = zyklonb kike kike.msg
all: $(targets) all: $(targets)
@ -15,6 +17,9 @@ clean:
zyklonb: src/zyklonb.c src/common.c src/siphash.c zyklonb: src/zyklonb.c src/common.c src/siphash.c
$(CC) src/zyklonb.c src/siphash.c -o $@ $(CFLAGS) $(LDFLAGS) $(CC) src/zyklonb.c src/siphash.c -o $@ $(CFLAGS) $(LDFLAGS)
kike: src/kike.c src/common.c src/siphash.c kike: src/kike.c src/common.c src/siphash.c
$(CC) src/kike.c src/siphash.c -o $@ $(CFLAGS) $(LDFLAGS) $(CC) src/kike.c src/siphash.c -o $@ $(CFLAGS) $(LDFLAGS)
kike.msg: src/kike.c
$(SHELL) kike-extract-messages.sh < $< > $@

15
kike-extract-messages.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/sh
LC_ALL=C exec awk '
BEGIN {
print "$quote \"";
print "$set 1";
}
/^\tIRC_(ERR|RPL)_[A-Z]+ *= *[0-9]+,?$/ {
match($3, /^[0-9]+/);
id[$1] = substr($3, RSTART, RLENGTH);
}
/^\t\[IRC_(ERR|RPL)_[A-Z]+\] *= *".*",?$/ {
z = substr($1, 2, length($1) - 2);
match($0, /".*"/);
print id[z] " " substr($0, RSTART, RLENGTH);
}'