On Sun, Nov 12, 2006 at 11:14:49PM +0100, Uwe Stöhr wrote: > I don't like the change made in > http://www.lyx.org/trac/changeset/15545 > and > http://www.lyx.org/trac/changeset/15546 > as this destroys the date formatting. > > Using > %A, %d %B %Y" > instead of > %A, %e %B %Y" > fixes the crash reported in bug 2839 > http://bugzilla.lyx.org/show_bug.cgi?id=2839 > and keeps the date formatting. > > Opinions?
What about the attached patch? -- Enrico
Index: src/support/os_unix.C =================================================================== --- src/support/os_unix.C (revision 15890) +++ src/support/os_unix.C (working copy) @@ -110,6 +110,13 @@ shell_type shell() } +size_t strftime(char *date, size_t size, string const & fmt, + struct tm const * loc_tm) +{ + return ::strftime(date, size, fmt.c_str(), loc_tm); +} + + char path_separator() { return ':'; Index: src/support/os.h =================================================================== --- src/support/os.h (revision 15890) +++ src/support/os.h (working copy) @@ -15,6 +15,7 @@ #define OS_H #include <string> +#include <time.h> namespace lyx { @@ -38,6 +39,9 @@ std::string current_root(); /// shell_type shell(); +/// Wrapper for the compiler dependent strftime +size_t strftime(char *, size_t, std::string const &, struct tm const *); + /// Name of the python interpreter std::string const python(); Index: src/support/os_win32.C =================================================================== --- src/support/os_win32.C (revision 15890) +++ src/support/os_win32.C (working copy) @@ -302,6 +302,17 @@ shell_type shell() } +size_t strftime(char *date, size_t size, string const & fmt, + struct tm const * loc_tm) +{ +#ifdef _MSC_VER + return ::strftime(date, size, subst(fmt, "%e", "%#d").c_str(), loc_tm); +#else + return ::strftime(date, size, fmt.c_str(), loc_tm); +#endif +} + + char path_separator() { return ';'; Index: src/support/lyxtime.C =================================================================== --- src/support/lyxtime.C (revision 15890) +++ src/support/lyxtime.C (working copy) @@ -11,9 +11,11 @@ #include <config.h> #include "support/lyxtime.h" +#include "support/os.h" #include "lyxrc.h" using std::string; +using lyx::support::os::strftime; namespace lyx { @@ -27,7 +29,7 @@ string const formatted_time(time_type t, { struct tm * loc_tm = localtime(&t); char date[50]; - strftime(date, sizeof(date), fmt.c_str(), loc_tm); + strftime(date, sizeof(date), fmt, loc_tm); return string(date); } Index: src/support/os_cygwin.C =================================================================== --- src/support/os_cygwin.C (revision 15890) +++ src/support/os_cygwin.C (working copy) @@ -270,6 +270,13 @@ shell_type shell() } +size_t strftime(char *date, size_t size, string const & fmt, + struct tm const * loc_tm) +{ + return ::strftime(date, size, fmt.c_str(), loc_tm); +} + + char path_separator() { return ':'; Index: src/lyxrc.C =================================================================== --- src/lyxrc.C (revision 15890) +++ src/lyxrc.C (working copy) @@ -282,7 +282,7 @@ void LyXRC::setDefaults() { show_banner = true; windows_style_tex_paths = false; tex_allows_spaces = false; - date_insert_format = "%x"; + date_insert_format = "%A, %e %B %Y"; cursor_follows_scrollbar = false; dialogs_iconify_with_main = false; label_init_length = 3;