Skip to content

Commit 5cb1b50

Browse files
committed
genimport: fix 16 bit shift in namedproperty mappings
While the inner reverse map of static_namedprop_map uses 16-bit propids, the inner forward map of static_namedprop_map is (still) on 32-bit proptags. The PROP_TAG(PT_UNSPECIFIED, x) call was not carried over, causing MT streams to carry no meaningful namedprop entries. Fixes: gromox-2.32-67-gcc38c6d7a References: DESK-2660
1 parent 887f54d commit 5cb1b50

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

tools/genimport.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,17 @@ void gi_dump_name_map(const gi_name_map &map)
8787
{
8888
if (!g_show_props)
8989
return;
90-
fprintf(stderr, "Named properties (%zu entries):\n", map.size());
91-
fprintf(stderr, "\t# PROPID (hex) <-> MAPINAMEID definition:\n");
92-
for (const auto &[propid, propname] : map) {
90+
fprintf(stderr, "Preamble's named property map (%zu entries):\n", map.size());
91+
fprintf(stderr, "\t# proptag (hex) -> MAPINAMEID definition:\n");
92+
for (const auto &[proptag, propname] : map) {
9393
char g[40];
9494
propname.guid.to_str(g, std::size(g), 38);
9595
if (propname.kind == MNID_ID)
96-
fprintf(stderr, "\t%04xh <-> {MNID_ID, %s, %xh}\n",
97-
propid, g, static_cast<unsigned int>(propname.lid));
96+
fprintf(stderr, "\t%08xh -> {MNID_ID, %s, %xh}\n",
97+
proptag, g, static_cast<unsigned int>(propname.lid));
9898
else if (propname.kind == MNID_STRING)
99-
fprintf(stderr, "\t%04xh <-> {MNID_STRING, %s, %s}\n",
100-
propid, g, propname.name.c_str());
99+
fprintf(stderr, "\t%08xh -> {MNID_STRING, %s, %s}\n",
100+
proptag, g, propname.name.c_str());
101101
}
102102
}
103103

@@ -172,10 +172,13 @@ void gi_name_map_write(const gi_name_map &map)
172172
throw std::bad_alloc();
173173
if (ep.p_uint64(map.size()) != EXT_ERR_SUCCESS)
174174
throw YError("PG-1110");
175-
for (const auto &[propid, xn] : map)
176-
if (ep.p_uint32(propid) != EXT_ERR_SUCCESS ||
175+
for (const auto &[proptag, xn] : map) {
176+
static_assert(sizeof(gi_name_map::key_type) == sizeof(uint32_t),
177+
"Something is fishy with the definition of gi_name_map");
178+
if (ep.p_uint32(proptag) != pack_result::ok ||
177179
ep.p_propname(static_cast<PROPERTY_NAME>(xn)) != EXT_ERR_SUCCESS)
178180
throw YError("PG-1111");
181+
}
179182
uint64_t xsize = cpu_to_le64(ep.m_offset);
180183
if (HXio_fullwrite(STDOUT_FILENO, &xsize, sizeof(xsize)) < 0)
181184
throw YError("PG-1112: %s", strerror(errno));

tools/mt2exm.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,8 @@ static void gi_dump_thru_map(const propididmap_t &map)
413413
{
414414
if (!g_show_props)
415415
return;
416-
fprintf(stderr, "Named properties, thru-map (%zu entries):\n", map.size());
416+
fprintf(stderr, "propid-to-propid map (%zu entries):\n", map.size());
417+
fprintf(stderr, "\t# src propid <-> dst propid:\n");
417418
for (const auto &[from, to] : map)
418419
fprintf(stderr, "\t%04xh <-> %04xh\n", from, to);
419420
}

tools/staticnpmap.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ struct namedprop_bimap {
1212
public:
1313
uint16_t emplace(uint16_t, PROPERTY_XNAME &&);
1414

15-
gi_name_map fwd;
15+
gi_name_map fwd; /* note this is uint32_t -> */
1616
std::unordered_map<std::string, uint16_t> rev;
1717
uint16_t nextid = 0x8000;
1818
};
@@ -38,7 +38,7 @@ uint16_t namedprop_bimap::emplace(uint16_t desired_propid, PROPERTY_XNAME &&name
3838
auto [iter, newly_added] = rev.emplace(txt, desired_propid);
3939
if (!newly_added)
4040
return iter->second;
41-
fwd.emplace(desired_propid, std::move(name));
41+
fwd.emplace(PROP_TAG(PT_UNSPECIFIED, desired_propid), std::move(name));
4242
nextid = std::max(nextid, static_cast<uint16_t>(desired_propid + 1));
4343
return desired_propid;
4444
}

0 commit comments

Comments
 (0)