summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorloganek <marcin.kolny@gmail.com>2013-07-31 19:14:59 +0200
committerMurray Cumming <murrayc@murrayc.com>2013-08-02 12:08:00 +0200
commite263011deb092730e6599414581ac52cae5523c3 (patch)
treea032a9b36b38d1e3f34075c6b5fe9a3b580ccfbc /tools
parentfc35fb6a7d16631b1d120631c4fc982f14e09a96 (diff)
downloadglibmm-e263011deb092730e6599414581ac52cae5523c3.tar.gz
enums.pl: fixed multi-argument defines as enum values
Diffstat (limited to 'tools')
-rwxr-xr-xtools/enum.pl30
1 files changed, 28 insertions, 2 deletions
diff --git a/tools/enum.pl b/tools/enum.pl
index 844b9245..c8dd301b 100755
--- a/tools/enum.pl
+++ b/tools/enum.pl
@@ -196,8 +196,33 @@ sub process($$)
my $unknown_val = "";
my $unknown_base = "";
my $unknown_increment = 0;
- foreach my $i (split(/,/, $line))
+
+ my @lines = split(/,/, $line);
+ my $iter = 0;
+
+ while ($iter < scalar @lines)
{
+ my $brackets_count = 0;
+ my $begin = $iter;
+
+ # ignore ',' inside () brackets
+ # except '(' and ')' enum values
+ if ($lines[$iter] =~ /^\s*\S+\s*=\s*'[\(\)]'$/)
+ {
+ $iter++;
+ }
+ else
+ {
+ do
+ {
+ $brackets_count += () = $lines[$iter] =~ /\(/g;
+ $brackets_count -= () = $lines[$iter] =~ /\)/g;
+ $iter++;
+ } while ($iter < scalar @lines && $brackets_count != 0);
+ }
+
+ my $i = join(',', @lines[$begin..$iter-1]);
+
# remove leading and trailing spaces.
$i =~ s/^\s+//;
$i =~ s/\s+$//;
@@ -255,7 +280,8 @@ sub process($$)
# if name with other name exists [like MY_FLAG_VALUE = MY_PREV_FLAG_VALUE
# or ~(MY_PREV_FLAG_VALUE | MY_EARLIER_VALUE | (1 << 5) - 1 | 0x200)].
# [MY_FLAG MY_OTHER_FLAG is also supported - note lack of equal char.]
- elsif ($i =~ /^(\S+)\s*=?\s*([ _x0-9a-fA-Z|()<~]+)$/)
+ # [SOME_DEFINITION([X, [Y, [...]]]) definition is also supported.]
+ elsif ($i =~ /^(\S+)\s*=?\s*([ _x0-9a-fA-Z|()<~,]+)$/)
{
my ($tmp1, $tmp2) = ($1, $2);
push(@c_names, $tmp1);