]> granicus.if.org Git - shadow/commitdiff
* libmisc/yesno.c: yes_or_no returns a bool instead of int.
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sun, 25 May 2008 23:01:14 +0000 (23:01 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sun, 25 May 2008 23:01:14 +0000 (23:01 +0000)
* libmisc/yesno.c: Avoid implicit conversion of pointers to booleans.
* libmisc/yesno.c: The return value of fflush is not checked on purpose.

ChangeLog
libmisc/yesno.c

index 975bba57b0588d35c27352320eb1a9d550925efe..58d7ef10bfd4fc1d1d5fdde836b7259024be55c7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-05-26  Nicolas François  <nicolas.francois@centraliens.net>
+
+       * libmisc/yesno.c: yes_or_no returns a bool instead of int.
+       * libmisc/yesno.c: Avoid implicit conversion of pointers to
+       booleans.
+       * libmisc/yesno.c: The return value of fflush is not checked
+       on purpose.
+
 2008-05-26  Nicolas François  <nicolas.francois@centraliens.net>
 
        * libmisc/age.c: Avoid implicit conversion of integers to
index 6cd085ab91305dbfe9fea507362e62795c5ec409..d65879424daa517dc6736611ea0610456ea2b181 100644 (file)
 /*
  * yes_or_no - get answer to question from the user
  *
- *     It returns 0 if no.
+ *     It returns false if no.
  *
- *     If the read_only flag is set, it will print No, and will return 0.
+ *     If the read_only flag is set, it will print No, and will return
+ *     false.
  */
-int yes_or_no (int read_only)
+bool yes_or_no (bool read_only)
 {
        char buf[80];
 
@@ -57,20 +58,22 @@ int yes_or_no (int read_only)
         */
        if (read_only) {
                puts (_("No"));
-               return 0;
+               return false;
        }
 
        /*
         * Typically, there's a prompt on stdout, sometimes unflushed.
         */
-       fflush (stdout);
+       (void) fflush (stdout);
 
        /*
         * Get a line and see what the first character is.
         */
        /* TODO: use gettext */
-       if (fgets (buf, sizeof buf, stdin))
+       if (fgets (buf, sizeof buf, stdin) == buf) {
                return buf[0] == 'y' || buf[0] == 'Y';
+       }
 
-       return 0;
+       return false;
 }
+