Module Name: src Committed By: martin Date: Sun Sep 27 17:36:40 UTC 2020
Modified Files: src/usr.sbin/sysinst: msg.mi.fr util.c Log Message: Fix display of timezone selection menu To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/usr.sbin/sysinst/msg.mi.fr cvs rdiff -u -r1.46 -r1.47 src/usr.sbin/sysinst/util.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.sbin/sysinst/msg.mi.fr diff -u src/usr.sbin/sysinst/msg.mi.fr:1.28 src/usr.sbin/sysinst/msg.mi.fr:1.29 --- src/usr.sbin/sysinst/msg.mi.fr:1.28 Tue May 26 15:20:45 2020 +++ src/usr.sbin/sysinst/msg.mi.fr Sun Sep 27 17:36:40 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: msg.mi.fr,v 1.28 2020/05/26 15:20:45 snj Exp $ */ +/* $NetBSD: msg.mi.fr,v 1.29 2020/09/27 17:36:40 martin Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -999,7 +999,7 @@ Appuyez sur la touche Entrée pour confir Appuyez sur "x" puis sur Entrée pour valider la sélection en cours. Par défaut : %s - Sélection actuelle : %s + Sélection actuelle : %s Heure locale : %s %s } Index: src/usr.sbin/sysinst/util.c diff -u src/usr.sbin/sysinst/util.c:1.46 src/usr.sbin/sysinst/util.c:1.47 --- src/usr.sbin/sysinst/util.c:1.46 Tue Sep 22 16:18:54 2020 +++ src/usr.sbin/sysinst/util.c Sun Sep 27 17:36:40 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: util.c,v 1.46 2020/09/22 16:18:54 martin Exp $ */ +/* $NetBSD: util.c,v 1.47 2020/09/27 17:36:40 martin Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -1343,6 +1343,26 @@ static char *tz_selected; /* timezonenam const char *tz_default; /* UTC, or whatever /etc/localtime points to */ static char tz_env[STRSIZE]; static int save_cursel, save_topline; +static int time_menu = -1; + +static void +update_time_display(void) +{ + time_t t; + struct tm *tm; + char cur_time[STRSIZE], *p; + + t = time(NULL); + tm = localtime(&t); + strlcpy(cur_time, safectime(&t), sizeof cur_time); + p = strchr(cur_time, '\n'); + if (p != NULL) + *p = 0; + + msg_clear(); + msg_fmt_table_add(MSG_choose_timezone, "%s%s%s%s", + tz_default, tz_selected, cur_time, tm ? tm->tm_zone : "?"); +} /* * Callback from timezone menu @@ -1350,9 +1370,7 @@ static int save_cursel, save_topline; static int set_tz_select(menudesc *m, void *arg) { - time_t t; char *new; - struct tm *tm; if (m && strcmp(tz_selected, m->opts[m->cursel].opt_name) != 0) { /* Change the displayed timezone */ @@ -1369,12 +1387,14 @@ set_tz_select(menudesc *m, void *arg) /* Warp curser to 'Exit' line on menu */ m->cursel = -1; - /* Update displayed time */ - t = time(NULL); - tm = localtime(&t); - msg_fmt_display(MSG_choose_timezone, "%s%s%s%s", - tz_default, tz_selected, safectime(&t), tm ? tm->tm_zone : - "?"); + update_time_display(); + if (time_menu >= 1) { + WINDOW *w = get_menudesc(time_menu)->mw; + if (w != NULL) { + touchwin(w); + wrefresh(w); + } + } return 0; } @@ -1529,8 +1549,6 @@ set_timezone(void) { char localtime_link[STRSIZE]; char localtime_target[STRSIZE]; - time_t t; - struct tm *tm; int menu_no; strlcpy(zoneinfo_dir, target_expand("/usr/share/zoneinfo/"), @@ -1542,10 +1560,7 @@ set_timezone(void) tz_selected = strdup(tz_default); snprintf(tz_env, sizeof(tz_env), "%s%s", zoneinfo_dir, tz_selected); setenv("TZ", tz_env, 1); - t = time(NULL); - tm = localtime(&t); - msg_fmt_display(MSG_choose_timezone, "%s%s%s%s", - tz_default, tz_selected, safectime(&t), tm ? tm->tm_zone : "?"); + update_time_display(); signal(SIGALRM, timezone_sig); alarm(60); @@ -1558,7 +1573,9 @@ set_timezone(void) if (menu_no < 0) goto done; /* error - skip timezone setting */ + time_menu = menu_no; process_menu(menu_no, NULL); + time_menu = -1; free_menu(menu_no);