automatically generated from GPLed version
[bpt/emacs.git] / src / strftime.c
index 51dbc38..90b2147 100644 (file)
 # include <config.h>
 #endif
 
+/* Some hosts need this in order to declare localtime_r properly.  */
+#ifndef _REENTRANT
+# define _REENTRANT 1
+#endif
+
 #ifdef _LIBC
 # define HAVE_LIMITS_H 1
 # define HAVE_MBLEN 1
@@ -91,6 +96,14 @@ extern char *tzname[];
 # endif
 #endif
 
+#ifdef _LIBC
+# define MEMPCPY(d, s, n) __mempcpy (d, s, n)
+#else
+# ifndef HAVE_MEMPCPY
+#  define MEMPCPY(d, s, n) ((void *) ((char *) memcpy (d, s, n) + (n)))
+# endif
+#endif
+
 #ifndef __P
 # if defined (__GNUC__) || (defined (__STDC__) && __STDC__)
 #  define __P(args) args
@@ -176,7 +189,7 @@ localtime_r (t, tp)
   return tp;
 }
 # endif /* ! HAVE_LOCALTIME_R */
-#endif /* ! defined (_LIBC) */
+#endif /* ! defined _LIBC */
 
 
 #if !defined memset && !defined HAVE_MEMSET && !defined _LIBC
@@ -196,8 +209,7 @@ static const char zeroes[16] = /* "0000000000000000" */
     do                                                                       \
       {                                                                              \
        int _this = _len > 16 ? 16 : _len;                                    \
-       memcpy ((P), spaces, _this);                                          \
-       (P) += _this;                                                         \
+       (P) = MEMPCPY ((P), spaces, _this);                                   \
        _len -= _this;                                                        \
       }                                                                              \
     while (_len > 0);                                                        \
@@ -210,8 +222,7 @@ static const char zeroes[16] = /* "0000000000000000" */
     do                                                                       \
       {                                                                              \
        int _this = _len > 16 ? 16 : _len;                                    \
-       memcpy ((P), zeroes, _this);                                          \
-       (P) += _this;                                                         \
+       (P) = MEMPCPY ((P), zeroes, _this);                                   \
        _len -= _this;                                                        \
       }                                                                              \
     while (_len > 0);                                                        \
@@ -879,6 +890,11 @@ my_strftime (s, maxsize, format, tp)
          cpy (buf + sizeof (buf) - bufp, bufp);
          break;
 
+       case 'F':
+         if (modifier != 0)
+           goto bad_format;
+         subfmt = "%Y-%m-%d";
+         goto subformat;
 
        case 'H':
          if (modifier == 'E')
@@ -1025,6 +1041,7 @@ my_strftime (s, maxsize, format, tp)
          add (1, *p = '\t');
          break;
 
+       case 'f':
        case 'u':               /* POSIX.2 extension.  */
          DO_NUMBER (1, (tp->tm_wday - 1 + 7) % 7 + 1);