@@ -5330,15 +5330,28 @@ sub process {
5330
5330
}
5331
5331
5332
5332
# concatenated string without spaces between elements
5333
- if ($line =~ / $String [A-Z_]/ || $line =~ / [A-Za-z0-9_]$String / ) {
5334
- CHK(" CONCATENATED_STRING" ,
5335
- " Concatenated strings should use spaces between elements\n " . $herecurr );
5333
+ if ($line =~ / $String [A-Za-z0-9_]/ || $line =~ / [A-Za-z0-9_]$String / ) {
5334
+ if (CHK(" CONCATENATED_STRING" ,
5335
+ " Concatenated strings should use spaces between elements\n " . $herecurr ) &&
5336
+ $fix ) {
5337
+ while ($line =~ / ($String )/g ) {
5338
+ my $extracted_string = substr ($rawline , $- [0], $+ [0] - $- [0]);
5339
+ $fixed [$fixlinenr ] =~ s /\Q $extracted_string\E ([A-Za-z0-9_])/ $extracted_string $1 / ;
5340
+ $fixed [$fixlinenr ] =~ s / ([A-Za-z0-9_])\Q $extracted_string\E / $1 $extracted_string / ;
5341
+ }
5342
+ }
5336
5343
}
5337
5344
5338
5345
# uncoalesced string fragments
5339
5346
if ($line =~ / $String \s *"/ ) {
5340
- WARN(" STRING_FRAGMENTS" ,
5341
- " Consecutive strings are generally better as a single string\n " . $herecurr );
5347
+ if (WARN(" STRING_FRAGMENTS" ,
5348
+ " Consecutive strings are generally better as a single string\n " . $herecurr ) &&
5349
+ $fix ) {
5350
+ while ($line =~ / ($String )(?=\s *")/g ) {
5351
+ my $extracted_string = substr ($rawline , $- [0], $+ [0] - $- [0]);
5352
+ $fixed [$fixlinenr ] =~ s /\Q $extracted_string\E\s *"/ substr($extracted_string , 0, -1)/ e ;
5353
+ }
5354
+ }
5342
5355
}
5343
5356
5344
5357
# check for non-standard and hex prefixed decimal printf formats
0 commit comments