Mercurial > vim
diff src/hardcopy.c @ 16621:7ad3fc329e08 v8.1.1313
patch 8.1.1313: warnings for using localtime() and ctime()
commit https://github.com/vim/vim/commit/63d2555c9cefbbeeca3ec87fdd5d241e9488f9dd
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri May 10 21:28:38 2019 +0200
patch 8.1.1313: warnings for using localtime() and ctime()
Problem: Warnings for using localtime() and ctime().
Solution: Use localtime_r() if available. Avoid using ctime().
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 10 May 2019 21:30:07 +0200 |
parents | 536dd2bc5ac9 |
children | ce04ebdf26b8 |
line wrap: on
line diff
--- a/src/hardcopy.c +++ b/src/hardcopy.c @@ -2723,9 +2723,7 @@ prt_add_resource(struct prt_ps_resource_ int mch_print_begin(prt_settings_T *psettings) { - time_t now; int bbox[4]; - char *p_time; double left; double right; double top; @@ -2734,7 +2732,6 @@ mch_print_begin(prt_settings_T *psetting struct prt_ps_resource_S *res_encoding; char buffer[256]; char_u *p_encoding; - char_u *p; struct prt_ps_resource_S *res_cidfont; struct prt_ps_resource_S *res_cmap; int retval = FALSE; @@ -2761,13 +2758,8 @@ mch_print_begin(prt_settings_T *psetting prt_dsc_textline("For", buffer); prt_dsc_textline("Creator", VIM_VERSION_LONG); /* Note: to ensure Clean8bit I don't think we can use LC_TIME */ - now = time(NULL); - p_time = ctime(&now); - /* Note: ctime() adds a \n so we have to remove it :-( */ - p = vim_strchr((char_u *)p_time, '\n'); - if (p != NULL) - *p = NUL; - prt_dsc_textline("CreationDate", p_time); + + prt_dsc_textline("CreationDate", get_ctime(time(NULL), FALSE)); prt_dsc_textline("DocumentData", "Clean8Bit"); prt_dsc_textline("Orientation", "Portrait"); prt_dsc_atend("Pages");