]> err.no Git - util-linux/commitdiff
include: add fallback for rpmatch()
authorFrancesco Cosoleto <cosoleto@gmail.com>
Sun, 2 Jan 2011 21:58:13 +0000 (22:58 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 5 Jan 2011 15:18:08 +0000 (16:18 +0100)
Simple replacement code with hardcoded y/n responses to allow
compilation on systems without rpmatch() such as Cygwin.

Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
fdisk/cfdisk.c
fdisk/fdisk.c
include/rpmatch.h [new file with mode: 0644]

index 866d02af0c077b468a26f01103873d70f0c46bc3..95f1864d4fb8dc9e4aa90dd3fc09ab69e3fe4580 100644 (file)
@@ -98,6 +98,7 @@
 #endif
 
 #include "nls.h"
+#include "rpmatch.h"
 #include "blkdev.h"
 #include "strutils.h"
 #include "common.h"
@@ -1448,17 +1449,12 @@ get_kernel_geometry(void) {
 
 static int
 said_yes(char answer) {
-#ifdef HAVE_RPMATCH
        char reply[2];
-       int yn;
 
        reply[0] = answer;
        reply[1] = 0;
-       yn = rpmatch(reply);    /* 1: yes, 0: no, -1: ? */
-       if (yn >= 0)
-               return yn;
-#endif
-       return (answer == 'y' || answer == 'Y');
+
+       return (rpmatch(reply) == 1) ? 1 : 0;
 }
 
 static void
index e1221aaa5e8b10c622adb90afa3c79cc308fbcf8..57e645d76ec90664bd1c3610c3dc19fac745b05e 100644 (file)
@@ -23,6 +23,7 @@
 #include <limits.h>
 
 #include "nls.h"
+#include "rpmatch.h"
 #include "blkdev.h"
 #include "common.h"
 #include "mbsalign.h"
diff --git a/include/rpmatch.h b/include/rpmatch.h
new file mode 100644 (file)
index 0000000..d62634b
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef UTIL_LINUX_RPMATCH_H
+#define UTIL_LINUX_RPMATCH_H
+
+#ifndef HAVE_RPMATCH
+#define rpmatch(r) \
+       (*r == 'y' || *r == 'Y' ? 1 : *r == 'n' || *r == 'N' ? 0 : -1)
+#endif
+
+#endif /* UTIL_LINUX_RPMATCH_H */