Skip to content

Commit 9062c63

Browse files
committed
fix language def parse errors with --read-lang-def, --force-lang-def, #954
in particular had to update language name match to account for possible leading "." as in ".NET"
1 parent 27cf3c7 commit 9062c63

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

Unix/cloc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5283,16 +5283,18 @@ sub read_lang_def { # {{{1
52835283

52845284
my $language = "";
52855285
my @lines = read_file($file);
5286+
my $line_num = 0;
52865287
foreach (@lines) {
5288+
++$line_num;
52875289
next if /^\s*#/ or /^\s*$/;
52885290

52895291
$_ = lc $_ if $ON_WINDOWS and /^\s+(filename|extension)\s/;
52905292

5291-
if (/^(\w+.*?)\s*$/) {
5293+
if (/^(\.?\w+.*?)\s*$/) {
52925294
$language = $1;
52935295
next;
52945296
}
5295-
die "Missing computer language name, line $. of $file\n"
5297+
die "Missing computer language name, line $line_num of $file\n"
52965298
unless $language;
52975299

52985300
if (/^\s{4}filter\s+(remove_between_(general|2re|regex))
@@ -5348,7 +5350,7 @@ sub read_lang_def { # {{{1
53485350
$rh_EOL_Continuation_re->{$language} = $1;
53495351

53505352
} else {
5351-
die "Unexpected data line $. of $file:\n$_\n";
5353+
die "Unexpected data line $line_num of $file:\n$_\n";
53525354
}
53535355

53545356
}
@@ -5373,17 +5375,19 @@ sub merge_lang_def { # {{{1
53735375
my $language = "";
53745376
my $already_know_it = undef;
53755377
my @lines = read_file($file);
5378+
my $line_num = 0;
53765379
foreach (@lines) {
5380+
++$line_num;
53775381
next if /^\s*#/ or /^\s*$/;
53785382

53795383
$_ = lc $_ if $ON_WINDOWS and /^\s+(filename|extension)\s/;
53805384

5381-
if (/^(\w+.*?)\s*$/) {
5385+
if (/^(\.?\w+.*?)\s*$/) {
53825386
$language = $1;
53835387
$already_know_it = defined $rh_Scale_Factor->{$language};
53845388
next;
53855389
}
5386-
die "Missing computer language name, line $. of $file\n"
5390+
die "Missing computer language name, line $line_num of $file\n"
53875391
unless $language;
53885392

53895393
if (/^\s{4}filter\s+(remove_between_(general|2re|regex))
@@ -5446,7 +5450,7 @@ sub merge_lang_def { # {{{1
54465450
$rh_EOL_Continuation_re->{$language} = $1;
54475451

54485452
} else {
5449-
die "Unexpected data line $. of $file:\n$_\n";
5453+
die "Unexpected data line $line_num of $file:\n$_\n";
54505454
}
54515455

54525456
}

cloc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5276,16 +5276,18 @@ sub read_lang_def { # {{{1
52765276

52775277
my $language = "";
52785278
my @lines = read_file($file);
5279+
my $line_num = 0;
52795280
foreach (@lines) {
5281+
++$line_num;
52805282
next if /^\s*#/ or /^\s*$/;
52815283

52825284
$_ = lc $_ if $ON_WINDOWS and /^\s+(filename|extension)\s/;
52835285

5284-
if (/^(\w+.*?)\s*$/) {
5286+
if (/^(\.?\w+.*?)\s*$/) {
52855287
$language = $1;
52865288
next;
52875289
}
5288-
die "Missing computer language name, line $. of $file\n"
5290+
die "Missing computer language name, line $line_num of $file\n"
52895291
unless $language;
52905292

52915293
if (/^\s{4}filter\s+(remove_between_(general|2re|regex))
@@ -5341,7 +5343,7 @@ sub read_lang_def { # {{{1
53415343
$rh_EOL_Continuation_re->{$language} = $1;
53425344

53435345
} else {
5344-
die "Unexpected data line $. of $file:\n$_\n";
5346+
die "Unexpected data line $line_num of $file:\n$_\n";
53455347
}
53465348

53475349
}
@@ -5366,17 +5368,19 @@ sub merge_lang_def { # {{{1
53665368
my $language = "";
53675369
my $already_know_it = undef;
53685370
my @lines = read_file($file);
5371+
my $line_num = 0;
53695372
foreach (@lines) {
5373+
++$line_num;
53705374
next if /^\s*#/ or /^\s*$/;
53715375

53725376
$_ = lc $_ if $ON_WINDOWS and /^\s+(filename|extension)\s/;
53735377

5374-
if (/^(\w+.*?)\s*$/) {
5378+
if (/^(\.?\w+.*?)\s*$/) {
53755379
$language = $1;
53765380
$already_know_it = defined $rh_Scale_Factor->{$language};
53775381
next;
53785382
}
5379-
die "Missing computer language name, line $. of $file\n"
5383+
die "Missing computer language name, line $line_num of $file\n"
53805384
unless $language;
53815385

53825386
if (/^\s{4}filter\s+(remove_between_(general|2re|regex))
@@ -5439,7 +5443,7 @@ sub merge_lang_def { # {{{1
54395443
$rh_EOL_Continuation_re->{$language} = $1;
54405444

54415445
} else {
5442-
die "Unexpected data line $. of $file:\n$_\n";
5446+
die "Unexpected data line $line_num of $file:\n$_\n";
54435447
}
54445448

54455449
}

0 commit comments

Comments
 (0)