@@ -6587,7 +6587,7 @@ d_lite_hash(VALUE self)
65876587
65886588#include "date_tmx.h"
65896589static void set_tmx (VALUE , struct tmx * );
6590- static VALUE strftimev (const char * , VALUE ,
6590+ static VALUE strftimev (VALUE , const char * , VALUE ,
65916591 void (* )(VALUE , struct tmx * ));
65926592
65936593/*
@@ -6604,7 +6604,7 @@ static VALUE strftimev(const char *, VALUE,
66046604static VALUE
66056605d_lite_to_s (VALUE self )
66066606{
6607- return strftimev ("%Y-%m-%d" , self , set_tmx );
6607+ return strftimev (Qnil , "%Y-%m-%d" , self , set_tmx );
66086608}
66096609
66106610#ifndef NDEBUG
@@ -6729,7 +6729,7 @@ size_t date_strftime(char *s, size_t maxsize, const char *format,
67296729
67306730#define SMALLBUF 100
67316731static size_t
6732- date_strftime_alloc (char * * buf , const char * format ,
6732+ date_strftime_alloc (char * * buf , VALUE formatv , const char * format ,
67336733 struct tmx * tmx )
67346734{
67356735 size_t size , len , flen ;
@@ -6756,6 +6756,7 @@ date_strftime_alloc(char **buf, const char *format,
67566756 if (len > 0 ) break ;
67576757 xfree (* buf );
67586758 if (size >= 1024 * flen ) {
6759+ if (!NIL_P (formatv )) rb_sys_fail_str (formatv );
67596760 rb_sys_fail (format );
67606761 break ;
67616762 }
@@ -6868,7 +6869,7 @@ date_strftime_internal(int argc, VALUE *argv, VALUE self,
68686869
68696870 str = rb_str_new (0 , 0 );
68706871 while (p < pe ) {
6871- len = date_strftime_alloc (& buf , p , & tmx );
6872+ len = date_strftime_alloc (& buf , vfmt , p , & tmx );
68726873 rb_str_cat (str , buf , len );
68736874 p += strlen (p );
68746875 if (buf != buffer ) {
@@ -6883,7 +6884,7 @@ date_strftime_internal(int argc, VALUE *argv, VALUE self,
68836884 return str ;
68846885 }
68856886 else
6886- len = date_strftime_alloc (& buf , fmt , & tmx );
6887+ len = date_strftime_alloc (& buf , vfmt , fmt , & tmx );
68876888
68886889 str = rb_str_new (buf , len );
68896890 if (buf != buffer ) xfree (buf );
@@ -7077,7 +7078,7 @@ d_lite_strftime(int argc, VALUE *argv, VALUE self)
70777078}
70787079
70797080static VALUE
7080- strftimev (const char * fmt , VALUE self ,
7081+ strftimev (VALUE vfmt , const char * fmt , VALUE self ,
70817082 void (* func )(VALUE , struct tmx * ))
70827083{
70837084 char buffer [SMALLBUF ], * buf = buffer ;
@@ -7086,7 +7087,7 @@ strftimev(const char *fmt, VALUE self,
70867087 VALUE str ;
70877088
70887089 (* func )(self , & tmx );
7089- len = date_strftime_alloc (& buf , fmt , & tmx );
7090+ len = date_strftime_alloc (& buf , vfmt , fmt , & tmx );
70907091 str = rb_usascii_str_new (buf , len );
70917092 if (buf != buffer ) xfree (buf );
70927093 return str ;
@@ -7105,7 +7106,7 @@ strftimev(const char *fmt, VALUE self,
71057106static VALUE
71067107d_lite_asctime (VALUE self )
71077108{
7108- return strftimev ("%a %b %e %H:%M:%S %Y" , self , set_tmx );
7109+ return strftimev (Qnil , "%a %b %e %H:%M:%S %Y" , self , set_tmx );
71097110}
71107111
71117112/*
@@ -7118,7 +7119,7 @@ d_lite_asctime(VALUE self)
71187119static VALUE
71197120d_lite_iso8601 (VALUE self )
71207121{
7121- return strftimev ("%Y-%m-%d" , self , set_tmx );
7122+ return strftimev (Qnil , "%Y-%m-%d" , self , set_tmx );
71227123}
71237124
71247125/*
@@ -7130,7 +7131,7 @@ d_lite_iso8601(VALUE self)
71307131static VALUE
71317132d_lite_rfc3339 (VALUE self )
71327133{
7133- return strftimev ("%Y-%m-%dT%H:%M:%S%:z" , self , set_tmx );
7134+ return strftimev (Qnil , "%Y-%m-%dT%H:%M:%S%:z" , self , set_tmx );
71347135}
71357136
71367137/*
@@ -7143,7 +7144,7 @@ d_lite_rfc3339(VALUE self)
71437144static VALUE
71447145d_lite_rfc2822 (VALUE self )
71457146{
7146- return strftimev ("%a, %-d %b %Y %T %z" , self , set_tmx );
7147+ return strftimev (Qnil , "%a, %-d %b %Y %T %z" , self , set_tmx );
71477148}
71487149
71497150/*
@@ -7157,7 +7158,7 @@ static VALUE
71577158d_lite_httpdate (VALUE self )
71587159{
71597160 volatile VALUE dup = dup_obj_with_new_offset (self , 0 );
7160- return strftimev ("%a, %d %b %Y %T GMT" , dup , set_tmx );
7161+ return strftimev (Qnil , "%a, %d %b %Y %T GMT" , dup , set_tmx );
71617162}
71627163
71637164static VALUE
@@ -7204,7 +7205,7 @@ d_lite_jisx0301(VALUE self)
72047205 get_d1 (self );
72057206 s = jisx0301_date (m_real_local_jd (dat ),
72067207 m_real_year (dat ));
7207- return strftimev (RSTRING_PTR (s ), self , set_tmx );
7208+ return strftimev (s , RSTRING_PTR (s ), self , set_tmx );
72087209}
72097210
72107211#ifndef NDEBUG
@@ -8294,7 +8295,7 @@ datetime_s_jisx0301(int argc, VALUE *argv, VALUE klass)
82948295static VALUE
82958296dt_lite_to_s (VALUE self )
82968297{
8297- return strftimev ("%Y-%m-%dT%H:%M:%S%:z" , self , set_tmx );
8298+ return strftimev (Qnil , "%Y-%m-%dT%H:%M:%S%:z" , self , set_tmx );
82988299}
82998300
83008301/*
@@ -8500,7 +8501,7 @@ iso8601_timediv(VALUE self, VALUE n)
85008501 rb_str_append (fmt , rb_f_sprintf (3 , argv ));
85018502 }
85028503 rb_str_append (fmt , rb_usascii_str_new2 ("%:z" ));
8503- return strftimev (RSTRING_PTR (fmt ), self , set_tmx );
8504+ return strftimev (fmt , RSTRING_PTR (fmt ), self , set_tmx );
85048505}
85058506
85068507/*
@@ -8526,7 +8527,7 @@ dt_lite_iso8601(int argc, VALUE *argv, VALUE self)
85268527 if (argc < 1 )
85278528 n = INT2FIX (0 );
85288529
8529- return f_add (strftimev ("%Y-%m-%d" , self , set_tmx ),
8530+ return f_add (strftimev (Qnil , "%Y-%m-%d" , self , set_tmx ),
85308531 iso8601_timediv (self , n ));
85318532}
85328533
@@ -8574,7 +8575,7 @@ dt_lite_jisx0301(int argc, VALUE *argv, VALUE self)
85748575 get_d1 (self );
85758576 s = jisx0301_date (m_real_local_jd (dat ),
85768577 m_real_year (dat ));
8577- return rb_str_append (strftimev (RSTRING_PTR (s ), self , set_tmx ),
8578+ return rb_str_append (strftimev (s , RSTRING_PTR (s ), self , set_tmx ),
85788579 iso8601_timediv (self , n ));
85798580 }
85808581}
0 commit comments