|
@@ -5330,15 +5330,28 @@ sub process {
|
|
|
}
|
|
|
|
|
|
# concatenated string without spaces between elements
|
|
|
- if ($line =~ /$String[A-Z_]/ || $line =~ /[A-Za-z0-9_]$String/) {
|
|
|
- CHK("CONCATENATED_STRING",
|
|
|
- "Concatenated strings should use spaces between elements\n" . $herecurr);
|
|
|
+ if ($line =~ /$String[A-Za-z0-9_]/ || $line =~ /[A-Za-z0-9_]$String/) {
|
|
|
+ if (CHK("CONCATENATED_STRING",
|
|
|
+ "Concatenated strings should use spaces between elements\n" . $herecurr) &&
|
|
|
+ $fix) {
|
|
|
+ while ($line =~ /($String)/g) {
|
|
|
+ my $extracted_string = substr($rawline, $-[0], $+[0] - $-[0]);
|
|
|
+ $fixed[$fixlinenr] =~ s/\Q$extracted_string\E([A-Za-z0-9_])/$extracted_string $1/;
|
|
|
+ $fixed[$fixlinenr] =~ s/([A-Za-z0-9_])\Q$extracted_string\E/$1 $extracted_string/;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
# uncoalesced string fragments
|
|
|
if ($line =~ /$String\s*"/) {
|
|
|
- WARN("STRING_FRAGMENTS",
|
|
|
- "Consecutive strings are generally better as a single string\n" . $herecurr);
|
|
|
+ if (WARN("STRING_FRAGMENTS",
|
|
|
+ "Consecutive strings are generally better as a single string\n" . $herecurr) &&
|
|
|
+ $fix) {
|
|
|
+ while ($line =~ /($String)(?=\s*")/g) {
|
|
|
+ my $extracted_string = substr($rawline, $-[0], $+[0] - $-[0]);
|
|
|
+ $fixed[$fixlinenr] =~ s/\Q$extracted_string\E\s*"/substr($extracted_string, 0, -1)/e;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
# check for non-standard and hex prefixed decimal printf formats
|