After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 642477 - import from CSV clobbers string value if leading space is present
import from CSV clobbers string value if leading space is present
Status: RESOLVED FIXED
Product: Gnumeric
Classification: Applications
Component: import/export Text
1.10.x
Other Linux
: Normal major
: ---
Assigned To: Morten Welinder
Jody Goldberg
Depends on:
Blocks:
 
 
Reported: 2011-02-16 16:23 UTC by Thomas Quinot
Modified: 2011-02-24 16:05 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Input CSV file (82 bytes, application/csv)
2011-02-16 16:23 UTC, Thomas Quinot
Details
screenshot of observed clobbered values (21.55 KB, image/png)
2011-02-16 16:24 UTC, Thomas Quinot
Details

Description Thomas Quinot 2011-02-16 16:23:21 UTC
Created attachment 181016 [details]
Input CSV file

When loading the attached toto.csv file (from the command line: "gnumeric toto.csv"), cell A3 contains "XXX#1500" instead of " XXX#1750"). Similarly, cell A5 contains "abcdeghh".

This is with Gnumeric 1.10.1 (Ubuntu 1.10.1-1ubuntu1).
Comment 1 Thomas Quinot 2011-02-16 16:24:04 UTC
Created attachment 181017 [details]
screenshot of observed clobbered values
Comment 2 Andreas J. Guelzow 2011-02-16 16:38:08 UTC
I do not see this with current git (which is essentially 1.10.13 plus a little bit) nor in 1.10.8 from ubuntu.

Same result if I try a french locale instead.

I suspect this may have been fixed since 1.10.1 but it is such a strange bug...
Comment 3 Andreas J. Guelzow 2011-02-16 16:46:54 UTC
Could you please verify what is really in those cells in question ie. A3 and A5 by editing those cells and seeing what shows up in the edit line? This may be an cell rendering problem. There have been fixes to the item grid rendering since 1.10.1.
Comment 4 Thomas Quinot 2011-02-16 16:55:16 UTC
confirmed. Cell contents is consistent with what is displayed in the edit line.
Comment 5 Andreas J. Guelzow 2011-02-16 17:23:59 UTC
Would you be able to update to a newer version of Gnumeric? Maverick has 1.10.8 and Natty has 1.10.13.
Comment 6 Morten Welinder 2011-02-17 14:25:05 UTC
This is weird, but I am also unable to reproduce.

Was Andreas right in guessing that this was with French locale?  (As
opposed to some other French-speaking locale.)  It shouldn't matter,
but still...
Comment 7 Thomas Quinot 2011-02-17 14:29:45 UTC
This was with a French locale but I see exactly the same behaviour with LANG=C.
Will try to upgrade as suggested.
Comment 8 Jean Bréfort 2011-02-19 06:56:24 UTC
I can reproduce with current git. When using the configuratble text import, things are OK in the dialog box in the two first tabs but the leading spaces disappear in the third, even if I run gnumeric in C locale. I must put the trim option to "Neither side" to make things work properly.
Comment 9 Andreas J. Guelzow 2011-02-19 07:49:35 UTC
@Jean: At this stage we aren't really worried about the spaces. Do you see the change in the string ie. "XXX#1500" instead of " XXX#1750" note the change 5->7 and " abcdefgh" "abcdeghh" note hte "ef"->"gh"!?
Comment 10 Andreas J. Guelzow 2011-02-19 07:52:13 UTC
that was supposed to be 7->5
Comment 11 Jean Bréfort 2011-02-19 07:58:15 UTC
No, I only see the leading white spaces issue.
Comment 12 Andreas J. Guelzow 2011-02-19 14:10:43 UTC
@Thomas, do you see the problem with the changed strings independent from the setting of the "trim" option?
Comment 13 Andreas J. Guelzow 2011-02-21 03:43:06 UTC
trim_spaces_inplace trims the spaces on the left by shifting the characters left using "strcpy". My manual page of strcpy says: "The  strings  may  not overlap, and the destination string dest must be large enough to receive the copy." In this specific case the strings do overlap. In the expected implementation of strcpy this should not be an issue but perhaps Thomas' compilation uses a different implementation where things fall apart.

I don't thin kwe should be using "strcpy".
Comment 14 Andreas J. Guelzow 2011-02-21 03:47:46 UTC
We probably should replace strcpy with memmove.
Comment 15 Morten Welinder 2011-02-21 23:20:47 UTC
aha.

I seem to recall that recent glibc may actually do things "wrong" if we
violate the requirements.
Comment 16 Morten Welinder 2011-02-21 23:32:13 UTC
Tentatively fixes.  Keeping open for confirmation that no-strip-spaces
works even before the fix.

> @Thomas, do you see the problem with the changed strings independent from the
> setting of the "trim" option?
Comment 17 Morten Welinder 2011-02-23 20:58:28 UTC
Believed fixed.
Comment 18 Thomas Quinot 2011-02-24 10:24:40 UTC
Thanks Morten! Indeed the symptom looks like what might happen with a strcpy on overlapping data.

Sorry for asking a basic question but... Where do I change the trim settings to check whether this indeed makes the problem disappear?
Comment 19 Morten Welinder 2011-02-24 13:40:07 UTC
Final page of the configurable text importer has that.
Not possible from command line.
Comment 20 Andreas J. Guelzow 2011-02-24 14:05:22 UTC
Onthe top left of the finalpage: "Coupure".
Comment 21 Thomas Quinot 2011-02-24 14:33:15 UTC
Got it! I confirm that the problem does not appear if importing without any trimming, or with just right-side trimming. It does show if importing with trimming on the left side or both sides.
Comment 22 Thomas Quinot 2011-02-24 14:44:17 UTC
For the record, I was able to reproduce the faulty behaviour on my machine (Ubuntu 10.04 with glibc 2.11.1), and check the validity of the fix, using a reduced C testcase:

#include <stdio.h>
#include <string.h>

char s1[] = " XXX#1750";
char *s2 = s1 + 1;
void main (void) {
#ifdef BAD
  strcpy (s1, s2);
#else
  memmove (s1, s2, 1 + strlen (s2));
#endif
  printf ("«%s»\n", s1);
}
Comment 23 Andreas J. Guelzow 2011-02-24 16:05:43 UTC
Thanks Thomas. Good to know that this should really have fixed the problem at hand. (It is always difficult to handle bugs we can't replicate.)