aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2012-03-02 09:28:13 +0100
committerLukas Fleischer <calcurse@cryptocrack.de>2012-03-12 20:36:22 +0100
commit481cb5524f8e165bbe3c17bb04bdc7330dd7a923 (patch)
tree34c4c09613e40c82a9bab4b15685cad949d7ce1c /src
parent0f4b45e62487e32e789571912fd2190168f753bc (diff)
downloadcalcurse-481cb5524f8e165bbe3c17bb04bdc7330dd7a923.tar.gz
calcurse-481cb5524f8e165bbe3c17bb04bdc7330dd7a923.zip
Do not strncpy() strings returned by gettext()
Translated strings returned by gettext() are statically allocated. There's no need to copy them to a buffer, we can use the pointers returned by gettext() instead. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src')
-rw-r--r--src/calcurse.h8
-rw-r--r--src/custom.c12
-rw-r--r--src/help.c2
-rw-r--r--src/notify.c2
-rw-r--r--src/utils.c9
-rw-r--r--src/wins.c13
6 files changed, 20 insertions, 26 deletions
diff --git a/src/calcurse.h b/src/calcurse.h
index fa026f8..a0e53e0 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -463,7 +463,7 @@ struct scrollwin {
struct window pad;
unsigned first_visible_line;
unsigned total_lines;
- char label[BUFSIZ];
+ const char *label;
};
/* Pad structure to handle scrolling. */
@@ -634,7 +634,7 @@ void custom_layout_config (void);
void custom_sidebar_config (void);
void custom_color_config (void);
void custom_color_theme_name (char *);
-void custom_confwin_init (struct window *, char *);
+void custom_confwin_init (struct window *, const char *);
void custom_set_swsiz (struct scrollwin *);
void custom_general_config (void);
void custom_keys_config (void);
@@ -897,7 +897,7 @@ void warnbox (const char *);
void status_mesg (char *, char *);
void erase_window_part (WINDOW *, int, int, int, int);
WINDOW *popup (int, int, int, int, char *, char *, int);
-void print_in_middle (WINDOW *, int, int, int, char *);
+void print_in_middle (WINDOW *, int, int, int, const char *);
int is_all_digit (const char *);
long get_item_time (long);
int get_item_hour (long);
@@ -985,7 +985,7 @@ void wins_scrollwin_up (struct scrollwin *, int);
void wins_scrollwin_down (struct scrollwin *, int);
void wins_reinit (void);
void wins_reinit_panels (void);
-void wins_show (WINDOW *, char *);
+void wins_show (WINDOW *, const char *);
void wins_get_config (void);
void wins_update_border (int);
void wins_update_panels (int);
diff --git a/src/custom.c b/src/custom.c
index 900c869..2ccae65 100644
--- a/src/custom.c
+++ b/src/custom.c
@@ -215,7 +215,7 @@ custom_layout_config (void)
struct scrollwin hwin;
struct window conf_win;
int ch, mark, cursor, need_reset;
- char label[BUFSIZ];
+ const char *label = _("layout configuration");
char *help_text =
_("With this configuration menu, one can choose where panels will be\n"
"displayed inside calcurse screen. \n"
@@ -226,7 +226,6 @@ custom_layout_config (void)
" 't' -> todo panel\n\n");
conf_win.p = NULL;
- strncpy (label, _("layout configuration"), BUFSIZ);
custom_confwin_init (&conf_win, label);
cursor = mark = wins_layout () - 1;
display_layout_config (&conf_win, mark, cursor);
@@ -374,7 +373,7 @@ set_confwin_attr (struct window *cwin)
* (useful in case of window resize).
*/
void
-custom_confwin_init (struct window *confwin, char *label)
+custom_confwin_init (struct window *confwin, const char *label)
{
if (confwin->p)
{
@@ -547,10 +546,9 @@ custom_color_config (void)
struct window conf_win;
int ch, cursor, need_reset, theme_changed;
int mark_fore, mark_back;
- char label[BUFSIZ];
+ const char *label = _("color theme");
conf_win.p = 0;
- strncpy (label, _("color theme"), BUFSIZ);
custom_confwin_init (&conf_win, label);
mark_fore = NBUSERCOLORS;
mark_back = SIZE - 1;
@@ -764,7 +762,7 @@ custom_general_config (void)
clear ();
custom_set_swsiz (&cwin);
- strncpy (cwin.label, _("general options"), BUFSIZ);
+ cwin.label = _("general options");
wins_scrollwin_init (&cwin);
wins_show (cwin.win.p, cwin.label);
status_mesg (number_str, keys);
@@ -969,7 +967,7 @@ custom_keys_config (void)
clear ();
custom_set_swsiz (&kwin);
nbdisplayed = (kwin.win.h - LABELLINES) / LINESPERKEY;
- strncpy (kwin.label, _("keys configuration"), BUFSIZ);
+ kwin.label = _("keys configuration");
wins_scrollwin_init (&kwin);
wins_show (kwin.win.p, kwin.label);
custom_keys_config_bar ();
diff --git a/src/help.c b/src/help.c
index eaca14b..14d10aa 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;
- strncpy (hwin->label, _("Calcurse help"), BUFSIZ);
+ hwin->label = _("Calcurse help");
wins_scrollwin_init (hwin);
wins_show (hwin->win.p, hwin->label);
}
diff --git a/src/notify.c b/src/notify.c
index 6529087..285238c 100644
--- a/src/notify.c
+++ b/src/notify.c
@@ -729,7 +729,7 @@ notify_config_bar (void)
clear ();
custom_set_swsiz (&cwin);
- strncpy (cwin.label, _("notification options"), BUFSIZ);
+ cwin.label = _("notification options");
wins_scrollwin_init (&cwin);
wins_show (cwin.win.p, cwin.label);
status_mesg (number_str, keys);
diff --git a/src/utils.c b/src/utils.c
index d756d62..0a28620 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -212,7 +212,8 @@ popup (int pop_row, int pop_col, int pop_y, int pop_x, char *title, char *msg,
/* prints in middle of a panel */
void
-print_in_middle (WINDOW *win, int starty, int startx, int width, char *string)
+print_in_middle (WINDOW *win, int starty, int startx, int width,
+ const char *string)
{
int len = strlen (string);
int x, y;
@@ -490,17 +491,17 @@ void
print_bool_option_incolor (WINDOW *win, unsigned option, int pos_y, int pos_x)
{
int color = 0;
- char option_value[BUFSIZ] = "";
+ const char *option_value;
if (option == 1)
{
color = ATTR_TRUE;
- strncpy (option_value, _("yes"), BUFSIZ);
+ option_value = _("yes");
}
else if (option == 0)
{
color = ATTR_FALSE;
- strncpy (option_value, _("no"), BUFSIZ);
+ option_value = _("no");
}
else
EXIT (_("option not defined"));
diff --git a/src/wins.c b/src/wins.c
index fa53dcb..6c74d0f 100644
--- a/src/wins.c
+++ b/src/wins.c
@@ -224,21 +224,16 @@ wins_slctd_next (void)
static void
wins_init_panels (void)
{
- char label[BUFSIZ];
-
win[CAL].p = newwin (CALHEIGHT, wins_sbar_width (), win[CAL].y, win[CAL].x);
- strncpy (label, _("Calendar"), BUFSIZ);
- wins_show (win[CAL].p, label);
+ wins_show (win[CAL].p, _("Calendar"));
win[APP].p = newwin (win[APP].h, win[APP].w, win[APP].y, win[APP].x);
- strncpy (label, _("Appointments"), BUFSIZ);
- wins_show (win[APP].p, label);
+ wins_show (win[APP].p, _("Appointments"));
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);
- strncpy (label, _("ToDo"), BUFSIZ);
- wins_show (win[TOD].p, label);
+ wins_show (win[TOD].p, _("ToDo"));
/* Enable function keys (i.e. arrow keys) in those windows */
keypad (win[CAL].p, TRUE);
@@ -353,7 +348,7 @@ wins_reinit (void)
/* Show the window with a border and a label. */
void
-wins_show (WINDOW *win, char *label)
+wins_show (WINDOW *win, const char *label)
{
int width = getmaxx (win);