Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[preload] Support whitespace within interface modifiers
  • Loading branch information
Thaodan committed Feb 5, 2021
1 parent bb2cd67 commit 625bcab
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion scratchbox2/preload/gen-interface.pl
Expand Up @@ -526,7 +526,38 @@ sub process_wrap_or_gate_modifiers {
my $fn = shift; # structure: parser results
my $all_modifiers = shift;

my @modifiers = split(/\s+/, $all_modifiers);
my @modifiers;
my $inside_braces;
my $build_mod;

# Split by space and then rebuild each modifier
foreach my $mod (split(/\s+/, $all_modifiers))
{
# First check if we are already rebuilding a modifier that previously started
# If not we need to check if a modifier with space is beginning
# but ignore one without space (eg. foo(bar))
if (!$inside_braces && $mod !~ m/(.*)\((.*)\)$/ && ($mod =~ m/([^\(]+)\)$/|| $mod =~ m/(.*)\(([^)]+)/)) {
$build_mod = "$mod ";
$inside_braces=1;
} else {
if ($inside_braces) {
$build_mod .= $mod;
if ($mod =~ m/(.*)\)$/) {
# Modifier with space ends
$inside_braces = 0;
push @modifiers, $build_mod;
undef $build_mod;
} else {
# There has to be space between each word in the middle of the modifier
$build_mod .= " ";
}
} else {
# Just a modifier without space
push @modifiers, $mod;
}
}
}

my $num_modifiers = @modifiers;

# cache some fn parser results to local vars
Expand Down

0 comments on commit 625bcab

Please sign in to comment.