@@ -4464,18 +4464,19 @@ get_limit(VALUE opt)
44644464#define rb_category_warn (category , fmt ) rb_warn(fmt)
44654465#endif
44664466
4467- static void
4467+ static VALUE
44684468check_limit (VALUE str , VALUE opt )
44694469{
44704470 size_t slen , limit ;
4471- if (NIL_P (str )) return ;
4471+ if (NIL_P (str )) return str ;
44724472 StringValue (str );
44734473 slen = RSTRING_LEN (str );
44744474 limit = get_limit (opt );
44754475 if (slen > limit ) {
44764476 rb_raise (rb_eArgError ,
44774477 "string length (%" PRI_SIZE_PREFIX "u) exceeds the limit %" PRI_SIZE_PREFIX "u" , slen , limit );
44784478 }
4479+ return str ;
44794480}
44804481
44814482static VALUE
@@ -4484,8 +4485,7 @@ date_s__parse_internal(int argc, VALUE *argv, VALUE klass)
44844485 VALUE vstr , vcomp , hash , opt ;
44854486
44864487 argc = rb_scan_args (argc , argv , "11:" , & vstr , & vcomp , & opt );
4487- check_limit (vstr , opt );
4488- StringValue (vstr );
4488+ vstr = check_limit (vstr , opt );
44894489 if (!rb_enc_str_asciicompat_p (vstr ))
44904490 rb_raise (rb_eArgError ,
44914491 "string should have ASCII compatible encoding" );
@@ -4620,7 +4620,7 @@ date_s__iso8601(int argc, VALUE *argv, VALUE klass)
46204620 VALUE str , opt ;
46214621
46224622 rb_scan_args (argc , argv , "1:" , & str , & opt );
4623- check_limit (str , opt );
4623+ str = check_limit (str , opt );
46244624
46254625 return date__iso8601 (str );
46264626}
@@ -4690,7 +4690,7 @@ date_s__rfc3339(int argc, VALUE *argv, VALUE klass)
46904690 VALUE str , opt ;
46914691
46924692 rb_scan_args (argc , argv , "1:" , & str , & opt );
4693- check_limit (str , opt );
4693+ str = check_limit (str , opt );
46944694
46954695 return date__rfc3339 (str );
46964696}
@@ -4759,7 +4759,7 @@ date_s__xmlschema(int argc, VALUE *argv, VALUE klass)
47594759 VALUE str , opt ;
47604760
47614761 rb_scan_args (argc , argv , "1:" , & str , & opt );
4762- check_limit (str , opt );
4762+ str = check_limit (str , opt );
47634763
47644764 return date__xmlschema (str );
47654765}
@@ -4828,7 +4828,7 @@ date_s__rfc2822(int argc, VALUE *argv, VALUE klass)
48284828 VALUE str , opt ;
48294829
48304830 rb_scan_args (argc , argv , "1:" , & str , & opt );
4831- check_limit (str , opt );
4831+ str = check_limit (str , opt );
48324832
48334833 return date__rfc2822 (str );
48344834}
@@ -4896,7 +4896,7 @@ date_s__httpdate(int argc, VALUE *argv, VALUE klass)
48964896 VALUE str , opt ;
48974897
48984898 rb_scan_args (argc , argv , "1:" , & str , & opt );
4899- check_limit (str , opt );
4899+ str = check_limit (str , opt );
49004900
49014901 return date__httpdate (str );
49024902}
@@ -4965,7 +4965,7 @@ date_s__jisx0301(int argc, VALUE *argv, VALUE klass)
49654965 VALUE str , opt ;
49664966
49674967 rb_scan_args (argc , argv , "1:" , & str , & opt );
4968- check_limit (str , opt );
4968+ str = check_limit (str , opt );
49694969
49704970 return date__jisx0301 (str );
49714971}
0 commit comments