MCDE dtpaint: Ctrl+S kept the path and title (t0704 follow-up)

DoSave(curPath) passed curPath as both the destination and the source of
snprintf, which is undefined; glibc emptied it, so after Ctrl+S the title
fell back to 'untitled' and the next Save opened Save As again.  Copy only
when the pointers differ.  Found while verifying the PseudoColor path on
Xvfb depth 8 (4-colour BMP round trip exact, selftest PASS); recorded in
AGENTS.md.
This commit is contained in:
lotherk committed 2026-11-22 05:50:22 +00:00
1 parent f599906311
commit fd66cdb200
2 files changed
+8 -2

No files matched your search

+4 -1
View File
@@ -80,7 +80,10 @@ narratives and test notes, is `docs/reference/mcde-agents-history-2026-11-13.txt
and refreshed after a load, and Open/Save/Invert convert colours through
the visual's masks on TrueColor (or in batches otherwise), never one X
round trip per pixel (measured 2026-11-21: open 18.3 s -> 0.02 s, invert
14.9 s -> 0.05 s, save 6.3 s -> 0.23 s on a 1024x768 BMP).
14.9 s -> 0.05 s, save 6.3 s -> 0.23 s on a 1024x768 BMP; PseudoColor
measured 2026-11-22 on Xvfb depth 8: 4-colour BMP round trip exact,
selftest PASS -- a picture with more colours than the 256-cell colormap
holds loses the excess, as any 8-bit paint must).
McdeSys has a catalog too (`lib/McdeSys/mcdesys.msg`, `lib/McdeSys/
text.c`, `mcde_sys_msg`): common.c's tool errors ask it for their sentence
(messages 1-9: not there, cannot start, failed with status, no pipe, no
+4 -1
View File
@@ -1109,7 +1109,10 @@ static void
DoSave(const char *path)
{
if (SaveBMP(path) == 0) {
snprintf(curPath, sizeof curPath, "%s", path);
/* C_SAVE passes curPath itself; snprintf onto the same buffer
* is undefined and emptied it (the title fell back to untitled) */
if (path != curPath)
snprintf(curPath, sizeof curPath, "%s", path);
dirty = 0;
SetTitle();
} else {