emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r110508: lread.c, macros.c, marker.c,


From: Paul Eggert
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r110508: lread.c, macros.c, marker.c, menu.c, minibuf.c: Use bool for booleans.
Date: Thu, 11 Oct 2012 09:23:37 -0700
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 110508
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Thu 2012-10-11 09:23:37 -0700
message:
  lread.c, macros.c, marker.c, menu.c, minibuf.c: Use bool for booleans.
  
  * lread.c (load_each_byte, new_backquote_flag, readchar)
  (read_filtered_event, lisp_file_lexically_bound_p)
  (safe_to_load_version, Fload, complete_filename_p, openp)
  (build_load_history, readevalloop, read_escape, read1)
  (string_to_number, read_vector, read_list):
  * macros.c (Fstart_kbd_macro):
  * marker.c (CONSIDER):
  * menu.c (parse_single_submenu, digest_single_submenu)
  (find_and_return_menu_selection, Fx_popup_menu):
  * minibuf.c (read_minibuf_noninteractive, read_minibuf)
  (Ftry_completion):
  * nsmenu.m (ns_update_menubar, runMenuAt:forFrame:keymaps:):
  (ns_menu_show):
  * xmenu.c (set_frame_menubar, create_and_show_popup_menu)
  (xmenu_show, xdialog_show):
  Use bool for booleans.
  * lread.c (safe_to_load_version): Rename from safe_to_load_p,
  as it's not a predicate.  All uses changed.  Omit unnecessary
  buffer termination.
modified:
  src/ChangeLog
  src/lisp.h
  src/lread.c
  src/macros.c
  src/marker.c
  src/menu.c
  src/menu.h
  src/minibuf.c
  src/nsmenu.m
  src/nsterm.h
  src/xmenu.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-10-11 13:23:12 +0000
+++ b/src/ChangeLog     2012-10-11 16:23:37 +0000
@@ -1,3 +1,26 @@
+2012-10-11  Paul Eggert  <address@hidden>
+
+       lread.c, macros.c, marker.c, menu.c, minibuf.c: Use bool for booleans.
+       * lread.c (load_each_byte, new_backquote_flag, readchar)
+       (read_filtered_event, lisp_file_lexically_bound_p)
+       (safe_to_load_version, Fload, complete_filename_p, openp)
+       (build_load_history, readevalloop, read_escape, read1)
+       (string_to_number, read_vector, read_list):
+       * macros.c (Fstart_kbd_macro):
+       * marker.c (CONSIDER):
+       * menu.c (parse_single_submenu, digest_single_submenu)
+       (find_and_return_menu_selection, Fx_popup_menu):
+       * minibuf.c (read_minibuf_noninteractive, read_minibuf)
+       (Ftry_completion):
+       * nsmenu.m (ns_update_menubar, runMenuAt:forFrame:keymaps:):
+       (ns_menu_show):
+       * xmenu.c (set_frame_menubar, create_and_show_popup_menu)
+       (xmenu_show, xdialog_show):
+       Use bool for booleans.
+       * lread.c (safe_to_load_version): Rename from safe_to_load_p,
+       as it's not a predicate.  All uses changed.  Omit unnecessary
+       buffer termination.
+
 2012-10-11  Dmitry Antipov  <address@hidden>
 
        * editfns.c (save_excursion_save): Use nil if mark points to nowhere.

=== modified file 'src/lisp.h'
--- a/src/lisp.h        2012-10-10 20:09:47 +0000
+++ b/src/lisp.h        2012-10-11 16:23:37 +0000
@@ -3027,7 +3027,7 @@
   } while (0)
 extern int openp (Lisp_Object, Lisp_Object, Lisp_Object,
                   Lisp_Object *, Lisp_Object);
-Lisp_Object string_to_number (char const *, int, int);
+extern Lisp_Object string_to_number (char const *, int, bool);
 extern void map_obarray (Lisp_Object, void (*) (Lisp_Object, Lisp_Object),
                          Lisp_Object);
 extern void dir_warning (const char *, Lisp_Object);

=== modified file 'src/lread.c'
--- a/src/lread.c       2012-10-05 05:57:24 +0000
+++ b/src/lread.c       2012-10-11 16:23:37 +0000
@@ -95,10 +95,10 @@
    It must be set to nil before all top-level calls to read0.  */
 static Lisp_Object read_objects;
 
-/* Nonzero means READCHAR should read bytes one by one (not character)
+/* True means READCHAR should read bytes one by one (not character)
    when READCHARFUN is Qget_file_char or Qget_emacs_mule_file_char.
-   This is set to 1 by read1 temporarily while handling address@hidden  */
-static int load_each_byte;
+   This is set by read1 temporarily while handling address@hidden  */
+static bool load_each_byte;
 
 /* List of descriptors now open for Fload.  */
 static Lisp_Object load_descriptor_list;
@@ -135,11 +135,11 @@
 /* This is the file position that string came from.  */
 static file_offset prev_saved_doc_string_position;
 
-/* Nonzero means inside a new-style backquote
+/* True means inside a new-style backquote
    with no surrounding parentheses.
-   Fread initializes this to zero, so we need not specbind it
+   Fread initializes this to false, so we need not specbind it
    or worry about what happens to it when there is an error.  */
-static int new_backquote_flag;
+static bool new_backquote_flag;
 static Lisp_Object Qold_style_backquotes;
 
 /* A list of file names for files being loaded in Fload.  Used to
@@ -150,7 +150,7 @@
 static int read_emacs_mule_char (int, int (*) (int, Lisp_Object),
                                  Lisp_Object);
 
-static void readevalloop (Lisp_Object, FILE*, Lisp_Object, int,
+static void readevalloop (Lisp_Object, FILE *, Lisp_Object, bool,
                           Lisp_Object, Lisp_Object,
                           Lisp_Object, Lisp_Object);
 static Lisp_Object load_unwind (Lisp_Object);
@@ -192,7 +192,7 @@
   int (*readbyte) (int, Lisp_Object);
   unsigned char buf[MAX_MULTIBYTE_LENGTH];
   int i, len;
-  int emacs_mule_encoding = 0;
+  bool emacs_mule_encoding = 0;
 
   if (multibyte)
     *multibyte = 0;
@@ -546,10 +546,10 @@
 static Lisp_Object read_internal_start (Lisp_Object, Lisp_Object,
                                         Lisp_Object);
 static Lisp_Object read0 (Lisp_Object);
-static Lisp_Object read1 (Lisp_Object, int *, int);
+static Lisp_Object read1 (Lisp_Object, int *, bool);
 
-static Lisp_Object read_list (int, Lisp_Object);
-static Lisp_Object read_vector (Lisp_Object, int);
+static Lisp_Object read_list (bool, Lisp_Object);
+static Lisp_Object read_vector (Lisp_Object, bool);
 
 static Lisp_Object substitute_object_recurse (Lisp_Object, Lisp_Object,
                                               Lisp_Object);
@@ -562,28 +562,28 @@
 
 /* Read input events until we get one that's acceptable for our purposes.
 
-   If NO_SWITCH_FRAME is non-zero, switch-frame events are stashed
+   If NO_SWITCH_FRAME, switch-frame events are stashed
    until we get a character we like, and then stuffed into
    unread_switch_frame.
 
-   If ASCII_REQUIRED is non-zero, we check function key events to see
+   If ASCII_REQUIRED, check function key events to see
    if the unmodified version of the symbol has a Qascii_character
    property, and use that character, if present.
 
-   If ERROR_NONASCII is non-zero, we signal an error if the input we
-   get isn't an ASCII character with modifiers.  If it's zero but
-   ASCII_REQUIRED is non-zero, we just re-read until we get an ASCII
+   If ERROR_NONASCII, signal an error if the input we
+   get isn't an ASCII character with modifiers.  If it's false but
+   ASCII_REQUIRED is true, just re-read until we get an ASCII
    character.
 
-   If INPUT_METHOD is nonzero, we invoke the current input method
+   If INPUT_METHOD, invoke the current input method
    if the character warrants that.
 
-   If SECONDS is a number, we wait that many seconds for input, and
+   If SECONDS is a number, wait that many seconds for input, and
    return Qnil if no input arrives within that time.  */
 
 static Lisp_Object
-read_filtered_event (int no_switch_frame, int ascii_required,
-                    int error_nonascii, int input_method, Lisp_Object seconds)
+read_filtered_event (bool no_switch_frame, bool ascii_required,
+                    bool error_nonascii, bool input_method, Lisp_Object 
seconds)
 {
   Lisp_Object val, delayed_switch_frame;
   EMACS_TIME end_time;
@@ -767,7 +767,7 @@
    positioned following the first line, if it is a comment or #! line,
    otherwise nothing is read.  */
 
-static int
+static bool
 lisp_file_lexically_bound_p (Lisp_Object readcharfun)
 {
   int ch = READCHAR;
@@ -797,11 +797,11 @@
   else
     /* Look for an appropriate file-variable in the first line.  */
     {
-      int rv = 0;
+      bool rv = 0;
       enum {
        NOMINAL, AFTER_FIRST_DASH, AFTER_ASTERIX,
       } beg_end_state = NOMINAL;
-      int in_file_vars = 0;
+      bool in_file_vars = 0;
 
 #define UPDATE_BEG_END_STATE(ch)                               \
   if (beg_end_state == NOMINAL)                                        \
@@ -897,20 +897,17 @@
    because of an incompatible change in the byte compiler.  */
 
 static int
-safe_to_load_p (int fd)
+safe_to_load_version (int fd)
 {
   char buf[512];
   int nbytes, i;
-  int safe_p = 1;
   int version = 1;
 
   /* Read the first few bytes from the file, and look for a line
      specifying the byte compiler version used.  */
-  nbytes = emacs_read (fd, buf, sizeof buf - 1);
+  nbytes = emacs_read (fd, buf, sizeof buf);
   if (nbytes > 0)
     {
-      buf[nbytes] = '\0';
-
       /* Skip to the next newline, skipping over the initial `ELC'
         with NUL bytes following it, but note the version.  */
       for (i = 0; i < nbytes && buf[i] != '\n'; ++i)
@@ -920,13 +917,11 @@
       if (i >= nbytes
          || fast_c_string_match_ignore_case (Vbytecomp_version_regexp,
                                              buf + i, nbytes - i) < 0)
-       safe_p = 0;
+       version = 0;
     }
-  if (safe_p)
-    safe_p = version;
 
   lseek (fd, 0, SEEK_SET);
-  return safe_p;
+  return version;
 }
 
 
@@ -1030,12 +1025,12 @@
   ptrdiff_t count = SPECPDL_INDEX ();
   struct gcpro gcpro1, gcpro2, gcpro3;
   Lisp_Object found, efound, hist_file_name;
-  /* 1 means we printed the ".el is newer" message.  */
-  int newer = 0;
-  /* 1 means we are loading a compiled file.  */
-  int compiled = 0;
+  /* True means we printed the ".el is newer" message.  */
+  bool newer = 0;
+  /* True means we are loading a compiled file.  */
+  bool compiled = 0;
   Lisp_Object handler;
-  int safe_p = 1;
+  bool safe_p = 1;
   const char *fmode = "r";
   Lisp_Object tmp[2];
   int version;
@@ -1190,7 +1185,7 @@
   record_unwind_protect (load_warn_old_style_backquotes, file);
 
   if (!memcmp (SDATA (found) + SBYTES (found) - 4, ".elc", 4)
-      || (fd >= 0 && (version = safe_to_load_p (fd)) > 0))
+      || (fd >= 0 && (version = safe_to_load_version (fd)) > 0))
     /* Load .elc files directly, but not when they are
        remote and have no handler!  */
     {
@@ -1202,7 +1197,7 @@
          GCPRO3 (file, found, hist_file_name);
 
          if (version < 0
-             && ! (version = safe_to_load_p (fd)))
+             && ! (version = safe_to_load_version (fd)))
            {
              safe_p = 0;
              if (!load_dangerous_libraries)
@@ -1394,10 +1389,10 @@
 #endif
 }
 
-static int
+static bool
 complete_filename_p (Lisp_Object pathname)
 {
-  register const unsigned char *s = SDATA (pathname);
+  const unsigned char *s = SDATA (pathname);
   return (IS_DIRECTORY_SEP (s[0])
          || (SCHARS (pathname) > 2
              && IS_DEVICE_SEP (s[1]) && IS_DIRECTORY_SEP (s[2])));
@@ -1447,11 +1442,11 @@
 int
 openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object 
*storeptr, Lisp_Object predicate)
 {
-  register int fd;
+  int fd;
   ptrdiff_t fn_size = 100;
   char buf[100];
-  register char *fn = buf;
-  int absolute = 0;
+  char *fn = buf;
+  bool absolute = 0;
   ptrdiff_t want_length;
   Lisp_Object filename;
   struct stat st;
@@ -1503,7 +1498,7 @@
        {
          ptrdiff_t fnlen, lsuffix = SBYTES (XCAR (tail));
          Lisp_Object handler;
-         int exists;
+         bool exists;
 
          /* Concatenate path element/specified name with the suffix.
             If the directory starts with /:, remove that.  */
@@ -1588,14 +1583,16 @@
    the source has an associated file name or not.
 
    FILENAME is the file name that we are loading from.
-   ENTIRE is 1 if loading that entire file, 0 if evaluating part of it.  */
+
+   ENTIRE is true if loading that entire file, false if evaluating
+   part of it.  */
 
 static void
-build_load_history (Lisp_Object filename, int entire)
+build_load_history (Lisp_Object filename, bool entire)
 {
-  register Lisp_Object tail, prev, newelt;
-  register Lisp_Object tem, tem2;
-  register int foundit = 0;
+  Lisp_Object tail, prev, newelt;
+  Lisp_Object tem, tem2;
+  bool foundit = 0;
 
   tail = Vload_history;
   prev = Qnil;
@@ -1680,7 +1677,7 @@
 readevalloop (Lisp_Object readcharfun,
              FILE *stream,
              Lisp_Object sourcename,
-             int printflag,
+             bool printflag,
              Lisp_Object unibyte, Lisp_Object readfun,
              Lisp_Object start, Lisp_Object end)
 {
@@ -1689,12 +1686,12 @@
   ptrdiff_t count = SPECPDL_INDEX ();
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
   struct buffer *b = 0;
-  int continue_reading_p;
+  bool continue_reading_p;
   Lisp_Object lex_bound;
-  /* Nonzero if reading an entire buffer.  */
-  int whole_buffer = 0;
-  /* 1 on the first time around.  */
-  int first_sexp = 1;
+  /* True if reading an entire buffer.  */
+  bool whole_buffer = 0;
+  /* True on the first time around.  */
+  bool first_sexp = 1;
   Lisp_Object macroexpand = intern ("internal-macroexpand-for-load");
 
   if (NILP (Ffboundp (macroexpand))
@@ -2072,9 +2069,9 @@
    If the escape sequence forces unibyte, return eight-bit char.  */
 
 static int
-read_escape (Lisp_Object readcharfun, int stringp)
+read_escape (Lisp_Object readcharfun, bool stringp)
 {
-  register int c = READCHAR;
+  int c = READCHAR;
   /* \u allows up to four hex digits, \U up to eight.  Default to the
      behavior for \u, and change this value in the case that \U is seen.  */
   int unicode_hex_count = 4;
@@ -2375,10 +2372,10 @@
    in *PCH and the return value is not interesting.  Else, we store
    zero in *PCH and we read and return one lisp object.
 
-   FIRST_IN_LIST is nonzero if this is the first element of a list.  */
+   FIRST_IN_LIST is true if this is the first element of a list.  */
 
 static Lisp_Object
-read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
+read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
 {
   int c;
   bool uninterned_symbol = 0;
@@ -2803,10 +2800,11 @@
        else
          {
            Lisp_Object value;
+           bool saved_new_backquote_flag = new_backquote_flag;
 
-           new_backquote_flag++;
+           new_backquote_flag = 1;
            value = read0 (readcharfun);
-           new_backquote_flag--;
+           new_backquote_flag = saved_new_backquote_flag;
 
            return Fcons (Qbackquote, Fcons (value, Qnil));
          }
@@ -2858,7 +2856,7 @@
       {
        int modifiers;
        int next_char;
-       int ok;
+       bool ok;
 
        c = READCHAR;
        if (c < 0)
@@ -2894,14 +2892,14 @@
       {
        char *p = read_buffer;
        char *end = read_buffer + read_buffer_size;
-       register int ch;
-       /* Nonzero if we saw an escape sequence specifying
+       int ch;
+       /* True if we saw an escape sequence specifying
           a multibyte character.  */
-       int force_multibyte = 0;
-       /* Nonzero if we saw an escape sequence specifying
+       bool force_multibyte = 0;
+       /* True if we saw an escape sequence specifying
           a single-byte character.  */
-       int force_singlebyte = 0;
-       int cancel = 0;
+       bool force_singlebyte = 0;
+       bool cancel = 0;
        ptrdiff_t nchars = 0;
 
        while ((ch = READCHAR) >= 0
@@ -3033,7 +3031,7 @@
     read_symbol:
       {
        char *p = read_buffer;
-       int quoted = 0;
+       bool quoted = 0;
        EMACS_INT start_position = readchar_count - 1;
 
        {
@@ -3250,17 +3248,17 @@
 /* Convert STRING to a number, assuming base BASE.  Return a fixnum if CP has
    integer syntax and fits in a fixnum, else return the nearest float if CP has
    either floating point or integer syntax and BASE is 10, else return nil.  If
-   IGNORE_TRAILING is nonzero, consider just the longest prefix of CP that has
+   IGNORE_TRAILING, consider just the longest prefix of CP that has
    valid floating point syntax.  Signal an overflow if BASE is not 10 and the
    number has integer syntax but does not fit.  */
 
 Lisp_Object
-string_to_number (char const *string, int base, int ignore_trailing)
+string_to_number (char const *string, int base, bool ignore_trailing)
 {
   int state;
   char const *cp = string;
   int leading_digit;
-  int float_syntax = 0;
+  bool float_syntax = 0;
   double value = 0;
 
   /* Compute NaN and infinities using a variable, to cope with compilers that
@@ -3270,9 +3268,9 @@
   /* Negate the value ourselves.  This treats 0, NaNs, and infinity properly on
      IEEE floating point hosts, and works around a formerly-common bug where
      atof ("-0.0") drops the sign.  */
-  int negative = *cp == '-';
+  bool negative = *cp == '-';
 
-  int signedp = negative || *cp == '+';
+  bool signedp = negative || *cp == '+';
   cp += signedp;
 
   state = 0;
@@ -3365,7 +3363,7 @@
       uintmax_t n;
 
       /* Fast special case for single-digit integers.  This also avoids a
-        glitch when BASE is 16 and IGNORE_TRAILING is nonzero, because in that
+        glitch when BASE is 16 and IGNORE_TRAILING, because in that
         case some versions of strtoumax accept numbers like "0x1" that Emacs
         does not allow.  */
       if (digit_to_number (string[signedp + 1], base) < 0)
@@ -3401,12 +3399,12 @@
 
 
 static Lisp_Object
-read_vector (Lisp_Object readcharfun, int bytecodeflag)
+read_vector (Lisp_Object readcharfun, bool bytecodeflag)
 {
   ptrdiff_t i, size;
-  register Lisp_Object *ptr;
-  register Lisp_Object tem, item, vector;
-  register struct Lisp_Cons *otem;
+  Lisp_Object *ptr;
+  Lisp_Object tem, item, vector;
+  struct Lisp_Cons *otem;
   Lisp_Object len;
 
   tem = read_list (1, readcharfun);
@@ -3478,13 +3476,13 @@
   return vector;
 }
 
-/* FLAG = 1 means check for ] to terminate rather than ) and .  */
+/* FLAG means check for ] to terminate rather than ) and .  */
 
 static Lisp_Object
-read_list (int flag, register Lisp_Object readcharfun)
+read_list (bool flag, Lisp_Object readcharfun)
 {
   Lisp_Object val, tail;
-  register Lisp_Object elt, tem;
+  Lisp_Object elt, tem;
   struct gcpro gcpro1, gcpro2;
   /* 0 is the normal case.
      1 means this list is a doc reference; replace it with the number 0.
@@ -3492,7 +3490,7 @@
   int doc_reference = 0;
 
   /* Initialize this to 1 if we are reading a list.  */
-  int first_in_list = flag <= 0;
+  bool first_in_list = flag <= 0;
 
   val = Qnil;
   tail = Qnil;

=== modified file 'src/macros.c'
--- a/src/macros.c      2012-09-15 07:06:56 +0000
+++ b/src/macros.c      2012-10-11 16:23:37 +0000
@@ -84,7 +84,7 @@
     {
       ptrdiff_t i;
       EMACS_INT len;
-      int cvt;
+      bool cvt;
 
       /* Check the type of last-kbd-macro in case Lisp code changed it.  */
       CHECK_VECTOR_OR_STRING (KVAR (current_kboard, Vlast_kbd_macro));

=== modified file 'src/marker.c'
--- a/src/marker.c      2012-10-11 04:33:12 +0000
+++ b/src/marker.c      2012-10-11 16:23:37 +0000
@@ -91,7 +91,7 @@
 #define CONSIDER(CHARPOS, BYTEPOS)                                     \
 {                                                                      \
   ptrdiff_t this_charpos = (CHARPOS);                                  \
-  int changed = 0;                                                     \
+  bool changed = 0;                                                    \
                                                                        \
   if (this_charpos == charpos)                                         \
     {                                                                  \
@@ -190,7 +190,7 @@
 
   if (charpos - best_below < best_above - charpos)
     {
-      int record = charpos - best_below > 5000;
+      bool record = charpos - best_below > 5000;
 
       while (best_below != charpos)
        {
@@ -215,7 +215,7 @@
     }
   else
     {
-      int record = best_above - charpos > 5000;
+      bool record = best_above - charpos > 5000;
 
       while (best_above != charpos)
        {
@@ -335,7 +335,7 @@
 
   if (bytepos - best_below_byte < best_above_byte - bytepos)
     {
-      int record = bytepos - best_below_byte > 5000;
+      bool record = bytepos - best_below_byte > 5000;
 
       while (best_below_byte < bytepos)
        {
@@ -362,7 +362,7 @@
     }
   else
     {
-      int record = best_above_byte - bytepos > 5000;
+      bool record = best_above_byte - bytepos > 5000;
 
       while (best_above_byte > bytepos)
        {
@@ -479,10 +479,10 @@
 
 static Lisp_Object
 set_marker_internal (Lisp_Object marker, Lisp_Object position,
-                    Lisp_Object buffer, int restricted)
+                    Lisp_Object buffer, bool restricted)
 {
-  register struct Lisp_Marker *m;
-  register struct buffer *b = live_buffer (buffer);
+  struct Lisp_Marker *m;
+  struct buffer *b = live_buffer (buffer);
 
   CHECK_MARKER (marker);
   m = XMARKER (marker);

=== modified file 'src/menu.c'
--- a/src/menu.c        2012-10-10 20:09:47 +0000
+++ b/src/menu.c        2012-10-11 16:23:37 +0000
@@ -519,14 +519,15 @@
 /* Set up data in menu_items for a menu bar item
    whose event type is ITEM_KEY (with string ITEM_NAME)
    and whose contents come from the list of keymaps MAPS.  */
-int
-parse_single_submenu (Lisp_Object item_key, Lisp_Object item_name, Lisp_Object 
maps)
+bool
+parse_single_submenu (Lisp_Object item_key, Lisp_Object item_name,
+                     Lisp_Object maps)
 {
   Lisp_Object length;
   EMACS_INT len;
   Lisp_Object *mapvec;
   ptrdiff_t i;
-  int top_level_items = 0;
+  bool top_level_items = 0;
   USE_SAFE_ALLOCA;
 
   length = Flength (maps);
@@ -616,13 +617,13 @@
    in menu_items starting at index START, up to index END.  */
 
 widget_value *
-digest_single_submenu (int start, int end, int top_level_items)
+digest_single_submenu (int start, int end, bool top_level_items)
 {
   widget_value *wv, *prev_wv, *save_wv, *first_wv;
   int i;
   int submenu_depth = 0;
   widget_value **submenu_stack;
-  int panes_seen = 0;
+  bool panes_seen = 0;
 
   submenu_stack = alloca (menu_items_used * sizeof *submenu_stack);
   wv = xmalloc_widget_value ();
@@ -668,7 +669,7 @@
          Lisp_Object pane_name;
          const char *pane_string;
 
-         panes_seen++;
+         panes_seen = 1;
 
          pane_name = AREF (menu_items, i + MENU_ITEMS_PANE_NAME);
 
@@ -735,7 +736,7 @@
          Lisp_Object help;
 
          /* All items should be contained in panes.  */
-         if (panes_seen == 0)
+         if (! panes_seen)
            emacs_abort ();
 
          item_name = AREF (menu_items, i + MENU_ITEMS_ITEM_NAME);
@@ -957,9 +958,9 @@
 
 #ifdef HAVE_NS
 /* As above, but return the menu selection instead of storing in kb buffer.
-   If keymaps==1, return full prefixes to selection. */
+   If KEYMAPS, return full prefixes to selection. */
 Lisp_Object
-find_and_return_menu_selection (FRAME_PTR f, int keymaps, void *client_data)
+find_and_return_menu_selection (FRAME_PTR f, bool keymaps, void *client_data)
 {
   Lisp_Object prefix, entry;
   int i;
@@ -999,7 +1000,7 @@
             = AREF (menu_items, i + MENU_ITEMS_ITEM_VALUE);
           if (aref_addr (menu_items, i) == client_data)
             {
-              if (keymaps != 0)
+              if (keymaps)
                 {
                   int j;
 
@@ -1071,8 +1072,8 @@
   Lisp_Object selection = Qnil;
   FRAME_PTR f = NULL;
   Lisp_Object x, y, window;
-  int keymaps = 0;
-  int for_click = 0;
+  bool keymaps = 0;
+  bool for_click = 0;
   ptrdiff_t specpdl_count = SPECPDL_INDEX ();
   struct gcpro gcpro1;
 
@@ -1083,7 +1084,7 @@
 
 #ifdef HAVE_MENUS
   {
-    int get_current_pos_p = 0;
+    bool get_current_pos_p = 0;
     /* FIXME!!  check_w32 (); or check_x (); or check_ns (); */
 
     /* Decode the first argument: find the window and the coordinates.  */

=== modified file 'src/menu.h'
--- a/src/menu.h        2012-07-09 16:38:45 +0000
+++ b/src/menu.h        2012-10-11 16:23:37 +0000
@@ -29,7 +29,7 @@
 extern void finish_menu_items (void) ATTRIBUTE_CONST;
 extern void discard_menu_items (void);
 extern void save_menu_items (void);
-extern int parse_single_submenu (Lisp_Object, Lisp_Object, Lisp_Object);
+extern bool parse_single_submenu (Lisp_Object, Lisp_Object, Lisp_Object);
 extern void list_of_panes (Lisp_Object);
 #if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NTGUI) \
   || defined (HAVE_NS)
@@ -38,7 +38,7 @@
 extern void find_and_call_menu_selection (FRAME_PTR, int,
                                           Lisp_Object, void *);
 extern widget_value *xmalloc_widget_value (void);
-extern widget_value *digest_single_submenu (int, int, int);
+extern widget_value *digest_single_submenu (int, int, bool);
 #endif
 
 #ifdef HAVE_X_WINDOWS
@@ -47,8 +47,8 @@
 
 extern Lisp_Object w32_menu_show (FRAME_PTR, int, int, int, int,
                                  Lisp_Object, const char **);
-extern Lisp_Object ns_menu_show (FRAME_PTR, int, int, int, int,
+extern Lisp_Object ns_menu_show (FRAME_PTR, int, int, bool, bool,
                                 Lisp_Object, const char **);
-extern Lisp_Object xmenu_show (FRAME_PTR, int, int, int, int,
+extern Lisp_Object xmenu_show (FRAME_PTR, int, int, bool, bool,
                               Lisp_Object, const char **, Time);
 #endif /* MENU_H */

=== modified file 'src/minibuf.c'
--- a/src/minibuf.c     2012-10-05 07:38:05 +0000
+++ b/src/minibuf.c     2012-10-11 16:23:37 +0000
@@ -173,17 +173,6 @@
 
 static Lisp_Object read_minibuf_unwind (Lisp_Object);
 static Lisp_Object run_exit_minibuf_hook (Lisp_Object);
-static Lisp_Object read_minibuf (Lisp_Object, Lisp_Object,
-                                 Lisp_Object,
-                                 int, Lisp_Object,
-                                 Lisp_Object, Lisp_Object,
-                                 int, int);
-static Lisp_Object read_minibuf_noninteractive (Lisp_Object, Lisp_Object,
-                                                Lisp_Object, Lisp_Object,
-                                                int, Lisp_Object,
-                                                Lisp_Object, Lisp_Object,
-                                                int, int);
-static Lisp_Object string_to_object (Lisp_Object, Lisp_Object);
 
 
 /* Read a Lisp object from VAL and return it.  If VAL is an empty
@@ -233,10 +222,10 @@
 static Lisp_Object
 read_minibuf_noninteractive (Lisp_Object map, Lisp_Object initial,
                             Lisp_Object prompt, Lisp_Object backup_n,
-                            int expflag,
+                            bool expflag,
                             Lisp_Object histvar, Lisp_Object histpos,
                             Lisp_Object defalt,
-                            int allow_props, int inherit_input_method)
+                            bool allow_props, bool inherit_input_method)
 {
   ptrdiff_t size, len;
   char *line;
@@ -376,23 +365,23 @@
    beginning of INITIAL if N <= 0.
 
    Normally return the result as a string (the text that was read),
-   but if EXPFLAG is nonzero, read it and return the object read.
+   but if EXPFLAG, read it and return the object read.
    If HISTVAR is given, save the value read on that history only if it doesn't
    match the front of that history list exactly.  The value is pushed onto
    the list as the string that was read.
 
    DEFALT specifies the default value for the sake of history commands.
 
-   If ALLOW_PROPS is nonzero, we do not throw away text properties.
+   If ALLOW_PROPS, do not throw away text properties.
 
-   if INHERIT_INPUT_METHOD is nonzero, the minibuffer inherits the
+   if INHERIT_INPUT_METHOD, the minibuffer inherits the
    current input method.  */
 
 static Lisp_Object
 read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
-             int expflag,
+             bool expflag,
              Lisp_Object histvar, Lisp_Object histpos, Lisp_Object defalt,
-             int allow_props, int inherit_input_method)
+             bool allow_props, bool inherit_input_method)
 {
   Lisp_Object val;
   ptrdiff_t count = SPECPDL_INDEX ();
@@ -1447,7 +1436,7 @@
              if (bestmatchsize != SCHARS (eltstring)
                  || bestmatchsize != matchsize)
                /* Don't count the same string multiple times.  */
-               matchcount++;
+               matchcount += matchcount <= 1;
              bestmatchsize = matchsize;
              if (matchsize <= SCHARS (string)
                  /* If completion-ignore-case is non-nil, don't

=== modified file 'src/nsmenu.m'
--- a/src/nsmenu.m      2012-10-11 00:26:58 +0000
+++ b/src/nsmenu.m      2012-10-11 16:23:37 +0000
@@ -181,7 +181,8 @@
       /* Fully parse one or more of the submenus. */
       int n = 0;
       int *submenu_start, *submenu_end;
-      int *submenu_top_level_items, *submenu_n_panes;
+      bool *submenu_top_level_items;
+      int *submenu_n_panes;
       struct buffer *prev = current_buffer;
       Lisp_Object buffer;
       ptrdiff_t specpdl_count = SPECPDL_INDEX ();
@@ -740,7 +741,7 @@
 
 /* run a menu in popup mode */
 - (Lisp_Object)runMenuAt: (NSPoint)p forFrame: (struct frame *)f
-                 keymaps: (int)keymaps
+                 keymaps: (bool)keymaps
 {
   EmacsView *view = FRAME_NS_VIEW (f);
   NSEvent *e, *event;
@@ -779,7 +780,7 @@
    ========================================================================== 
*/
 
 Lisp_Object
-ns_menu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps,
+ns_menu_show (FRAME_PTR f, int x, int y, bool for_click, bool keymaps,
              Lisp_Object title, const char **error)
 {
   EmacsMenu *pmenu;
@@ -801,7 +802,7 @@
 
 #if 0
   /* FIXME: a couple of one-line differences prevent reuse */
-  wv = digest_single_submenu (0, menu_items_used, Qnil);
+  wv = digest_single_submenu (0, menu_items_used, 0);
 #else
   {
   widget_value *save_wv = 0, *prev_wv = 0;

=== modified file 'src/nsterm.h'
--- a/src/nsterm.h      2012-10-07 10:07:23 +0000
+++ b/src/nsterm.h      2012-10-11 16:23:37 +0000
@@ -161,7 +161,7 @@
 - (EmacsMenu *)addSubmenuWithTitle: (const char *)title forFrame: (struct 
frame *)f;
 - (void) clear;
 - (Lisp_Object)runMenuAt: (NSPoint)p forFrame: (struct frame *)f
-                 keymaps: (int)keymaps;
+                 keymaps: (bool)keymaps;
 @end
 
 
@@ -792,7 +792,7 @@
 extern void find_and_call_menu_selection (FRAME_PTR f,
     int menu_bar_items_used, Lisp_Object vector, void *client_data);
 extern Lisp_Object find_and_return_menu_selection (FRAME_PTR f,
-                                                   int keymaps,
+                                                   bool keymaps,
                                                    void *client_data);
 extern Lisp_Object ns_popup_dialog (Lisp_Object position, Lisp_Object contents,
                                     Lisp_Object header);

=== modified file 'src/xmenu.c'
--- a/src/xmenu.c       2012-09-23 19:36:31 +0000
+++ b/src/xmenu.c       2012-10-11 16:23:37 +0000
@@ -111,7 +111,7 @@
 static Lisp_Object Qdebug_on_next_call;
 
 #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
-static Lisp_Object xdialog_show (FRAME_PTR, int, Lisp_Object, Lisp_Object,
+static Lisp_Object xdialog_show (FRAME_PTR, bool, Lisp_Object, Lisp_Object,
                                  const char **);
 #endif
 
@@ -930,7 +930,8 @@
   widget_value *wv, *first_wv, *prev_wv = 0;
   int i;
   int *submenu_start, *submenu_end;
-  int *submenu_top_level_items, *submenu_n_panes;
+  bool *submenu_top_level_items;
+  int *submenu_n_panes;
 
   if (! FRAME_X_P (f))
     emacs_abort ();
@@ -1346,8 +1347,8 @@
 /* F is the frame the menu is for.
    X and Y are the frame-relative specified position,
    relative to the inside upper left corner of the frame F.
-   FOR_CLICK is nonzero if this menu was invoked for a mouse click.
-   KEYMAPS is 1 if this menu was specified with keymaps;
+   FOR_CLICK is true if this menu was invoked for a mouse click.
+   KEYMAPS is true if this menu was specified with keymaps;
     in that case, we return a list containing the chosen item's value
     and perhaps also the pane's prefix.
    TITLE is the specified menu title.
@@ -1427,14 +1428,14 @@
    menu_item_selection will be set to the selection.  */
 static void
 create_and_show_popup_menu (FRAME_PTR f, widget_value *first_wv, int x, int y,
-                           int for_click, Time timestamp)
+                           bool for_click, Time timestamp)
 {
   int i;
   GtkWidget *menu;
   GtkMenuPositionFunc pos_func = 0;  /* Pop up at pointer.  */
   struct next_popup_x_y popup_x_y;
   ptrdiff_t specpdl_count = SPECPDL_INDEX ();
-  int use_pos_func = ! for_click;
+  bool use_pos_func = ! for_click;
 
 #ifdef HAVE_GTK3
   /* Always use position function for Gtk3.  Otherwise menus may become
@@ -1539,7 +1540,7 @@
    menu_item_selection will be set to the selection.  */
 static void
 create_and_show_popup_menu (FRAME_PTR f, widget_value *first_wv,
-                           int x, int y, int for_click, Time timestamp)
+                           int x, int y, bool for_click, Time timestamp)
 {
   int i;
   Arg av[2];
@@ -1623,7 +1624,7 @@
 }
 
 Lisp_Object
-xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps,
+xmenu_show (FRAME_PTR f, int x, int y, bool for_click, bool keymaps,
            Lisp_Object title, const char **error_name, Time timestamp)
 {
   int i;
@@ -1878,7 +1879,7 @@
                = AREF (menu_items, i + MENU_ITEMS_ITEM_VALUE);
              if (menu_item_selection == aref_addr (menu_items, i))
                {
-                 if (keymaps != 0)
+                 if (keymaps)
                    {
                      int j;
 
@@ -2011,7 +2012,7 @@
 
 static Lisp_Object
 xdialog_show (FRAME_PTR f,
-              int keymaps,
+              bool keymaps,
               Lisp_Object title,
               Lisp_Object header,
               const char **error_name)
@@ -2277,7 +2278,7 @@
 
 
 Lisp_Object
-xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps,
+xmenu_show (FRAME_PTR f, int x, int y, bool for_click, bool keymaps,
            Lisp_Object title, const char **error_name, Time timestamp)
 {
   Window root;
@@ -2528,7 +2529,7 @@
                    {
                      entry
                        = AREF (menu_items, i + MENU_ITEMS_ITEM_VALUE);
-                     if (keymaps != 0)
+                     if (keymaps)
                        {
                          entry = Fcons (entry, Qnil);
                          if (!NILP (pane_prefix))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]