Browse Source

rpmatch: simple inline version

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>
Mike Frysinger 12 years ago
parent
commit
ecc6a1d158
1 changed files with 7 additions and 2 deletions
  1. 7 2
      include/stdlib.h

+ 7 - 2
include/stdlib.h

@@ -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