]> granicus.if.org Git - onig/commitdiff
define xstrncy() for strncpy_s()
authorkosako <kosako@sofnec.co.jp>
Mon, 18 Apr 2016 05:21:08 +0000 (14:21 +0900)
committerkosako <kosako@sofnec.co.jp>
Mon, 18 Apr 2016 05:21:08 +0000 (14:21 +0900)
src/regposerr.c

index c6db2e20efc35ff79b867ec2ec8dfcf3eaed0aa1..fc71eee40e1cb6419e5ef471bbd66478f345bc7e 100644 (file)
 
 #if defined(_WIN32) && !defined(__GNUC__)
 #define xsnprintf   sprintf_s
+#define xstrncpy(dest,src,size)   strncpy_s(dest,size,src,_TRUNCATE)
 #else
 #define xsnprintf   snprintf
+#define xstrncpy    strncpy
 #endif
 
 static char* ESTRING[] = {
@@ -96,7 +98,7 @@ regerror(int posix_ecode, const regex_t* reg ARG_UNUSED, char* buf,
   len = strlen(s) + 1; /* use strlen() because s is ascii encoding. */
 
   if (buf != NULL && size > 0) {
-    strncpy(buf, s, size - 1);
+    xstrncpy(buf, s, size - 1);
     buf[size - 1] = '\0';
   }
   return len;