OSDN Git Service

rpmatch: simple inline version
authorMike Frysinger <vapier@gentoo.org>
Mon, 30 Apr 2012 04:40:49 +0000 (00:40 -0400)
committerMike Frysinger <vapier@gentoo.org>
Mon, 30 Apr 2012 04:42:27 +0000 (00:42 -0400)
Since rpmatch will match ^[Yy] and ^[Nn] regardless of locale, this
lets us create a simple inline version.  Newer procps versions use
this function.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
include/stdlib.h

index 352e58a..05a18eb 100644 (file)
@@ -828,12 +828,17 @@ __END_NAMESPACE_STD
 #endif /* __UCLIBC_HAS_WCHAR__ */
 
 
-#if 0 /*def __USE_SVID*/
+#ifdef __USE_SVID
 /* Determine whether the string value of RESPONSE matches the affirmation
    or negative response expression as specified by the LC_MESSAGES category
    in the program's current locale.  Returns 1 if affirmative, 0 if
    negative, and -1 if not matching.  */
-extern int rpmatch (__const char *__response) __THROW __nonnull ((1)) __wur;
+__THROW __nonnull ((1)) __wur
+static inline int rpmatch (__const char *__response)
+{
+       return (__response[0] == 'y' || __response[0] == 'Y') ? 1 :
+               (__response[0] == 'n' || __response[0] == 'N') ? 0 : -1;
+}
 #endif