Commit 5ef75629 authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

Warning killer.

2001-04-30  Morten Welinder  <terra@diku.dk>

	* src/func.c (tokenized_help_find): Warning killer.

	* src/value.c (value_new_array): Kill warnings.
	(value_new_array_empty): Ditto.
	(value_release): Ditto.

	* src/print-cell.c (print_show): Use proper types.
	(get_width_string_n): Ditto.

	* src/number-match.c (gnumeric_error_init): Warning killer.

	* src/parser.y (deallocate_all): Warning killer.

	* src/item-bar.c (item_bar_draw): Avoid signedness problems.

	* src/format-template.c (hash_table_destroy): Warning killer.

	* src/colrow.h (struct _ColRowInfo): Make size_pixels an int.

	* src/value-sheet.c (value_area_get_width, value_area_get_height):
 	Return an int, not a guint.

2001-04-26  Morten Welinder  <terra@diku.dk>

	* fn-string.c (gnumeric_mid): Un-suckify.
	(gnumeric_find): Un-suckify.
	(gnumeric_substitute): Warning killer.
	(match_string): Warning killer.

	* fn-information.c (translate_cell_format): Warning killer.

	* fn-eng.c (val_to_base): Warning killer.

2001-04-30  Morten Welinder  <terra@diku.dk>

	* ms-summary.c (sum_name_to_excel): Fix index count.  Constify.
  	Make static.
	(excel_to_gnum_mapping): Make static.
parent d5fb613b
......@@ -8,8 +8,6 @@ release, and longer term bugs.
Release Critical
----------------
- Fix MID and FIND bogosity.
- defining file patterns in plugin spec overrides 'has_probe' flag silently.
- pasting with singleton destination circumvents checks for arrays and
......
2001-04-30 Morten Welinder <terra@diku.dk>
* src/func.c (tokenized_help_find): Warning killer.
* src/value.c (value_new_array): Kill warnings.
(value_new_array_empty): Ditto.
(value_release): Ditto.
* src/print-cell.c (print_show): Use proper types.
(get_width_string_n): Ditto.
* src/number-match.c (gnumeric_error_init): Warning killer.
* src/parser.y (deallocate_all): Warning killer.
* src/item-bar.c (item_bar_draw): Avoid signedness problems.
* src/format-template.c (hash_table_destroy): Warning killer.
* src/colrow.h (struct _ColRowInfo): Make size_pixels an int.
* src/value-sheet.c (value_area_get_width, value_area_get_height):
Return an int, not a guint.
2001-04-30 Almer S. Tigelaar <almer@gnome.org>
* src/commands.c (cmd_clear_selection): More descriptive
......
......@@ -10,6 +10,7 @@ Almer:
Chema:
* GNUMERIC_ENABLE_XL_OVERWRITE
* Implemented clone, write and load for some sheet objects
Jody:
* Outline mode
* Restore horizontal FILL alignment.
......@@ -27,12 +28,14 @@ Jon K
* Fix dialog placement.
Morten:
* Make search-and-destroy work better on comments.
* Changed a large number of dirty diapers.
* Plugged gnumeric leaks too.
* Make search-and-destroy work better on comments.
* Fixed parsing of numbers like "-4,885". (We used to get -3115
== -4 * 1000 + 885...)
* Fixed formulae with leading dash, like "-995/5".
* Fix MID and FIND.
* Improve signed-vs-unsigned situation.
Vlad Harchev
* Improve i18n support for XL import/export
......
2001-04-30 Morten Welinder <terra@diku.dk>
* src/func.c (tokenized_help_find): Warning killer.
* src/value.c (value_new_array): Kill warnings.
(value_new_array_empty): Ditto.
(value_release): Ditto.
* src/print-cell.c (print_show): Use proper types.
(get_width_string_n): Ditto.
* src/number-match.c (gnumeric_error_init): Warning killer.
* src/parser.y (deallocate_all): Warning killer.
* src/item-bar.c (item_bar_draw): Avoid signedness problems.
* src/format-template.c (hash_table_destroy): Warning killer.
* src/colrow.h (struct _ColRowInfo): Make size_pixels an int.
* src/value-sheet.c (value_area_get_width, value_area_get_height):
Return an int, not a guint.
2001-04-30 Almer S. Tigelaar <almer@gnome.org>
* src/commands.c (cmd_clear_selection): More descriptive
......
2001-04-30 Morten Welinder <terra@diku.dk>
* src/func.c (tokenized_help_find): Warning killer.
* src/value.c (value_new_array): Kill warnings.
(value_new_array_empty): Ditto.
(value_release): Ditto.
* src/print-cell.c (print_show): Use proper types.
(get_width_string_n): Ditto.
* src/number-match.c (gnumeric_error_init): Warning killer.
* src/parser.y (deallocate_all): Warning killer.
* src/item-bar.c (item_bar_draw): Avoid signedness problems.
* src/format-template.c (hash_table_destroy): Warning killer.
* src/colrow.h (struct _ColRowInfo): Make size_pixels an int.
* src/value-sheet.c (value_area_get_width, value_area_get_height):
Return an int, not a guint.
2001-04-30 Almer S. Tigelaar <almer@gnome.org>
* src/commands.c (cmd_clear_selection): More descriptive
......
2001-04-30 Morten Welinder <terra@diku.dk>
* src/func.c (tokenized_help_find): Warning killer.
* src/value.c (value_new_array): Kill warnings.
(value_new_array_empty): Ditto.
(value_release): Ditto.
* src/print-cell.c (print_show): Use proper types.
(get_width_string_n): Ditto.
* src/number-match.c (gnumeric_error_init): Warning killer.
* src/parser.y (deallocate_all): Warning killer.
* src/item-bar.c (item_bar_draw): Avoid signedness problems.
* src/format-template.c (hash_table_destroy): Warning killer.
* src/colrow.h (struct _ColRowInfo): Make size_pixels an int.
* src/value-sheet.c (value_area_get_width, value_area_get_height):
Return an int, not a guint.
2001-04-30 Almer S. Tigelaar <almer@gnome.org>
* src/commands.c (cmd_clear_selection): More descriptive
......
2001-04-30 Morten Welinder <terra@diku.dk>
* src/func.c (tokenized_help_find): Warning killer.
* src/value.c (value_new_array): Kill warnings.
(value_new_array_empty): Ditto.
(value_release): Ditto.
* src/print-cell.c (print_show): Use proper types.
(get_width_string_n): Ditto.
* src/number-match.c (gnumeric_error_init): Warning killer.
* src/parser.y (deallocate_all): Warning killer.
* src/item-bar.c (item_bar_draw): Avoid signedness problems.
* src/format-template.c (hash_table_destroy): Warning killer.
* src/colrow.h (struct _ColRowInfo): Make size_pixels an int.
* src/value-sheet.c (value_area_get_width, value_area_get_height):
Return an int, not a guint.
2001-04-30 Almer S. Tigelaar <almer@gnome.org>
* src/commands.c (cmd_clear_selection): More descriptive
......
......@@ -22,6 +22,27 @@ AM_PATH_GTK(1.2.7)
## this should come after `AC_PROG_CC'
GNOME_COMPILE_WARNINGS
set_mode_warnings=yes
if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
for option in -Wsign-promo -Wsign-compare -Wpointer-arith -Wnested-externs -Wchar-subscripts; do
SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $option"
AC_MSG_CHECKING([whether gcc understands $option])
AC_TRY_COMPILE([], [],
has_option=yes,
has_option=no,)
if test $has_option = no; then
CFLAGS="$SAVE_CFLAGS"
fi
AC_MSG_RESULT($has_option)
unset has_option
unset SAVE_CFLAGS
done
unset option
fi
GNOME_X_CHECKS
GNOME_XML_CHECK
......
2001-04-30 Morten Welinder <terra@diku.dk>
* ms-summary.c (sum_name_to_excel): Fix index count. Constify.
Make static.
(excel_to_gnum_mapping): Make static.
2001-04-29 Jody Goldberg <jgoldberg@home.com>
* ms-excel-write.c (write_window2) : Headers are in default style.
......
......@@ -42,7 +42,7 @@ typedef struct {
SummaryItemBuiltin gnumeric;
} mapping_t;
mapping_t excel_to_gnum_mapping[] =
static const mapping_t excel_to_gnum_mapping[] =
{ /* Needs beefing up */
{ MS_OLE_SUMMARY_CODEPAGE, MS_OLE_PS_SUMMARY_INFO, SUMMARY_I_CODEPAGE },
{ MS_OLE_SUMMARY_TITLE, MS_OLE_PS_SUMMARY_INFO, SUMMARY_I_TITLE },
......@@ -77,8 +77,9 @@ mapping_t excel_to_gnum_mapping[] =
{ MS_OLE_SUMMARY_LINKSDIRTY, MS_OLE_PS_DOCUMENT_SUMMARY_INFO, SUMMARY_I_LINKSDIRTY }
};
#define EXCEL_TO_GNUM_MAPPING_COUNT \
((int)(sizeof (excel_to_gnum_mapping) / sizeof (excel_to_gnum_mapping[0])))
int sum_name_to_excel (gchar *name, MsOleSummaryPID *pid, MsOlePropertySetID psid);
/*static SummaryItemBuiltin
excel_to_gnumeric (guint32 type)
......@@ -99,8 +100,8 @@ excel_to_gnumeric (guint32 type)
* converts it back to an MsOleSummaryPID.
*
**/
int
sum_name_to_excel (gchar *name, MsOleSummaryPID *pid, MsOlePropertySetID psid)
static int
sum_name_to_excel (const gchar *name, MsOleSummaryPID *pid, MsOlePropertySetID psid)
{
gint i, j;
......@@ -110,9 +111,9 @@ sum_name_to_excel (gchar *name, MsOleSummaryPID *pid, MsOlePropertySetID psid)
* in excel_to_gnum_mapping[]. What we want is the corresponding
* MsOleSummaryPID in that same array.
*/
for (i = 0; i < sizeof (summary_item_name); i++) {
for (i = 0; i < SUMMARY_I_MAX; i++) {
if (g_strcasecmp (summary_item_name[i], name) == 0) {
for (j = 0; j < sizeof (excel_to_gnum_mapping) / sizeof (mapping_t); j++) {
for (j = 0; j < EXCEL_TO_GNUM_MAPPING_COUNT; j++) {
if ((excel_to_gnum_mapping[j].ps_id == psid) &&
(excel_to_gnum_mapping[j].gnumeric == i) ) {
*pid = excel_to_gnum_mapping[j].excel;
......@@ -135,7 +136,7 @@ read_summary_items (SummaryInfo *sin, MsOleSummary *si, MsOlePropertySetID psid)
SummaryItem *sit;
gboolean ok;
for (i = 0; i < sizeof (excel_to_gnum_mapping)/sizeof(mapping_t); i++) {
for (i = 0; i < EXCEL_TO_GNUM_MAPPING_COUNT; i++) {
if (excel_to_gnum_mapping[i].ps_id == psid) {
MsOleSummaryPID p = excel_to_gnum_mapping[i].excel;
gchar *name;
......
......@@ -118,7 +118,7 @@ val_to_base (FunctionEvalInfo *ei, Value **argv, int num_argv,
if (places > max)
max = places;
if (max >= sizeof (buffer))
if (max >= (int)sizeof (buffer))
return value_new_error (ei->pos, _("Unimplemented"));
for (digit = max - 1; digit >= 0; digit--) {
......
......@@ -124,6 +124,7 @@ translate_cell_format (StyleFormat const *format)
{
int i;
char *fmt;
const int translate_table_count = sizeof (translate_table) / sizeof(translate_t);
if (format == NULL)
return value_new_string ("G");
......@@ -133,7 +134,7 @@ translate_cell_format (StyleFormat const *format)
/*
* TODO : What does this do in different locales ??
*/
for (i = 0; i < sizeof (translate_table)/sizeof(translate_t); i++) {
for (i = 0; i < translate_table_count; i++) {
const translate_t *t = &translate_table[i];
if (!g_strcasecmp (fmt, t->format)) {
......
......@@ -217,22 +217,23 @@ gnumeric_mid (FunctionEvalInfo *ei, Value **argv)
char *s, *source;
if (argv [0]->type != VALUE_STRING ||
argv [1]->type != VALUE_INTEGER ||
argv [2]->type != VALUE_INTEGER)
!VALUE_IS_NUMBER (argv [1]) ||
!VALUE_IS_NUMBER (argv [2]))
return value_new_error (ei->pos, _("Type mismatch"));
len = value_get_as_int (argv [2]);
pos = value_get_as_int (argv [1]);
len = value_get_as_int (argv [2]);
if (len < 0 || pos <= 0)
return value_new_error (ei->pos, _("Invalid arguments"));
pos--; /* Make pos zero-based. */
source = argv [0]->v_str.val->str;
if (pos > strlen (source))
return value_new_string ("");
pos--;
s = g_new (gchar, len+1);
strncpy (s, &source[pos], len);
len = MIN (len, (int)strlen (source) - pos);
s = g_new (gchar, len + 1);
memcpy (s, source + pos, len);
s[len] = '\0';
v = value_new_string (s);
g_free (s);
......@@ -468,24 +469,32 @@ static char *help_find = {
static Value *
gnumeric_find (FunctionEvalInfo *ei, Value **argv)
{
int count;
char *s, *p;
if (argv[2])
count = value_get_as_int(argv[2]);
else
count = 1;
int count, haystacksize;
char *haystack, *needle;
Value *res;
if ( count > strlen(argv[1]->v_str.val->str) ||
count == 0) /* start position too high or low */
return value_new_error (ei->pos, _("Invalid argument"));
needle = value_get_as_string (argv[0]);
haystack = value_get_as_string (argv[1]);
count = argv[2] ? value_get_as_int (argv[2]) : 1;
haystacksize = strlen (haystack);
if (count <= 0 || count > haystacksize) {
res = value_new_error (ei->pos, gnumeric_err_VALUE);
} else {
const char *haystart = haystack + (count - 1);
const char *p = strstr (haystart, needle);
if (p)
res = value_new_int (count + (p - haystart));
else
/* Really? */
res = value_new_error (ei->pos, gnumeric_err_VALUE);
}
g_assert (count >= 1);
s = argv[1]->v_str.val->str + count - 1;
if ( (p = strstr(s, argv[0]->v_str.val->str)) == NULL )
return value_new_error (ei->pos, _("Invalid argument"));
g_free (needle);
g_free (haystack);
return value_new_int (count + p - s);
return res;
}
/***************************************************************************/
......@@ -978,8 +987,8 @@ gnumeric_substitute (FunctionEvalInfo *ei, Value **argv)
{
Value *v;
gchar *text, *old, *new, *p ,*f;
gint num;
guint oldlen, newlen, len, inst;
int num;
int oldlen, newlen, len, inst;
struct subs_string *s;
text = value_get_as_string (argv[0]);
......@@ -1001,14 +1010,14 @@ gnumeric_substitute (FunctionEvalInfo *ei, Value **argv)
p = text;
inst = 0;
while (p-text < len) {
if ( (f=strstr(p, old)) == NULL )
while (p - text < len) {
if ( (f = strstr (p, old)) == NULL )
break;
if (num == 0 || num == ++inst) {
if (s == NULL) {
strncpy (f, new, newlen);
} else {
subs_string_append_n (s, p, f-p);
subs_string_append_n (s, p, f - p);
subs_string_append_n (s, new, newlen);
}
if (num != 0 && num == inst)
......@@ -1017,7 +1026,7 @@ gnumeric_substitute (FunctionEvalInfo *ei, Value **argv)
p = f + oldlen;
}
if (newlen != oldlen) { /* FIXME: (p-text) might be bad ? */
subs_string_append_n (s, p, len - (p-text) );
subs_string_append_n (s, p, len - (p - text) );
p = s->str;
} else
p = text;
......@@ -1215,27 +1224,27 @@ match_string(gchar *str, string_search_t *cond, gchar **match_start,
{
gchar *p;
if (cond->min_skip > strlen(str))
if (cond->min_skip > (int)strlen (str))
return 0;
if (*cond->str == '\0') {
*match_start = str;
*match_end = str+1;
*match_end = str + 1;
return 1;
}
p = strstr(str+cond->min_skip, cond->str);
p = strstr(str + cond->min_skip, cond->str);
/* Check no match case */
if (p == NULL)
return 0;
/* Check if match in a wrong place and no wildcard */
if (! cond->wildcard_prefix && p > str+cond->min_skip)
if (!cond->wildcard_prefix && p > str + cond->min_skip)
return 0;
/* Matches correctly */
*match_start = p-cond->min_skip;
*match_end = p+strlen(cond->str);
*match_start = p - cond->min_skip;
*match_end = p + strlen(cond->str);
return 1;
}
......
......@@ -8,7 +8,7 @@ struct _ColRowInfo {
/* Size including margins, and right grid line */
float size_pts;
unsigned size_pixels;
int size_pixels;
/* These are not scaled, and are the same in points and pixels */
unsigned margin_a : 3; /* top/left margin */
......
......@@ -70,7 +70,7 @@ hash_table_destroy_entry_cb (gpointer pkey, gpointer pvalue, gpointer data)
static GHashTable *
hash_table_destroy (GHashTable *table)
{
int size;
int size, removed;
if (table == NULL)
return NULL;
......@@ -81,8 +81,9 @@ hash_table_destroy (GHashTable *table)
* before removal as a sanity check
*/
size = g_hash_table_size (table);
removed = g_hash_table_foreach_remove (table, hash_table_destroy_entry_cb, NULL);
if (g_hash_table_foreach_remove (table, hash_table_destroy_entry_cb, NULL) != size)
if (removed != size)
g_warning ("format-template.c: Not all items removed from hash table!");
g_hash_table_destroy (table);
......
......@@ -1029,11 +1029,11 @@ tokenized_help_find (TokenizedHelp *tok, const char *token)
if (!tok || !tok->sections)
return "Incorrect Function Description.";
for (lp = 0; lp + 1 < tok->sections->len; lp++) {
for (lp = 0; lp + 1 < (int)tok->sections->len; lp++) {
const char *cmp = g_ptr_array_index (tok->sections, lp);
if (g_strcasecmp (cmp, token) == 0){
return g_ptr_array_index (tok->sections, lp+1);
return g_ptr_array_index (tok->sections, lp + 1);
}
}
return "Cannot find token";
......
2001-04-26 Morten Welinder <terra@diku.dk>
* fn-string.c (gnumeric_mid): Un-suckify.
(gnumeric_find): Un-suckify.
(gnumeric_substitute): Warning killer.
(match_string): Warning killer.
* fn-information.c (translate_cell_format): Warning killer.
* fn-eng.c (val_to_base): Warning killer.
2001-04-29 Almer S. Tigelaar <almer@gnome.org>
* fn-information.c (gnumeric_cell): Implement remaining
......
......@@ -118,7 +118,7 @@ val_to_base (FunctionEvalInfo *ei, Value **argv, int num_argv,
if (places > max)
max = places;
if (max >= sizeof (buffer))
if (max >= (int)sizeof (buffer))
return value_new_error (ei->pos, _("Unimplemented"));
for (digit = max - 1; digit >= 0; digit--) {
......
......@@ -124,6 +124,7 @@ translate_cell_format (StyleFormat const *format)
{
int i;
char *fmt;
const int translate_table_count = sizeof (translate_table) / sizeof(translate_t);
if (format == NULL)
return value_new_string ("G");
......@@ -133,7 +134,7 @@ translate_cell_format (StyleFormat const *format)
/*
* TODO : What does this do in different locales ??
*/
for (i = 0; i < sizeof (translate_table)/sizeof(translate_t); i++) {
for (i = 0; i < translate_table_count; i++) {
const translate_t *t = &translate_table[i];
if (!g_strcasecmp (fmt, t->format)) {
......
......@@ -217,22 +217,23 @@ gnumeric_mid (FunctionEvalInfo *ei, Value **argv)
char *s, *source;
if (argv [0]->type != VALUE_STRING ||
argv [1]->type != VALUE_INTEGER ||
argv [2]->type != VALUE_INTEGER)
!VALUE_IS_NUMBER (argv [1]) ||
!VALUE_IS_NUMBER (argv [2]))
return value_new_error (ei->pos, _("Type mismatch"));
len = value_get_as_int (argv [2]);
pos = value_get_as_int (argv [1]);
len = value_get_as_int (argv [2]);
if (len < 0 || pos <= 0)
return value_new_error (ei->pos, _("Invalid arguments"));
pos--; /* Make pos zero-based. */
source = argv [0]->v_str.val->str;
if (pos > strlen (source))
return value_new_string ("");
pos--;
s = g_new (gchar, len+1);
strncpy (s, &source[pos], len);
len = MIN (len, (int)strlen (source) - pos);
s = g_new (gchar, len + 1);
memcpy (s, source + pos, len);
s[len] = '\0';
v = value_new_string (s);
g_free (s);
......@@ -468,24 +469,32 @@ static char *help_find = {
static Value *
gnumeric_find (FunctionEvalInfo *ei, Value **argv)
{
int count;
char *s, *p;
if (argv[2])
count = value_get_as_int(argv[2]);
else
count = 1;
int count, haystacksize;
char *haystack, *needle;
Value *res;
if ( count > strlen(argv[1]->v_str.val->str) ||
count == 0) /* start position too high or low */
return value_new_error (ei->pos, _("Invalid argument"));
needle = value_get_as_string (argv[0]);
haystack = value_get_as_string (argv[1]);
count = argv[2] ? value_get_as_int (argv[2]) : 1;
haystacksize = strlen (haystack);
if (count <= 0 || count > haystacksize) {
res = value_new_error (ei->pos, gnumeric_err_VALUE);
} else {
const char *haystart = haystack + (count - 1);
const char *p = strstr (haystart, needle);
if (p)
res = value_new_int (count + (p - haystart));
else
/* Really? */
res = value_new_error (ei->pos, gnumeric_err_VALUE);
}
g_assert (count >= 1);
s = argv[1]->v_str.val->str + count - 1;
if ( (p = strstr(s, argv[0]->v_str.val->str)) == NULL )
return value_new_error (ei->pos, _("Invalid argument"));
g_free (needle);
g_free (haystack);
return value_new_int (count + p - s);
return res;
}
/***************************************************************************/
......@@ -978,8 +987,8 @@ gnumeric_substitute (FunctionEvalInfo *ei, Value **argv)
{
Value *v;
gchar *text, *old, *new, *p ,*f;
gint num;
guint oldlen, newlen, len, inst;
int num;
int oldlen, newlen, len, inst;
struct subs_string *s;
text = value_get_as_string (argv[0]);
......@@ -1001,14 +1010,14 @@ gnumeric_substitute (FunctionEvalInfo *ei, Value **argv)
p = text;
inst = 0;
while (p-text < len) {
if ( (f=strstr(p, old)) == NULL )
while (p - text < len) {
if ( (f = strstr (p, old)) == NULL )
break;
if (num == 0 || num == ++inst) {
if (s == NULL) {
strncpy (f, new, newlen);
} else {
subs_string_append_n (s, p, f-p);
subs_string_append_n (s, p, f - p);
subs_string_append_n (s, new, newlen);
}
if (num != 0 && num == inst)
......@@ -1017,7 +1026,7 @@ gnumeric_substitute (FunctionEvalInfo *ei, Value **argv)
p = f + oldlen;
}
if (newlen != oldlen) { /* FIXME: (p-text) might be bad ? */
subs_string_append_n (s, p, len - (p-text) );
subs_string_append_n (s, p, len - (