Back to index

glibc  2.9
Defines | Functions | Variables
strftime_l.c File Reference
#include <ctype.h>
#include <sys/types.h>
#include <time.h>
#include "time_r.h"
#include <endian.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define DO_MULTIBYTE   (HAVE_MBLEN && ! MULTIBYTE_IS_FORMAT_SAFE)
#define memcpy(d, s, n)   bcopy ((s), (d), (n))
#define CHAR_T   char
#define UCHAR_T   unsigned char
#define L_(Str)   Str
#define NLW(Sym)   Sym
#define MEMCPY(d, s, n)   bcopy ((s), (d), (n))
#define STRLEN(s)   strlen (s)
#define MEMPCPY(d, s, n)   ((void *) ((char *) memcpy (d, s, n) + (n)))
#define PTR   char *
#define CHAR_BIT   8
#define NULL   0
#define TYPE_SIGNED(t)   ((t) -1 < 0)
#define INT_STRLEN_BOUND(t)   ((sizeof (t) * CHAR_BIT - TYPE_SIGNED (t)) * 302 / 1000 + 1 + TYPE_SIGNED (t))
#define TM_YEAR_BASE   1900
#define __isleap(year)   ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
#define __gmtime_r   gmtime_r
#define __localtime_r   localtime_r
#define memset_space(P, Len)
#define memset_zero(P, Len)
#define add(n, f)
#define cpy(n, s)
#define LOCALE_PARAM
#define LOCALE_PARAM_PROTO
#define LOCALE_ARG
#define LOCALE_PARAM_DECL
#define HELPER_LOCALE_ARG
#define TOUPPER(Ch, L)   (islower (Ch) ? toupper (Ch) : (Ch))
#define TOLOWER(Ch, L)   (isupper (Ch) ? tolower (Ch) : (Ch))
#define ISDIGIT(Ch)   ((unsigned int) (Ch) - L_('0') <= 9)
#define tm_diff   ftime_tm_diff
#define ISO_WEEK_START_WDAY   1 /* Monday */
#define ISO_WEEK1_WDAY   4 /* Thursday */
#define YDAY_MINIMUM   (-366)
#define my_strftime   strftime
#define nl_get_alt_digit   _nl_get_alt_digit
#define ut_argument
#define ut_argument_spec
#define ut_argument_spec_iso
#define ut   0
#define f_wkday   (weekday_name[tp->tm_wday])
#define f_month   (month_name[tp->tm_mon])
#define a_wkday   f_wkday
#define a_month   f_month
#define ampm   (L_("AMPM") + 2 * (tp->tm_hour > 11))
#define DO_NUMBER(d, v)
#define DO_NUMBER_SPACEPAD(d, v)

Functions

static CHAR_Tmemcpy_lowcase (CHAR_T *dest, const CHAR_T *src, size_t len LOCALE_PARAM_PROTO) __THROW
static CHAR_Tmemcpy_lowcase (dest, src, len LOCALE_PARAM) CHAR_T *dest
static CHAR_Tmemcpy_uppcase (dest, src, len LOCALE_PARAM) CHAR_T *dest
static int tm_diff (struct tm *a, const struct tm *b) const
static int iso_week_days (int, int)
static size_t __strftime_internal (CHAR_T *, size_t, const CHAR_T *, const struct tm *, bool *ut_argument_spec_iso LOCALE_PARAM_PROTO) __THROW
size_t my_strftime (s, maxsize, format, tp ut_argument LOCALE_PARAM) CHAR_T *s

Variables

static const CHAR_T spaces [16]
static const CHAR_T zeroes [16]
const CHAR_Tsrc
size_t len
static CHAR_T const weekday_name [][10]
static CHAR_T const month_name [][10]
size_t maxsize
const CHAR_Tformat
struct tmtp
bool * tzset_called

Define Documentation

#define __gmtime_r   gmtime_r

Definition at line 176 of file strftime_l.c.

#define __isleap (   year)    ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))

Definition at line 157 of file strftime_l.c.

#define __localtime_r   localtime_r

Definition at line 177 of file strftime_l.c.

#define a_month   f_month
#define a_wkday   f_wkday
#define add (   n,
  f 
)
Value:
do                                                                   \
    {                                                                \
      int _n = (n);                                                  \
      int _delta = width - _n;                                              \
      int _incr = _n + (_delta > 0 ? _delta : 0);                           \
      if ((size_t) _incr >= maxsize - i)                             \
       return 0;                                                     \
      if (p)                                                         \
       {                                                             \
         if (_delta > 0)                                             \
           {                                                         \
             if (pad == L_('0'))                                     \
              memset_zero (p, _delta);                               \
	      else							      \
		memset_space (p, _delta);                            \
           }                                                         \
         f;                                                          \
         p += _n;                                                    \
       }                                                             \
      i += _incr;                                                    \
    } while (0)

Definition at line 232 of file strftime_l.c.

#define ampm   (L_("AMPM") + 2 * (tp->tm_hour > 11))
#define CHAR_BIT   8

Definition at line 135 of file strftime_l.c.

#define CHAR_T   char

Definition at line 105 of file strftime_l.c.

#define cpy (   n,
  s 
)
Value:
add ((n),                                                            \
        if (to_lowcase)                                              \
          memcpy_lowcase (p, (s), _n LOCALE_ARG);                           \
        else if (to_uppcase)                                                \
          memcpy_uppcase (p, (s), _n LOCALE_ARG);                           \
	 else								      \
	   MEMCPY ((PTR) p, (const PTR) (s), _n))

Definition at line 255 of file strftime_l.c.

#define DO_MULTIBYTE   (HAVE_MBLEN && ! MULTIBYTE_IS_FORMAT_SAFE)

Definition at line 65 of file strftime_l.c.

#define DO_NUMBER (   d,
 
)
Value:
digits = d > width ? d : width;                               \
         number_value = v; goto do_number
#define DO_NUMBER_SPACEPAD (   d,
 
)
Value:
digits = d > width ? d : width;                               \
         number_value = v; goto do_number_spacepad
#define f_month   (month_name[tp->tm_mon])
#define f_wkday   (weekday_name[tp->tm_wday])

Definition at line 304 of file strftime_l.c.

#define INT_STRLEN_BOUND (   t)    ((sizeof (t) * CHAR_BIT - TYPE_SIGNED (t)) * 302 / 1000 + 1 + TYPE_SIGNED (t))

Definition at line 149 of file strftime_l.c.

#define ISDIGIT (   Ch)    ((unsigned int) (Ch) - L_('0') <= 9)

Definition at line 334 of file strftime_l.c.

#define ISO_WEEK1_WDAY   4 /* Thursday */

Definition at line 403 of file strftime_l.c.

#define ISO_WEEK_START_WDAY   1 /* Monday */

Definition at line 402 of file strftime_l.c.

#define L_ (   Str)    Str

Definition at line 107 of file strftime_l.c.

#define LOCALE_ARG

Definition at line 299 of file strftime_l.c.

#define LOCALE_PARAM

Definition at line 297 of file strftime_l.c.

Definition at line 300 of file strftime_l.c.

Definition at line 298 of file strftime_l.c.

#define memcpy (   d,
  s,
  n 
)    bcopy ((s), (d), (n))

Definition at line 90 of file strftime_l.c.

#define MEMCPY (   d,
  s,
  n 
)    bcopy ((s), (d), (n))

Definition at line 111 of file strftime_l.c.

#define MEMPCPY (   d,
  s,
  n 
)    ((void *) ((char *) memcpy (d, s, n) + (n)))

Definition at line 121 of file strftime_l.c.

#define memset_space (   P,
  Len 
)
Value:
do {                                                                 \
    int _len = (Len);                                                       \
                                                                     \
    do                                                               \
      {                                                                     \
       int _this = _len > 16 ? 16 : _len;                            \
       (P) = MEMPCPY ((P), spaces, _this * sizeof (CHAR_T));                \
       _len -= _this;                                                       \
      }                                                                     \
    while (_len > 0);                                                       \
  } while (0)

Definition at line 197 of file strftime_l.c.

#define memset_zero (   P,
  Len 
)
Value:
do {                                                                 \
    int _len = (Len);                                                       \
                                                                     \
    do                                                               \
      {                                                                     \
       int _this = _len > 16 ? 16 : _len;                            \
       (P) = MEMPCPY ((P), zeroes, _this * sizeof (CHAR_T));                \
       _len -= _this;                                                       \
      }                                                                     \
    while (_len > 0);                                                       \
  } while (0)

Definition at line 210 of file strftime_l.c.

#define my_strftime   strftime

Definition at line 447 of file strftime_l.c.

Definition at line 448 of file strftime_l.c.

#define NLW (   Sym)    Sym

Definition at line 108 of file strftime_l.c.

#define NULL   0

Definition at line 139 of file strftime_l.c.

#define PTR   char *

Definition at line 130 of file strftime_l.c.

#define STRLEN (   s)    strlen (s)

Definition at line 115 of file strftime_l.c.

#define tm_diff   ftime_tm_diff
#define TM_YEAR_BASE   1900

Definition at line 152 of file strftime_l.c.

#define TOLOWER (   Ch,
  L 
)    (isupper (Ch) ? tolower (Ch) : (Ch))

Definition at line 327 of file strftime_l.c.

#define TOUPPER (   Ch,
  L 
)    (islower (Ch) ? toupper (Ch) : (Ch))

Definition at line 326 of file strftime_l.c.

#define TYPE_SIGNED (   t)    ((t) -1 < 0)

Definition at line 142 of file strftime_l.c.

#define UCHAR_T   unsigned char

Definition at line 106 of file strftime_l.c.

#define ut   0

Definition at line 454 of file strftime_l.c.

#define ut_argument

Definition at line 450 of file strftime_l.c.

Definition at line 451 of file strftime_l.c.

Definition at line 452 of file strftime_l.c.

#define YDAY_MINIMUM   (-366)

Definition at line 404 of file strftime_l.c.


Function Documentation

static size_t __strftime_internal ( CHAR_T ,
size_t  ,
const CHAR_T ,
const struct tm ,
bool *ut_argument_spec_iso  LOCALE_PARAM_PROTO 
) [static]
static int iso_week_days ( int  ,
int   
) [static]

Definition at line 405 of file strftime_l.c.

{
  /* Add enough to the first operand of % to make it nonnegative.  */
  int big_enough_multiple_of_7 = (-YDAY_MINIMUM / 7 + 2) * 7;
  return (yday
         - (yday - wday + ISO_WEEK1_WDAY + big_enough_multiple_of_7) % 7
         + ISO_WEEK1_WDAY - ISO_WEEK_START_WDAY);
}
static CHAR_T* memcpy_lowcase ( CHAR_T dest,
const CHAR_T src,
size_t len  LOCALE_PARAM_PROTO 
) [static]
static CHAR_T* memcpy_lowcase ( dest  ,
src  ,
len  LOCALE_PARAM 
) [static]
static CHAR_T* memcpy_uppcase ( dest  ,
src  ,
len  LOCALE_PARAM 
) [static]
size_t my_strftime ( s  ,
maxsize  ,
format  ,
tp ut_argument  LOCALE_PARAM 
)
static int tm_diff ( struct tm a,
const struct tm b 
) const [static]

Definition at line 373 of file strftime_l.c.

{
  /* Compute intervening leap days correctly even if year is negative.
     Take care to avoid int overflow in leap day calculations,
     but it's OK to assume that A and B are close to each other.  */
  int a4 = (a->tm_year >> 2) + (TM_YEAR_BASE >> 2) - ! (a->tm_year & 3);
  int b4 = (b->tm_year >> 2) + (TM_YEAR_BASE >> 2) - ! (b->tm_year & 3);
  int a100 = a4 / 25 - (a4 % 25 < 0);
  int b100 = b4 / 25 - (b4 % 25 < 0);
  int a400 = a100 >> 2;
  int b400 = b100 >> 2;
  int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400);
  int years = a->tm_year - b->tm_year;
  int days = (365 * years + intervening_leap_days
             + (a->tm_yday - b->tm_yday));
  return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour))
              + (a->tm_min - b->tm_min))
         + (a->tm_sec - b->tm_sec));
}

Variable Documentation

Definition at line 473 of file strftime_l.c.

Definition at line 343 of file strftime_l.c.

Definition at line 472 of file strftime_l.c.

CHAR_T const month_name[][10] [static]
Initial value:
  {
    L_("January"), L_("February"), L_("March"), L_("April"), L_("May"),
    L_("June"), L_("July"), L_("August"), L_("September"), L_("October"),
    L_("November"), L_("December")
  }

Definition at line 428 of file strftime_l.c.

const CHAR_T spaces[16] [static]
Initial value:
 
{
  L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),
  L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),L_(' ')
}

Definition at line 186 of file strftime_l.c.

Definition at line 342 of file strftime_l.c.

struct tm * tp

Definition at line 474 of file strftime_l.c.

bool* tzset_called

Definition at line 500 of file strftime_l.c.

CHAR_T const weekday_name[][10] [static]
Initial value:
  {
    L_("Sunday"), L_("Monday"), L_("Tuesday"), L_("Wednesday"),
    L_("Thursday"), L_("Friday"), L_("Saturday")
  }

Definition at line 423 of file strftime_l.c.

const CHAR_T zeroes[16] [static]
Initial value:
 
{
  L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),
  L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),L_('0')
}

Definition at line 191 of file strftime_l.c.