The sieve extension 'vacation-seconds' contains a dash, which is not an
allowed character for C identifiers [A-Z_a-z][0-9A-Z_a-z]*.
Replace all other characters by _ when generating IMAP_ENUMs.

Signed-off-by: Philipp Hahn <h...@univention.de>
---
 tools/config2header |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/tools/config2header b/tools/config2header
index 75b044e..93b0698 100755
--- a/tools/config2header
+++ b/tools/config2header
@@ -164,6 +164,7 @@ while (<STDIN>) {
            # strip quotes from default value
            $def = substr($2, 1, -1);
            $e = "IMAP_ENUM_" . uc($opt) . "_" . uc($def);
+           $e =~ s/[^0-9A-Z_a-z]/_/g;
            $def = $use_gcc_extension
                        ? "(union config_value)((enum enum_value) $e)"
                        : "{(void *)($e)}";
@@ -171,6 +172,7 @@ while (<STDIN>) {
            # output the enum_options
            foreach $v (@values) {
                $e = "IMAP_ENUM_" . uc($opt) . "_" . uc($v);
+               $e =~ s/[^0-9A-Z_a-z]/_/g;
                $enums .= " { \"$v\" , $e },\n     ";
 
                # if this is the first enum value, normalize to zero
@@ -214,7 +216,9 @@ while (<STDIN>) {
            @values = split(' ', $def);
            $e = "";
            foreach $v (@values) {
-               $e .= "IMAP_ENUM_" . uc($opt) . "_" . uc($v) . "\n\t\t\t | ";
+               my $ev = "IMAP_ENUM_" . uc($opt) . "_" . uc($v);
+               $ev =~ s/[^0-9A-Z_a-z]/_/g;
+               $e .= "$ev\n\t\t\t | ";
            }
            $e .= "0";
            $def = $use_gcc_extension
@@ -225,6 +229,7 @@ while (<STDIN>) {
            @values = eval $4;
            foreach $v (@values) {
                $e = "IMAP_ENUM_" . uc($opt) . "_" . uc($v);
+               $e =~ s/[^0-9A-Z_a-z]/_/g;
                $enums .= " { \"$v\" , $e },\n     ";
 
                # add the corresponding bit value
-- 
1.7.1

Reply via email to