moved the new string escape function here and also it for the
2007-10-11 Sven Neumann <sven@gimp.org> * plug-ins/script-fu/script-fu-scripts.[ch]: moved the new string escape function here and also it for the non-interactive case. * plug-ins/script-fu/script-fu-interface.c: changed accordingly. svn path=/trunk/; revision=23802
This commit is contained in:
committed by
Sven Neumann
parent
426eb27e7e
commit
66fecb60e6
@ -103,8 +103,6 @@ static void script_fu_brush_callback (gpointer data,
|
||||
const guchar *mask_data,
|
||||
gboolean closing);
|
||||
|
||||
static gchar * script_fu_strescape (const gchar *source);
|
||||
|
||||
|
||||
/*
|
||||
* Local variables
|
||||
@ -1012,67 +1010,3 @@ script_fu_reset (SFScript *script)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Escapes the special characters '\b', '\f', '\n', '\r', '\t', '\' and '"'
|
||||
* in the string source by inserting a '\' before them.
|
||||
*/
|
||||
static gchar *
|
||||
script_fu_strescape (const gchar *source)
|
||||
{
|
||||
const guchar *p;
|
||||
gchar *dest;
|
||||
gchar *q;
|
||||
|
||||
g_return_val_if_fail (source != NULL, NULL);
|
||||
|
||||
p = (const guchar *) source;
|
||||
|
||||
/* Each source byte needs maximally two destination chars */
|
||||
q = dest = g_malloc (strlen (source) * 2 + 1);
|
||||
|
||||
while (*p)
|
||||
{
|
||||
switch (*p)
|
||||
{
|
||||
case '\b':
|
||||
*q++ = '\\';
|
||||
*q++ = 'b';
|
||||
break;
|
||||
case '\f':
|
||||
*q++ = '\\';
|
||||
*q++ = 'f';
|
||||
break;
|
||||
case '\n':
|
||||
*q++ = '\\';
|
||||
*q++ = 'n';
|
||||
break;
|
||||
case '\r':
|
||||
*q++ = '\\';
|
||||
*q++ = 'r';
|
||||
break;
|
||||
case '\t':
|
||||
*q++ = '\\';
|
||||
*q++ = 't';
|
||||
break;
|
||||
case '\\':
|
||||
*q++ = '\\';
|
||||
*q++ = '\\';
|
||||
break;
|
||||
case '"':
|
||||
*q++ = '\\';
|
||||
*q++ = '"';
|
||||
break;
|
||||
default:
|
||||
*q++ = *p;
|
||||
break;
|
||||
}
|
||||
|
||||
p++;
|
||||
}
|
||||
|
||||
*q = 0;
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user