diff options
author | Thomas Haller <thaller@redhat.com> | 2017-01-04 09:30:38 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-01-04 09:33:50 +0100 |
commit | 36ec46e8f86db03a9777c5885ff685ad8cf74957 (patch) | |
tree | 6a4a9d8ee5fff4ab479a4109aee94101b49680cd /tools | |
parent | c5f17a97ea8e4cee85c93ee9cfa04057f83e13ab (diff) | |
download | NetworkManager-36ec46e8f86db03a9777c5885ff685ad8cf74957.tar.gz |
docs: fix handling enums without explicit numeric value in "tools/enums-to-docbook.pl"
Previously, an enum that didn't explicitly specify a numeric value
would wrongly start counting at 1.
E.g.
typedef enum {
MY_VAL,
} Name;
would result in documentation with MY_VAL=1.
https://bugzilla.gnome.org/show_bug.cgi?id=776848
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/enums-to-docbook.pl | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/tools/enums-to-docbook.pl b/tools/enums-to-docbook.pl index d3d8c33c32..845598acff 100755 --- a/tools/enums-to-docbook.pl +++ b/tools/enums-to-docbook.pl @@ -62,8 +62,11 @@ sub inc { my $val = shift; - if ($val =~ /^\d+$/) { + if ($val =~ /^-?\d+$/) { my $len = length $val; + if ($val =~ /^-/ && ($val + 1 == 0)) { + $len = $len - 1 + } return sprintf "%0${len}d", $val + 1; } elsif ($val =~ /^0x(.+)$/) { my $len = length $1; @@ -117,7 +120,7 @@ if (/^\/\*\*$/) { $choice = undef; } elsif (/^typedef enum/) { # Start of an enum - $val = 0; + $val = -1; } elsif (/^\s+(\S+)\s+=\s+([^,\s]+)/) { # A choice with a literal value next unless @choices; |