From 1d167ce6113221a66f84f910fc77568d61d75173 Mon Sep 17 00:00:00 2001 From: Jehan Date: Sun, 1 Feb 2026 19:19:55 +0100 Subject: [PATCH] =?UTF-8?q?pdb:=20better=20deprecated=20message,=20assumin?= =?UTF-8?q?g=20it=20can=20be=20a=20function,=20GEGL=20op=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … or a content to use as-is. Until now, it was assuming the deprecated content was a function. So if I want to deprecate in favor of a GEGL op (e.g. "gimp:levels"), we'd have warnings showing a "Deprecated: Use gimp:levels() instead". Now it will try to recognize the type of suggested replacement with a basic heuristic: if there is a space, it'll just use the replacement text as-is; else if there is a colon, it'll assume it's a filter name. Else it assumes it's a replacement function, as it used to. --- pdb/app.pl | 25 +++++++++++++++++++++++-- pdb/lib.pl | 19 ++++++++++++++++--- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/pdb/app.pl b/pdb/app.pl index c5773cb159..fcf0031a56 100644 --- a/pdb/app.pl +++ b/pdb/app.pl @@ -935,13 +935,29 @@ sub generate { $help .= "Deprecated: There is no replacement for this procedure."; } else { + my $replacement = $proc->{deprecated}; + chomp $replacement; + if ($replacement =~ / /) { + # Use the deprecated string as-is. + $replacement =~ s/"/\\"/g; + } + elsif ($replacement =~ /:/) { + # Replacement is a GEGL operation. + $replacement = "filter \\\"$replacement\\\""; + } + else { + # Replacement is another function. + $replacement =~ s/-/_/g; + $replacement .= '()'; + } + if (!$blurb) { $blurb = "Deprecated: Use '$proc->{deprecated}' instead."; } if ($help) { $help .= "\n\n"; } - $help .= "Deprecated: Use '$proc->{deprecated}' instead."; + $help .= "Deprecated: Use $replacement instead."; } } @@ -980,9 +996,14 @@ sub generate { CODE if ($proc->{deprecated}) { + my $replacement = $proc->{deprecated}; + chomp $replacement; + if ($replacement =~ /"/) { + $replacement =~ s/"/\\"/g; + } $out->{register} .= <{deprecated}"); + "$replacement"); CODE } diff --git a/pdb/lib.pl b/pdb/lib.pl index 8fe10e54f6..d47baf532e 100644 --- a/pdb/lib.pl +++ b/pdb/lib.pl @@ -561,8 +561,21 @@ CODE "for this procedure."); } else { - my $underscores = $proc->{deprecated}; - $underscores =~ s/-/_/g; + my $replacement = $proc->{deprecated}; + chomp $replacement; + if ($replacement =~ / /) { + # Use the deprecated string as-is. + #$replacement =~ s/"/\\"/g; + } + elsif ($replacement =~ /:/) { + # Replacement is a GEGL operation. + $replacement = "filter \"$replacement\""; + } + else { + # Replacement is another function. + $replacement =~ s/-/_/g; + $replacement .= '()'; + } if ($proc->{blurb}) { $procdesc = &desc_wrap($proc->{blurb}) . "\n *\n"; @@ -571,7 +584,7 @@ CODE $procdesc .= &desc_wrap($proc->{help}) . "\n *\n"; } $procdesc .= &desc_wrap("Deprecated: " . - "Use $underscores() instead."); + "Use $replacement instead."); } } else {