[PD] makefilename-bug (was: number to symbol)
Martin Peach
martinrp at vax2.concordia.ca
Thu Nov 17 17:41:10 CET 2005
s.koepf wrote:
>> the solution is pretty simple: pd does a very bad job when it comes
>> to escaping special characters. "{" and "}" are such special
>> characters (in tcl world); this is why they are banned from normal
>> user-input.
>> however, 123 is the ascii value of "{", and by using [symbol\ you are
>> sending this special symbol to the pd-gui (tcl/tk!); now tcl uses "{"
>> for starting a list and WAITS for "}" to end the list.
>> if you manage to send "}" (ascii 125) to the pd-gui, pd will unfreeze
>> and everything is fine again.
>>
>> example:
>>
>> [123, 125(
>> |
>> [makefilename %c]
>> |
>> [symbol\
>>
>
> Thanks IOhannes,
>
> I followed many ot those dicussions on the subject on this list, but
> what I never saw is a complete list of all "dangerous" characters in
> pd/tcl/tk. Would be nice to have one.
>
Here on WinXP and Miller's pd039_test7 it's the [print] that does it.
[symbol] on its own is OK.
In the source code s_print.c it looks like four characters are escaped:
'\', '{', '}', and ';'.
But if they are escaped they should not freeze the gui...
static void dopost(const char *s)
{
...
if (c == '\\' || c == '{' || c == '}' || c == ';') <- if
it's a dangerous character for tcl
upbuf[ptout++] = '\\'; <- add a backslash before the
dangerous character
upbuf[ptout] = s[ptin]; <- then put the character
...
sys_vgui("pdtk_post {%s}\n", upbuf); <- then send it to tcl
interpreter
If I try entering them in a print box I get different results. '\' and
'}' are rejected:
\}: dropped
\\: dropped
';' is accepted
'{' freezes the gui.
In g_editor.c:
void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av)
{
...
if (keynum == '\\' || keynum == '{' || keynum == '}') <-a dangerous
character
{
post("%c: dropped", (int)keynum); <-should be dropped, but for
'{' this doesn't get printed
return;
}
...dopost() is called from post() so '{' is causing trouble even when it
is escaped with a backslash.
Martin
More information about the Pd-list
mailing list