Re: [Midnight Commander] #134: [PATCH] some time formatting fixes
#134: [PATCH] some time formatting fixes +--- Reporter: Enrico Weigelt weig...@metux.de | Owner: Type: enhancement| Status: closed Priority: major | Milestone: 4.7 Component: mc-core| Version: 4.6.1 Resolution: fixed |Keywords: committed-master committed-mc-4.6 Blocking: | Blockedby: +--- Changes (by winnie): * status: new = closed * resolution: = fixed -- Ticket URL: www.midnight-commander.org/ticket/134#comment:7 Midnight Commander www.midnight-commander.org Midnight Development Center ___ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel
Re: [Midnight Commander] #134: [PATCH] some time formatting fixes
#134: [PATCH] some time formatting fixes +--- Reporter: Enrico Weigelt weig...@metux.de | Owner: Type: enhancement| Status: new Priority: major | Milestone: 4.7 Component: mc-core| Version: 4.6.1 Resolution: |Keywords: review Blocking: | Blockedby: +--- Comment(by metux): No, I don't think its an enhancement, since it fixes the time formatting bug -- Ticket URL: www.midnight-commander.org/ticket/134#comment:5 Midnight Commander www.midnight-commander.org Midnight Development Center ___ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel
Re: [Midnight Commander] #134: [PATCH] some time formatting fixes
#134: [PATCH] some time formatting fixes +--- Reporter: Enrico Weigelt weig...@metux.de | Owner: Type: enhancement| Status: new Priority: major | Milestone: 4.7 Component: mc-core| Version: 4.6.1 Resolution: |Keywords: committed-master committed-mc-4.6 Blocking: | Blockedby: +--- Changes (by metux): * keywords: review = committed-master committed-mc-4.6 -- Ticket URL: www.midnight-commander.org/ticket/134#comment:6 Midnight Commander www.midnight-commander.org Midnight Development Center ___ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel
Re: [Midnight Commander] #134: [PATCH] some time formatting fixes
#134: [PATCH] some time formatting fixes +--- Reporter: Enrico Weigelt weig...@metux.de | Owner: Type: enhancement| Status: new Priority: major | Milestone: 4.7 Component: mc-core| Version: 4.6.1 Resolution: |Keywords: review Blocking: | Blockedby: +--- Changes (by slavazanko): * type: defect = enhancement * milestone: 4.6.2 = 4.7 Comment: Enrico, where branch? :) Milestone changed to 4.7 because this patch is an enhancement, not bug fixing... IMHO. -- Ticket URL: www.midnight-commander.org/ticket/134#comment:4 Midnight Commander www.midnight-commander.org Midnight Development Center ___ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel
Re: [Midnight Commander] #134: [PATCH] some time formatting fixes
* MC Ticket System tick...@midnight-commander.org schrieb: Comment: Enrico, where branch? :) Milestone changed to 4.7 because this patch is an enhancement, not bug fixing... IMHO. No, the issue started with some fix for a bug which makes mc segfault when it sees invalid mtime's - I've just refined it. So, it should go into next release, IMHO. cu -- - Enrico Weigelt== metux IT service - http://www.metux.de/ - Please visit the OpenSource QM Taskforce: http://wiki.metux.de/public/OpenSource_QM_Taskforce Patches / Fixes for a lot dozens of packages in dozens of versions: http://patches.metux.de/ - ___ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel
Re: [Midnight Commander] #134: [PATCH] some time formatting fixes
#134: [PATCH] some time formatting fixes +--- Reporter: Enrico Weigelt weig...@metux.de | Owner: Type: defect | Status: new Priority: major | Milestone: 4.6.2 Component: mc-core| Version: 4.6.1 Resolution: |Keywords: review Blocking: | Blockedby: +--- Changes (by metux): * keywords: = review Old description: this patch goes a bit deeper into the strftime()+localtime() issue. a) introduce some new shortcut macros and use them in some places b) adds additional checks (where the macros dont fit) New description: this patch goes a bit deeper into the strftime()+localtime() issue. a) introduce some new shortcut macros and use them in some places b) adds additional checks (where the macros dont fit) -- -- Ticket URL: www.midnight-commander.org/ticket/134#comment:3 Midnight Commander www.midnight-commander.org Midnight Development Center ___ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel
[Midnight Commander] #134: [PATCH] some time formatting fixes
#134: [PATCH] some time formatting fixes ---+ Reporter: Enrico Weigelt weig...@metux.de | Owner: Type: defect | Status: new Priority: major | Milestone: Component: mc-core| Version: 4.6.1 Keywords: |Blocking: Blockedby: | ---+ this patch goes a bit deeper into the strftime()+localtime() issue. a) introduce some new shortcut macros and use them in some places b) adds additional checks (where the macros dont fit) -- Ticket URL: /ticket/134 Midnight Commander www.midnight-commander.org Midnight Development Center ___ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel
[PATCH] some time formatting fixes
Hi folks, this patch goes a bit deeper into the strftime()+localtime() issue. a) introduce some new shortcut macros and use them in some places b) adds additional checks (where the macros dont fit) cu -- -- Enrico Weigelt, metux IT service -- http://www.metux.de/ cellphone: +49 174 7066481 email: i...@metux.de skype: nekrad666 -- Embedded-Linux / Portierung / Opensource-QM / Verteilte Systeme -- # # Adds an safe(r) strftime()/localtime() handling, as replacement # for the mc-4.6.1-invalid-mtime.diff patch # # Source: metux # Reference:4.6.1 # Submit-By:Enrico Weigelt, metux IT service weig...@metux.de # Submit-Date: 2008-12-30 # Obsoletes:mc-4.6.1-invalid-mtime.diff # diff -ruN mc-4.6.1.orig/edit/edit.c mc-4.6.1/edit/edit.c --- mc-4.6.1.orig/edit/edit.c 2008-12-30 01:52:56.0 +0100 +++ mc-4.6.1/edit/edit.c2008-12-30 01:53:41.0 +0100 @@ -29,6 +29,7 @@ #include ../src/cmd.h/* view_other_cmd() */ #include ../src/user.h /* user_menu_cmd() */ #include ../src/wtools.h /* query_dialog() */ +#include ../src/timefmt.h/* time formatting */ /* what editor are we going to emulate? one of EDIT_KEY_EMULATION_NORMAL @@ -2512,20 +2513,13 @@ break; case CK_Date:{ - time_t t; -#ifdef HAVE_STRFTIME char s[1024]; /* fool gcc to prevent a Y2K warning */ char time_format[] = _c; time_format[0] = '%'; -#endif - time (t); -#ifdef HAVE_STRFTIME - strftime (s, sizeof (s), time_format, localtime (t)); + + FMT_LOCALTIME_CURRENT(s, sizeof(s), time_format); edit_print_string (edit, s); -#else - edit_print_string (edit, ctime (t)); -#endif edit-force |= REDRAW_PAGE; break; } diff -ruN mc-4.6.1.orig/src/Makefile.am mc-4.6.1/src/Makefile.am --- mc-4.6.1.orig/src/Makefile.am 2008-12-30 01:52:56.0 +0100 +++ mc-4.6.1/src/Makefile.am2008-12-30 01:53:41.0 +0100 @@ -57,9 +57,9 @@ popt.c poptconfig.c popt.h popthelp.c poptint.h poptparse.c \ profile.c profile.h regex.c rxvt.c screen.c setup.c setup.h \ slint.c subshell.c subshell.h textconf.c textconf.h \ - tree.c tree.h treestore.c treestore.h tty.h user.c user.h \ - util.c util.h utilunix.c view.c view.h vfsdummy.h widget.c \ - widget.h win.c win.h wtools.c wtools.h \ + tree.c tree.h treestore.c treestore.h timefmt.h tty.h user.c\ + user.h util.c util.h utilunix.c view.c view.h vfsdummy.h\ + widget.c widget.h win.c win.h wtools.c wtools.h \ x11conn.h x11conn.c if CHARSET diff -ruN mc-4.6.1.orig/src/timefmt.h mc-4.6.1/src/timefmt.h --- mc-4.6.1.orig/src/timefmt.h 1970-01-01 01:00:00.0 +0100 +++ mc-4.6.1/src/timefmt.h 2008-12-30 01:53:41.0 +0100 @@ -0,0 +1,43 @@ +#ifndef __UTIL_TIMEFMT_H +#define __UTIL_TIMEFMT_H + +#include sys/types.h + +#define INVALID_TIME_TEXT (invalid) + +#ifdef HAVE_STRFTIME + +/* safe localtime formatting - strftime()-using version */ +#define FMT_LOCALTIME(buffer, bufsize, fmt, when) \ +{ \ + struct tm *whentm; \ + whentm = localtime(when); \ + if (whentm == NULL) \ + { \ + strncpy(buffer, INVALID_TIME_TEXT, bufsize);\ + buffer[bufsize-1] = 0; \ + } \ + else\ + { \ + strftime(buffer, bufsize, fmt, whentm); \ + } \ +} \ + +#else + +/* fallback when strftime/localtime not available */ +#define FMT_LOCALTIME(buffer,bufsize,fmt,when) \ +{ \ + ctime_r(when,buffer); \ +} \ + +#endif + +#define FMT_LOCALTIME_CURRENT(buffer, bufsize, fmt)\ +{ \ + time_t __current_time; \ + time(__current_time);