diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-04-19 13:32:41 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-04-19 13:32:41 +0000 |
commit | 606ac38e20db5bbde6210444539153242c52e9fd (patch) | |
tree | 33f5af3b114a84a6365c76a13090d1e3fb7849bf | |
parent | 32203423909cea1f1857fc918e150331acc595f0 (diff) |
merges r22919 from trunk into ruby_1_9_1.
--
* util.c (rv_strdup): macro to duplicate nul-terminated string.
[ruby-core:22852]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@23213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | util.c | 18 |
2 files changed, 15 insertions, 8 deletions
@@ -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:14:01 2009 Tanaka Akira <akr@fsij.org> * ext/openssl/ossl_ssl.c (ossl_ssl_def_const): use INT2NUM because @@ -3063,15 +3063,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) @@ -3085,6 +3085,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, @@ -3217,9 +3219,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 @@ -3227,7 +3229,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 |