Skip to content

Commit

Permalink
improve handling of Oracle PL/SQL files, #875
Browse files Browse the repository at this point in the history
Regexp::Common::comment parser for PL/SQL messes up, use my own
  • Loading branch information
AlDanial committed Dec 3, 2024
1 parent 3bc0303 commit 50b715f
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 11 deletions.
9 changes: 4 additions & 5 deletions Unix/cloc
Original file line number Diff line number Diff line change
Expand Up @@ -10553,17 +10553,16 @@ sub set_constants { # {{{1
'Oracle Forms' => [ [ 'call_regexp_common' , 'C' ], ],
'Oracle Reports' => [ [ 'call_regexp_common' , 'C' ], ],
'Oracle PL/SQL' => [
[ 'call_regexp_common' , 'PL/SQL' ],
# [ 'call_regexp_common' , 'PL/SQL' ], # bad results
[ 'call_regexp_common' , 'C' ],
[ 'remove_matches' , '^\s*--' ],
[ 'remove_inline' , '--.*$' ],
],
'Pascal' => [
[ 'remove_between_regex', '\{[^$]', '}' ],
[ 'remove_between_general', '(*', '*)' ],
[ 'remove_matches' , '^\s*//' ],
],
####'Pascal' => [
#### [ 'call_regexp_common' , 'Pascal' ],
#### [ 'remove_matches' , '^\s*//' ],
#### ],
'Pascal/Puppet' => [ [ 'die' , ], ], # never called
'Puppet' => [
[ 'remove_matches' , '^\s*#' ],
Expand Down
10 changes: 9 additions & 1 deletion Unix/t/00_C.t
Original file line number Diff line number Diff line change
Expand Up @@ -816,11 +816,19 @@ my @Tests = (
'ref' => '../tests/outputs/Rounds.scad.yaml',
'args' => '../tests/inputs/Rounds.scad',
},

{
'name' => 'Oracle PL/SQL',
'name' => 'Oracle PL/SQL 1',
'ref' => '../tests/outputs/bubs_tak_ard.prc.yaml',
'args' => '../tests/inputs/bubs_tak_ard.prc',
},

{
'name' => 'Oracle PL/SQL 2',
'ref' => '../tests/outputs/issue_875.bdy.yaml',
'args' => '../tests/inputs/issue_875.bdy',
},

{
'name' => 'P4',
'ref' => '../tests/outputs/basic.p4.yaml',
Expand Down
9 changes: 4 additions & 5 deletions cloc
Original file line number Diff line number Diff line change
Expand Up @@ -10543,17 +10543,16 @@ sub set_constants { # {{{1
'Oracle Forms' => [ [ 'call_regexp_common' , 'C' ], ],
'Oracle Reports' => [ [ 'call_regexp_common' , 'C' ], ],
'Oracle PL/SQL' => [
[ 'call_regexp_common' , 'PL/SQL' ],
# [ 'call_regexp_common' , 'PL/SQL' ], # bad results
[ 'call_regexp_common' , 'C' ],
[ 'remove_matches' , '^\s*--' ],
[ 'remove_inline' , '--.*$' ],
],
'Pascal' => [
[ 'remove_between_regex', '\{[^$]', '}' ],
[ 'remove_between_general', '(*', '*)' ],
[ 'remove_matches' , '^\s*//' ],
],
####'Pascal' => [
#### [ 'call_regexp_common' , 'Pascal' ],
#### [ 'remove_matches' , '^\s*//' ],
#### ],
'Pascal/Puppet' => [ [ 'die' , ], ], # never called
'Puppet' => [
[ 'remove_matches' , '^\s*#' ],
Expand Down
26 changes: 26 additions & 0 deletions tests/inputs/issue_875.bdy
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* bubble sort
*/
DECLARE
TYPE number_array IS VARRAY(100) OF NUMBER;
arr number_array := number_array(64, 34, 25, 12, 22, 11, 90);
n NUMBER := arr.COUNT;
i NUMBER := 0;
j NUMBER := 0;
temp NUMBER;
BEGIN
FOR i IN 1 .. (n - 1) LOOP -- outer
FOR j IN 1 .. (n - i - 1) LOOP -- inner
IF arr(j) > arr(j + 1) THEN
temp := arr(j);
arr(j) := arr(j + 1);
arr(j + 1) := temp;
END IF;
END LOOP;
END LOOP;
-- print
FOR i IN 1 .. n LOOP
DBMS_OUTPUT.PUT_LINE(arr(i));
END LOOP;
END;
/
21 changes: 21 additions & 0 deletions tests/outputs/issue_875.bdy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# github.com/AlDanial/cloc
header :
cloc_url : github.com/AlDanial/cloc
cloc_version : 2.03
elapsed_seconds : 0.00424885749816895
n_files : 1
n_lines : 26
files_per_second : 235.357387352
lines_per_second : 6119.29207115201
report_file : ../outputs/issue_875.bdy.yaml
'Oracle PL/SQL' :
nFiles: 1
blank: 0
comment: 4
code: 22
SUM:
blank: 0
comment: 4
code: 22
nFiles: 1

0 comments on commit 50b715f

Please sign in to comment.