Commit 1ae8e0a9 authored by Morten Welinder's avatar Morten Welinder

Misc. fixes.

parent 9232cb8e
1999-06-20 Morten Welinder <terra@diku.dk>
* src/fn-math.c (gnumeric_mod): Another try.
(gnumeric_int): Fix for negative numbers.
* src/sheet.c (sheet_set_text): Set value directly, not via text. Also
improve entry when a format is already set.
(sheet_cancel_pending_input): Fixed behavior of canceling a cell
entry. [From Bake Timmon.]
1999-06-18 Jukka-Pekka Iivonen <iivonen@iki.fi>
* samples/dbfuns.xls: Added new file for database functions.
......
1999-06-20 Morten Welinder <terra@diku.dk>
* src/fn-math.c (gnumeric_mod): Another try.
(gnumeric_int): Fix for negative numbers.
* src/sheet.c (sheet_set_text): Set value directly, not via text. Also
improve entry when a format is already set.
(sheet_cancel_pending_input): Fixed behavior of canceling a cell
entry. [From Bake Timmon.]
1999-06-18 Jukka-Pekka Iivonen <iivonen@iki.fi>
* samples/dbfuns.xls: Added new file for database functions.
......
1999-06-20 Morten Welinder <terra@diku.dk>
* src/fn-math.c (gnumeric_mod): Another try.
(gnumeric_int): Fix for negative numbers.
* src/sheet.c (sheet_set_text): Set value directly, not via text. Also
improve entry when a format is already set.
(sheet_cancel_pending_input): Fixed behavior of canceling a cell
entry. [From Bake Timmon.]
1999-06-18 Jukka-Pekka Iivonen <iivonen@iki.fi>
* samples/dbfuns.xls: Added new file for database functions.
......
1999-06-20 Morten Welinder <terra@diku.dk>
* src/fn-math.c (gnumeric_mod): Another try.
(gnumeric_int): Fix for negative numbers.
* src/sheet.c (sheet_set_text): Set value directly, not via text. Also
improve entry when a format is already set.
(sheet_cancel_pending_input): Fixed behavior of canceling a cell
entry. [From Bake Timmon.]
1999-06-18 Jukka-Pekka Iivonen <iivonen@iki.fi>
* samples/dbfuns.xls: Added new file for database functions.
......
......@@ -943,13 +943,8 @@ static Value *
gnumeric_int (struct FunctionDefinition *i,
Value *argv [], char **error_string)
{
float_t t;
/* FIXME: What about strings and empty cells? */
t = value_get_as_float (argv [0]);
return value_new_float (t > 0.0 ? floor (t) : ceil (t));
return value_new_float (floor (value_get_as_float (argv [0])));
}
static char *help_log = {
......@@ -1098,7 +1093,7 @@ static char *help_mod = {
"@DESCRIPTION="
"Implements modulo arithmetic."
"Returns the remainder when divisor is divided into abs(number)."
"Returns the remainder when @divisor is divided into @number."
"\n"
"Returns #DIV/0! if divisor is zero."
"@SEEALSO=INT,FLOOR,CEIL")
......@@ -1112,27 +1107,24 @@ gnumeric_mod (struct FunctionDefinition *i,
a = value_get_as_int (argv[0]);
b = value_get_as_int (argv[1]);
/* Obscure handling of C's mod function */
if (a<0) a = -a;
if (a < 0){ /* -0 */
*error_string = gnumeric_err_NUM;
if (b == 0) {
*error_string = gnumeric_err_DIV0;
return NULL;
}
if (b < 0){
if (b < 0) {
a = -a;
b = -b;
}
if (b < 0) { /* -0 */
*error_string = gnumeric_err_NUM;
return NULL;
}
if (b == 0) {
*error_string = gnumeric_err_DIV0;
return NULL;
/* FIXME: check for overflow. */
}
return value_new_int (a % b);
if (a >= 0)
return value_new_int (a % b);
else {
int invres = (-a) % b;
return value_new_int (invres == 0 ? 0 : b - invres);
}
}
static char *help_radians = {
......
......@@ -943,13 +943,8 @@ static Value *
gnumeric_int (struct FunctionDefinition *i,
Value *argv [], char **error_string)
{
float_t t;
/* FIXME: What about strings and empty cells? */
t = value_get_as_float (argv [0]);
return value_new_float (t > 0.0 ? floor (t) : ceil (t));
return value_new_float (floor (value_get_as_float (argv [0])));
}
static char *help_log = {
......@@ -1098,7 +1093,7 @@ static char *help_mod = {
"@DESCRIPTION="
"Implements modulo arithmetic."
"Returns the remainder when divisor is divided into abs(number)."
"Returns the remainder when @divisor is divided into @number."
"\n"
"Returns #DIV/0! if divisor is zero."
"@SEEALSO=INT,FLOOR,CEIL")
......@@ -1112,27 +1107,24 @@ gnumeric_mod (struct FunctionDefinition *i,
a = value_get_as_int (argv[0]);
b = value_get_as_int (argv[1]);
/* Obscure handling of C's mod function */
if (a<0) a = -a;
if (a < 0){ /* -0 */
*error_string = gnumeric_err_NUM;
if (b == 0) {
*error_string = gnumeric_err_DIV0;
return NULL;
}
if (b < 0){
if (b < 0) {
a = -a;
b = -b;
}
if (b < 0) { /* -0 */
*error_string = gnumeric_err_NUM;
return NULL;
}
if (b == 0) {
*error_string = gnumeric_err_DIV0;
return NULL;
/* FIXME: check for overflow. */
}
return value_new_int (a % b);
if (a >= 0)
return value_new_int (a % b);
else {
int invres = (-a) % b;
return value_new_int (invres == 0 ? 0 : b - invres);
}
}
static char *help_radians = {
......
......@@ -943,13 +943,8 @@ static Value *
gnumeric_int (struct FunctionDefinition *i,
Value *argv [], char **error_string)
{
float_t t;
/* FIXME: What about strings and empty cells? */
t = value_get_as_float (argv [0]);
return value_new_float (t > 0.0 ? floor (t) : ceil (t));
return value_new_float (floor (value_get_as_float (argv [0])));
}
static char *help_log = {
......@@ -1098,7 +1093,7 @@ static char *help_mod = {
"@DESCRIPTION="
"Implements modulo arithmetic."
"Returns the remainder when divisor is divided into abs(number)."
"Returns the remainder when @divisor is divided into @number."
"\n"
"Returns #DIV/0! if divisor is zero."
"@SEEALSO=INT,FLOOR,CEIL")
......@@ -1112,27 +1107,24 @@ gnumeric_mod (struct FunctionDefinition *i,
a = value_get_as_int (argv[0]);
b = value_get_as_int (argv[1]);
/* Obscure handling of C's mod function */
if (a<0) a = -a;
if (a < 0){ /* -0 */
*error_string = gnumeric_err_NUM;
if (b == 0) {
*error_string = gnumeric_err_DIV0;
return NULL;
}
if (b < 0){
if (b < 0) {
a = -a;
b = -b;
}
if (b < 0) { /* -0 */
*error_string = gnumeric_err_NUM;
return NULL;
}
if (b == 0) {
*error_string = gnumeric_err_DIV0;
return NULL;
/* FIXME: check for overflow. */
}
return value_new_int (a % b);
if (a >= 0)
return value_new_int (a % b);
else {
int invres = (-a) % b;
return value_new_int (invres == 0 ? 0 : b - invres);
}
}
static char *help_radians = {
......
......@@ -729,7 +729,7 @@ sheet_set_text (Sheet *sheet, int col, int row, const char *str)
* a rendered version of the text, if they compare equally, then
* use that.
*/
if (!CELL_IS_FORMAT_SET (cell) && *text != '=') {
if (*text != '=') {
char *end, *format;
double v;
......@@ -741,22 +741,21 @@ sheet_set_text (Sheet *sheet, int col, int row, const char *str)
} else if (format_match (text, &v, &format)) {
StyleFormat *sf;
char *new_text;
char buffer [50];
Value *vf = value_new_float (v);
/* Render it */
sf = style_format_new (format);
new_text = format_value (sf, vf, NULL);
value_release (vf);
style_format_unref (sf);
/* Compare it */
if (strcasecmp (new_text, text) == 0){
cell_set_format_simple (cell, format);
sprintf (buffer, "%f", v);
cell_set_text (cell, buffer);
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);
}
}
......@@ -840,6 +839,7 @@ sheet_cancel_pending_input (Sheet *sheet)
gnumeric_sheet_destroy_editing_cursor (gsheet);
}
sheet->editing = FALSE;
}
void
......
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