There's some memory corruption in COPYDEF when copying a procedure that's defined with DEFINE. Specifically the title line of the new procedure is corrupted when viewed by "PO" (it starts with garbage characters instead of "to" and doesn't include any inputs.
I reproduced this UCBLogo 6.2.5 and FMSLogo 6.23.0. FMSLogo 6.22.0 and earlier don't have this bug. I suspect this was introduced by the fix for Bug #317, which I copied from UCBLogo.
The bug is that cpdf_newname assumes that the title line is a word. When a procedure is defined by TO, that's true. When a procedure is defined by DEFINE, it's a list.
// For the purpose of this function, the title line
// consists of three parts:
// (TO|.MACRO) (procname) (args)*
const wchar_t * titlestr = getstrptr(TitleLine); // <-- BUG
// Set p1 to just before the procedure name
// Either "TO" or ".MACRO" comes before it.
const wchar_t * p1 = titlestr + wcscspn(titlestr, L" \t");
p1 = p1 + wcsspn(p1, L" \t");
It's surprising that this doesn't crash, but the memory corruption does lead to some problems. For example, because the title line is corrupted, EDALL includes a procedure that can't be saved.
Steps to Reproduce:
DEFINE "a [ [x] ]
COPYDEF "b "a
PO "b
What Happens:
The title line for "b" doesn't start with "TO" but instead with some garbage characters and doesn't include the input.
ȁb
end
Expected Result:
The output for "b" is well-formed. It looks like
to b :x
end