1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* util.c (rv_strdup): macro to duplicate nul-terminated string.

[ruby-core:22852]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-03-12 23:06:51 +00:00
parent 2412162959
commit 0f71c10acb
3 changed files with 17 additions and 10 deletions

View file

@ -1,3 +1,8 @@
Fri Mar 13 08:06:48 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* util.c (rv_strdup): macro to duplicate nul-terminated string.
[ruby-core:22852]
Thu Mar 12 22:41:41 2009 Tanaka Akira <akr@fsij.org>
* ext/openssl: suppress warnings.

18
util.c
View file

@ -3055,15 +3055,15 @@ quorem(Bigint *b, Bigint *S)
static char *dtoa_result;
#endif
#ifndef MULTIPLE_THREADS
static char *
rv_alloc(int i)
{
return
#ifndef MULTIPLE_THREADS
dtoa_result =
#endif
xmalloc(i);
return dtoa_result = xmalloc(i);
}
#else
#define rv_alloc(i) xmalloc(i)
#endif
static char *
nrv_alloc(const char *s, char **rve, int n)
@ -3077,6 +3077,8 @@ nrv_alloc(const char *s, char **rve, int n)
return rv;
}
#define rv_strdup(s, rve) nrv_alloc(s, rve, strlen(s)+1)
#ifndef MULTIPLE_THREADS
/* freedtoa(s) must be used to free values s returned by dtoa
* when MULTIPLE_THREADS is #defined. It should be used in all cases,
@ -3209,9 +3211,9 @@ ruby_dtoa(double d_, int mode, int ndigits, int *decpt, int *sign, char **rve)
*decpt = 9999;
#ifdef IEEE_Arith
if (!word1(d) && !(word0(d) & 0xfffff))
return nrv_alloc("Infinity", rve, 8);
return rv_strdup("Infinity", rve);
#endif
return nrv_alloc("NaN", rve, 3);
return rv_strdup("NaN", rve);
}
#endif
#ifdef IBM
@ -3219,7 +3221,7 @@ ruby_dtoa(double d_, int mode, int ndigits, int *decpt, int *sign, char **rve)
#endif
if (!dval(d)) {
*decpt = 1;
return nrv_alloc("0", rve, 1);
return rv_strdup("0", rve);
}
#ifdef SET_INEXACT

View file

@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.2"
#define RUBY_RELEASE_DATE "2009-03-12"
#define RUBY_RELEASE_DATE "2009-03-13"
#define RUBY_PATCHLEVEL -1
#define RUBY_BRANCH_NAME "trunk"
@ -8,7 +8,7 @@
#define RUBY_VERSION_TEENY 1
#define RUBY_RELEASE_YEAR 2009
#define RUBY_RELEASE_MONTH 3
#define RUBY_RELEASE_DAY 12
#define RUBY_RELEASE_DAY 13
#ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[];