GNOME Bugzilla – Bug 628893
Error with string-append and gimp-drawable-get-name, when the layer name contains certain characters.
Last modified: 2010-09-21 03:37:51 UTC
-> Open GIMP 2.6 and create a new image. -> Create two new layers named "é" and "e". -> Open the script-fu console. -> Get the ID of each layer. (to get the ID of a layer: -get the ID (imageID) of the image by seeing the top of its window (imageName-imageID) -in the layer dialog select the layer that you want to now its ID -type this on the console : (gimp-image-get-active-drawable imageID) , it returns the active layer ID ) -> type this: > (car (gimp-drawable-get-name lay1)) ==> "é" > (car (gimp-drawable-get-name lay2)) ==> "e" for the moment : no error (> means what you type, ==> means what GIMP returns, lay1 is the ID of the layer named "é" and lay2 is the ID of the layer named "e") -> type this: > (string-append "é" "a") ==> "éa" > (string-append "e" "a") ==> "ea" no error -> type this: > (string-append (car (gimp-drawable-get-name lay1)) "a") ==> > (string-append (car (gimp-drawable-get-name lay2)) "a") ==> "ea" The second expression does not create an error. The first expression must returns "éa" but GIMP does not return anything. -> type this : > (string-append (car (gimp-drawable-get-name lay1)) "é") ==> > (string-append (car (gimp-drawable-get-name lay2)) "é") ==> "eé" Note that the behaviour of GIMP is the same if you type "a" or any other character or string in the string-append expression. -> type this > (gimp-drawable-set-name lay1 (string-append (car (gimp-drawable-get-name lay1)) "a") ) ==> Error: Procedure execution of gimp-drawable-set-name failed on invalid input arguments: La procédure « gimp-drawable-set-name » a été appelée avec la valeur « > (gimp-drawable-set-name lay2 (string-append (car (gimp-drawable-get-name lay2)) "a") ) ==> (#t) The first expression returns an error, it is logic because the string-append expression does not return anything. -> Now change the name of the layer named "é" by "²", "è", "à", "°","§", "ù", "§", "ù", "ô", "ï" or what you want. Note that if the name of the layer contains certain characters and if you type this : (string-append (car (gimp-drawable-get-name lay1)) "a") , it generates an error.
This bug appears to be a duplicate of #572865 (see the end of comment #2). I'm leaving this report open for now as it has additional test cases.
Confirming. I have a fixed one bug in string-append but I'm still seeing some problems with a couple of the other test cases in this report.
Fixed in the 2.6 branch of GIMP: commit 136bfb61cc655d51b0ee7066f5126ceb33cf56c5 First part of fixes for handling UTF-8 coded strings (Bugs 572865 & 628893) commit c00dfc97d7bf8f47e4bb888079d6675f3e791e1e Last part of fixes for handling UTF-8 coded strings (Bugs 572865 & 628893) Fixed in the master branch of GIMP. commit 68552674702653abde0bfc5d4b0cd84d045b5d92 First part of fixes for handling UTF-8 coded strings (Bugs 572865 & 628893) commit ae6670ba8b20f03a7d12d5eba57c5be3b9dcb1db Last part of fixes for handling UTF-8 coded strings (Bugs 572865 & 628893)
Created attachment 170671 [details] [review] Proposed patch Executing OP_STRAPPEND and OP_SUBSTR you call 'mk_empty_string' to initialize a cell pointer and to allocate the string. But that way, if the string contains non-ASCII characters the 'strlength' is initialized with the number of bytes. Try: Welcome to TinyScheme Copyright (c) Dimitrios Souflis Script-Fu Console - Interactive Scheme Development > (define b (make-string 2 (integer->char 931))) b > (define a (string-append b b)) a > (string-length a) 4 > (string-length (string-append a a)) 4 Welcome to TinyScheme Copyright (c) Dimitrios Souflis Script-Fu Console - Interactive Scheme Development > (define b (make-string 8 (integer->char 931))) b > (define a (substring b 4)) a > (string-length a) 4 > (string-length (string-append a a)) 4
Fixed in the 2.6 branch of GIMP: commit 0a6d646c4af2ac5cb3afbc2ca7b477615ab36469 Additional fixes for handling UTF-8 coded strings (Bugs 572865 & 628893) Fixed in the master branch of GIMP. commit b0d8ba5ffddd46798a7480d75f5de3c8d808b9ad Additional fixes for handling UTF-8 coded strings (Bugs 572865 & 628893)