[前][次][番号順一覧][スレッド一覧]

ruby-changes:48646

From: nobu <ko1@a...>
Date: Tue, 14 Nov 2017 12:03:02 +0900 (JST)
Subject: [ruby-changes:48646] nobu:r60761 (trunk): string.c: prefer rb_syserr_fail

nobu	2017-11-14 12:02:58 +0900 (Tue, 14 Nov 2017)

  New Revision: 60761

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60761

  Log:
    string.c: prefer rb_syserr_fail

  Modified files:
    trunk/string.c
Index: string.c
===================================================================
--- string.c	(revision 60760)
+++ string.c	(revision 60761)
@@ -8842,8 +8842,10 @@ rb_str_crypt(VALUE str, VALUE salt) https://github.com/ruby/ruby/blob/trunk/string.c#L8842
 #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) https://github.com/ruby/ruby/blob/trunk/string.c#L8883
     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;
 }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]