After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 663576 - make -C plug-ins/script-fu check-for-deprecated-procedures-in-script-fu lists files that do not use deprecated functions
make -C plug-ins/script-fu check-for-deprecated-procedures-in-script-fu lists...
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Script-Fu
git master
Other All
: Normal minor
: 2.10
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2011-11-07 17:59 UTC by Alexis Wilhelm
Modified: 2018-01-01 13:26 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch (1.59 KB, patch)
2011-11-07 18:02 UTC, Alexis Wilhelm
none Details | Review
smaller patch (1.28 KB, patch)
2011-11-09 08:53 UTC, Alexis Wilhelm
none Details | Review
patch (1.29 KB, patch)
2017-12-30 12:18 UTC, Alexis Wilhelm
none Details | Review

Description Alexis Wilhelm 2011-11-07 17:59:24 UTC
See bug #647834, comment #9.

grep treats - as a non-word character, so `grep -w gimp-text` finds gimp-text-font, for example. Moreover, some calls are commented out, so we should not worry about them.

This patch fixes that. Also, I replaced the inner loop with a regexp, so now it is much faster.
Comment 1 Alexis Wilhelm 2011-11-07 18:02:23 UTC
Created attachment 200902 [details] [review]
patch
Comment 2 Kevin Cozens 2011-11-08 02:49:08 UTC
The original version could have been fixed by appending \\s to the regexp used to look for the procedure name. The patch adds the requirement that the machine used to build GIMP must have tr, sed, cut, and uniq in addition to grep to use the check-for-deprecated-procedures-in-script-fu make target. Is it safe to assume that all environments used to build GIMP will have these utilities programs?
Comment 3 Alexis Wilhelm 2011-11-08 08:13:37 UTC
Well, it uses for, if and grep already, which I think are UNIX specific, so I thought it was meant to be used in environments that have these. If not, it should use perl or python or whatever is available.

However, \s cannot be used with grep unless you specify -P (perl-regexp); the POSIX equivalent is [[:blank:]]. And we should prepend a ( to the procedure's name so we do not find whatever-gimp-text (although it may not be necessary since all names begin with gimp-). The cut part is useful too, since the diagnosis should not warn about names appearing in comments. A Perl regexp can do it, but I do not think a POSIX regexp can.

Getting rid of the inner loop only make it faster, so it is not as useful.
Comment 4 Alexis Wilhelm 2011-11-09 08:53:15 UTC
Created attachment 201046 [details] [review]
smaller patch

Uh seems like my brain was asleep when I wrote this: the cut part can easily be replaced with ^[^;]* at the beginning of the regexp. This new patch changes only the pattern that grep looks for. Also this time I made sure that it works when the procedure takes no parameter or appear at the end of a line.

Anyway, what is most important for now is that the bug #647834 got fixed, and this issue can wait until next time the API changes. I use almost exclusively Linux, so I cannot tell if it is OK to use other tools like tr, sed, cut and uniq. I am leaving my previous patch here because of how much faster it is.
Comment 5 Michael Schumacher 2016-05-25 17:03:45 UTC
Comment on attachment 200902 [details] [review]
patch

per comment 4
Comment 6 Kevin Cozens 2016-05-26 03:04:50 UTC
Review of attachment 201046 [details] [review]:

The idea behind the patch is good but the actual patch doesn't look right. The code being patched is being used to check Script-Fu scripts. It needs to look for the open parenthesis, followed by optional whitespace, the procedure name, then non-optional whitespace.
Comment 7 Michael Natterer 2016-11-16 16:58:42 UTC
Kevin, can you just push something that makes the matching work
and close this bug please?
Comment 8 Alexis Wilhelm 2017-12-30 12:18:35 UTC
Created attachment 366111 [details] [review]
patch

This new regex is a little stronger than the previous one (it does not match e.g. whatever-gimp-levels).

It looks for:
 - no semicolon (to ignore comments)
 - whitespace OR opening parenthesis OR beginning of line
 - the procedure name
 - whitespace OR closing parenthesis OR end of line

It does not require an opening parenthesis because:
 - the opening parenthesis might be on the previous line
 - the procedure might be used as an argument to map or reduce
Comment 9 Michael Natterer 2017-12-30 23:18:03 UTC
Thanks! This is minor enough to be on the 2.10 milestone :)
Comment 10 Michael Natterer 2018-01-01 13:26:04 UTC
Fixed in master:

commit a51efd09d12b4a40de8e3d0ae169f004be1cf1d1
Author: Alexis Wilhelm <alexiswilhelm@gmail.com>
Date:   Sat Dec 30 13:09:14 2017 +0100

    Bug 663576 - make -C plug-ins/script-fu check-for-deprecated-procedures-in-script-fu...
    
    ...lists files that do not use deprecated functions
    
    Better regex that matches the right stuff.

 plug-ins/script-fu/Makefile.am | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)