MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / lang_cfc_text

Function lang_cfc_text

src/discover/language.c:1541–1569  ·  view source on GitHub ↗

Disambiguate .cfc files: a ColdFusion component may be written in the script * dialect ("component { ... }", parsed by the JS-like cfscript grammar) or the * tag dialect (" ... ", parsed by the HTML-derived cfml * grammar). The extension table defaults to cfscript because that is what modern * Lucee/ACF templates use, but large legacy codebases are predominantly tag-ba

Source from the content-addressed store, hash-verified

1539 * - anything else ("component { ... }") ⇒ cfscript.
1540 * Defaults to CBM_LANG_CFSCRIPT on any doubt (preserves table behaviour). */
1541static CBMLanguage lang_cfc_text(const char *buf) {
1542 /* Rule 1: explicit tag-component markers ⇒ tag dialect. */
1543 if (cbm_strcasestr(buf, "<cfcomponent") != NULL || cbm_strcasestr(buf, "<cffunction") != NULL) {
1544 return CBM_LANG_CFML;
1545 }
1546
1547 /* Rule 2: locate the first significant token, past whitespace and comments. */
1548 const char *p = buf;
1549 for (;;) {
1550 while (*p && isspace((unsigned char)*p)) {
1551 p++;
1552 }
1553 if (starts_with_ci(p, "<!---")) {
1554 const char *end = strstr(p + SLEN("<!---"), "--->");
1555 if (!end) {
1556 break; /* comment runs past the buffer — treat as no token */
1557 }
1558 p = end + SLEN("--->");
1559 continue;
1560 }
1561 break;
1562 }
1563 if (*p == '<') {
1564 /* A leading <cfscript> wrapper is script content; any other leading tag
1565 * (bare-tag file) is tag content. */
1566 return starts_with_ci(p, "<cfscript") ? CBM_LANG_CFSCRIPT : CBM_LANG_CFML;
1567 }
1568 return CBM_LANG_CFSCRIPT;
1569}
1570
1571CBMLanguage cbm_disambiguate_cfc(const char *path) {
1572 unsigned char head[LANG_PROBE_CFC];

Callers 2

cbm_disambiguate_cfcFunction · 0.85

Calls 2

cbm_strcasestrFunction · 0.85
starts_with_ciFunction · 0.85

Tested by

no test coverage detected