emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] trunk r113223: Fix minor problems found by static checking


From: Paul Eggert
Subject: [Emacs-diffs] trunk r113223: Fix minor problems found by static checking.
Date: Sat, 29 Jun 2013 15:52:26 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 113223
revision-id: address@hidden
parent: address@hidden
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Sat 2013-06-29 08:52:20 -0700
message:
  Fix minor problems found by static checking.
  
  * coding.c (encode_inhibit_flag, inhibit_flag): New functions.
  Redo the latter's body to sidestep GCC parenthesization warnings.
  (setup_coding_system, detect_coding, detect_coding_system): Use them.
  * coding.c (detect_coding, detect_coding_system):
  * coding.h (struct undecided_spec):
  Use bool for boolean.
  * image.c (QCmax_width, QCmax_height): Now static.
  * xdisp.c (Fmove_point_visually): Remove unused local.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/coding.c                   coding.c-20091113204419-o5vbwnq5f7feedwu-1077
  src/coding.h                   coding.h-20091113204419-o5vbwnq5f7feedwu-1078
  src/image.c                    image.c-20091113204419-o5vbwnq5f7feedwu-2969
  src/xdisp.c                    xdisp.c-20091113204419-o5vbwnq5f7feedwu-240
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-06-29 13:36:19 +0000
+++ b/src/ChangeLog     2013-06-29 15:52:20 +0000
@@ -1,3 +1,15 @@
+2013-06-29  Paul Eggert  <address@hidden>
+
+       Fix minor problems found by static checking.
+       * coding.c (encode_inhibit_flag, inhibit_flag): New functions.
+       Redo the latter's body to sidestep GCC parenthesization warnings.
+       (setup_coding_system, detect_coding, detect_coding_system): Use them.
+       * coding.c (detect_coding, detect_coding_system):
+       * coding.h (struct undecided_spec):
+       Use bool for boolean.
+       * image.c (QCmax_width, QCmax_height): Now static.
+       * xdisp.c (Fmove_point_visually): Remove unused local.
+
 2013-06-29  Eli Zaretskii  <address@hidden>
 
        * xdisp.c (Fmove_point_visually): New function.

=== modified file 'src/coding.c'
--- a/src/coding.c      2013-06-28 15:00:17 +0000
+++ b/src/coding.c      2013-06-29 15:52:20 +0000
@@ -649,6 +649,23 @@
 #define max(a, b) ((a) > (b) ? (a) : (b))
 #endif
 
+/* Encode a flag that can be nil, something else, or t as -1, 0, 1.  */
+
+static int
+encode_inhibit_flag (Lisp_Object flag)
+{
+  return NILP (flag) ? -1 : EQ (flag, Qt);
+}
+
+/* True if the value of ENCODED_FLAG says a flag should be treated as set.
+   1 means yes, -1 means no, 0 means ask the user variable VAR.  */
+
+static bool
+inhibit_flag (int encoded_flag, bool var)
+{
+  return 0 < encoded_flag + var;
+}
+
 #define CODING_GET_INFO(coding, attrs, charset_list)   \
   do {                                                 \
     (attrs) = CODING_ID_ATTRS ((coding)->id);          \
@@ -5706,17 +5723,11 @@
       coding->encoder = encode_coding_raw_text;
       coding->common_flags |= CODING_REQUIRE_DETECTION_MASK;
       coding->spec.undecided.inhibit_nbd
-       = (NILP (AREF (attrs, 
coding_attr_undecided_inhibit_null_byte_detection))
-          ? -1
-          : EQ (AREF (attrs, 
coding_attr_undecided_inhibit_null_byte_detection), Qt)
-          ? 1
-          : 0);
+       = (encode_inhibit_flag
+          (AREF (attrs, coding_attr_undecided_inhibit_null_byte_detection)));
       coding->spec.undecided.inhibit_ied
-       = (NILP (AREF (attrs, 
coding_attr_undecided_inhibit_iso_escape_detection))
-          ? -1
-          : EQ (AREF (attrs, 
coding_attr_undecided_inhibit_iso_escape_detection), Qt)
-          ? 1
-          : 0);
+       = (encode_inhibit_flag
+          (AREF (attrs, coding_attr_undecided_inhibit_iso_escape_detection)));
       coding->spec.undecided.prefer_utf_8
        = ! NILP (AREF (attrs, coding_attr_undecided_prefer_utf_8));
     }
@@ -6476,16 +6487,11 @@
       int c, i;
       struct coding_detection_info detect_info;
       bool null_byte_found = 0, eight_bit_found = 0;
-      int inhibit_nbd          /* null byte detection */
-       = (coding->spec.undecided.inhibit_nbd > 0
-          | (coding->spec.undecided.inhibit_nbd == 0
-             & inhibit_null_byte_detection));
-      int inhibit_ied          /* iso escape detection */
-       = (coding->spec.undecided.inhibit_ied > 0
-          | (coding->spec.undecided.inhibit_ied == 0
-             & inhibit_iso_escape_detection));
-      int prefer_utf_8
-       = coding->spec.undecided.prefer_utf_8;
+      bool inhibit_nbd = inhibit_flag (coding->spec.undecided.inhibit_nbd,
+                                      inhibit_null_byte_detection);
+      bool inhibit_ied = inhibit_flag (coding->spec.undecided.inhibit_ied,
+                                      inhibit_iso_escape_detection);
+      bool prefer_utf_8 = coding->spec.undecided.prefer_utf_8;
 
       coding->head_ascii = 0;
       detect_info.checked = detect_info.found = detect_info.rejected = 0;
@@ -8544,17 +8550,11 @@
       enum coding_category category IF_LINT (= 0);
       struct coding_system *this IF_LINT (= NULL);
       int c, i;
-      int inhibit_nbd          /* null byte detection */
-       = (coding.spec.undecided.inhibit_nbd > 0
-          | (coding.spec.undecided.inhibit_nbd == 0
-             & inhibit_null_byte_detection));
-      int inhibit_ied          /* iso escape detection */
-       = (coding.spec.undecided.inhibit_ied > 0
-          | (coding.spec.undecided.inhibit_ied == 0
-             & inhibit_iso_escape_detection));
-      int prefer_utf_8
-       = coding.spec.undecided.prefer_utf_8;
-
+      bool inhibit_nbd = inhibit_flag (coding.spec.undecided.inhibit_nbd,
+                                      inhibit_null_byte_detection);
+      bool inhibit_ied = inhibit_flag (coding.spec.undecided.inhibit_ied,
+                                      inhibit_iso_escape_detection);
+      bool prefer_utf_8 = coding.spec.undecided.prefer_utf_8;
 
       /* Skip all ASCII bytes except for a few ISO2022 controls.  */
       for (; src < src_end; src++)

=== modified file 'src/coding.h'
--- a/src/coding.h      2013-06-28 14:59:33 +0000
+++ b/src/coding.h      2013-06-29 15:52:20 +0000
@@ -382,9 +382,15 @@
 
 struct undecided_spec
 {
-  int inhibit_nbd;             /* nbd: null byte detection */
-  int inhibit_ied;             /* ied: iso escape detection */
-  int prefer_utf_8;
+  /* Inhibit null byte detection.  1 means always inhibit,
+     -1 means do not inhibit, 0 means rely on user variable.  */
+  int inhibit_nbd;
+
+  /* Inhibit ISO escape detection.  -1, 0, 1 as above.  */
+  int inhibit_ied;
+
+  /* Prefer UTF-8 when the input could be other encodings.  */
+  bool prefer_utf_8;
 };
 
 enum utf_bom_type

=== modified file 'src/image.c'
--- a/src/image.c       2013-06-28 23:36:14 +0000
+++ b/src/image.c       2013-06-29 15:52:20 +0000
@@ -130,7 +130,7 @@
 static unsigned long *colors_in_color_table (int *n);
 #endif
 
-Lisp_Object QCmax_width, QCmax_height;
+static Lisp_Object QCmax_width, QCmax_height;
 
 /* Code to deal with bitmaps.  Bitmaps are referenced by their bitmap
    id, which is just an int that this section returns.  Bitmaps are

=== modified file 'src/xdisp.c'
--- a/src/xdisp.c       2013-06-29 13:36:19 +0000
+++ b/src/xdisp.c       2013-06-29 15:52:20 +0000
@@ -20252,7 +20252,6 @@
       struct it it;
       int pt_x, target_x, pixel_width, pt_vpos;
       bool at_eol_p;
-      bool disp_string_at_start_p = 0;
       bool overshoot_expected = false;
       bool target_is_eol_p = false;
 


reply via email to

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