diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-07-11 13:24:47 +0200 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-07-11 13:29:35 +0200 |
commit | d4301bdbc057d0fdeb4bceaea693f59490197a74 (patch) | |
tree | 46aa0b3414a77ac477b85370d48af6b9fe4ac41c | |
parent | 8aa06f085b1ea12e3e4503364545c06fa037a624 (diff) | |
download | cmumble-d4301bdbc057d0fdeb4bceaea693f59490197a74.tar.gz cmumble-d4301bdbc057d0fdeb4bceaea693f59490197a74.tar.bz2 cmumble-d4301bdbc057d0fdeb4bceaea693f59490197a74.zip |
Use a sed script for generating messages.h
Drop the prior used shell script.
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rwxr-xr-x | src/gen_message.sh | 11 | ||||
-rw-r--r-- | src/gen_messages.sed | 25 |
4 files changed, 28 insertions, 13 deletions
diff --git a/configure.ac b/configure.ac index 0f18774..6aa8568 100644 --- a/configure.ac +++ b/configure.ac @@ -15,6 +15,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) # Check for programs AC_PROG_CC +AC_PROG_SED PKG_PROG_PKG_CONFIG() PKG_CHECK_MODULES(PROTOBUF, [libprotobuf-c],[], [ diff --git a/src/Makefile.am b/src/Makefile.am index be35cd2..c9b4b50 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -10,8 +10,8 @@ AM_CFLAGS = $(GCC_FLAGS) $(cmumble_SOURCES): messages.h mumble.pb-c.h -messages.h: messages.txt gen_message.sh - $(AM_V_GEN) ./gen_message.sh < $< > $@ +messages.h: messages.txt gen_messages.sed + $(AM_V_GEN) $(SED) -f gen_messages.sed $< > $@ mumble.pb-c.c mumble.pb-c.h: mumble.proto $(AM_V_GEN) $(PROTOBUF_EXECUTABLE) --c_out=. $< diff --git a/src/gen_message.sh b/src/gen_message.sh deleted file mode 100755 index 47b81e6..0000000 --- a/src/gen_message.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -echo "#ifndef _MESSAGES_H_" -echo "#define _MESSAGES_H_" -echo "#define MUMBLE_MSGS \\" -while read message -do - underscore_name=$(echo "$message" | sed -e "s/\([a-z]\)\([A-Z]\)/\1_\L\2/g" -e "s/[A-Z]*/\L\0/g") - echo -e "\tMUMBLE_MSG(${message}, ${underscore_name}) \\" -done -echo -echo "#endif" diff --git a/src/gen_messages.sed b/src/gen_messages.sed new file mode 100644 index 0000000..0bc51f1 --- /dev/null +++ b/src/gen_messages.sed @@ -0,0 +1,25 @@ +1 { +i\ +#ifndef _MESSAGES_H_ \ +#define _MESSAGES_H_ \ +\ +#define MUMBLE_MSGS \\ +} + +# Duplicate & Seperate with "," +s/^.*$/\0, \0/ + +# Lowercase and prefix uppercase characters that follow a lowercase one +:a; s/^\([^,]*, .*[a-z]\)\([A-Z]\)/\1_\L\2\E/g; ta + +# Lowercase remaining uppercase characters +s/\([^,]*, [a-z_]*\)\([A-Z]*\)/\1\L\2\E/g + +# Put template macro around +s/^.*$/\tMUMBLE_MSG(\0) \\/ + +$ { +a\ +\ +#endif /* _MESSAGES_H_ */ +} |