diff options
author | Francesco Cosoleto <cosoleto@gmail.com> | 2011-01-02 22:58:13 +0100 |
---|---|---|
committer | Karel Zak <kzak@redhat.com> | 2011-01-05 16:18:08 +0100 |
commit | e66ac5d344dd038adb664e237c4c2610020f3f62 (patch) | |
tree | 8782b8fb7a51accbf7e0a8d9c56c538637abddd6 | |
parent | aead9d139dc81db70a6a6d72c2163021a3656d74 (diff) | |
download | util-linux-old-e66ac5d344dd038adb664e237c4c2610020f3f62.tar.gz |
include: add fallback for rpmatch()
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>
-rw-r--r-- | fdisk/cfdisk.c | 10 | ||||
-rw-r--r-- | fdisk/fdisk.c | 1 | ||||
-rw-r--r-- | include/rpmatch.h | 9 |
3 files changed, 13 insertions, 7 deletions
diff --git a/fdisk/cfdisk.c b/fdisk/cfdisk.c index 866d02af..95f1864d 100644 --- a/fdisk/cfdisk.c +++ b/fdisk/cfdisk.c @@ -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 diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c index e1221aaa..57e645d7 100644 --- a/fdisk/fdisk.c +++ b/fdisk/fdisk.c @@ -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 index 00000000..d62634bd --- /dev/null +++ b/include/rpmatch.h @@ -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 */ |