[gimp/soc-2010-cage] Bug 620604 - Description of "histogram" procedure is slightly inaccurate
- From: Michael Muré <mmure src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/soc-2010-cage] Bug 620604 - Description of "histogram" procedure is slightly inaccurate
- Date: Wed, 30 Jun 2010 22:06:16 +0000 (UTC)
commit c939bac0dd46e78ea342c741b55629c2e496bfe6
Author: Michael Natterer <mitch gimp org>
Date: Sat Jun 5 19:26:06 2010 +0200
Bug 620604 - Description of "histogram" procedure is slightly inaccurate
Fix totally broken value ranges of integer PDB parameters. Magically,
the bug was affecting only exactly the two cases mentioned in above
bug report.
* tools/pdbgen/pdb.pl (arg_parse): return <, <=, > and >= literally
instead of applying a mapping that was originally meant for
generated C code that would e.g. transform "0 <= int32 < 10" into
"if (value < 0 || value >= 10) fail". This inversion of all
operators is now wrong because PDB parameters have been turned into
GParamSpecs which always need inclusive ranges as min and max
values.
* tools/pdbgen/pdbgen.pl (arrayexpand): generated array length type
specs must be "0 <= int32", not "0 < int32".
* tools/pdbgen/app.pl: when generating integer param specs, check if
the value range is specified in terms of < instead of <=, and
add/subtract 1, resuting in the inclusive range needed for integer
GParamSpecs.
* app/pdb/color-cmds.c: regenerated, fixing the two broken ranges
mentioned in the bug report.
app/pdb/color-cmds.c | 4 ++--
tools/pdbgen/app.pl | 42 ++++++++++++++++++++++++++++++++++++------
tools/pdbgen/pdb.pl | 16 +---------------
tools/pdbgen/pdbgen.pl | 4 ++--
4 files changed, 41 insertions(+), 25 deletions(-)
---
diff --git a/app/pdb/color-cmds.c b/app/pdb/color-cmds.c
index b3e8ce0..bfa24a4 100644
--- a/app/pdb/color-cmds.c
+++ b/app/pdb/color-cmds.c
@@ -1116,13 +1116,13 @@ register_color_procs (GimpPDB *pdb)
gimp_param_spec_int32 ("start-range",
"start range",
"Start of the intensity measurement range",
- 0, 256, 0,
+ 0, 255, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("end-range",
"end range",
"End of the intensity measurement range",
- 0, 256, 0,
+ 0, 255, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_double ("mean",
diff --git a/tools/pdbgen/app.pl b/tools/pdbgen/app.pl
index f867449..2a143f1 100644
--- a/tools/pdbgen/app.pl
+++ b/tools/pdbgen/app.pl
@@ -324,8 +324,18 @@ g_param_spec_double ("$name",
CODE
}
elsif ($pdbtype eq 'int32') {
- $min = defined $typeinfo[0] ? $typeinfo[0] : G_MININT32;
- $max = defined $typeinfo[2] ? $typeinfo[2] : G_MAXINT32;
+ if (defined $typeinfo[0]) {
+ $min = ($typeinfo[1] eq '<') ? ($typeinfo[0] + 1) : $typeinfo[0];
+ }
+ else {
+ $min = G_MININT32;
+ }
+ if (defined $typeinfo[2]) {
+ $max = ($typeinfo[3] eq '<') ? ($typeinfo[2] - 1) : $typeinfo[2];
+ }
+ else {
+ $max = G_MAXINT32;
+ }
$default = exists $arg->{default} ? $arg->{default} : defined $typeinfo[0] ? $typeinfo[0] : 0;
$pspec = <<CODE;
gimp_param_spec_int32 ("$name",
@@ -336,8 +346,18 @@ gimp_param_spec_int32 ("$name",
CODE
}
elsif ($pdbtype eq 'int16') {
- $min = defined $typeinfo[0] ? $typeinfo[0] : G_MININT16;
- $max = defined $typeinfo[2] ? $typeinfo[2] : G_MAXINT16;
+ if (defined $typeinfo[0]) {
+ $min = ($typeinfo[1] eq '<') ? ($typeinfo[0] + 1) : $typeinfo[0];
+ }
+ else {
+ $min = G_MININT16;
+ }
+ if (defined $typeinfo[2]) {
+ $max = ($typeinfo[3] eq '<') ? ($typeinfo[2] - 1) : $typeinfo[2];
+ }
+ else {
+ $max = G_MAXINT16;
+ }
$default = exists $arg->{default} ? $arg->{default} : defined $typeinfo[0] ? $typeinfo[0] : 0;
$pspec = <<CODE;
gimp_param_spec_int16 ("$name",
@@ -348,8 +368,18 @@ gimp_param_spec_int16 ("$name",
CODE
}
elsif ($pdbtype eq 'int8') {
- $min = defined $typeinfo[0] ? $typeinfo[0] : 0;
- $max = defined $typeinfo[2] ? $typeinfo[2] : G_MAXUINT8;
+ if (defined $typeinfo[0]) {
+ $min = ($typeinfo[1] eq '<') ? ($typeinfo[0] + 1) : $typeinfo[0];
+ }
+ else {
+ $min = 0;
+ }
+ if (defined $typeinfo[2]) {
+ $max = ($typeinfo[3] eq '<') ? ($typeinfo[2] - 1) : $typeinfo[2];
+ }
+ else {
+ $max = G_MAXUINT8;
+ }
$default = exists $arg->{default} ? $arg->{default} : defined $typeinfo[0] ? $typeinfo[0] : 0;
$pspec = <<CODE;
gimp_param_spec_int8 ("$name",
diff --git a/tools/pdbgen/pdb.pl b/tools/pdbgen/pdb.pl
index 4ca1904..4058302 100644
--- a/tools/pdbgen/pdb.pl
+++ b/tools/pdbgen/pdb.pl
@@ -228,20 +228,6 @@ package Gimp::CodeGen::pdb;
# Split out the parts of an arg constraint
sub arg_parse {
- my %premap = (
- '<' => '<=',
- '>' => '>=',
- '<=' => '<',
- '>=' => '>'
- );
-
- my %postmap = (
- '<' => '>=',
- '>' => '<=',
- '<=' => '>',
- '>=' => '<'
- );
-
my $arg = shift;
if ($arg =~ /^enum (\w+)(.*)/) {
@@ -264,7 +250,7 @@ sub arg_parse {
\s* (\w+) \s*
(?:(<=|<) \s* ([+-.\dA-Z_][^\s]*))?
/x) {
- return ($3, $1, $2 ? $premap{$2} : $2, $5, $4 ? $postmap{$4} : $4);
+ return ($3, $1, $2, $5, $4);
}
}
diff --git a/tools/pdbgen/pdbgen.pl b/tools/pdbgen/pdbgen.pl
index 57444a0..57cd1e7 100755
--- a/tools/pdbgen/pdbgen.pl
+++ b/tools/pdbgen/pdbgen.pl
@@ -164,10 +164,10 @@ sub arrayexpand {
# We can't have negative lengths, but let them set a min number
unless (exists $arg->{type}) {
- $arg->{type} = '0 < int32';
+ $arg->{type} = '0 <= int32';
}
elsif ($arg->{type} !~ /^\s*\d+\s*</) {
- $arg->{type} = '0 < ' . $arg->{type};
+ $arg->{type} = '0 <= ' . $arg->{type};
}
$arg->{void_ret} = 1 if exists $_->{void_ret};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]