r25115: move normalizing of the define string into a function
authorStefan Metzmacher <metze@samba.org>
Wed, 12 Sep 2007 12:36:42 +0000 (12:36 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 20:06:42 +0000 (15:06 -0500)
and replace '-' with '_' as '-' isn't a string constant in C

jelmer: I assume the "..". for the public header was a bug...

metze

source/script/mkproto.pl

index f09d99243f454f277699c99ee3985042c1665dd4..5c4f71e8a4c0aa0edae56c44b316e66e76233ae0 100755 (executable)
@@ -68,20 +68,24 @@ GetOptions(
        'help' => \&usage
 ) or exit(1);
 
        'help' => \&usage
 ) or exit(1);
 
-if (not defined($public_define) and defined($public_file)) {
-       $public_define = ".." . uc($public_file) . "__";
-       $public_define =~ tr{./}{__};
-} elsif (not defined($public_define)) {
-       $public_define = '_PROTO_H_';
-}
+sub normalize_define($$)
+{
+       my ($define, $file) = @_;
+
+       if (not defined($define) and defined($file)) {
+               $define = "__" . uc($file) . "__";
+               $define =~ tr{./}{__};
+               $define =~ tr{\-}{_};
+       } elsif (not defined($define)) {
+               $define = '_PROTO_H_';
+       }
 
 
-if (not defined($private_define) and defined($private_file)) {
-       $private_define = "__" . uc($private_file) . "__";
-       $private_define =~ tr{./}{__};
-} elsif (not defined($public_define)) {
-       $public_define = '_PROTO_H_';
+       return $define;
 }
 
 }
 
+$public_define = normalize_define($public_define, $public_file);
+$private_define = normalize_define($private_define, $private_file);
+
 if ((defined($private_file) and defined($public_file) and ($private_file eq $public_file)) or 
        (not defined($private_file) and not defined($public_file))) {
        $private_data = $public_data;
 if ((defined($private_file) and defined($public_file) and ($private_file eq $public_file)) or 
        (not defined($private_file) and not defined($public_file))) {
        $private_data = $public_data;