Skip to content
3 changes: 2 additions & 1 deletion man/scount.1
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Cb Cb
L L.
Abbr.|Description
LLC|Logical lines of code
LOC|Physical lines of code
PHL|Hard physical lines
WRD|Number of words
CHR|Number of characters
Expand Down Expand Up @@ -55,7 +56,7 @@ This option can only be used on a single file input.
.B \-l, \-\-lines
Compute and display only line-specific metrics.
.br
This includes logical and physical lines.
This includes logical lines of code, physical lines of code and hard physical lines.
.TP
.B \-\-show\-files
Show a table of individual files in the result when the given input path refers to a directory.
Expand Down
1 change: 1 addition & 0 deletions src/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ target_sources(
"c/lang_cpp.c"
"c/logical.c"
"c/physical.c"
"c/loc.c"
"c/statistics.c"
"c/tree.c"
"c/words.c"
Expand Down
22 changes: 22 additions & 0 deletions src/lib/c/evaluation.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,28 @@ NodeVisitor createEvaluationFunction(RcnTextFormat language);
*/
const char* getInlineSourceCommentString(RcnTextFormat language);

/**
* Returns the opening marker for block comments in the specified programming
* language (e.g. slash-star for C-family languages), or NULL if the language
* does not support block comments. The caller does not own the returned string
* and must not attempt to free it.
*/
const char* getBlockCommentStartString(RcnTextFormat language);

/**
* Returns the closing marker for block comments in the specified programming
* language (e.g. star-slash for C-family languages), or NULL if the language
* does not support block comments. The caller does not own the returned string
* and must not attempt to free it.
*/
const char* getBlockCommentEndString(RcnTextFormat language);

/**
* Returns true if the specified format denotes a supported programming
* language for LOC counting, false otherwise (e.g. for plain-text).
*/
bool isLocEnabled(RcnTextFormat language);

/**
* Allocates a new node evaluation context for an annotation operation.
* Ownership of the returned context is transferred to the caller. It must be
Expand Down
48 changes: 48 additions & 0 deletions src/lib/c/factories.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,54 @@ const char* getInlineSourceCommentString(RcnTextFormat language) {
}
}

const char* getBlockCommentStartString(RcnTextFormat language) {
switch (language) {
case RCN_LANG_C:
case RCN_LANG_JAVA:
case RCN_LANG_CPP:
case RCN_LANG_JAVASCRIPT:
case RCN_LANG_TYPESCRIPT:
return "/*";
case RCN_LANG_PYTHON:
case RCN_LANG_R:
case RCN_LANG_BASH:
default:
return NULL;
}
}

const char* getBlockCommentEndString(RcnTextFormat language) {
switch (language) {
case RCN_LANG_C:
case RCN_LANG_JAVA:
case RCN_LANG_CPP:
case RCN_LANG_JAVASCRIPT:
case RCN_LANG_TYPESCRIPT:
return "*/";
case RCN_LANG_PYTHON:
case RCN_LANG_R:
case RCN_LANG_BASH:
default:
return NULL;
}
}

bool isLocEnabled(RcnTextFormat language) {
switch (language) {
case RCN_LANG_C:
case RCN_LANG_JAVA:
case RCN_LANG_PYTHON:
case RCN_LANG_CPP:
case RCN_LANG_JAVASCRIPT:
case RCN_LANG_TYPESCRIPT:
case RCN_LANG_R:
case RCN_LANG_BASH:
return true;
default:
return false;
}
}

SourceFormatDetection detectSourceFormat(const RcnSourceFile* file) {
SourceFormatDetection detection = {
.isSupportedFormat = false,
Expand Down
Loading