phobos src level stats

DlangUser38 DlangUser38 at nowhere.se
Tue Sep 22 23:22:42 UTC 2020


On Tuesday, 22 September 2020 at 21:01:17 UTC, Bruce Carneal 
wrote:
> The empty line numbers seem a little high to me.  I may have a 
> bug in the code for that:
>
> ulong countEmptyLines(string rawText) @nogc nothrow pure @safe
> {
>     ulong empties;
>     lineLoop: foreach (line; lineSplitter(rawText))
>     {
>         foreach_reverse (ch; line)
>             if (ch != ' ' && ch != '\t')
>                 continue lineLoop;
>         ++empties;
>     }
>     return empties;
> }

you can count empty lines using a sliding window of two token 
over the token range.
The difference between the two token position give empty line. 
string literal and comments require a special processing but 
otherwise this is quite straightforward to implement.


More information about the Digitalmars-d mailing list