mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-07-21 18:24:49 +00:00
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
This commit is contained in:
parent
c5f17a97ea
commit
36ec46e8f8
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue