emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] Changes to emacs/src/coding.c


From: Ken Raeburn
Subject: [Emacs-diffs] Changes to emacs/src/coding.c
Date: Sun, 14 Jul 2002 20:00:46 -0400

Index: emacs/src/coding.c
diff -c emacs/src/coding.c:1.248 emacs/src/coding.c:1.249
*** emacs/src/coding.c:1.248    Thu Jul 11 10:09:22 2002
--- emacs/src/coding.c  Sun Jul 14 20:00:36 2002
***************
*** 5224,5230 ****
              else if (VECTORP (val) || STRINGP (val))
                {
                  int len = (VECTORP (val)
!                            ? XVECTOR (val)->size : XSTRING (val)->size);
                  int i;
                  for (i = 0; i < len; i++)
                    {
--- 5224,5230 ----
              else if (VECTORP (val) || STRINGP (val))
                {
                  int len = (VECTORP (val)
!                            ? XVECTOR (val)->size : SCHARS (val));
                  int i;
                  for (i = 0; i < len; i++)
                    {
***************
*** 5832,5838 ****
    buf->enable_multibyte_characters = multibyte ? Qt : Qnil;
  
    insert_from_string (str, 0, 0,
!                     XSTRING (str)->size, STRING_BYTES (XSTRING (str)), 0);
    UNGCPRO;
    inhibit_pre_post_conversion = 1;
    if (encodep)
--- 5832,5838 ----
    buf->enable_multibyte_characters = multibyte ? Qt : Qnil;
  
    insert_from_string (str, 0, 0,
!                     SCHARS (str), SBYTES (str), 0);
    UNGCPRO;
    inhibit_pre_post_conversion = 1;
    if (encodep)
***************
*** 5864,5870 ****
    int consumed, consumed_char, produced, produced_char;
  
    from = 0;
!   to_byte = STRING_BYTES (XSTRING (str));
  
    saved_coding_symbol = coding->symbol;
    coding->src_multibyte = STRING_MULTIBYTE (str);
--- 5864,5870 ----
    int consumed, consumed_char, produced, produced_char;
  
    from = 0;
!   to_byte = SBYTES (str);
  
    saved_coding_symbol = coding->symbol;
    coding->src_multibyte = STRING_MULTIBYTE (str);
***************
*** 5874,5880 ****
        /* See the comments in code_convert_region.  */
        if (coding->type == coding_type_undecided)
        {
!         detect_coding (coding, XSTRING (str)->data, to_byte);
          if (coding->type == coding_type_undecided)
            {
              coding->type = coding_type_emacs_mule;
--- 5874,5880 ----
        /* See the comments in code_convert_region.  */
        if (coding->type == coding_type_undecided)
        {
!         detect_coding (coding, SDATA (str), to_byte);
          if (coding->type == coding_type_undecided)
            {
              coding->type = coding_type_emacs_mule;
***************
*** 5889,5895 ****
          && coding->type != coding_type_ccl)
        {
          saved_coding_symbol = coding->symbol;
!         detect_eol (coding, XSTRING (str)->data, to_byte);
          if (coding->eol_type == CODING_EOL_UNDECIDED)
            coding->eol_type = CODING_EOL_LF;
          /* We had better recover the original eol format if we
--- 5889,5895 ----
          && coding->type != coding_type_ccl)
        {
          saved_coding_symbol = coding->symbol;
!         detect_eol (coding, SDATA (str), to_byte);
          if (coding->eol_type == CODING_EOL_UNDECIDED)
            coding->eol_type = CODING_EOL_LF;
          /* We had better recover the original eol format if we
***************
*** 5908,5914 ****
      {
        /* Decoding routines expect the source text to be unibyte.  */
        str = Fstring_as_unibyte (str);
!       to_byte = STRING_BYTES (XSTRING (str));
        nocopy = 1;
        coding->src_multibyte = 0;
      }
--- 5908,5914 ----
      {
        /* Decoding routines expect the source text to be unibyte.  */
        str = Fstring_as_unibyte (str);
!       to_byte = SBYTES (str);
        nocopy = 1;
        coding->src_multibyte = 0;
      }
***************
*** 5916,5939 ****
    /* Try to skip the heading and tailing ASCIIs.  */
    if (require_decoding && coding->type != coding_type_ccl)
      {
!       SHRINK_CONVERSION_REGION (&from, &to_byte, coding, XSTRING (str)->data,
                                0);
        if (from == to_byte)
        require_decoding = 0;
!       shrinked_bytes = from + (STRING_BYTES (XSTRING (str)) - to_byte);
      }
  
    if (!require_decoding)
      {
!       coding->consumed = STRING_BYTES (XSTRING (str));
!       coding->consumed_char = XSTRING (str)->size;
        if (coding->dst_multibyte)
        {
          str = Fstring_as_multibyte (str);
          nocopy = 1;
        }
!       coding->produced = STRING_BYTES (XSTRING (str));
!       coding->produced_char = XSTRING (str)->size;
        return (nocopy ? str : Fcopy_sequence (str));
      }
  
--- 5916,5939 ----
    /* Try to skip the heading and tailing ASCIIs.  */
    if (require_decoding && coding->type != coding_type_ccl)
      {
!       SHRINK_CONVERSION_REGION (&from, &to_byte, coding, SDATA (str),
                                0);
        if (from == to_byte)
        require_decoding = 0;
!       shrinked_bytes = from + (SBYTES (str) - to_byte);
      }
  
    if (!require_decoding)
      {
!       coding->consumed = SBYTES (str);
!       coding->consumed_char = SCHARS (str);
        if (coding->dst_multibyte)
        {
          str = Fstring_as_multibyte (str);
          nocopy = 1;
        }
!       coding->produced = SBYTES (str);
!       coding->produced_char = SCHARS (str);
        return (nocopy ? str : Fcopy_sequence (str));
      }
  
***************
*** 5945,5951 ****
    consumed = consumed_char = produced = produced_char = 0;
    while (1)
      {
!       result = decode_coding (coding, XSTRING (str)->data + from + consumed,
                              buf.data + produced, to_byte - from - consumed,
                              buf.size - produced);
        consumed += coding->consumed;
--- 5945,5951 ----
    consumed = consumed_char = produced = produced_char = 0;
    while (1)
      {
!       result = decode_coding (coding, SDATA (str) + from + consumed,
                              buf.data + produced, to_byte - from - consumed,
                              buf.size - produced);
        consumed += coding->consumed;
***************
*** 6014,6024 ****
    else
      newstr = make_uninit_string (produced + shrinked_bytes);
    if (from > 0)
!     bcopy (XSTRING (str)->data, XSTRING (newstr)->data, from);
!   bcopy (buf.data, XSTRING (newstr)->data + from, produced);
    if (shrinked_bytes > from)
!     bcopy (XSTRING (str)->data + to_byte,
!          XSTRING (newstr)->data + from + produced,
           shrinked_bytes - from);
    free_conversion_buffer (&buf);
  
--- 6014,6024 ----
    else
      newstr = make_uninit_string (produced + shrinked_bytes);
    if (from > 0)
!     bcopy (SDATA (str), SDATA (newstr), from);
!   bcopy (buf.data, SDATA (newstr) + from, produced);
    if (shrinked_bytes > from)
!     bcopy (SDATA (str) + to_byte,
!          SDATA (newstr) + from + produced,
           shrinked_bytes - from);
    free_conversion_buffer (&buf);
  
***************
*** 6052,6059 ****
      str = run_pre_post_conversion_on_str (str, coding, 1);
  
    from = 0;
!   to = XSTRING (str)->size;
!   to_byte = STRING_BYTES (XSTRING (str));
  
    /* Encoding routines determine the multibyteness of the source text
       by coding->src_multibyte.  */
--- 6052,6059 ----
      str = run_pre_post_conversion_on_str (str, coding, 1);
  
    from = 0;
!   to = SCHARS (str);
!   to_byte = SBYTES (str);
  
    /* Encoding routines determine the multibyteness of the source text
       by coding->src_multibyte.  */
***************
*** 6061,6075 ****
    coding->dst_multibyte = 0;
    if (! CODING_REQUIRE_ENCODING (coding))
      {
!       coding->consumed = STRING_BYTES (XSTRING (str));
!       coding->consumed_char = XSTRING (str)->size;
        if (STRING_MULTIBYTE (str))
        {
          str = Fstring_as_unibyte (str);
          nocopy = 1;
        }
!       coding->produced = STRING_BYTES (XSTRING (str));
!       coding->produced_char = XSTRING (str)->size;
        return (nocopy ? str : Fcopy_sequence (str));
      }
  
--- 6061,6075 ----
    coding->dst_multibyte = 0;
    if (! CODING_REQUIRE_ENCODING (coding))
      {
!       coding->consumed = SBYTES (str);
!       coding->consumed_char = SCHARS (str);
        if (STRING_MULTIBYTE (str))
        {
          str = Fstring_as_unibyte (str);
          nocopy = 1;
        }
!       coding->produced = SBYTES (str);
!       coding->produced_char = SCHARS (str);
        return (nocopy ? str : Fcopy_sequence (str));
      }
  
***************
*** 6079,6089 ****
    /* Try to skip the heading and tailing ASCIIs.  */
    if (coding->type != coding_type_ccl)
      {
!       SHRINK_CONVERSION_REGION (&from, &to_byte, coding, XSTRING (str)->data,
                                1);
        if (from == to_byte)
        return (nocopy ? str : Fcopy_sequence (str));
!       shrinked_bytes = from + (STRING_BYTES (XSTRING (str)) - to_byte);
      }
  
    len = encoding_buffer_size (coding, to_byte - from);
--- 6079,6089 ----
    /* Try to skip the heading and tailing ASCIIs.  */
    if (coding->type != coding_type_ccl)
      {
!       SHRINK_CONVERSION_REGION (&from, &to_byte, coding, SDATA (str),
                                1);
        if (from == to_byte)
        return (nocopy ? str : Fcopy_sequence (str));
!       shrinked_bytes = from + (SBYTES (str) - to_byte);
      }
  
    len = encoding_buffer_size (coding, to_byte - from);
***************
*** 6092,6098 ****
    consumed = consumed_char = produced = produced_char = 0;
    while (1)
      {
!       result = encode_coding (coding, XSTRING (str)->data + from + consumed,
                              buf.data + produced, to_byte - from - consumed,
                              buf.size - produced);
        consumed += coding->consumed;
--- 6092,6098 ----
    consumed = consumed_char = produced = produced_char = 0;
    while (1)
      {
!       result = encode_coding (coding, SDATA (str) + from + consumed,
                              buf.data + produced, to_byte - from - consumed,
                              buf.size - produced);
        consumed += coding->consumed;
***************
*** 6114,6124 ****
  
    newstr = make_uninit_string (produced + shrinked_bytes);
    if (from > 0)
!     bcopy (XSTRING (str)->data, XSTRING (newstr)->data, from);
!   bcopy (buf.data, XSTRING (newstr)->data + from, produced);
    if (shrinked_bytes > from)
!     bcopy (XSTRING (str)->data + to_byte,
!          XSTRING (newstr)->data + from + produced,
           shrinked_bytes - from);
  
    free_conversion_buffer (&buf);
--- 6114,6124 ----
  
    newstr = make_uninit_string (produced + shrinked_bytes);
    if (from > 0)
!     bcopy (SDATA (str), SDATA (newstr), from);
!   bcopy (buf.data, SDATA (newstr) + from, produced);
    if (shrinked_bytes > from)
!     bcopy (SDATA (str) + to_byte,
!          SDATA (newstr) + from + produced,
           shrinked_bytes - from);
  
    free_conversion_buffer (&buf);
***************
*** 6160,6166 ****
        val = Fcompleting_read (prompt, Vcoding_system_alist, Qnil,
                              Qt, Qnil, Qcoding_system_history, Qnil, Qnil);
      }
!   while (XSTRING (val)->size == 0);
    return (Fintern (val, Qnil));
  }
  
--- 6160,6166 ----
        val = Fcompleting_read (prompt, Vcoding_system_alist, Qnil,
                              Qt, Qnil, Qcoding_system_history, Qnil, Qnil);
      }
!   while (SCHARS (val) == 0);
    return (Fintern (val, Qnil));
  }
  
***************
*** 6176,6182 ****
    val = Fcompleting_read (prompt, Vcoding_system_alist, Qnil,
                          Qt, Qnil, Qcoding_system_history,
                          default_coding_system, Qnil);
!   return (XSTRING (val)->size == 0 ? Qnil : Fintern (val, Qnil));
  }
  
  DEFUN ("check-coding-system", Fcheck_coding_system, Scheck_coding_system,
--- 6176,6182 ----
    val = Fcompleting_read (prompt, Vcoding_system_alist, Qnil,
                          Qt, Qnil, Qcoding_system_history,
                          default_coding_system, Qnil);
!   return (SCHARS (val) == 0 ? Qnil : Fintern (val, Qnil));
  }
  
  DEFUN ("check-coding-system", Fcheck_coding_system, Scheck_coding_system,
***************
*** 6318,6329 ****
  {
    CHECK_STRING (string);
  
!   return detect_coding_system (XSTRING (string)->data,
                               /* "+ 1" is to include the anchor byte
                                  `\0'.  With this, code detectors can
                                  handle the tailing bytes more
                                  accurately.  */
!                              STRING_BYTES (XSTRING (string)) + 1,
                               !NILP (highest),
                               STRING_MULTIBYTE (string));
  }
--- 6318,6329 ----
  {
    CHECK_STRING (string);
  
!   return detect_coding_system (SDATA (string),
                               /* "+ 1" is to include the anchor byte
                                  `\0'.  With this, code detectors can
                                  handle the tailing bytes more
                                  accurately.  */
!                              SBYTES (string) + 1,
                               !NILP (highest),
                               STRING_MULTIBYTE (string));
  }
***************
*** 6420,6428 ****
      {
        if (!STRING_MULTIBYTE (start))
        return Qt;
!       p1 = XSTRING (start)->data, p1end = p1 + STRING_BYTES (XSTRING (start));
        p2 = p2end = p1end;
!       if (XSTRING (start)->size != STRING_BYTES (XSTRING (start)))
        non_ascii_p = 1;
      }
    else
--- 6420,6428 ----
      {
        if (!STRING_MULTIBYTE (start))
        return Qt;
!       p1 = SDATA (start), p1end = p1 + SBYTES (start);
        p2 = p2end = p1end;
!       if (SCHARS (start) != SBYTES (start))
        non_ascii_p = 1;
      }
    else
***************
*** 6508,6514 ****
      return make_number (to - from);
  
    if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0)
!     error ("Invalid coding system: %s", XSTRING (SYMBOL_NAME 
(coding_system))->data);
  
    coding.mode |= CODING_MODE_LAST_BLOCK;
    coding.src_multibyte = coding.dst_multibyte
--- 6508,6514 ----
      return make_number (to - from);
  
    if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0)
!     error ("Invalid coding system: %s", SDATA (SYMBOL_NAME (coding_system)));
  
    coding.mode |= CODING_MODE_LAST_BLOCK;
    coding.src_multibyte = coding.dst_multibyte
***************
*** 6563,6569 ****
      return (NILP (nocopy) ? Fcopy_sequence (string) : string);
  
    if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0)
!     error ("Invalid coding system: %s", XSTRING (SYMBOL_NAME 
(coding_system))->data);
  
    coding.mode |= CODING_MODE_LAST_BLOCK;
    string = (encodep
--- 6563,6569 ----
      return (NILP (nocopy) ? Fcopy_sequence (string) : string);
  
    if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0)
!     error ("Invalid coding system: %s", SDATA (SYMBOL_NAME (coding_system)));
  
    coding.mode |= CODING_MODE_LAST_BLOCK;
    string = (encodep
***************
*** 6622,6628 ****
      return string;
  
    if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0)
!     error ("Invalid coding system: %s", XSTRING (SYMBOL_NAME 
(coding_system))->data);
  
    coding.composing = COMPOSITION_DISABLED;
    coding.mode |= CODING_MODE_LAST_BLOCK;
--- 6622,6628 ----
      return string;
  
    if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0)
!     error ("Invalid coding system: %s", SDATA (SYMBOL_NAME (coding_system)));
  
    coding.composing = COMPOSITION_DISABLED;
    coding.mode |= CODING_MODE_LAST_BLOCK;
***************
*** 6867,6873 ****
      error ("Invalid first argument");
    if (nargs < 1 + XINT (target_idx))
      error ("Too few arguments for operation: %s",
!          XSTRING (SYMBOL_NAME (operation))->data);
    target = args[XINT (target_idx) + 1];
    if (!(STRINGP (target)
        || (EQ (operation, Qopen_network_stream) && INTEGERP (target))))
--- 6867,6873 ----
      error ("Invalid first argument");
    if (nargs < 1 + XINT (target_idx))
      error ("Too few arguments for operation: %s",
!          SDATA (SYMBOL_NAME (operation)));
    target = args[XINT (target_idx) + 1];
    if (!(STRINGP (target)
        || (EQ (operation, Qopen_network_stream) && INTEGERP (target))))
***************
*** 7430,7436 ****
        Lisp_Object dec = code_convert_string_norecord (build_string (str),
                                                      Vlocale_coding_system,
                                                      0);
!       str = (char *) XSTRING (dec)->data;
      }
  
    return str;
--- 7430,7436 ----
        Lisp_Object dec = code_convert_string_norecord (build_string (str),
                                                      Vlocale_coding_system,
                                                      0);
!       str = (char *) SDATA (dec);
      }
  
    return str;



reply via email to

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