diff --git a/src/lib/c/factories.c b/src/lib/c/factories.c
index b9d9970..0b0b025 100644
--- a/src/lib/c/factories.c
+++ b/src/lib/c/factories.c
@@ -83,6 +83,9 @@ SourceFormatDetection detectSourceFormat(const RcnSourceFile* file) {
|| strcmp(extension, "markdown") == 0) {
detection.isSupportedFormat = true;
detection.format = RCN_TEXT_MARKDOWN;
+ } else if (strcmp(extension, "xml") == 0) {
+ detection.isSupportedFormat = true;
+ detection.format = RCN_TEXT_XML;
} else if (strcmp(extension, "txt") == 0) {
detection.isSupportedFormat = true;
detection.format = RCN_TEXT_UNFORMATTED;
diff --git a/src/lib/include/reckon/reckon.h b/src/lib/include/reckon/reckon.h
index a282c50..6e67e4d 100644
--- a/src/lib/include/reckon/reckon.h
+++ b/src/lib/include/reckon/reckon.h
@@ -100,7 +100,7 @@ extern "C" {
* The total number of supported text formats, including
* supported programming languages.
*/
-#define RECKON_NUM_SUPPORTED_FORMATS 4
+#define RECKON_NUM_SUPPORTED_FORMATS 5
/**
* Macro to create a format option bitmask.
@@ -145,15 +145,20 @@ typedef enum RcnTextFormat {
*/
RCN_TEXT_MARKDOWN = 1,
+ /**
+ * Text formatted in XML, as found in files with a '.xml' extension.
+ */
+ RCN_TEXT_XML = 2,
+
/**
* Source files for the C programming language.
*/
- RCN_LANG_C = 2,
+ RCN_LANG_C = 3,
/**
* Source files for the Java programming language.
*/
- RCN_LANG_JAVA = 3
+ RCN_LANG_JAVA = 4
} RcnTextFormat;
@@ -691,6 +696,11 @@ typedef enum RcnFormatOption {
*/
RCN_OPT_TEXT_MARKDOWN = RECKON_MK_FRMT_OPT(RCN_TEXT_MARKDOWN),
+ /**
+ * Option to select statistics for XML files.
+ */
+ RCN_OPT_TEXT_XML = RECKON_MK_FRMT_OPT(RCN_TEXT_XML),
+
/**
* Option to select statistics for source code files written in
* the C programming language.
diff --git a/src/lib/tests/res/misc/sample.xml b/src/lib/tests/res/misc/sample.xml
new file mode 100644
index 0000000..ee5840b
--- /dev/null
+++ b/src/lib/tests/res/misc/sample.xml
@@ -0,0 +1,16 @@
+
+
+ Sample Document
+
+ - Alpha
+ - Beta
+ -
+ Gamma
+ 42
+
+
+
+ 1970-01-01
+
+
+
diff --git a/src/lib/tests/unit/c/test_statistics.c b/src/lib/tests/unit/c/test_statistics.c
index 425ba3d..3df833f 100644
--- a/src/lib/tests/unit/c/test_statistics.c
+++ b/src/lib/tests/unit/c/test_statistics.c
@@ -244,6 +244,31 @@ void testCountResultGroupLogicalLineCheckField(void) {
rcnFreeCountStatistics(stats);
}
+void testCountResultsXml(void) {
+ char* path = RECKON_TEST_PATH_RES_BASE "/misc/sample.xml";
+ RcnCountStatistics* stats = rcnCreateCountStatistics(path);
+ RcnStatOptions options = {
+ .formats = RCN_OPT_TEXT_XML
+ };
+
+ rcnCount(stats, options);
+
+ TEST_ASSERT_EQUAL_INT(1, stats->count.size);
+ RcnSourceFile* file = &stats->count.files[0];
+ RcnCountResultGroup* result = &stats->count.results[0];
+ TEST_ASSERT_TRUE(result->state.ok);
+ TEST_ASSERT_EQUAL_INT(RCN_ERR_NONE, result->state.errorCode);
+ TEST_ASSERT_NULL(result->state.errorMessage);
+ TEST_ASSERT_EQUAL_STRING("sample.xml", file->name);
+ TEST_ASSERT_TRUE(result->isProcessed);
+ TEST_ASSERT_EQUAL_INT(0, result->logicalLines);
+ TEST_ASSERT_EQUAL_INT(16, result->physicalLines);
+ TEST_ASSERT_EQUAL_INT(35, result->words);
+ TEST_ASSERT_EQUAL_INT(471, result->characters);
+ TEST_ASSERT_EQUAL_INT(471, result->sourceSize);
+ rcnFreeCountStatistics(stats);
+}
+
// NOLINTEND(readability-magic-numbers)
int main(void) {
@@ -255,5 +280,6 @@ int main(void) {
RUN_TEST(testCountWhenFileHasUnsupportedFormat);
RUN_TEST(testCountWithMultipleFilesWhenOneFileHasError);
RUN_TEST(testCountResultGroupLogicalLineCheckField);
+ RUN_TEST(testCountResultsXml);
return UNITY_END();
}
diff --git a/src/scount/c/print.c b/src/scount/c/print.c
index 7bc9993..f60b0d2 100644
--- a/src/scount/c/print.c
+++ b/src/scount/c/print.c
@@ -480,6 +480,9 @@ static void prSummaryRows(
case RCN_TEXT_MARKDOWN:
label = "Markdown";
break;
+ case RCN_TEXT_XML:
+ label = "XML";
+ break;
case RCN_LANG_C:
label = "C";
hasLogicalLines = true;
diff --git a/src/scount/tests/functionality/res/expected/mixed.txt b/src/scount/tests/functionality/res/expected/mixed.txt
index c418eec..f1f30a3 100644
--- a/src/scount/tests/functionality/res/expected/mixed.txt
+++ b/src/scount/tests/functionality/res/expected/mixed.txt
@@ -1,5 +1,5 @@
Directory: mixed
-Scanned files: 8
+Scanned files: 10
o---------- File ----------o--- LLC ---o--- PHL ---o--- WRD ---o--- CHR ---o--- SZE ---o
| Sample1.java | 3 | 12 | 34 | 233 | 233 |
@@ -7,9 +7,11 @@ Scanned files: 8
| sample1.c | 4 | 10 | 29 | 180 | 180 |
| sample1.md | n/a | 1 | 8 | 52 | 52 |
| sample1.txt | n/a | 1 | 9 | 52 | 52 |
+ | sample1.xml | n/a | 9 | 18 | 204 | 204 |
| sample2.c | 5 | 11 | 33 | 219 | 219 |
| sample2.md | n/a | 1 | 8 | 53 | 53 |
| sample2.txt | n/a | 2 | 13 | 75 | 75 |
+ | sample2.xml | n/a | 10 | 21 | 237 | 237 |
o--------------------------o-----------o-----------o-----------o-----------o-----------o
Summary:
@@ -17,10 +19,11 @@ Summary:
o-------- Language --------o--- LLC ---o--- PHL ---o--- WRD ---o--- CHR ---o--- SZE ---o
| Plain Text | n/a | 3 | 22 | 127 | 127 |
| Markdown | n/a | 2 | 16 | 105 | 105 |
+ | XML | n/a | 19 | 39 | 441 | 441 |
| C | 9 | 21 | 62 | 399 | 399 |
| Java | 7 | 25 | 72 | 519 | 519 |
o==========================o===========o===========o===========o===========o===========o
- | Total: | 16 | 51 | 172 | 1150 | 1150 |
+ | Total: | 16 | 70 | 211 | 1591 | 1591 |
o==========================o===========o===========o===========o===========o===========o
diff --git a/src/scount/tests/functionality/res/mixed/sample1.xml b/src/scount/tests/functionality/res/mixed/sample1.xml
new file mode 100644
index 0000000..2cd203f
--- /dev/null
+++ b/src/scount/tests/functionality/res/mixed/sample1.xml
@@ -0,0 +1,9 @@
+
+
+ First Sample
+
+
+
+
+
+
diff --git a/src/scount/tests/functionality/res/mixed/sample2.xml b/src/scount/tests/functionality/res/mixed/sample2.xml
new file mode 100644
index 0000000..e0f7b6a
--- /dev/null
+++ b/src/scount/tests/functionality/res/mixed/sample2.xml
@@ -0,0 +1,10 @@
+
+
+ Second Sample
+
+
+
+
+
+
+