Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
GHC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex D
GHC
Commits
fbbe50f3
Commit
fbbe50f3
authored
Sep 23, 2009
by
Ian Lynagh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add count_lines back into the repo
parent
fb1ac2f2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
0 deletions
+63
-0
utils/count_lines/count_lines
utils/count_lines/count_lines
+63
-0
No files found.
utils/count_lines/count_lines
0 → 100644
View file @
fbbe50f3
#! /usr/bin/perl
#
%DirCount
=
();
%ModCount
=
();
%DirComments
=
();
%ModComments
=
();
foreach
$f
(
@ARGV
)
{
if
(
$f
=~
/\.lhs$/
)
{
open
(
INF
,
"
../utils/unlit/unlit
$f
- |
")
||
die
"
Couldn't unlit
$f
!
\n
";
}
else
{
open
(
INF
,
"
<
$f
")
||
die
"
Couldn't open
$f
!
\n
";
}
$cnt
=
0
;
while
(
<
INF
>
)
{
s/--.*//
;
s/{-.*-}//
;
next
if
/^\s*$/
;
$cnt
++
;
}
close
(
INF
);
$f_wc
=
`
wc
$f
`;
die
"
wc failed:
$f
\n
"
if
$?
!=
0
;
if
(
$f_wc
=~
/\s*(\d+)\s*(\d+)\s*(\d+)/
)
{
$comments
=
$
1
-
$cnt
;
}
else
{
die
"
Can't grok wc format:
$f_wc
";
}
if
(
$f
=~
/(.*)\/(.*)/
)
{
local
(
$dir
)
=
$
1
;
local
(
$mod
)
=
$
2
;
$DirCount
{
$dir
}
+=
$cnt
;
$ModCount
{
$mod
}
+=
$cnt
;
$DirComments
{
$dir
}
+=
$comments
;
$ModComments
{
$mod
}
+=
$comments
;
}
else
{
print
STDERR
"
not counted in a directory:
$f
\n
";
$ModCount
{
$f
}
+=
$cnt
;
$ModComments
{
$f
}
+=
$comments
;
}
}
# print the info
$tot
=
0
;
$totcmts
=
0
;
foreach
$d
(
sort
(
keys
%DirCount
))
{
printf
"
%-20s %6d %6d
\n
",
$d
,
$DirCount
{
$d
},
$DirComments
{
$d
};
$tot
+=
$DirCount
{
$d
};
$totcmts
+=
$DirComments
{
$d
};
}
printf
"
\n
%-20s %6d %6d
\n\n\n
",
'
TOTAL:
',
$tot
,
$totcmts
;
$tot
=
0
;
$totcmts
=
0
;
printf
"
\n
Code Comments
\n
";
foreach
$m
(
sort
(
keys
%ModCount
))
{
printf
"
%-20s %6d %6d
\n
",
$m
,
$ModCount
{
$m
},
$ModComments
{
$m
};
$tot
+=
$ModCount
{
$m
};
$totcmts
+=
$ModComments
{
$m
};
}
printf
"
\n
%-20s %6d %6d
\n
",
'
TOTAL:
',
$tot
,
$totcmts
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment