[gimp/gimp-2-6] Bug 620604 - Description of "histogram" procedure is slightly inaccurate
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-6] Bug 620604 - Description of "histogram" procedure is slightly inaccurate
- Date: Sat, 5 Jun 2010 17:44:23 +0000 (UTC)
commit 9f98dedd45fa4ddc1d58519b043fcf3ea4eae04a
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.
(cherry picked from commit 9dd373d86e71ac69301e4cbfaaeb4bee0eb5be6a)
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 56d6427..7e38ed1 100644
--- a/app/pdb/color-cmds.c
+++ b/app/pdb/color-cmds.c
@@ -1102,13 +1102,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 a67b749..92f498a 100644
--- a/tools/pdbgen/app.pl
+++ b/tools/pdbgen/app.pl
@@ -325,8 +325,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",
@@ -337,8 +347,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",
@@ -349,8 +369,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 8b2e99a..deabdf1 100644
--- a/tools/pdbgen/pdb.pl
+++ b/tools/pdbgen/pdb.pl
@@ -215,20 +215,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+)(.*)/) {
@@ -251,7 +237,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 f2e0ffb..e65ebd3 100755
--- a/tools/pdbgen/pdbgen.pl
+++ b/tools/pdbgen/pdbgen.pl
@@ -165,10 +165,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]