$NetBSD: patch-ab,v 1.2 2008/08/31 20:09:12 dholland Exp $ --- src/stats.c.orig 2004-04-29 04:06:10.000000000 -0400 +++ src/stats.c 2008-08-31 16:01:50.000000000 -0400 @@ -24,6 +24,8 @@ ****************************************************************************/ #include +#include +#include /* for mkstemp */ #include "stats.h" #include "wrapbox.h" @@ -76,7 +78,7 @@ increment (htable_t *table, char *str) { entry_t *entry = htable_insert (table, str, 0); - entry->content = (void *) ((int) entry->content + 1); + entry->content = (void *) ((intptr_t) entry->content + 1); } @@ -144,11 +146,11 @@ dump_stat (entry_t *entry) { float percent; - percent = ((int) entry->content) / + percent = ((int)(intptr_t) entry->content) / (float) (wrapbox_marray->count - no_field); fprintf (dump_fp, " %d (%.2f%%) - ", - (int) entry->content, percent * 100.0); + (int)(intptr_t) entry->content, percent * 100.0); print_key (dump_fp, entry->key); } @@ -185,6 +187,8 @@ stats_dump (void) FILE *fp; mail_t *mail; struct estats stats; + int fd; + char fn[25] = "/tmp/elmostats.XXXXXXXXX"; if (wrapbox_marray == NULL) return; @@ -200,9 +204,12 @@ stats_dump (void) process_mail (& stats, mail); } - fp = fopen ("/tmp/elmostats", "w"); - if (fp == NULL){ - error_ (errno, _("couldn't open %s"), "/tmp/elmostats"); + fp = NULL; + fd = mkstemp(fn); + if (fd != -1 ) + fp = fdopen (fd, "w"); + if (fp == NULL) { + error_ (errno, _("couldn't open %s"), fn); destroy_stats (& stats); return; }