summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2011-10-17 17:43:16 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2011-11-02 18:31:10 +0100
commit44bc9605d6d3af9162dc917c43b7a466a24a230b (patch)
treec0a4a48f4bbbc6daa4df25213590b09b2afeccc7 /src
parent9aa9fde504fa3a05fcad04d6db086806ac8830c7 (diff)
downloadcalcurse-44bc9605d6d3af9162dc917c43b7a466a24a230b.tar.gz
calcurse-44bc9605d6d3af9162dc917c43b7a466a24a230b.zip
Avoid use of printf()/fprintf()
Use one of the following functions where appropriate: * puts() (whenever we print hard coded strings to stdout) * fputs() (whenever we print hard coded strings to a stream) * putchar() (whenever we print a single character to stdout) * fputc() (whenever we print a single character to a stream) * strncpy() (whenever we copy hard coded strings to a buffer) This removes the overhead introduced by the format string parser and reduces the number of false positive C-format strings spotted by xgettext(1)'s heuristics. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src')
-rw-r--r--src/apoint.c4
-rw-r--r--src/args.c2
-rw-r--r--src/custom.c10
-rw-r--r--src/getstring.c2
-rw-r--r--src/help.c2
-rw-r--r--src/io.c225
-rw-r--r--src/keys.c2
-rw-r--r--src/mem.c14
-rw-r--r--src/notify.c2
-rw-r--r--src/recur.c8
-rw-r--r--src/todo.c2
-rw-r--r--src/utils.c2
-rw-r--r--src/wins.c6
13 files changed, 138 insertions, 143 deletions
diff --git a/src/apoint.c b/src/apoint.c
index 56028ca..593ec31 100644
--- a/src/apoint.c
+++ b/src/apoint.c
@@ -436,9 +436,9 @@ apoint_write (struct apoint *o, FILE *f)
(void)fprintf (f, ">%s ", o->note);
if (o->state & APOINT_NOTIFY)
- (void)fprintf (f, "!");
+ (void)fputc ('!', f);
else
- (void)fprintf (f, "|");
+ (void)fputc ('|', f);
(void)fprintf (f, "%s\n", o->mesg);
}
diff --git a/src/args.c b/src/args.c
index 5e50c03..8926391 100644
--- a/src/args.c
+++ b/src/args.c
@@ -179,7 +179,7 @@ status_arg (void)
else if (dpid)
fprintf (stdout, _("calcurse is running in background (pid %d)\n"), dpid);
else
- fprintf (stdout, _("calcurse is not running\n"));
+ puts (_("calcurse is not running\n"));
}
/*
diff --git a/src/custom.c b/src/custom.c
index 90e28be..65cf2a5 100644
--- a/src/custom.c
+++ b/src/custom.c
@@ -573,7 +573,7 @@ custom_layout_config (void)
" 't' -> todo panel\n\n");
conf_win.p = (WINDOW *)0;
- (void)snprintf (label, BUFSIZ, _("layout configuration"));
+ (void)strncpy (label, _("layout configuration"), BUFSIZ);
custom_confwin_init (&conf_win, label);
cursor = mark = wins_layout () - 1;
display_layout_config (&conf_win, mark, cursor);
@@ -893,7 +893,7 @@ custom_color_config (void)
char label[BUFSIZ];
conf_win.p = 0;
- (void)snprintf (label, BUFSIZ, _("color theme"));
+ (void)strncpy (label, _("color theme"), BUFSIZ);
custom_confwin_init (&conf_win, label);
mark_fore = NBUSERCOLORS;
mark_back = SIZE - 1;
@@ -995,7 +995,7 @@ custom_color_theme_name (char *theme_name)
};
if (!colorize)
- (void)snprintf (theme_name, BUFSIZ, "0");
+ (void)strncpy (theme_name, "0", BUFSIZ);
else
{
pair_content (COLR_CUSTOM, &color[0], &color[1]);
@@ -1160,7 +1160,7 @@ custom_general_config (struct conf *conf)
clear ();
custom_set_swsiz (&cwin);
- (void)snprintf (cwin.label, BUFSIZ, _("general options"));
+ (void)strncpy (cwin.label, _("general options"), BUFSIZ);
wins_scrollwin_init (&cwin);
wins_show (cwin.win.p, cwin.label);
status_mesg (number_str, keys);
@@ -1365,7 +1365,7 @@ custom_keys_config (void)
clear ();
custom_set_swsiz (&kwin);
nbdisplayed = (kwin.win.h - LABELLINES) / LINESPERKEY;
- (void)snprintf (kwin.label, BUFSIZ, _("keys configuration"));
+ (void)strncpy (kwin.label, _("keys configuration"), BUFSIZ);
wins_scrollwin_init (&kwin);
wins_show (kwin.win.p, kwin.label);
custom_keys_config_bar ();
diff --git a/src/getstring.c b/src/getstring.c
index 8633ef3..7570474 100644
--- a/src/getstring.c
+++ b/src/getstring.c
@@ -115,7 +115,7 @@ getstr_ins_char (struct getstr_status *st, char *c)
static void
bell (void)
{
- printf ("\a");
+ putchar ('\a');
}
/* Initialize getstring data structure. */
diff --git a/src/help.c b/src/help.c
index 88b23d6..5064723 100644
--- a/src/help.c
+++ b/src/help.c
@@ -168,7 +168,7 @@ help_wins_init (struct scrollwin *hwin, int x, int y, int h, int w)
hwin->pad.h = BUFSIZ;
hwin->pad.w = hwin->win.w - 2 * PADOFFSET + 1;
- (void)snprintf (hwin->label, BUFSIZ, _("Calcurse help"));
+ (void)strncpy (hwin->label, _("Calcurse help"), BUFSIZ);
wins_scrollwin_init (hwin);
wins_show (hwin->win.p, hwin->label);
}
diff --git a/src/io.c b/src/io.c
index 831f6b6..14299bd 100644
--- a/src/io.c
+++ b/src/io.c
@@ -295,41 +295,41 @@ foreach_date_dump (const long date_end, struct rpt *rpt, llist_t *exc,
static void
ical_export_valarm (FILE *stream)
{
- (void)fprintf (stream, "BEGIN:VALARM\n");
+ (void)fputs ("BEGIN:VALARM\n", stream);
pthread_mutex_lock (&nbar.mutex);
(void)fprintf (stream, "TRIGGER:-P%dS\n", nbar.cntdwn);
pthread_mutex_unlock (&nbar.mutex);
- (void)fprintf (stream, "ACTION:DISPLAY\n");
- (void)fprintf (stream, "END:VALARM\n");
+ (void)fputs ("ACTION:DISPLAY\n", stream);
+ (void)fputs ("END:VALARM\n", stream);
}
/* Export header. */
static void
ical_export_header (FILE *stream)
{
- (void)fprintf (stream, "BEGIN:VCALENDAR\n");
+ (void)fputs ("BEGIN:VCALENDAR\n", stream);
(void)fprintf (stream, "PRODID:-//calcurse//NONSGML v%s//EN\n", VERSION);
- (void)fprintf (stream, "VERSION:2.0\n");
+ (void)fputs ("VERSION:2.0\n", stream);
}
static void
pcal_export_header (FILE *stream)
{
- (void)fprintf (stream, "# calcurse pcal export\n");
- (void)fprintf (stream, "\n# =======\n# options\n# =======\n");
+ (void)fputs ("# calcurse pcal export\n", stream);
+ (void)fputs ("\n# =======\n# options\n# =======\n", stream);
(void)fprintf (stream, "opt -A -K -l -m -F %s\n",
calendar_week_begins_on_monday () ?
"Monday" : "Sunday");
- (void)fprintf (stream, "# Display week number (i.e. 1-52) on every Monday\n");
+ (void)fputs ("# Display week number (i.e. 1-52) on every Monday\n", stream);
(void)fprintf (stream, "all monday in all %s %%w\n", _("Week"));
- (void)fprintf (stream, "\n");
+ (void)fputc ('\n', stream);
}
/* Export footer. */
static void
ical_export_footer (FILE *stream)
{
- (void)fprintf (stream, "END:VCALENDAR\n");
+ (void)fputs ("END:VCALENDAR\n", stream);
}
static void
@@ -348,7 +348,7 @@ ical_export_recur_events (FILE *stream)
{
struct recur_event *rev = LLIST_GET_DATA (i);
date_sec2date_fmt (rev->day, ICALDATEFMT, ical_date);
- (void)fprintf (stream, "BEGIN:VEVENT\n");
+ (void)fputs ("BEGIN:VEVENT\n", stream);
(void)fprintf (stream, "DTSTART:%s\n", ical_date);
(void)fprintf (stream, "RRULE:FREQ=%s;INTERVAL=%d",
ical_recur_type[rev->rpt->type], rev->rpt->freq);
@@ -359,25 +359,25 @@ ical_export_recur_events (FILE *stream)
(void)fprintf (stream, ";UNTIL=%s\n", ical_date);
}
else
- (void)fprintf (stream, "\n");
+ (void)fputc ('\n', stream);
if (LLIST_FIRST (&rev->exc))
{
- (void)fprintf (stream, "EXDATE:");
+ (void)fputs ("EXDATE:", stream);
LLIST_FOREACH (&rev->exc, j)
{
struct excp *exc = LLIST_GET_DATA (j);
date_sec2date_fmt (exc->st, ICALDATEFMT, ical_date);
(void)fprintf (stream, "%s", ical_date);
if (LLIST_NEXT (j))
- (void)fprintf (stream, ",");
+ (void)fputc (',', stream);
else
- (void)fprintf (stream, "\n");
+ (void)fputc ('\n', stream);
}
}
(void)fprintf (stream, "SUMMARY:%s\n", rev->mesg);
- (void)fprintf (stream, "END:VEVENT\n");
+ (void)fputs ("END:VEVENT\n", stream);
}
}
@@ -412,11 +412,11 @@ pcal_export_recur_events (FILE *stream)
llist_item_t *i;
char pcal_date[BUFSIZ];
- (void)fprintf (stream, "\n# =============");
- (void)fprintf (stream, "\n# Recur. Events");
- (void)fprintf (stream, "\n# =============\n");
- (void)fprintf (stream,
- "# (pcal does not support from..until dates specification\n");
+ (void)fputs ("\n# =============", stream);
+ (void)fputs ("\n# Recur. Events", stream);
+ (void)fputs ("\n# =============\n", stream);
+ (void)fputs ("# (pcal does not support from..until dates specification\n",
+ stream);
LLIST_FOREACH (&recur_elist, i)
{
@@ -472,10 +472,10 @@ ical_export_events (FILE *stream)
{
struct event *ev = LLIST_TS_GET_DATA (i);
date_sec2date_fmt (ev->day, ICALDATEFMT, ical_date);
- (void)fprintf (stream, "BEGIN:VEVENT\n");
+ (void)fputs ("BEGIN:VEVENT\n", stream);
(void)fprintf (stream, "DTSTART:%s\n", ical_date);
(void)fprintf (stream, "SUMMARY:%s\n", ev->mesg);
- (void)fprintf (stream, "END:VEVENT\n");
+ (void)fputs ("END:VEVENT\n", stream);
}
}
@@ -484,13 +484,13 @@ pcal_export_events (FILE *stream)
{
llist_item_t *i;
- (void)fprintf (stream, "\n# ======\n# Events\n# ======\n");
+ (void)fputs ("\n# ======\n# Events\n# ======\n", stream);
LLIST_FOREACH (&eventlist, i)
{
struct event *ev = LLIST_TS_GET_DATA (i);
pcal_dump_event (stream, ev->day, 0, ev->mesg);
}
- (void)fprintf (stream, "\n");
+ (void)fputc ('\n', stream);
}
/* Export recurrent appointments. */
@@ -507,7 +507,7 @@ ical_export_recur_apoints (FILE *stream)
struct recur_apoint *rapt = LLIST_TS_GET_DATA (i);
date_sec2date_fmt (rapt->start, ICALDATETIMEFMT, ical_datetime);
- (void)fprintf (stream, "BEGIN:VEVENT\n");
+ (void)fputs ("BEGIN:VEVENT\n", stream);
(void)fprintf (stream, "DTSTART:%s\n", ical_datetime);
(void)fprintf (stream, "DURATION:PT0H0M%ldS\n", rapt->dur);
(void)fprintf (stream, "RRULE:FREQ=%s;INTERVAL=%d",
@@ -520,27 +520,27 @@ ical_export_recur_apoints (FILE *stream)
(void)fprintf (stream, ";UNTIL=%s\n", ical_date);
}
else
- (void)fprintf (stream, "\n");
+ (void)fputc ('\n', stream);
if (LLIST_FIRST (&rapt->exc))
{
- (void)fprintf (stream, "EXDATE:");
+ (void)fputs ("EXDATE:", stream);
LLIST_FOREACH (&rapt->exc, j)
{
struct excp *exc = LLIST_GET_DATA (j);
date_sec2date_fmt (exc->st, ICALDATEFMT, ical_date);
(void)fprintf (stream, "%s", ical_date);
if (LLIST_NEXT (j))
- (void)fprintf (stream, ",");
+ (void)fputc (',', stream);
else
- (void)fprintf (stream, "\n");
+ (void)fputc ('\n', stream);
}
}
(void)fprintf (stream, "SUMMARY:%s\n", rapt->mesg);
if (rapt->state & APOINT_NOTIFY)
ical_export_valarm (stream);
- (void)fprintf (stream, "END:VEVENT\n");
+ (void)fputs ("END:VEVENT\n", stream);
}
LLIST_TS_UNLOCK (&recur_alist_p);
}
@@ -551,11 +551,11 @@ pcal_export_recur_apoints (FILE *stream)
llist_item_t *i;
char pcal_date[BUFSIZ], pcal_beg[BUFSIZ], pcal_end[BUFSIZ];
- (void)fprintf (stream, "\n# ==============");
- (void)fprintf (stream, "\n# Recur. Apoints");
- (void)fprintf (stream, "\n# ==============\n");
- (void)fprintf (stream,
- "# (pcal does not support from..until dates specification\n");
+ (void)fputs ("\n# ==============", stream);
+ (void)fputs ("\n# Recur. Apoints", stream);
+ (void)fputs ("\n# ==============\n", stream);
+ (void)fputs ("# (pcal does not support from..until dates specification\n",
+ stream);
LLIST_TS_FOREACH (&recur_alist_p, i)
{
@@ -618,13 +618,13 @@ ical_export_apoints (FILE *stream)
{
struct apoint *apt = LLIST_TS_GET_DATA (i);
date_sec2date_fmt (apt->start, ICALDATETIMEFMT, ical_datetime);
- (void)fprintf (stream, "BEGIN:VEVENT\n");
+ (void)fputs ("BEGIN:VEVENT\n", stream);
(void)fprintf (stream, "DTSTART:%s\n", ical_datetime);
(void)fprintf (stream, "DURATION:PT0H0M%ldS\n", apt->dur);
(void)fprintf (stream, "SUMMARY:%s\n", apt->mesg);
if (apt->state & APOINT_NOTIFY)
ical_export_valarm (stream);
- (void)fprintf (stream, "END:VEVENT\n");
+ (void)fputs ("END:VEVENT\n", stream);
}
LLIST_TS_UNLOCK (&alist_p);
}
@@ -634,7 +634,7 @@ pcal_export_apoints (FILE *stream)
{
llist_item_t *i;
- (void)fprintf (stream, "\n# ============\n# Appointments\n# ============\n");
+ (void)fputs ("\n# ============\n# Appointments\n# ============\n", stream);
LLIST_TS_LOCK (&alist_p);
LLIST_TS_FOREACH (&alist_p, i)
{
@@ -642,7 +642,7 @@ pcal_export_apoints (FILE *stream)
pcal_dump_apoint (stream, apt->start, apt->dur, apt->mesg);
}
LLIST_TS_UNLOCK (&alist_p);
- (void)fprintf (stream, "\n");
+ (void)fputc ('\n', stream);
}
/* Export todo items. */
@@ -657,10 +657,10 @@ ical_export_todo (FILE *stream)
if (todo->id < 0) /* completed items */
continue;
- (void)fprintf (stream, "BEGIN:VTODO\n");
+ (void)fputs ("BEGIN:VTODO\n", stream);
(void)fprintf (stream, "PRIORITY:%d\n", todo->id);
(void)fprintf (stream, "SUMMARY:%s\n", todo->mesg);
- (void)fprintf (stream, "END:VTODO\n");
+ (void)fputs ("END:VTODO\n", stream);
}
}
@@ -669,17 +669,17 @@ pcal_export_todo (FILE *stream)
{
llist_item_t *i;
- (void)fprintf (stream, "#\n# Todos\n#\n");
+ (void)fputs ("#\n# Todos\n#\n", stream);
LLIST_FOREACH (&todolist, i)
{
struct todo *todo = LLIST_TS_GET_DATA (i);
if (todo->id < 0) /* completed items */
continue;
- (void)fprintf (stream, "note all ");
+ (void)fputs ("note all ", stream);
(void)fprintf (stream, "%d. %s\n", todo->id, todo->mesg);
}
- (void)fprintf (stream, "\n");
+ (void)fputc ('\n', stream);
}
/* Append a line to a file. */
@@ -772,7 +772,7 @@ io_init (char *cfile, char *datadir)
{
case 'N':
case 'n':
- printf (_("aborting...\n"));
+ puts (_("aborting...\n"));
exit_calcurse (EXIT_FAILURE);
break;
@@ -787,12 +787,12 @@ io_init (char *cfile, char *datadir)
else
{
printf (_("%s successfully created\n"), path_apts);
- printf (_("starting interactive mode...\n"));
+ puts (_("starting interactive mode...\n"));
}
break;
default:
- printf (_("aborting...\n"));
+ puts (_("aborting...\n"));
exit_calcurse (EXIT_FAILURE);
break;
}
@@ -862,121 +862,116 @@ io_save_conf (struct conf *conf)
(void)fprintf (fp, "%s\n", config_txt);
- (void)fprintf (fp, "# If this option is set to yes, "
- "automatic save is done when quitting\n");
- (void)fprintf (fp, "auto_save=");
+ (void)fputs ("# If this option is set to yes, "
+ "automatic save is done when quitting\n", fp);
+ (void)fputs ("auto_save=", fp);
(void)fprintf (fp, "%s\n", (conf->auto_save) ? "yes" : "no");
- (void)fprintf (fp, "\n# If this option is set to yes, "
- "the GC is run automatically when quitting\n");
- (void)fprintf (fp, "auto_gc=");
+ (void)fputs ("\n# If this option is set to yes, "
+ "the GC is run automatically when quitting\n", fp);
+ (void)fputs ("auto_gc=", fp);
(void)fprintf (fp, "%s\n", (conf->auto_gc) ? "yes" : "no");
- (void)fprintf (fp, "\n# If not null, perform automatic saves every "
- "'periodic_save' minutes\n");
- (void)fprintf (fp, "periodic_save=");
+ (void)fputs ("\n# If not null, perform automatic saves every "
+ "'periodic_save' minutes\n", fp);
+ (void)fputs ("periodic_save=", fp);
(void)fprintf (fp, "%d\n", conf->periodic_save);
- (void)fprintf (fp, "\n# If this option is set to yes, "
- "confirmation is required before quitting\n");
- (void)fprintf (fp, "confirm_quit=");
+ (void)fputs ("\n# If this option is set to yes, "
+ "confirmation is required before quitting\n", fp);
+ (void)fputs ("confirm_quit=", fp);
(void)fprintf (fp, "%s\n", (conf->confirm_quit) ? "yes" : "no");
- (void)fprintf (fp, "\n# If this option is set to yes, "
- "confirmation is required before deleting an event\n");
- (void)fprintf (fp, "confirm_delete=");
+ (void)fputs ("\n# If this option is set to yes, "
+ "confirmation is required before deleting an event\n", fp);
+ (void)fputs ("confirm_delete=", fp);
(void)fprintf (fp, "%s\n", (conf->confirm_delete) ? "yes" : "no");
- (void)fprintf (fp, "\n# If this option is set to yes, "
- "messages about loaded and saved data will not be displayed\n");
- (void)fprintf (fp, "skip_system_dialogs=");
+ (void)fputs ("\n# If this option is set to yes, messages about loaded and "
+ "saved data will not be displayed\n", fp);
+ (void)fputs ("skip_system_dialogs=", fp);
(void)fprintf (fp, "%s\n", (conf->skip_system_dialogs) ? "yes" : "no");
- (void)fprintf (fp,
- "\n# If this option is set to yes, progress bar appearing "
- "when saving data will not be displayed\n");
- (void)fprintf (fp, "skip_progress_bar=");
+ (void)fputs ("\n# If this option is set to yes, progress bar appearing "
+ "when saving data will not be displayed\n", fp);
+ (void)fputs ("skip_progress_bar=", fp);
(void)fprintf (fp, "%s\n", (conf->skip_progress_bar) ? "yes" : "no");
- (void)fprintf (fp, "\n# Default calendar view (0)monthly (1)weekly:\n");
- (void)fprintf (fp, "calendar_default_view=");
+ (void)fputs ("\n# Default calendar view (0)monthly (1)weekly:\n", fp);
+ (void)fputs ("calendar_default_view=", fp);
(void)fprintf (fp, "%d\n", calendar_get_view ());
- (void)fprintf (fp, "\n# If this option is set to yes, "
- "monday is the first day of the week, else it is sunday\n");
- (void)fprintf (fp, "week_begins_on_monday=");
+ (void)fputs ("\n# If this option is set to yes, "
+ "monday is the first day of the week, else it is sunday\n", fp);
+ (void)fputs ("week_begins_on_monday=", fp);
(void)fprintf (fp, "%s\n",
(calendar_week_begins_on_monday ())? "yes" : "no");
- (void)fprintf (fp, "\n# This is the color theme used for menus :\n");
- (void)fprintf (fp, "color-theme=");
+ (void)fputs ("\n# This is the color theme used for menus :\n", fp);
+ (void)fputs ("color-theme=", fp);
(void)fprintf (fp, "%s\n", theme_name);
- (void)fprintf (fp, "\n# This is the layout of the calendar :\n");
- (void)fprintf (fp, "layout=");
+ (void)fputs ("\n# This is the layout of the calendar :\n", fp);
+ (void)fputs ("layout=", fp);
(void)fprintf (fp, "%d\n", wins_layout ());
- (void)fprintf (fp, "\n# Width (in percentage, 0 being minimun width) "
- "of the side bar :\n");
- (void)fprintf (fp, "side-bar_width=");
+ (void)fputs ("\n# Width ( percentage, 0 being minimun width, fp) "
+ "of the side bar :\n", fp);
+ (void)fputs ("side-bar_width=", fp);
(void)fprintf (fp, "%d\n", wins_sbar_wperc ());
if (ui_mode == UI_CURSES)
pthread_mutex_lock (&nbar.mutex);
- (void)fprintf (fp,
- "\n# If this option is set to yes, "
- "notify-bar will be displayed :\n");
- (void)fprintf (fp, "notify-bar_show=");
+ (void)fputs ("\n# If this option is set to yes, "
+ "notify-bar will be displayed :\n", fp);
+ (void)fputs ("notify-bar_show=", fp);
(void)fprintf (fp, "%s\n", (nbar.show) ? "yes" : "no");
- (void)fprintf (fp,
- "\n# Format of the date to be displayed inside notify-bar :\n");
- (void)fprintf (fp, "notify-bar_date=");
+ (void)fputs ("\n# Format of the date to be displayed inside notify-bar :\n", fp);
+ (void)fputs ("notify-bar_date=", fp);
(void)fprintf (fp, "%s\n", nbar.datefmt);
- (void)fprintf (fp,
- "\n# Format of the time to be displayed inside notify-bar :\n");
- (void)fprintf (fp, "notify-bar_clock=");
+ (void)fputs ("\n# Format of the time to be displayed inside notify-bar :\n", fp);
+ (void)fputs ("notify-bar_clock=", fp);
(void)fprintf (fp, "%s\n", nbar.timefmt);
- (void)fprintf (fp,
- "\n# Warn user if he has an appointment within next "
- "'notify-bar_warning' seconds :\n");
- (void)fprintf (fp, "notify-bar_warning=");
+ (void)fputs ("\n# Warn user if he has an appointment within next "
+ "'notify-bar_warning' seconds :\n", fp);
+ (void)fputs ("notify-bar_warning=", fp);
(void)fprintf (fp, "%d\n", nbar.cntdwn);
- (void)fprintf (fp, "\n# Command used to notify user of "
- "an upcoming appointment :\n");
- (void)fprintf (fp, "notify-bar_command=");
+ (void)fputs ("\n# Command used to notify user of "
+ "an upcoming appointment :\n", fp);
+ (void)fputs ("notify-bar_command=", fp);
(void)fprintf (fp, "%s\n", nbar.cmd);
- (void)fprintf (fp, "\n# Notify all appointments instead of flagged ones only\n");
- (void)fprintf (fp, "notify-all=");
+ (void)fputs ("\n# Notify all appointments instead of flagged ones only\n", fp);
+ (void)fputs ("notify-all=", fp);
(void)fprintf (fp, "%s\n", (nbar.notify_all) ? "yes" : "no");
- (void)fprintf (fp, "\n# Format of the date to be displayed "
- "in non-interactive mode :\n");
- (void)fprintf (fp, "output_datefmt=");
+ (void)fputs ("\n# Format of the date to be displayed "
+ "in non-interactive mode :\n", fp);
+ (void)fputs ("output_datefmt=", fp);
(void)fprintf (fp, "%s\n", conf->output_datefmt);
- (void)fprintf (fp, "\n# Format to be used when entering a date "
- "(1)mm/dd/yyyy (2)dd/mm/yyyy (3)yyyy/mm/dd) "
- "(4)yyyy-mm-dd:\n");
- (void)fprintf (fp, "input_datefmt=");
+ (void)fputs ("\n# Format to be used when entering a date "
+ "(1)mm/dd/yyyy (2)dd/mm/yyyy (3)yyyy/mm/dd) "
+ "(4)yyyy-mm-dd:\n", fp);
+ (void)fputs ("input_datefmt=", fp);
(void)fprintf (fp, "%d\n", conf->input_datefmt);
if (ui_mode == UI_CURSES)
pthread_mutex_unlock (&nbar.mutex);
- (void)fprintf (fp, "\n# If this option is set to yes, "
- "calcurse will run in background to get notifications "
- "after exiting\n");
- (void)fprintf (fp, "notify-daemon_enable=");
+ (void)fputs ("\n# If this option is set to yes, "
+ "calcurse will run in background to get notifications "
+ "after exiting\n", fp);
+ (void)fputs ("notify-daemon_enable=", fp);
(void)fprintf (fp, "%s\n", dmon.enable ? "yes" : "no");
- (void)fprintf (fp, "\n# If this option is set to yes, "
- "activity will be logged when running in background\n");
- (void)fprintf (fp, "notify-daemon_log=");
+ (void)fputs ("\n# If this option is set to yes, "
+ "activity will be logged when running in background\n", fp);
+ (void)fputs ("notify-daemon_log=", fp);
(void)fprintf (fp, "%s\n", dmon.log ? "yes" : "no");
file_close (fp, __FILE_POS__);
diff --git a/src/keys.c b/src/keys.c
index 180b80d..b885b63 100644
--- a/src/keys.c
+++ b/src/keys.c
@@ -444,7 +444,7 @@ keys_format_label (char *key, int keylen)
bzero (fmtkey, sizeof (fmtkey));
if (len == 0)
- (void)snprintf (fmtkey, sizeof (fmtkey), "?");
+ (void)strncpy (fmtkey, "?", sizeof (fmtkey));
else if (len <= keylen)
{
for (i = 0; i < keylen - len; i++)
diff --git a/src/mem.c b/src/mem.c
index 82b28f3..63aea73 100644
--- a/src/mem.c
+++ b/src/mem.c
@@ -287,24 +287,24 @@ dump_block_info (struct mem_blk *blk)
if (blk == NULL)
return;
- printf (_("---==== MEMORY BLOCK ====----------------\n"));
+ puts (_("---==== MEMORY BLOCK ====----------------\n"));
printf (_(" id: %u\n"), blk->id);
printf (_(" size: %u\n"), blk->size);
printf (_(" allocated in: %s\n"), blk->pos);
- printf (_("-----------------------------------------\n"));
+ puts (_("-----------------------------------------\n"));
}
void
mem_stats (void)
{
- printf ("\n");
- printf (_("+------------------------------+\n"));
- printf (_("| calcurse memory usage report |\n"));
- printf (_("+------------------------------+\n"));
+ putchar ('\n');
+ puts (_("+------------------------------+\n"));
+ puts (_("| calcurse memory usage report |\n"));
+ puts (_("+------------------------------+\n"));
printf (_(" number of calls: %u\n"), mstats.ncall);
printf (_(" allocated blocks: %u\n"), mstats.nalloc);
printf (_(" unfreed blocks: %u\n"), mstats.nalloc - mstats.nfree);
- printf ("\n");
+ putchar ("\n");
if (mstats.nfree < mstats.nalloc)
{
diff --git a/src/notify.c b/src/notify.c
index bf0fd29..f69b477 100644
--- a/src/notify.c
+++ b/src/notify.c
@@ -727,7 +727,7 @@ notify_config_bar (void)
clear ();
custom_set_swsiz (&cwin);
- (void)snprintf (cwin.label, BUFSIZ, _("notification options"));
+ (void)strncpy (cwin.label, _("notification options"), BUFSIZ);
wins_scrollwin_init (&cwin);
wins_show (cwin.win.p, cwin.label);
status_mesg (number_str, keys);
diff --git a/src/recur.c b/src/recur.c
index 87e4e36..7b3c9fe 100644
--- a/src/recur.c
+++ b/src/recur.c
@@ -481,13 +481,13 @@ recur_apoint_write (struct recur_apoint *o, FILE *f)
lt->tm_mon + 1, lt->tm_mday, 1900 + lt->tm_year);
}
recur_write_exc (&o->exc, f);
- (void)fprintf (f, "} ");
+ (void)fputs ("} ", f);
if (o->note != NULL)
(void)fprintf (f, ">%s ", o->note);
if (o->state & APOINT_NOTIFY)
- (void)fprintf (f, "!");
+ (void)fputc ('!', f);
else
- (void)fprintf (f, "|");
+ (void)fputc ('|', f);
(void)fprintf (f, "%s\n", o->mesg);
}
@@ -524,7 +524,7 @@ recur_event_write (struct recur_event *o, FILE *f)
end_mon, end_day, end_year);
}
recur_write_exc (&o->exc, f);
- (void)fprintf (f, "} ");
+ (void)fputs ("} ", f);
if (o->note != NULL)
(void)fprintf (f, ">%s ", o->note);
(void)fprintf (f, "%s\n", o->mesg);
diff --git a/src/todo.c b/src/todo.c
index 017fa9a..c1e0465 100644
--- a/src/todo.c
+++ b/src/todo.c
@@ -391,7 +391,7 @@ display_todo_item (int incolor, char *msg, int prio, int note, int width, int y,
if (prio > 0)
snprintf (priostr, sizeof priostr, "%d", prio);
else
- snprintf (priostr, sizeof priostr, "X");
+ strncpy (priostr, "X", sizeof priostr);
if (incolor == 0)
custom_apply_attr (w, ATTR_HIGHEST);
diff --git a/src/utils.c b/src/utils.c
index 2501d9b..f007ee1 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -293,7 +293,7 @@ date_sec2date_str (long sec, char *datefmt)
char *datestr = (char *) mem_calloc (BUFSIZ, sizeof (char));
if (sec == 0)
- (void)snprintf (datestr, BUFSIZ, "0");
+ (void)strncpy (datestr, "0", BUFSIZ);
else
{
lt = localtime ((time_t *)&sec);
diff --git a/src/wins.c b/src/wins.c
index efe324f..a98a287 100644
--- a/src/wins.c
+++ b/src/wins.c
@@ -227,17 +227,17 @@ wins_init_panels (void)
char label[BUFSIZ];
win[CAL].p = newwin (CALHEIGHT, wins_sbar_width (), win[CAL].y, win[CAL].x);
- (void)snprintf (label, BUFSIZ, _("Calendar"));
+ (void)strncpy (label, _("Calendar"), BUFSIZ);
wins_show (win[CAL].p, label);
win[APP].p = newwin (win[APP].h, win[APP].w, win[APP].y, win[APP].x);
- (void)snprintf (label, BUFSIZ, _("Appointments"));
+ (void)strncpy (label, _("Appointments"), BUFSIZ);
wins_show (win[APP].p, label);
apad.width = win[APP].w - 3;
apad.ptrwin = newpad (apad.length, apad.width);
win[TOD].p = newwin (win[TOD].h, win[TOD].w, win[TOD].y, win[TOD].x);
- (void)snprintf (label, BUFSIZ, _("ToDo"));
+ (void)strncpy (label, _("ToDo"), BUFSIZ);
wins_show (win[TOD].p, label);
/* Enable function keys (i.e. arrow keys) in those windows */