Commit 26adfbca authored by Morten Welinder's avatar Morten Welinder

stf: debug improvements.

parent b4a8a34a
2011-03-28 Morten Welinder <terra@gnome.org>
* src/stf-parse.c (dump_guessed_options): New function.
(stf_parse_options_guess,stf_parse_options_guess_csv): Optionally
call dump_guessed_options.
* src/stf-parse.h (enum StfTrimType_t): Use the values intended.
2011-03-27 Andreas J. Guelzow <aguelzow@pyrshep.ca>
* src/sheet-control-gui.c (snap_pos_to_grid): don't move an aligned
......
......@@ -176,7 +176,7 @@ csv_page_parseoptions_to_gui (StfDialogData *pagedata)
}
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pagedata->csv.csv_duplicates),
po->duplicates);
po->sep.duplicates);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pagedata->csv.csv_trim_seps),
po->trim_seps);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pagedata->csv.csv_2x_indicator),
......
......@@ -145,7 +145,7 @@ stf_parse_options_new (void)
parseoptions->stringindicator = '"';
parseoptions->indicator_2x_is_single = TRUE;
parseoptions->duplicates = FALSE;
parseoptions->sep.duplicates = FALSE;
parseoptions->trim_seps = FALSE;
parseoptions->sep.str = NULL;
......@@ -336,7 +336,7 @@ stf_parse_options_csv_set_duplicates (StfParseOptions_t *parseoptions, gboolean
{
g_return_if_fail (parseoptions != NULL);
parseoptions->duplicates = duplicates;
parseoptions->sep.duplicates = duplicates;
}
/**
......@@ -656,7 +656,7 @@ stf_parse_csv_cell (GString *text, Source_t *src, StfParseOptions_t *parseoption
src->position = cur;
if (saw_sep && parseoptions->duplicates)
if (saw_sep && parseoptions->sep.duplicates)
stf_parse_eat_separators (src, parseoptions);
return saw_sep ? STF_CELL_FIELD_SEP : STF_CELL_FIELD_NO_SEP;
......@@ -1457,6 +1457,46 @@ count_character (GPtrArray *lines, gunichar c, double quantile)
return res;
}
static void
dump_guessed_options (const StfParseOptions_t *res)
{
GSList *l;
char ubuffer[6 + 1];
g_printerr ("Guessed format:\n");
switch (res->parsetype) {
case PARSE_TYPE_CSV:
g_printerr (" type = sep\n");
g_printerr (" separator = %s\n", res->sep.chr);
g_printerr (" see two as one = %s\n",
res->sep.duplicates ? "yes" : "no");
break;
case PARSE_TYPE_FIXED:
g_printerr (" type = sep\n");
break;
default:
;
}
g_printerr (" trim space = %d\n", res->trim_spaces);
ubuffer[g_unichar_to_utf8 (res->stringindicator, ubuffer)] = 0;
g_printerr (" string indicator = %s\n", ubuffer);
g_printerr (" see two as one = %s\n",
res->indicator_2x_is_single ? "yes" : "no");
g_printerr (" line terminators =");
for (l = res->terminator; l; l = l->next) {
const char *t = l->data;
if (strcmp (t, "\n"))
g_printerr (" unix");
else if (strcmp (t, "\r"))
g_printerr (" mac");
else if (strcmp (t, "\r\n"))
g_printerr (" dos");
}
g_printerr ("\n");
}
StfParseOptions_t *
stf_parse_options_guess (char const *data)
......@@ -1530,6 +1570,9 @@ stf_parse_options_guess (char const *data)
stf_parse_general_free (lines);
g_string_chunk_free (lines_chunk);
if (gnm_debug_flag ("stf"))
dump_guessed_options (res);
return res;
}
......@@ -1614,5 +1657,8 @@ stf_parse_options_guess_csv (char const *data)
stf_parse_general_free (lines);
g_string_chunk_free (lines_chunk);
if (gnm_debug_flag ("stf"))
dump_guessed_options (res);
return res;
}
......@@ -17,7 +17,7 @@ typedef enum {
typedef enum {
TRIM_TYPE_NEVER = 0,
TRIM_TYPE_LEFT = 1 << 0,
TRIM_TYPE_RIGHT = 2 << 1
TRIM_TYPE_RIGHT = 1 << 1
} StfTrimType_t;
typedef struct {
......@@ -35,10 +35,10 @@ typedef struct {
struct {
GSList *str;
char *chr;
gboolean duplicates; /* See two text separators as one? */
} sep;
gunichar stringindicator; /* String indicator */
gboolean indicator_2x_is_single;/* 2 quote chars form a single non-terminating quote */
gboolean duplicates; /* See two text separators as one? */
gboolean trim_seps; /* Ignore initial seps. */
/* Fixed width related */
......
......@@ -165,12 +165,16 @@ resize_columns (Sheet *sheet)
{
GnmRange r;
if (gnm_debug_flag ("stf"))
g_printerr ("Auto-fitting columns...\n");
range_init_full_sheet (&r, sheet);
colrow_autofit (sheet, &r, TRUE,
TRUE, /* Ignore strings */
TRUE, /* Don't shrink */
TRUE, /* Don't shrink */
NULL, NULL);
if (gnm_debug_flag ("stf"))
g_printerr ("Auto-fitting columns... done\n");
sheet_queue_respan (sheet, 0, gnm_sheet_get_last_row (sheet));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment