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

const issues.

2000-07-05  Morten Welinder  <terra@diku.dk>

	* src/clipboard.c (x_selection_to_cell_region): Copy data and zero
 	terminate it.

	* src/stf-parse.c (stf_parse_fixed_line): Kill unneeded cast.
	(stf_parse_convert_to_unix): Unconstify.  Don't bother keeping
 	track of len.  Handle form-feeds better.
parent 01b8664a
2000-07-05 Morten Welinder <terra@diku.dk>
* src/clipboard.c (x_selection_to_cell_region): Copy data and zero
terminate it.
* src/stf-parse.c (stf_parse_fixed_line): Kill unneeded cast.
(stf_parse_convert_to_unix): Unconstify. Don't bother keeping
track of len. Handle form-feeds better.
2000-07-05 Almer. S. Tigelaar. <almer1@dds.nl>
* src/stf-parse.c:
......
2000-07-05 Morten Welinder <terra@diku.dk>
* src/clipboard.c (x_selection_to_cell_region): Copy data and zero
terminate it.
* src/stf-parse.c (stf_parse_fixed_line): Kill unneeded cast.
(stf_parse_convert_to_unix): Unconstify. Don't bother keeping
track of len. Handle form-feeds better.
2000-07-05 Almer. S. Tigelaar. <almer1@dds.nl>
* src/stf-parse.c:
......
2000-07-05 Morten Welinder <terra@diku.dk>
* src/clipboard.c (x_selection_to_cell_region): Copy data and zero
terminate it.
* src/stf-parse.c (stf_parse_fixed_line): Kill unneeded cast.
(stf_parse_convert_to_unix): Unconstify. Don't bother keeping
track of len. Handle form-feeds better.
2000-07-05 Almer. S. Tigelaar. <almer1@dds.nl>
* src/stf-parse.c:
......
2000-07-05 Morten Welinder <terra@diku.dk>
* src/clipboard.c (x_selection_to_cell_region): Copy data and zero
terminate it.
* src/stf-parse.c (stf_parse_fixed_line): Kill unneeded cast.
(stf_parse_convert_to_unix): Unconstify. Don't bother keeping
track of len. Handle form-feeds better.
2000-07-05 Almer. S. Tigelaar. <almer1@dds.nl>
* src/stf-parse.c:
......
2000-07-05 Morten Welinder <terra@diku.dk>
* src/clipboard.c (x_selection_to_cell_region): Copy data and zero
terminate it.
* src/stf-parse.c (stf_parse_fixed_line): Kill unneeded cast.
(stf_parse_convert_to_unix): Unconstify. Don't bother keeping
track of len. Handle form-feeds better.
2000-07-05 Almer. S. Tigelaar. <almer1@dds.nl>
* src/stf-parse.c:
......
2000-07-05 Morten Welinder <terra@diku.dk>
* src/clipboard.c (x_selection_to_cell_region): Copy data and zero
terminate it.
* src/stf-parse.c (stf_parse_fixed_line): Kill unneeded cast.
(stf_parse_convert_to_unix): Unconstify. Don't bother keeping
track of len. Handle form-feeds better.
2000-07-05 Almer. S. Tigelaar. <almer1@dds.nl>
* src/stf-parse.c:
......
2000-07-05 Morten Welinder <terra@diku.dk>
* src/clipboard.c (x_selection_to_cell_region): Copy data and zero
terminate it.
* src/stf-parse.c (stf_parse_fixed_line): Kill unneeded cast.
(stf_parse_convert_to_unix): Unconstify. Don't bother keeping
track of len. Handle form-feeds better.
2000-07-05 Almer. S. Tigelaar. <almer1@dds.nl>
* src/stf-parse.c:
......
......@@ -398,12 +398,17 @@ paste_target_init (PasteTarget *pt, Sheet *sheet, Range const *r, int flags)
}
static CellRegion *
x_selection_to_cell_region (CommandContext *context, char const * data,
x_selection_to_cell_region (CommandContext *context, const char *src,
int len)
{
DialogStfResult_t *dialogresult;
CellRegion *cr = NULL;
CellRegion *crerr;
char *data;
data = g_new (char, len + 1);
memcpy (data, src, len);
data[len] = 0;
crerr = g_new (CellRegion, 1);
crerr->list = NULL;
......@@ -412,15 +417,13 @@ x_selection_to_cell_region (CommandContext *context, char const * data,
crerr->styles = NULL;
if (!stf_parse_convert_to_unix (data)) {
g_free ( (char*) data);
g_free (data);
g_warning (_("Error while trying to pre-convert clipboard data"));
return crerr;
}
if (!stf_parse_is_valid_data (data)) {
g_free ( (char*) data);
g_free (data);
g_warning (_("This data on the clipboard does not seem to be valid text"));
return crerr;
}
......@@ -434,8 +437,7 @@ x_selection_to_cell_region (CommandContext *context, char const * data,
cr = stf_parse_region (dialogresult->parseoptions, dialogresult->newstart);
if (cr == NULL) {
g_free ( (char*) data);
g_free (data);
g_warning (_("Parse error while trying to parse data into cellregion"));
return crerr;
}
......@@ -466,13 +468,12 @@ x_selection_to_cell_region (CommandContext *context, char const * data,
}
stf_dialog_result_free (dialogresult);
}
else {
} else {
return crerr;
}
g_free (crerr);
g_free (data);
return cr;
}
......
......@@ -923,7 +923,7 @@ stf_parse_fixed_line (Source_t *src, StfParseOptions_t *parseoptions)
while (*src->position && *src->position != parseoptions->terminator) {
char *field;
field = (char *)stf_parse_fixed_cell (src, parseoptions);
field = stf_parse_fixed_cell (src, parseoptions);
trim_spaces_inplace (field, parseoptions);
......@@ -1340,43 +1340,32 @@ stf_parse_get_colwidth (StfParseOptions_t *parseoptions, const char *data, int i
* unix line-terminated format. this means that CRLF (windows) will be converted to LF
* and CR (Macintosh) to LF.
* In addition to that form feed (\F) characters will be removed.
* NOTE : This will not resize the buffer
* NOTE: This will not resize the buffer
*
* returns : TRUE on success, FALSE otherwise.
* returns: TRUE on success, FALSE otherwise.
**/
gboolean
stf_parse_convert_to_unix (const char *data)
stf_parse_convert_to_unix (char *data)
{
const char *iterator = data;
char *dest = (char *) data;
int len = 0;
char *dest = data;
if (!iterator)
return FALSE;
while (*iterator) {
if (*iterator == '\r') {
const char *temp = iterator;
temp++;
if (*temp != '\n') {
*dest = '\n';
dest++;
len++;
}
*dest++ = '\n';
iterator++;
if (*iterator == '\n')
iterator++;
continue;
} else if (*iterator == '\f') {
iterator++;
continue;
}
*dest = *iterator;
iterator++;
dest++;
len++;
*dest++ = *iterator++;
}
*dest = '\0';
......@@ -1427,9 +1416,9 @@ stf_parse_is_valid_data (const char *data)
*
**/
void
stf_parse_options_fixed_autodiscover (StfParseOptions_t *parseoptions, int data_lines, char *data)
stf_parse_options_fixed_autodiscover (StfParseOptions_t *parseoptions, int data_lines, const char *data)
{
char *iterator = data;
const char *iterator = data;
GSList *list = NULL;
GSList *list_start = NULL;
int lines = 0;
......
......@@ -120,10 +120,10 @@ int stf_parse_get_longest_row_width (StfParseO
int stf_parse_get_colwidth (StfParseOptions_t *parseoptions, const char *data, int index);
gboolean stf_parse_convert_to_unix (const char *data);
gboolean stf_parse_convert_to_unix (char *data);
gboolean stf_parse_is_valid_data (const char *data);
void stf_parse_options_fixed_autodiscover (StfParseOptions_t *parseoptions, int data_lines, char *data);
void stf_parse_options_fixed_autodiscover (StfParseOptions_t *parseoptions, int data_lines, const char *data);
/* Higher level functions, can be used for directly parsing into an application specific data container */
Sheet *stf_parse_sheet (StfParseOptions_t *parseoptions, const char *data, Sheet *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