aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2013-06-29 08:52:20 -0700
committerPaul Eggert2013-06-29 08:52:20 -0700
commit9c90cc06dd36f217422973ea41663a1f2105296f (patch)
treea48e62dc276027cd616f1c5a76155ce1e5255144 /src
parent79007321264153e8b4e6bfb9974ae6a99babe8c1 (diff)
downloademacs-9c90cc06dd36f217422973ea41663a1f2105296f.tar.gz
emacs-9c90cc06dd36f217422973ea41663a1f2105296f.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog12
-rw-r--r--src/coding.c62
-rw-r--r--src/coding.h12
-rw-r--r--src/image.c2
-rw-r--r--src/xdisp.c1
5 files changed, 53 insertions, 36 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 1e1b54a72d0..521e18583a5 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,15 @@
12013-06-29 Paul Eggert <eggert@cs.ucla.edu>
2
3 Fix minor problems found by static checking.
4 * coding.c (encode_inhibit_flag, inhibit_flag): New functions.
5 Redo the latter's body to sidestep GCC parenthesization warnings.
6 (setup_coding_system, detect_coding, detect_coding_system): Use them.
7 * coding.c (detect_coding, detect_coding_system):
8 * coding.h (struct undecided_spec):
9 Use bool for boolean.
10 * image.c (QCmax_width, QCmax_height): Now static.
11 * xdisp.c (Fmove_point_visually): Remove unused local.
12
12013-06-29 Eli Zaretskii <eliz@gnu.org> 132013-06-29 Eli Zaretskii <eliz@gnu.org>
2 14
3 * xdisp.c (Fmove_point_visually): New function. 15 * xdisp.c (Fmove_point_visually): New function.
diff --git a/src/coding.c b/src/coding.c
index c4aaefa8182..1ab59294b98 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -649,6 +649,23 @@ static struct coding_system coding_categories[coding_category_max];
649#define max(a, b) ((a) > (b) ? (a) : (b)) 649#define max(a, b) ((a) > (b) ? (a) : (b))
650#endif 650#endif
651 651
652/* Encode a flag that can be nil, something else, or t as -1, 0, 1. */
653
654static int
655encode_inhibit_flag (Lisp_Object flag)
656{
657 return NILP (flag) ? -1 : EQ (flag, Qt);
658}
659
660/* True if the value of ENCODED_FLAG says a flag should be treated as set.
661 1 means yes, -1 means no, 0 means ask the user variable VAR. */
662
663static bool
664inhibit_flag (int encoded_flag, bool var)
665{
666 return 0 < encoded_flag + var;
667}
668
652#define CODING_GET_INFO(coding, attrs, charset_list) \ 669#define CODING_GET_INFO(coding, attrs, charset_list) \
653 do { \ 670 do { \
654 (attrs) = CODING_ID_ATTRS ((coding)->id); \ 671 (attrs) = CODING_ID_ATTRS ((coding)->id); \
@@ -5706,17 +5723,11 @@ setup_coding_system (Lisp_Object coding_system, struct coding_system *coding)
5706 coding->encoder = encode_coding_raw_text; 5723 coding->encoder = encode_coding_raw_text;
5707 coding->common_flags |= CODING_REQUIRE_DETECTION_MASK; 5724 coding->common_flags |= CODING_REQUIRE_DETECTION_MASK;
5708 coding->spec.undecided.inhibit_nbd 5725 coding->spec.undecided.inhibit_nbd
5709 = (NILP (AREF (attrs, coding_attr_undecided_inhibit_null_byte_detection)) 5726 = (encode_inhibit_flag
5710 ? -1 5727 (AREF (attrs, coding_attr_undecided_inhibit_null_byte_detection)));
5711 : EQ (AREF (attrs, coding_attr_undecided_inhibit_null_byte_detection), Qt)
5712 ? 1
5713 : 0);
5714 coding->spec.undecided.inhibit_ied 5728 coding->spec.undecided.inhibit_ied
5715 = (NILP (AREF (attrs, coding_attr_undecided_inhibit_iso_escape_detection)) 5729 = (encode_inhibit_flag
5716 ? -1 5730 (AREF (attrs, coding_attr_undecided_inhibit_iso_escape_detection)));
5717 : EQ (AREF (attrs, coding_attr_undecided_inhibit_iso_escape_detection), Qt)
5718 ? 1
5719 : 0);
5720 coding->spec.undecided.prefer_utf_8 5731 coding->spec.undecided.prefer_utf_8
5721 = ! NILP (AREF (attrs, coding_attr_undecided_prefer_utf_8)); 5732 = ! NILP (AREF (attrs, coding_attr_undecided_prefer_utf_8));
5722 } 5733 }
@@ -6476,16 +6487,11 @@ detect_coding (struct coding_system *coding)
6476 int c, i; 6487 int c, i;
6477 struct coding_detection_info detect_info; 6488 struct coding_detection_info detect_info;
6478 bool null_byte_found = 0, eight_bit_found = 0; 6489 bool null_byte_found = 0, eight_bit_found = 0;
6479 int inhibit_nbd /* null byte detection */ 6490 bool inhibit_nbd = inhibit_flag (coding->spec.undecided.inhibit_nbd,
6480 = (coding->spec.undecided.inhibit_nbd > 0 6491 inhibit_null_byte_detection);
6481 | (coding->spec.undecided.inhibit_nbd == 0 6492 bool inhibit_ied = inhibit_flag (coding->spec.undecided.inhibit_ied,
6482 & inhibit_null_byte_detection)); 6493 inhibit_iso_escape_detection);
6483 int inhibit_ied /* iso escape detection */ 6494 bool prefer_utf_8 = coding->spec.undecided.prefer_utf_8;
6484 = (coding->spec.undecided.inhibit_ied > 0
6485 | (coding->spec.undecided.inhibit_ied == 0
6486 & inhibit_iso_escape_detection));
6487 int prefer_utf_8
6488 = coding->spec.undecided.prefer_utf_8;
6489 6495
6490 coding->head_ascii = 0; 6496 coding->head_ascii = 0;
6491 detect_info.checked = detect_info.found = detect_info.rejected = 0; 6497 detect_info.checked = detect_info.found = detect_info.rejected = 0;
@@ -8544,17 +8550,11 @@ detect_coding_system (const unsigned char *src,
8544 enum coding_category category IF_LINT (= 0); 8550 enum coding_category category IF_LINT (= 0);
8545 struct coding_system *this IF_LINT (= NULL); 8551 struct coding_system *this IF_LINT (= NULL);
8546 int c, i; 8552 int c, i;
8547 int inhibit_nbd /* null byte detection */ 8553 bool inhibit_nbd = inhibit_flag (coding.spec.undecided.inhibit_nbd,
8548 = (coding.spec.undecided.inhibit_nbd > 0 8554 inhibit_null_byte_detection);
8549 | (coding.spec.undecided.inhibit_nbd == 0 8555 bool inhibit_ied = inhibit_flag (coding.spec.undecided.inhibit_ied,
8550 & inhibit_null_byte_detection)); 8556 inhibit_iso_escape_detection);
8551 int inhibit_ied /* iso escape detection */ 8557 bool prefer_utf_8 = coding.spec.undecided.prefer_utf_8;
8552 = (coding.spec.undecided.inhibit_ied > 0
8553 | (coding.spec.undecided.inhibit_ied == 0
8554 & inhibit_iso_escape_detection));
8555 int prefer_utf_8
8556 = coding.spec.undecided.prefer_utf_8;
8557
8558 8558
8559 /* Skip all ASCII bytes except for a few ISO2022 controls. */ 8559 /* Skip all ASCII bytes except for a few ISO2022 controls. */
8560 for (; src < src_end; src++) 8560 for (; src < src_end; src++)
diff --git a/src/coding.h b/src/coding.h
index 453805e233a..7b7078e06fa 100644
--- a/src/coding.h
+++ b/src/coding.h
@@ -382,9 +382,15 @@ struct ccl_spec;
382 382
383struct undecided_spec 383struct undecided_spec
384{ 384{
385 int inhibit_nbd; /* nbd: null byte detection */ 385 /* Inhibit null byte detection. 1 means always inhibit,
386 int inhibit_ied; /* ied: iso escape detection */ 386 -1 means do not inhibit, 0 means rely on user variable. */
387 int prefer_utf_8; 387 int inhibit_nbd;
388
389 /* Inhibit ISO escape detection. -1, 0, 1 as above. */
390 int inhibit_ied;
391
392 /* Prefer UTF-8 when the input could be other encodings. */
393 bool prefer_utf_8;
388}; 394};
389 395
390enum utf_bom_type 396enum utf_bom_type
diff --git a/src/image.c b/src/image.c
index d5d5d4053f9..2c288342028 100644
--- a/src/image.c
+++ b/src/image.c
@@ -130,7 +130,7 @@ static void free_color_table (void);
130static unsigned long *colors_in_color_table (int *n); 130static unsigned long *colors_in_color_table (int *n);
131#endif 131#endif
132 132
133Lisp_Object QCmax_width, QCmax_height; 133static Lisp_Object QCmax_width, QCmax_height;
134 134
135/* Code to deal with bitmaps. Bitmaps are referenced by their bitmap 135/* Code to deal with bitmaps. Bitmaps are referenced by their bitmap
136 id, which is just an int that this section returns. Bitmaps are 136 id, which is just an int that this section returns. Bitmaps are
diff --git a/src/xdisp.c b/src/xdisp.c
index 420ff0c918b..963553e10cc 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -20252,7 +20252,6 @@ Value is the new character position of point. */)
20252 struct it it; 20252 struct it it;
20253 int pt_x, target_x, pixel_width, pt_vpos; 20253 int pt_x, target_x, pixel_width, pt_vpos;
20254 bool at_eol_p; 20254 bool at_eol_p;
20255 bool disp_string_at_start_p = 0;
20256 bool overshoot_expected = false; 20255 bool overshoot_expected = false;
20257 bool target_is_eol_p = false; 20256 bool target_is_eol_p = false;
20258 20257