Skip to content

Commit 585665c

Browse files
committed
fix(xpkg): survive the full mcpp-index corpus — 42/42 descriptors parse strict
Dry-running the new lint over every existing mcpp-index descriptor found three gaps, all fixed: - list_xpkg_versions only accepted double-quoted version keys; tensorvia's ['0.1.1'] spelling made its versions invisible. Accept both quotes. - linux/macosx/windows per-platform sub-tables are KNOWN schema keys (the current platform's body is merged before the key loop); they no longer read as unknown on other platforms. - Form A descriptors (no mcpp segment; build info from the source's own mcpp.toml) are a valid form: `xpkg parse` reports form A and passes instead of failing on the missing segment. Corpus check: all 42 pkgs/*.lua in mcpp-index now pass `xpkg parse` (strict) with zero warnings.
1 parent 8cc8e46 commit 585665c

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

‎src/cli/cmd_xpkg.cppm‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,22 @@ export int cmd_xpkg_parse(const mcpplibs::cmdline::ParsedArgs& parsed) {
9595
return 1;
9696
}
9797

98+
// Form A descriptors carry no `mcpp = {}` table — build info comes
99+
// from the fetched source's own mcpp.toml. Nothing further to parse.
100+
auto field = mcpp::manifest::extract_mcpp_field(lua);
101+
if (field.kind != mcpp::manifest::McppField::TableBody) {
102+
if (asJson) {
103+
std::println("{{\"namespace\":\"{}\",\"name\":\"{}\",\"form\":\"A\"}}",
104+
json_escape(id.ns), json_escape(id.name));
105+
} else {
106+
std::println("package {} (namespace '{}')", fqn, id.ns);
107+
std::println("form A — no mcpp segment (build info from the "
108+
"source's mcpp.toml)");
109+
std::println("parse OK");
110+
}
111+
return 0;
112+
}
113+
98114
// The parse users get at build time — same function, same grammar.
99115
auto m = mcpp::manifest::synthesize_from_xpkg_lua(lua, fqn, anyVersion);
100116
if (!m) {

‎src/manifest/xpkg.cppm‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -702,11 +702,12 @@ list_xpkg_versions(std::string_view luaContent, std::string_view platform) {
702702
if (text[q] == '[') {
703703
std::size_t r = q + 1;
704704
while (r < plat_end && (text[r] == ' ' || text[r] == '\t')) ++r;
705-
if (r < plat_end && text[r] == '"') {
705+
if (r < plat_end && (text[r] == '"' || text[r] == '\'')) {
706+
const char quote = text[r];
706707
++r;
707708
std::size_t key_start = r;
708-
while (r < plat_end && text[r] != '"' && text[r] != '\n') ++r;
709-
if (r < plat_end && text[r] == '"') {
709+
while (r < plat_end && text[r] != quote && text[r] != '\n') ++r;
710+
if (r < plat_end && text[r] == quote) {
710711
versions.emplace_back(luaContent.substr(key_start, r - key_start));
711712
}
712713
}
@@ -1182,6 +1183,12 @@ synthesize_from_xpkg_lua(std::string_view luaContent,
11821183
}
11831184
cur.consume('}');
11841185
}
1186+
else if (key == "linux" || key == "macosx" || key == "windows") {
1187+
// Per-platform sub-table. The CURRENT platform's body was already
1188+
// appended to the segment before this loop (see above), so every
1189+
// spelling here is a known key: skip the table itself.
1190+
if (cur.peek() == '{') cur.skip_table();
1191+
}
11851192
else if (key == "schema") {
11861193
// Descriptor schema tag (e.g. "0.1") — accepted, currently
11871194
// informational only.

0 commit comments

Comments
 (0)