Commit c0a877a4 authored by Morten Welinder's avatar Morten Welinder

Get rid of a use of "double" that should have been float_t.

Fix Excel loading of bool constants.
parent 68522af2
1999-06-22 Morten Welinder <terra@diku.dk>
* src/fn-date.c (get_serial_date): Cleanup.
(get_serial_time): Ditto.
* src/sheet.c (sheet_set_text): Abandon old reverse test that lead
to trouble with floating point formats.
* src/number-match.c (format_match): Change from double to
float_t. All callers changed.
(compute_value): Ditto.
1999-06-22 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/fn-stat.c: Added TTEST().
......
1999-06-22 Morten Welinder <terra@diku.dk>
* src/fn-date.c (get_serial_date): Cleanup.
(get_serial_time): Ditto.
* src/sheet.c (sheet_set_text): Abandon old reverse test that lead
to trouble with floating point formats.
* src/number-match.c (format_match): Change from double to
float_t. All callers changed.
(compute_value): Ditto.
1999-06-22 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/fn-stat.c: Added TTEST().
......
1999-06-22 Morten Welinder <terra@diku.dk>
* src/fn-date.c (get_serial_date): Cleanup.
(get_serial_time): Ditto.
* src/sheet.c (sheet_set_text): Abandon old reverse test that lead
to trouble with floating point formats.
* src/number-match.c (format_match): Change from double to
float_t. All callers changed.
(compute_value): Ditto.
1999-06-22 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/fn-stat.c: Added TTEST().
......
1999-06-22 Morten Welinder <terra@diku.dk>
* src/fn-date.c (get_serial_date): Cleanup.
(get_serial_time): Ditto.
* src/sheet.c (sheet_set_text): Abandon old reverse test that lead
to trouble with floating point formats.
* src/number-match.c (format_match): Change from double to
float_t. All callers changed.
(compute_value): Ditto.
1999-06-22 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/fn-stat.c: Added TTEST().
......
1999-06-21 Morten Welinder <terra@diku.dk>
* ms-excel-read.c (ms_excel_read_cell): Insert bools as values,
not constant expresssions.
(biff_get_text): Make a little more quiet.
(ms_excel_read_cell): Insert strings as values, not via text.
* ms-excel-read.c (ms_excel_read_cell): Handle errors and boolean
constants without going through text. (In particular, this gets
errors right and prepares for a proper bool type.)
......
......@@ -115,6 +115,7 @@ biff_get_text (BYTE *pos, guint32 length, guint32* byte_length)
guint32 byte_len ;
gboolean header ;
gboolean high_byte ;
static gboolean high_byte_warned = FALSE;
gboolean ext_str ;
gboolean rich_str ;
......@@ -139,8 +140,11 @@ biff_get_text (BYTE *pos, guint32 length, guint32* byte_length)
ptr = pos ;
/* A few friendly warnings */
if (high_byte)
if (high_byte && !high_byte_warned)
{
printf ("FIXME: unicode support unimplemented: truncating\n") ;
high_byte_warned = TRUE;
}
if (rich_str) /* The data for this appears after the string */
{
guint16 formatting_runs = BIFF_GETWORD(ptr) ;
......@@ -2025,15 +2029,15 @@ ms_excel_read_cell (BIFF_QUERY * q, MS_EXCEL_SHEET * sheet)
}
case BIFF_LABELSST:
{
char *str;
guint32 idx = BIFF_GETLONG (q->data + 6) ;
if (!sheet->wb->global_strings || idx >= sheet->wb->global_string_max)
printf ("string index 0x%x out of range\n", idx) ;
else
{
else {
const char *str;
str = sheet->wb->global_strings[idx] ;
ms_excel_sheet_insert (sheet, EX_GETXF (q), EX_GETCOL (q), EX_GETROW (q), str);
ms_excel_sheet_insert_val (sheet, EX_GETXF (q), EX_GETCOL (q), EX_GETROW (q),
value_new_string (str));
}
break;
}
......@@ -2062,14 +2066,20 @@ ms_excel_read_cell (BIFF_QUERY * q, MS_EXCEL_SHEET * sheet)
}
case BIFF_BOOLERR: /* S59D5F.HTM */
{
ExprTree *e;
if (BIFF_GETBYTE(q->data + 7)) /* Error */
if (BIFF_GETBYTE(q->data + 7)) {
/* Error */
ExprTree *e;
e = expr_tree_new_error (biff_get_error_text (BIFF_GETBYTE(q->data + 6)));
else /* Boolean */
e = expr_tree_new_constant (value_new_bool (BIFF_GETBYTE(q->data + 6)));
ms_excel_sheet_insert_form (sheet, EX_GETXF (q), EX_GETCOL (q),
EX_GETROW (q), e);
expr_tree_unref (e);
ms_excel_sheet_insert_form (sheet, EX_GETXF (q), EX_GETCOL (q),
EX_GETROW (q), e);
expr_tree_unref (e);
} else {
/* Boolean */
Value *v;
v = value_new_bool (BIFF_GETBYTE(q->data + 6));
ms_excel_sheet_insert_val (sheet, EX_GETXF (q), EX_GETCOL (q),
EX_GETROW (q), v);
}
break;
}
default:
......
......@@ -23,11 +23,8 @@ get_serial_date (Value *v)
serial = value_get_as_float (v);
else {
char *format;
double dserial;
if (format_match (v->v.str->str, &dserial, &format)) {
serial = dserial;
} else
if (!format_match (v->v.str->str, &serial, &format))
serial = 0;
}
return floor (serial);
......@@ -43,11 +40,8 @@ get_serial_time (Value *v)
serial = value_get_as_float (v);
else {
char *format;
double dserial;
if (format_match (v->v.str->str, &dserial, &format)) {
serial = dserial;
} else
if (!format_match (v->v.str->str, &serial, &format))
serial = 0;
}
return serial - floor (serial);
......
......@@ -465,7 +465,7 @@ gnumeric_n (struct FunctionDefinition *n,
Value *argv [], char **error_string)
{
const char *str;
double v;
float_t v;
char *format;
if (VALUE_IS_NUMBER (argv[0]))
......
......@@ -23,11 +23,8 @@ get_serial_date (Value *v)
serial = value_get_as_float (v);
else {
char *format;
double dserial;
if (format_match (v->v.str->str, &dserial, &format)) {
serial = dserial;
} else
if (!format_match (v->v.str->str, &serial, &format))
serial = 0;
}
return floor (serial);
......@@ -43,11 +40,8 @@ get_serial_time (Value *v)
serial = value_get_as_float (v);
else {
char *format;
double dserial;
if (format_match (v->v.str->str, &dserial, &format)) {
serial = dserial;
} else
if (!format_match (v->v.str->str, &serial, &format))
serial = 0;
}
return serial - floor (serial);
......
......@@ -465,7 +465,7 @@ gnumeric_n (struct FunctionDefinition *n,
Value *argv [], char **error_string)
{
const char *str;
double v;
float_t v;
char *format;
if (VALUE_IS_NUMBER (argv[0]))
......
......@@ -23,11 +23,8 @@ get_serial_date (Value *v)
serial = value_get_as_float (v);
else {
char *format;
double dserial;
if (format_match (v->v.str->str, &dserial, &format)) {
serial = dserial;
} else
if (!format_match (v->v.str->str, &serial, &format))
serial = 0;
}
return floor (serial);
......@@ -43,11 +40,8 @@ get_serial_time (Value *v)
serial = value_get_as_float (v);
else {
char *format;
double dserial;
if (format_match (v->v.str->str, &dserial, &format)) {
serial = dserial;
} else
if (!format_match (v->v.str->str, &serial, &format))
serial = 0;
}
return serial - floor (serial);
......
......@@ -465,7 +465,7 @@ gnumeric_n (struct FunctionDefinition *n,
Value *argv [], char **error_string)
{
const char *str;
double v;
float_t v;
char *format;
if (VALUE_IS_NUMBER (argv[0]))
......
......@@ -538,10 +538,10 @@ extract_text (const char *str, const regmatch_t *mp)
*/
static gboolean
compute_value (const char *s, const regmatch_t *mp,
GByteArray *array, double *v)
GByteArray *array, float_t *v)
{
const int len = array->len;
double number = 0.0;
float_t number = 0.0;
gchar *data = array->data;
gboolean percentify = FALSE;
gboolean is_number = FALSE;
......@@ -717,7 +717,7 @@ compute_value (const char *s, const regmatch_t *mp,
#define NM 40
gboolean
format_match (const char *s, double *v, char **format)
format_match (const char *s, float_t *v, char **format)
{
GList *l;
regmatch_t mp [NM+1];
......
#ifndef GNUMERIC_NUMBER_MATCH_H
#define GNUMERIC_NUMBER_MATCH_H
#include "numbers.h"
int format_match_define (const char *format);
void format_match_init (void);
void format_match_finish (void);
gboolean format_match (const char *s, double *v, char **format);
gboolean format_match (const char *s, float_t *v, char **format);
#endif /* GNUMERIC_NUMBER_MATCH_H */
......@@ -731,7 +731,7 @@ sheet_set_text (Sheet *sheet, int col, int row, const char *str)
*/
if (*text != '=') {
char *end, *format;
double v;
float_t v;
(void) strtod (text, &end);
if (end != text && *end == 0) {
......@@ -739,24 +739,10 @@ sheet_set_text (Sheet *sheet, int col, int row, const char *str)
that we would other wise actually set a "0" format
for integers and that it would stick. */
} else if (format_match (text, &v, &format)) {
StyleFormat *sf;
char *new_text;
Value *vf = value_new_float (v);
/* Render it */
sf = style_format_new (format);
new_text = format_value (sf, vf, NULL);
style_format_unref (sf);
/* Compare it */
if (strcasecmp (new_text, text) == 0){
if (!CELL_IS_FORMAT_SET (cell))
cell_set_format_simple (cell, format);
cell_set_value (cell, vf);
text_set = TRUE;
} else
value_release (vf);
g_free (new_text);
if (!CELL_IS_FORMAT_SET (cell))
cell_set_format_simple (cell, format);
cell_set_value (cell, value_new_float (v));
text_set = TRUE;
}
}
......
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