From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dan Nicolaescu Newsgroups: gmane.emacs.devel Subject: Problem report #111 [2/2]: base/src/emacs/src/coding.c (detect_coding_system); UNINIT Date: Tue, 2 Dec 2008 14:20:18 -0800 (PST) Message-ID: <200812022220.mB2MKIkh021752@mothra.ics.uci.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1228256554 3361 80.91.229.12 (2 Dec 2008 22:22:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 2 Dec 2008 22:22:34 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Dec 02 23:23:36 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1L7deN-00063T-Rh for ged-emacs-devel@m.gmane.org; Tue, 02 Dec 2008 23:23:25 +0100 Original-Received: from localhost ([127.0.0.1]:43027 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L7ddD-0005rB-FD for ged-emacs-devel@m.gmane.org; Tue, 02 Dec 2008 17:22:11 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L7dbb-0005GV-CB for emacs-devel@gnu.org; Tue, 02 Dec 2008 17:20:31 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L7dba-0005GE-MD for emacs-devel@gnu.org; Tue, 02 Dec 2008 17:20:31 -0500 Original-Received: from [199.232.76.173] (port=50476 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L7dba-0005G7-EL for emacs-devel@gnu.org; Tue, 02 Dec 2008 17:20:30 -0500 Original-Received: from barrelv2.ics.uci.edu ([128.195.1.114]:43654) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA1:24) (Exim 4.60) (envelope-from ) id 1L7dbZ-0001G6-K8 for emacs-devel@gnu.org; Tue, 02 Dec 2008 17:20:30 -0500 Original-Received: from mothra.ics.uci.edu (mothra.ics.uci.edu [128.195.6.93]) by barrelv2.ics.uci.edu (8.13.7+Sun/8.13.7) with ESMTP id mB2MKJJ8018348 for ; Tue, 2 Dec 2008 14:20:19 -0800 (PST) Original-Received: (from dann@localhost) by mothra.ics.uci.edu (8.13.8+Sun/8.13.6/Submit) id mB2MKIkh021752; Tue, 2 Dec 2008 14:20:18 -0800 (PST) Original-Lines: 323 X-ICS-MailScanner-Information: Please contact the ISP for more information X-ICS-MailScanner-ID: mB2MKJJ8018348 X-ICS-MailScanner: Found to be clean X-ICS-MailScanner-SpamCheck: not spam, SpamAssassin (score=-1.44, required 5, autolearn=disabled, ALL_TRUSTED -1.44) X-ICS-MailScanner-From: dann@mothra.ics.uci.edu X-detected-operating-system: by monty-python.gnu.org: Solaris 10 (beta) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:106449 Archived-At: CID: 111 Checker: UNINIT (help) File: base/src/emacs/src/coding.c Function: detect_coding_system Description: Using uninitialized value "val" Event var_decl: Declared variable "val" without initializer Also see events: [uninit_use] 7642 Lisp_Object val; 7643 struct coding_system coding; 7644 int id; 7645 struct coding_detection_info detect_info; 7646 enum coding_category base_category; 7647 int null_byte_found = 0, eight_bit_found = 0; 7648 7649 if (NILP (coding_system)) 7650 coding_system = Qundecided; 7651 setup_coding_system (coding_system, &coding); 7652 attrs = CODING_ID_ATTRS (coding.id); 7653 eol_type = CODING_ID_EOL_TYPE (coding.id); 7654 coding_system = CODING_ATTR_BASE_NAME (attrs); 7655 7656 coding.source = src; 7657 coding.src_chars = src_chars; 7658 coding.src_bytes = src_bytes; 7659 coding.src_multibyte = multibytep; 7660 coding.consumed = 0; 7661 coding.mode |= CODING_MODE_LAST_BLOCK; 7662 coding.head_ascii = 0; 7663 7664 detect_info.checked = detect_info.found = detect_info.rejected = 0; 7665 7666 /* At first, detect text-format if necessary. */ 7667 base_category = XINT (CODING_ATTR_CATEGORY (attrs)); 7668 if (base_category == coding_category_undecided) 7669 { 7670 enum coding_category category; 7671 struct coding_system *this; 7672 int c, i; 7673 7674 /* Skip all ASCII bytes except for a few ISO2022 controls. */ 7675 for (; src < src_end; src++) 7676 { 7677 c = *src; 7678 if (c & 0x80) 7679 { 7680 eight_bit_found = 1; 7681 if (null_byte_found) 7682 break; 7683 } 7684 else if (c < 0x20) 7685 { 7686 if ((c == ISO_CODE_ESC || c == ISO_CODE_SI || c == ISO_CODE_SO) 7687 && ! inhibit_iso_escape_detection 7688 && ! detect_info.checked) 7689 { 7690 if (detect_coding_iso_2022 (&coding, &detect_info)) 7691 { 7692 /* We have scanned the whole data. */ 7693 if (! (detect_info.rejected & CATEGORY_MASK_ISO_7_ELSE)) 7694 { 7695 /* We didn't find an 8-bit code. We may 7696 have found a null-byte, but it's very 7697 rare that a binary file confirm to 7698 ISO-2022. */ 7699 src = src_end; 7700 coding.head_ascii = src - coding.source; 7701 } 7702 detect_info.rejected |= ~CATEGORY_MASK_ISO_ESCAPE; 7703 break; 7704 } 7705 } 7706 else if (! c) 7707 { 7708 null_byte_found = 1; 7709 if (eight_bit_found) 7710 break; 7711 } 7712 if (! eight_bit_found) 7713 coding.head_ascii++; 7714 } 7715 else if (! eight_bit_found) 7716 coding.head_ascii++; 7717 } 7718 7719 if (null_byte_found || eight_bit_found 7720 || coding.head_ascii < coding.src_bytes 7721 || detect_info.found) 7722 { 7723 if (coding.head_ascii == coding.src_bytes) 7724 /* As all bytes are 7-bit, we can ignore non-ISO-2022 codings. */ At conditional (1): "i < 19" taking true path At conditional (3): "i < 19" taking true path At conditional (5): "i < 19" taking false path 7725 for (i = 0; i < coding_category_raw_text; i++) 7726 { 7727 category = coding_priorities[i]; 7728 this = coding_categories + category; At conditional (2): "(detect_info).found & 1 << category != 0" taking false path At conditional (4): "(detect_info).found & 1 << category != 0" taking false path 7729 if (detect_info.found & (1 << category)) 7730 break; 7731 } 7732 else 7733 { 7734 if (null_byte_found) 7735 { 7736 detect_info.checked |= ~CATEGORY_MASK_UTF_16; 7737 detect_info.rejected |= ~CATEGORY_MASK_UTF_16; 7738 } 7739 for (i = 0; i < coding_category_raw_text; i++) 7740 { 7741 category = coding_priorities[i]; 7742 this = coding_categories + category; 7743 7744 if (this->id < 0) 7745 { 7746 /* No coding system of this category is defined. */ 7747 detect_info.rejected |= (1 << category); 7748 } 7749 else if (category >= coding_category_raw_text) 7750 continue; 7751 else if (detect_info.checked & (1 << category)) 7752 { 7753 if (highest 7754 && (detect_info.found & (1 << category))) 7755 break; 7756 } 7757 else if ((*(this->detector)) (&coding, &detect_info) 7758 && highest 7759 && (detect_info.found & (1 << category))) 7760 { 7761 if (category == coding_category_utf_16_auto) 7762 { 7763 if (detect_info.found & CATEGORY_MASK_UTF_16_LE) 7764 category = coding_category_utf_16_le; 7765 else 7766 category = coding_category_utf_16_be; 7767 } 7768 break; 7769 } 7770 } 7771 } 7772 } 7773 At conditional (6): "(detect_info).rejected & 524287 == 524287" taking false path 7774 if ((detect_info.rejected & CATEGORY_MASK_ANY) == CATEGORY_MASK_ANY) 7775 { 7776 detect_info.found = CATEGORY_MASK_RAW_TEXT; 7777 id = coding_categories[coding_category_raw_text].id; 7778 val = Fcons (make_number (id), Qnil); 7779 } At conditional (7): "(detect_info).rejected == 0" taking false path 7780 else if (! detect_info.rejected && ! detect_info.found) 7781 { 7782 detect_info.found = CATEGORY_MASK_ANY; 7783 id = coding_categories[coding_category_undecided].id; 7784 val = Fcons (make_number (id), Qnil); 7785 } At conditional (8): "highest != 0" taking true path 7786 else if (highest) 7787 { At conditional (9): "(detect_info).found != 0" taking false path 7788 if (detect_info.found) 7789 { 7790 detect_info.found = 1 << category; 7791 val = Fcons (make_number (this->id), Qnil); 7792 } 7793 else At conditional (10): "i < 19" taking true path At conditional (12): "i < 19" taking true path At conditional (14): "i < 19" taking true path At conditional (16): "i < 19" taking false path 7794 for (i = 0; i < coding_category_raw_text; i++) At conditional (11): "(detect_info).rejected & 1 << coding_priorities[i] == 0" taking false path At conditional (13): "(detect_info).rejected & 1 << coding_priorities[i] == 0" taking false path At conditional (15): "(detect_info).rejected & 1 << coding_priorities[i] == 0" taking false path 7795 if (! (detect_info.rejected & (1 << coding_priorities[i]))) 7796 { 7797 detect_info.found = 1 << coding_priorities[i]; 7798 id = coding_categories[coding_priorities[i]].id; 7799 val = Fcons (make_number (id), Qnil); 7800 break; 7801 } 7802 } 7803 else 7804 { 7805 int mask = detect_info.rejected | detect_info.found; 7806 int found = 0; 7807 val = Qnil; 7808 7809 for (i = coding_category_raw_text - 1; i >= 0; i--) 7810 { 7811 category = coding_priorities[i]; 7812 if (! (mask & (1 << category))) 7813 { 7814 found |= 1 << category; 7815 id = coding_categories[category].id; 7816 if (id >= 0) 7817 val = Fcons (make_number (id), val); 7818 } 7819 } 7820 for (i = coding_category_raw_text - 1; i >= 0; i--) 7821 { 7822 category = coding_priorities[i]; 7823 if (detect_info.found & (1 << category)) 7824 { 7825 id = coding_categories[category].id; 7826 val = Fcons (make_number (id), val); 7827 } 7828 } 7829 detect_info.found |= found; 7830 } 7831 } 7832 else if (base_category == coding_category_utf_8_auto) 7833 { 7834 if (detect_coding_utf_8 (&coding, &detect_info)) 7835 { 7836 struct coding_system *this; 7837 7838 if (detect_info.found & CATEGORY_MASK_UTF_8_SIG) 7839 this = coding_categories + coding_category_utf_8_sig; 7840 else 7841 this = coding_categories + coding_category_utf_8_nosig; 7842 val = Fcons (make_number (this->id), Qnil); 7843 } 7844 } 7845 else if (base_category == coding_category_utf_16_auto) 7846 { 7847 if (detect_coding_utf_16 (&coding, &detect_info)) 7848 { 7849 struct coding_system *this; 7850 7851 if (detect_info.found & CATEGORY_MASK_UTF_16_LE) 7852 this = coding_categories + coding_category_utf_16_le; 7853 else if (detect_info.found & CATEGORY_MASK_UTF_16_BE) 7854 this = coding_categories + coding_category_utf_16_be; 7855 else if (detect_info.rejected & CATEGORY_MASK_UTF_16_LE_NOSIG) 7856 this = coding_categories + coding_category_utf_16_be_nosig; 7857 else 7858 this = coding_categories + coding_category_utf_16_le_nosig; 7859 val = Fcons (make_number (this->id), Qnil); 7860 } 7861 } 7862 else 7863 { 7864 detect_info.found = 1 << XINT (CODING_ATTR_CATEGORY (attrs)); 7865 val = Fcons (make_number (coding.id), Qnil); 7866 } 7867 7868 /* Then, detect eol-format if necessary. */ 7869 { 7870 int normal_eol = -1, utf_16_be_eol = -1, utf_16_le_eol; 7871 Lisp_Object tail; 7872 At conditional (17): "eol_type & 7 == 4" taking true path At conditional (18): "((0), (eol_type & -8))->size & 4611686018427387904 == 0" taking true path 7873 if (VECTORP (eol_type)) 7874 { At conditional (19): "(detect_info).found & -15873 != 0" taking false path 7875 if (detect_info.found & ~CATEGORY_MASK_UTF_16) 7876 { 7877 if (null_byte_found) 7878 normal_eol = EOL_SEEN_LF; 7879 else 7880 normal_eol = detect_eol (coding.source, src_bytes, 7881 coding_category_raw_text); 7882 } At conditional (20): "(detect_info).found & 5120 != 0" taking false path 7883 if (detect_info.found & (CATEGORY_MASK_UTF_16_BE 7884 | CATEGORY_MASK_UTF_16_BE_NOSIG)) 7885 utf_16_be_eol = detect_eol (coding.source, src_bytes, 7886 coding_category_utf_16_be); At conditional (21): "(detect_info).found & 10240 != 0" taking false path 7887 if (detect_info.found & (CATEGORY_MASK_UTF_16_LE 7888 | CATEGORY_MASK_UTF_16_LE_NOSIG)) 7889 utf_16_le_eol = detect_eol (coding.source, src_bytes, 7890 coding_category_utf_16_le); 7891 } 7892 else 7893 { 7894 if (EQ (eol_type, Qunix)) 7895 normal_eol = utf_16_be_eol = utf_16_le_eol = EOL_SEEN_LF; 7896 else if (EQ (eol_type, Qdos)) 7897 normal_eol = utf_16_be_eol = utf_16_le_eol = EOL_SEEN_CRLF; 7898 else 7899 normal_eol = utf_16_be_eol = utf_16_le_eol = EOL_SEEN_CR; 7900 } 7901 Event uninit_use: Using uninitialized value "val" Also see events: [var_decl] 7902 for (tail = val; CONSP (tail); tail = XCDR (tail)) 7903 { 7904 enum coding_category category; 7905 int this_eol;