aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
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/coding.c
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/coding.c')
-rw-r--r--src/coding.c62
1 files changed, 31 insertions, 31 deletions
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++)