]> git.eshelyaron.com Git - emacs.git/commitdiff
* charset.c: Include <limits.h>.
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 8 Mar 2011 00:35:37 +0000 (16:35 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 8 Mar 2011 00:35:37 +0000 (16:35 -0800)
(Fsort_charsets): Redo min/max calculation to shorten the code a bit
and to avoid gcc -Wuninitialized warning.

src/ChangeLog
src/charset.c

index ec7322cfe43100ca8609b63030f573e4ea9b8ebd..39f806283f336d9b9001078d8777f724c7d304fa 100644 (file)
@@ -31,6 +31,9 @@
        * charset.h (CHECK_CHARSET_GET_CHARSET): Rename locals to avoid
        shadowing.
        * charset.c (map_charset_for_dump, Fchar_charset): Likewise.
+       Include <limits.h>.
+       (Fsort_charsets): Redo min/max calculation to shorten the code a bit
+       and to avoid gcc -Wuninitialized warning.
 
 2011-03-06  Chong Yidong  <cyd@stupidchicken.com>
 
index f2fcb5bf9d73431bf3e0fe88f88cfdeb7dc75301..0ce548d5a18baca89b401250f26221df31f468b1 100644 (file)
@@ -29,6 +29,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <stdio.h>
 #include <unistd.h>
 #include <ctype.h>
+#include <limits.h>
 #include <sys/types.h>
 #include <setjmp.h>
 #include "lisp.h"
@@ -2250,7 +2251,7 @@ See also `charset-priority-list' and `set-charset-priority'.  */)
   int n = XFASTINT (len), i, j, done;
   Lisp_Object tail, elt, attrs;
   struct charset_sort_data *sort_data;
-  int id, min_id, max_id;
+  int id, min_id = INT_MAX, max_id = INT_MIN;
   USE_SAFE_ALLOCA;
 
   if (n == 0)
@@ -2262,11 +2263,9 @@ See also `charset-priority-list' and `set-charset-priority'.  */)
       CHECK_CHARSET_GET_ATTR (elt, attrs);
       sort_data[i].charset = elt;
       sort_data[i].id = id = XINT (CHARSET_ATTR_ID (attrs));
-      if (i == 0)
-       min_id = max_id = id;
-      else if (id < min_id)
+      if (id < min_id)
        min_id = id;
-      else if (id > max_id)
+      if (id > max_id)
        max_id = id;
     }
   for (done = 0, tail = Vcharset_ordered_list, i = 0;