Re: [patch] escaping double quotes in SF_STRING values
Tor Lillqvist writes: | | Tamito KAJIYAMA writes: | I've just installed 1.1.15 and found a bug (IMO) that Script-Fu | failed if a string containing double quotes was given as an | argument of the SF_STRING type. Attached is a quick and dirty | patch for fixing that bug. | | This patch is unnecessary when using GLib 1.3 or later, as the whole | point of g_strescape() (which is what the ESCAPE macro in the source | calls) is to escape chars that are risky in a C (or script-fu) string, | like double quotes or nonprinting characters. Good news :) | Unfortunately g_strescape as implemented in GLib 1.2 escapes only | backslashes... (because or my shortsightedness, I confess), not double | quotes (or nonprinting characters). However, the code in the GIMP that | uses g_strescape() gets unnecessary complex if we start taking that | into consideration. Yes. My patch was a compromise. | Wouldn't it be far simpler to release a newer version of GLib 1.2, | with g_strescape() having the same calling convention as before (the | prototype was changed in GLib 1.3 (partial sigh)), but with a wider | range of characters handled, and then require this GLib version | (1.2.7?) for the development GIMP? I cast my vote for this approach. -- KAJIYAMA, Tamito [EMAIL PROTECTED]
[patch] escaping double quotes in SF_STRING values
Hi. I've just installed 1.1.15 and found a bug (IMO) that Script-Fu failed if a string containing double quotes was given as an argument of the SF_STRING type. Attached is a quick and dirty patch for fixing that bug. I wonder if we need to escape the values of the SF_FILENAME type in the same way, although I believe that few people use double quotes in file names. I hope this helps. Regards, -- KAJIYAMA, Tamito [EMAIL PROTECTED] diff -ru gimp-1.1.15.orig/plug-ins/script-fu/script-fu-scripts.c gimp-1.1.15/plug-ins/script-fu/script-fu-scripts.c --- gimp-1.1.15.orig/plug-ins/script-fu/script-fu-scripts.c Mon Jan 3 05:52:56 2000 +++ gimp-1.1.15/plug-ins/script-fu/script-fu-scripts.c Mon Jan 17 07:22:08 2000 @@ -1543,9 +1543,9 @@ char *command, *c; char buffer[MAX_STRING_LENGTH]; int length; - int i; + int i, j; GdkFont *font; - char *escaped; + char *escaped, *p, *q; if ((script = sf_interface.script) == NULL) return; @@ -1586,7 +1586,11 @@ break; case SF_STRING: escaped = ESCAPE (gtk_entry_get_text (GTK_ENTRY (script-args_widgets[i]))); - length += strlen (escaped) + 3; + j = 0; /* number of double quotes */ + for (p = escaped; *p; p++) + if (*p == '"') + j++; + length += strlen (escaped) + j + 3; g_free (escaped); break; case SF_ADJUSTMENT: @@ -1649,9 +1653,21 @@ text = gtk_entry_get_text (GTK_ENTRY (script-args_widgets[i])); g_free (script-arg_values[i].sfa_value); script-arg_values[i].sfa_value = g_strdup (text); - escaped = ESCAPE (text); + p = ESCAPE (text); + j = 0; /* number of double quotes */ + for (q = p; *q; q++) + if (*q == '"') + j++; + q = escaped = g_new (gchar, strlen (p) + j + 1); + for (j = 0; p[j]; j++) { + if (p[j] == '"') + *q++ = '\\'; + *q++ = p[j]; + } + *q = '\0'; g_snprintf (buffer, MAX_STRING_LENGTH, "\"%s\"", escaped); g_free (escaped); + g_free (p); text = buffer; break; case SF_ADJUSTMENT:
[patch] gimp-drawable-get/set-pixel bugfix
Hi. I found a bug that gimp-drawable-get/set-pixel swapped the specified x and y coordinates when getting/setting a pixel. I found the bug in 1.1.10 but the bug seems not to be fixed in 1.1.11. Attached is a patch that fixes the bug. Regards, -- KAJIYAMA, Tamito [EMAIL PROTECTED] --- drawable_cmds.c.origThu Oct 7 04:55:27 1999 +++ drawable_cmds.c Mon Nov 8 17:38:15 1999 @@ -1057,7 +1057,7 @@ x %= TILE_WIDTH; y %= TILE_WIDTH; - p = tile_data_pointer (tile, y, x); + p = tile_data_pointer (tile, x, y); for (b = 0; b num_channels; b++) pixel[b] = p[b]; @@ -1167,7 +1167,7 @@ x %= TILE_WIDTH; y %= TILE_WIDTH; - p = tile_data_pointer (tile, y, x); + p = tile_data_pointer (tile, x, y); for (b = 0; b num_channels; b++) *p++ = *pixel++;