Commit b3e56741 authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

Add maxlines argument. All callers changed.

2003-10-14  Morten Welinder  <terra@gnome.org>

	* src/stf-parse.c (stf_parse_general): Add maxlines argument.  All
	callers changed.
parent 01381dec
2003-10-14 Morten Welinder <terra@gnome.org>
* src/stf-parse.c (stf_parse_general): Add maxlines argument. All
callers changed.
2003-10-13 Jody Goldberg <jody@gnome.org>
* src/number-match.c (format_match_init) : trivial optimization to
......
......@@ -13,6 +13,8 @@ Morten:
* Fix crash with STF import and gazillions of columns.
* Drastically reduce memory usage during STF import with lots of
small fields.
* Speed up STF import by now creating field structures for lines
not shown in the preview anyway.
Rodrigo:
* Bump requirement to libgda/libgnomedb 1.0.1
......
2003-10-14 Morten Welinder <terra@gnome.org>
* src/stf-parse.c (stf_parse_general): Add maxlines argument. All
callers changed.
2003-10-13 Jody Goldberg <jody@gnome.org>
* src/number-match.c (format_match_init) : trivial optimization to
......
2003-10-14 Morten Welinder <terra@gnome.org>
* src/stf-parse.c (stf_parse_general): Add maxlines argument. All
callers changed.
2003-10-13 Jody Goldberg <jody@gnome.org>
* src/number-match.c (format_match_init) : trivial optimization to
......
......@@ -94,7 +94,8 @@ csv_page_global_change (G_GNUC_UNUSED GtkWidget *widget,
trim = parseoptions->trim_spaces;
stf_parse_options_set_trim_spaces (parseoptions, TRIM_TYPE_NEVER);
lines = stf_parse_general (parseoptions, lines_chunk,
pagedata->cur, pagedata->cur_end);
pagedata->cur, pagedata->cur_end,
LINE_DISPLAY_LIMIT);
stf_parse_options_set_trim_spaces (parseoptions, trim);
stf_preview_set_lines (renderdata, lines_chunk, lines);
......
......@@ -389,7 +389,8 @@ fixed_page_update_preview (StfDialogData *pagedata)
trim = parseoptions->trim_spaces;
stf_parse_options_set_trim_spaces (parseoptions, TRIM_TYPE_NEVER);
lines = stf_parse_general (parseoptions, lines_chunk,
pagedata->cur, pagedata->cur_end);
pagedata->cur, pagedata->cur_end,
LINE_DISPLAY_LIMIT);
stf_parse_options_set_trim_spaces (parseoptions, trim);
stf_preview_set_lines (renderdata, lines_chunk, lines);
......
......@@ -342,7 +342,8 @@ format_page_update_preview (StfDialogData *pagedata)
stf_parse_general (pagedata->parseoptions,
lines_chunk,
pagedata->cur,
pagedata->cur_end));
pagedata->cur_end,
LINE_DISPLAY_LIMIT));
col_import_array_len_old = pagedata->format.col_import_array_len;
pagedata->format.col_import_array_len = renderdata->colcount;
......
......@@ -75,9 +75,12 @@ main_page_update_preview (StfDialogData *pagedata)
GStringChunk *lines_chunk = g_string_chunk_new (100 * 1024);
GPtrArray *lines = stf_parse_lines (pagedata->parseoptions,
lines_chunk,
pagedata->utf8_data, TRUE);
pagedata->utf8_data,
SHEET_MAX_ROWS,
TRUE);
unsigned int ui;
pagedata->rowcount = lines->len;
pagedata->longest_line = 0;
for (ui = 0; ui < lines->len; ui++) {
GPtrArray *line = g_ptr_array_index (lines, ui);
......
......@@ -24,11 +24,7 @@
#include <gtk/gtktooltips.h>
#define LINE_DISPLAY_LIMIT 500
#define RAW_LINE_DISPLAY_LIMIT 4096
#define X_OVERFLOW_PROTECT 2048
#define COLUMN_CAPTION N_("Column %d")
#define MOUSE_SENSITIVITY 5
typedef struct {
GtkWidget *data_container;
......
......@@ -394,7 +394,7 @@ stf_dialog (WorkbookControlGUI *wbcg,
dialogresult->encoding = pagedata.encoding;
pagedata.encoding = NULL;
dialogresult->rowcount = pagedata.format.renderdata->lines->len;
dialogresult->rowcount = pagedata.rowcount;
dialogresult->parseoptions = pagedata.parseoptions;
pagedata.parseoptions = NULL;
......
......@@ -113,6 +113,7 @@ typedef struct {
const char *source; /* Where we are reading from (UTF-8) */
int rowcount;
int longest_line; /* #characters in longest line. */
MainInfo_t main;
......
......@@ -784,7 +784,8 @@ stf_parse_general_free (GPtrArray *lines)
GPtrArray *
stf_parse_general (StfParseOptions_t *parseoptions,
GStringChunk *lines_chunk,
char const *data, char const *data_end)
char const *data, char const *data_end,
int maxlines)
{
GPtrArray *lines;
Source_t src;
......@@ -815,6 +816,9 @@ stf_parse_general (StfParseOptions_t *parseoptions,
g_ptr_array_add (lines, line);
src.position += compare_terminator (src.position, parseoptions);
if (row >= maxlines)
break;
}
return lines;
......@@ -823,7 +827,8 @@ stf_parse_general (StfParseOptions_t *parseoptions,
GPtrArray *
stf_parse_lines (StfParseOptions_t *parseoptions,
GStringChunk *lines_chunk,
const char *data, gboolean with_lineno)
const char *data,
int maxlines, gboolean with_lineno)
{
GPtrArray *lines;
int lineno = 1;
......@@ -837,7 +842,7 @@ stf_parse_lines (StfParseOptions_t *parseoptions,
if (with_lineno) {
char buf[4 * sizeof (int)];
sprintf (buf, "%d", lineno++);
sprintf (buf, "%d", lineno);
g_ptr_array_add (line,
g_string_chunk_insert (lines_chunk, buf));
}
......@@ -865,6 +870,10 @@ stf_parse_lines (StfParseOptions_t *parseoptions,
}
g_ptr_array_add (lines, line);
lineno++;
if (lineno >= maxlines)
break;
}
return lines;
}
......@@ -1169,7 +1178,8 @@ stf_parse_sheet (StfParseOptions_t *parseoptions,
if (!data_end)
data_end = data + strlen (data);
lines_chunk = g_string_chunk_new (100 * 1024);
lines = stf_parse_general (parseoptions, lines_chunk, data, data_end);
lines = stf_parse_general (parseoptions, lines_chunk, data, data_end,
SHEET_MAX_ROWS);
for (row = start_row, lrow = 0; lrow < lines->len ; row++, lrow++) {
unsigned int lcol, lcol_target = 0;
GPtrArray *line = g_ptr_array_index (lines, lrow);
......@@ -1220,7 +1230,8 @@ stf_parse_region (StfParseOptions_t *parseoptions, char const *data, char const
if (!data_end)
data_end = data + strlen (data);
lines_chunk = g_string_chunk_new (100 * 1024);
lines = stf_parse_general (parseoptions, lines_chunk, data, data_end);
lines = stf_parse_general (parseoptions, lines_chunk, data, data_end,
SHEET_MAX_ROWS);
for (row = 0; row < lines->len; row++) {
GPtrArray *line = g_ptr_array_index (lines, row);
unsigned int col, targetcol = 0;
......@@ -1394,7 +1405,7 @@ stf_parse_options_guess (const char *data)
res = stf_parse_options_new ();
lines_chunk = g_string_chunk_new (100 * 1024);
lines = stf_parse_lines (res, lines_chunk, data, FALSE);
lines = stf_parse_lines (res, lines_chunk, data, SHEET_MAX_ROWS, FALSE);
tabcount = count_character (lines, '\t', 0.2);
sepcount = count_character (lines, sepchar, 0.2);
......
......@@ -98,11 +98,13 @@ int stf_parse_options_fixed_splitpositions_nth (StfParseOptions_t *parse
GPtrArray *stf_parse_general (StfParseOptions_t *parseoptions,
GStringChunk *lines_chunk,
char const *data,
char const *data_end);
char const *data_end,
int maxlines);
void stf_parse_general_free (GPtrArray *lines);
GPtrArray *stf_parse_lines (StfParseOptions_t *parseoptions,
GStringChunk *lines_chunk,
const char *data,
int maxlines,
gboolean with_lineno);
void stf_parse_options_fixed_autodiscover (StfParseOptions_t *parseoptions,
......
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