Skip to content

Commit

Permalink
TableConvert: Fixing an issue on handling \r and \n (Windows style fi…
Browse files Browse the repository at this point in the history
…les) and 'empty' lines inside created table
  • Loading branch information
frlan committed Oct 5, 2014
1 parent aef37b0 commit 15d28a5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tableconvert/ChangeLog
@@ -1,3 +1,10 @@
2014-10-05 Frank Lanitz <frank@frank.uvena.de>

* Fixing an issue where \r and \n on e.g. Windows files handled as
seperate lines ending up in 'empty' table lines.



2014-09-28 Frank Lanitz <frank@frank.uvena.de>

* SQL: Treating every column as a string when transfering data to SQL
Expand Down
8 changes: 8 additions & 0 deletions tableconvert/src/tableconvert.c
Expand Up @@ -184,10 +184,18 @@ static void convert_to_table(gboolean header)
gchar *selection = NULL;
gchar **rows = NULL;
gchar *replacement = NULL;
GString *selection_str = NULL;

/* Actually grabbing selection and splitting it into single
* lines we will work on later */
selection = sci_get_selection_contents(doc->editor->sci);

selection_str = g_string_new(selection);
utils_string_replace_all(selection_str, "\r\n", "\n");

g_free(selection);
selection = g_string_free(selection_str, FALSE);

rows = g_strsplit_set(selection, "\r\n", -1);
g_free(selection);

Expand Down

0 comments on commit 15d28a5

Please sign in to comment.