aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-14 03:02:58 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-14 03:02:58 +0000
commit01e010b3cf81db4b5e7e55a02bfbd3a39737b416 (patch)
treebb355100dc461d5b8a6c7ed896924083f92f9717 /string.c
parent266bf74ce3166846139249b5d740860149caedfc (diff)
downloadruby-01e010b3cf81db4b5e7e55a02bfbd3a39737b416.tar.gz
string.c: prefer rb_syserr_fail
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/string.c b/string.c
index 6f91cd3878..806436e327 100644
--- a/string.c
+++ b/string.c
@@ -8842,8 +8842,10 @@ rb_str_crypt(VALUE str, VALUE salt)
#ifdef HAVE_CRYPT_R
VALUE databuf;
struct crypt_data *data;
+# define CRYPT_END() ALLOCV_END(databuf)
#else
extern char *crypt(const char *, const char *);
+# define CRYPT_END() (void)0
#endif
VALUE result;
const char *s, *saltp;
@@ -8881,17 +8883,12 @@ rb_str_crypt(VALUE str, VALUE salt)
res = crypt(s, saltp);
#endif
if (!res) {
-#ifdef HAVE_CRYPT_R
int err = errno;
- ALLOCV_END(databuf);
- errno = err;
-#endif
- rb_sys_fail("crypt");
+ CRYPT_END();
+ rb_syserr_fail(err, "crypt");
}
result = rb_str_new_cstr(res);
-#ifdef HAVE_CRYPT_R
- ALLOCV_END(databuf);
-#endif
+ CRYPT_END();
FL_SET_RAW(result, OBJ_TAINTED_RAW(str) | OBJ_TAINTED_RAW(salt));
return result;
}