-
Notifications
You must be signed in to change notification settings - Fork 4
Improve matching of use base-style statements with arrays
#1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Improve matching of use base-style statements with arrays
#1
Conversation
Previously, we were not able to match `use base ("Package1", "Package2");`.
This style is used extensively by OpenAPI Generator
(https://openapi-generator.tech).
As a result, all Perl code generated by this tool fails to install the correct
dependencies when using perl-generators in the specfile.
With this change, we check for a single- or double-quoted array (as opposed
to the current lexing of qw arrays) following a `use X` statement, and parse
this into the $list scalar, stripping out quotes, splitting on quotes and
joining on commas, to keep the same format that $list currently uses.
|
Thanks for the PR. I tried to apply the patch and rebuild all packages which use The package perl-SVK contains following code in file SVK-v2.2.3/lib/SVK/Inspector/Root.pm which ends with this change found by rpmdiff perl-Prima code in Prima-1.76/Prima/Edit.pm code in Prima-1.76/Prima/Sliders.pm changes Could you please check it? |
|
Thanks for spotting this case! It appears that this behaviour stems from the presence of tab characters in the source files, as I was able to reproduce a minimal example using The existing code for handling
Therefore the solution is to strip all leading and trailing whitespace from each element of |
The existing code stores the arguments of various statements into $list as a space-separated scalar. It's much cleaner to store this as an array, so we now do that instead.
Handling tabs and spaces is tricky, especially around in the complex
logic that surrounds use base qw{ stuff };
d031391 to
36c9c00
Compare
|
Hi @jplesnik, I think I've fixed the issues you identified as well as a few things we found internally. Please do let me know if there's anything else needed to get this merged 😄 |
Previously, we were not able to match
use base ("Package1", "Package2");.This style is used extensively by OpenAPI Generator
(https://openapi-generator.tech).
As a result, all Perl code generated by this tool fails to install the correct
dependencies when using perl-generators in the specfile.
With this change, we check for a single- or double-quoted array (as opposed
to the current lexing of qw arrays) following a
use Xstatement, and parsethis into the
$listscalar, stripping out quotes, splitting on quotes andjoining on commas, to keep the same format that
$listcurrently uses.Tested locally (albeit with some hackery to make packages load correctly in the tests):