/[emacs]/emacs/src/coding.c
ViewVC logotype

Diff of /emacs/src/coding.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.248 by lektu, Thu Jul 11 14:09:22 2002 UTC revision 1.249 by raeburn, Mon Jul 15 00:00:36 2002 UTC
# Line 5224  coding_save_composition (coding, from, t Line 5224  coding_save_composition (coding, from, t
5224                else if (VECTORP (val) || STRINGP (val))                else if (VECTORP (val) || STRINGP (val))
5225                  {                  {
5226                    int len = (VECTORP (val)                    int len = (VECTORP (val)
5227                               ? XVECTOR (val)->size : XSTRING (val)->size);                               ? XVECTOR (val)->size : SCHARS (val));
5228                    int i;                    int i;
5229                    for (i = 0; i < len; i++)                    for (i = 0; i < len; i++)
5230                      {                      {
# Line 5832  run_pre_post_conversion_on_str (str, cod Line 5832  run_pre_post_conversion_on_str (str, cod
5832    buf->enable_multibyte_characters = multibyte ? Qt : Qnil;    buf->enable_multibyte_characters = multibyte ? Qt : Qnil;
5833    
5834    insert_from_string (str, 0, 0,    insert_from_string (str, 0, 0,
5835                        XSTRING (str)->size, STRING_BYTES (XSTRING (str)), 0);                        SCHARS (str), SBYTES (str), 0);
5836    UNGCPRO;    UNGCPRO;
5837    inhibit_pre_post_conversion = 1;    inhibit_pre_post_conversion = 1;
5838    if (encodep)    if (encodep)
# Line 5864  decode_coding_string (str, coding, nocop Line 5864  decode_coding_string (str, coding, nocop
5864    int consumed, consumed_char, produced, produced_char;    int consumed, consumed_char, produced, produced_char;
5865    
5866    from = 0;    from = 0;
5867    to_byte = STRING_BYTES (XSTRING (str));    to_byte = SBYTES (str);
5868    
5869    saved_coding_symbol = coding->symbol;    saved_coding_symbol = coding->symbol;
5870    coding->src_multibyte = STRING_MULTIBYTE (str);    coding->src_multibyte = STRING_MULTIBYTE (str);
# Line 5874  decode_coding_string (str, coding, nocop Line 5874  decode_coding_string (str, coding, nocop
5874        /* See the comments in code_convert_region.  */        /* See the comments in code_convert_region.  */
5875        if (coding->type == coding_type_undecided)        if (coding->type == coding_type_undecided)
5876          {          {
5877            detect_coding (coding, XSTRING (str)->data, to_byte);            detect_coding (coding, SDATA (str), to_byte);
5878            if (coding->type == coding_type_undecided)            if (coding->type == coding_type_undecided)
5879              {              {
5880                coding->type = coding_type_emacs_mule;                coding->type = coding_type_emacs_mule;
# Line 5889  decode_coding_string (str, coding, nocop Line 5889  decode_coding_string (str, coding, nocop
5889            && coding->type != coding_type_ccl)            && coding->type != coding_type_ccl)
5890          {          {
5891            saved_coding_symbol = coding->symbol;            saved_coding_symbol = coding->symbol;
5892            detect_eol (coding, XSTRING (str)->data, to_byte);            detect_eol (coding, SDATA (str), to_byte);
5893            if (coding->eol_type == CODING_EOL_UNDECIDED)            if (coding->eol_type == CODING_EOL_UNDECIDED)
5894              coding->eol_type = CODING_EOL_LF;              coding->eol_type = CODING_EOL_LF;
5895            /* We had better recover the original eol format if we            /* We had better recover the original eol format if we
# Line 5908  decode_coding_string (str, coding, nocop Line 5908  decode_coding_string (str, coding, nocop
5908      {      {
5909        /* Decoding routines expect the source text to be unibyte.  */        /* Decoding routines expect the source text to be unibyte.  */
5910        str = Fstring_as_unibyte (str);        str = Fstring_as_unibyte (str);
5911        to_byte = STRING_BYTES (XSTRING (str));        to_byte = SBYTES (str);
5912        nocopy = 1;        nocopy = 1;
5913        coding->src_multibyte = 0;        coding->src_multibyte = 0;
5914      }      }
# Line 5916  decode_coding_string (str, coding, nocop Line 5916  decode_coding_string (str, coding, nocop
5916    /* Try to skip the heading and tailing ASCIIs.  */    /* Try to skip the heading and tailing ASCIIs.  */
5917    if (require_decoding && coding->type != coding_type_ccl)    if (require_decoding && coding->type != coding_type_ccl)
5918      {      {
5919        SHRINK_CONVERSION_REGION (&from, &to_byte, coding, XSTRING (str)->data,        SHRINK_CONVERSION_REGION (&from, &to_byte, coding, SDATA (str),
5920                                  0);                                  0);
5921        if (from == to_byte)        if (from == to_byte)
5922          require_decoding = 0;          require_decoding = 0;
5923        shrinked_bytes = from + (STRING_BYTES (XSTRING (str)) - to_byte);        shrinked_bytes = from + (SBYTES (str) - to_byte);
5924      }      }
5925    
5926    if (!require_decoding)    if (!require_decoding)
5927      {      {
5928        coding->consumed = STRING_BYTES (XSTRING (str));        coding->consumed = SBYTES (str);
5929        coding->consumed_char = XSTRING (str)->size;        coding->consumed_char = SCHARS (str);
5930        if (coding->dst_multibyte)        if (coding->dst_multibyte)
5931          {          {
5932            str = Fstring_as_multibyte (str);            str = Fstring_as_multibyte (str);
5933            nocopy = 1;            nocopy = 1;
5934          }          }
5935        coding->produced = STRING_BYTES (XSTRING (str));        coding->produced = SBYTES (str);
5936        coding->produced_char = XSTRING (str)->size;        coding->produced_char = SCHARS (str);
5937        return (nocopy ? str : Fcopy_sequence (str));        return (nocopy ? str : Fcopy_sequence (str));
5938      }      }
5939    
# Line 5945  decode_coding_string (str, coding, nocop Line 5945  decode_coding_string (str, coding, nocop
5945    consumed = consumed_char = produced = produced_char = 0;    consumed = consumed_char = produced = produced_char = 0;
5946    while (1)    while (1)
5947      {      {
5948        result = decode_coding (coding, XSTRING (str)->data + from + consumed,        result = decode_coding (coding, SDATA (str) + from + consumed,
5949                                buf.data + produced, to_byte - from - consumed,                                buf.data + produced, to_byte - from - consumed,
5950                                buf.size - produced);                                buf.size - produced);
5951        consumed += coding->consumed;        consumed += coding->consumed;
# Line 6014  decode_coding_string (str, coding, nocop Line 6014  decode_coding_string (str, coding, nocop
6014    else    else
6015      newstr = make_uninit_string (produced + shrinked_bytes);      newstr = make_uninit_string (produced + shrinked_bytes);
6016    if (from > 0)    if (from > 0)
6017      bcopy (XSTRING (str)->data, XSTRING (newstr)->data, from);      bcopy (SDATA (str), SDATA (newstr), from);
6018    bcopy (buf.data, XSTRING (newstr)->data + from, produced);    bcopy (buf.data, SDATA (newstr) + from, produced);
6019    if (shrinked_bytes > from)    if (shrinked_bytes > from)
6020      bcopy (XSTRING (str)->data + to_byte,      bcopy (SDATA (str) + to_byte,
6021             XSTRING (newstr)->data + from + produced,             SDATA (newstr) + from + produced,
6022             shrinked_bytes - from);             shrinked_bytes - from);
6023    free_conversion_buffer (&buf);    free_conversion_buffer (&buf);
6024    
# Line 6052  encode_coding_string (str, coding, nocop Line 6052  encode_coding_string (str, coding, nocop
6052      str = run_pre_post_conversion_on_str (str, coding, 1);      str = run_pre_post_conversion_on_str (str, coding, 1);
6053    
6054    from = 0;    from = 0;
6055    to = XSTRING (str)->size;    to = SCHARS (str);
6056    to_byte = STRING_BYTES (XSTRING (str));    to_byte = SBYTES (str);
6057    
6058    /* Encoding routines determine the multibyteness of the source text    /* Encoding routines determine the multibyteness of the source text
6059       by coding->src_multibyte.  */       by coding->src_multibyte.  */
# Line 6061  encode_coding_string (str, coding, nocop Line 6061  encode_coding_string (str, coding, nocop
6061    coding->dst_multibyte = 0;    coding->dst_multibyte = 0;
6062    if (! CODING_REQUIRE_ENCODING (coding))    if (! CODING_REQUIRE_ENCODING (coding))
6063      {      {
6064        coding->consumed = STRING_BYTES (XSTRING (str));        coding->consumed = SBYTES (str);
6065        coding->consumed_char = XSTRING (str)->size;        coding->consumed_char = SCHARS (str);
6066        if (STRING_MULTIBYTE (str))        if (STRING_MULTIBYTE (str))
6067          {          {
6068            str = Fstring_as_unibyte (str);            str = Fstring_as_unibyte (str);
6069            nocopy = 1;            nocopy = 1;
6070          }          }
6071        coding->produced = STRING_BYTES (XSTRING (str));        coding->produced = SBYTES (str);
6072        coding->produced_char = XSTRING (str)->size;        coding->produced_char = SCHARS (str);
6073        return (nocopy ? str : Fcopy_sequence (str));        return (nocopy ? str : Fcopy_sequence (str));
6074      }      }
6075    
# Line 6079  encode_coding_string (str, coding, nocop Line 6079  encode_coding_string (str, coding, nocop
6079    /* Try to skip the heading and tailing ASCIIs.  */    /* Try to skip the heading and tailing ASCIIs.  */
6080    if (coding->type != coding_type_ccl)    if (coding->type != coding_type_ccl)
6081      {      {
6082        SHRINK_CONVERSION_REGION (&from, &to_byte, coding, XSTRING (str)->data,        SHRINK_CONVERSION_REGION (&from, &to_byte, coding, SDATA (str),
6083                                  1);                                  1);
6084        if (from == to_byte)        if (from == to_byte)
6085          return (nocopy ? str : Fcopy_sequence (str));          return (nocopy ? str : Fcopy_sequence (str));
6086        shrinked_bytes = from + (STRING_BYTES (XSTRING (str)) - to_byte);        shrinked_bytes = from + (SBYTES (str) - to_byte);
6087      }      }
6088    
6089    len = encoding_buffer_size (coding, to_byte - from);    len = encoding_buffer_size (coding, to_byte - from);
# Line 6092  encode_coding_string (str, coding, nocop Line 6092  encode_coding_string (str, coding, nocop
6092    consumed = consumed_char = produced = produced_char = 0;    consumed = consumed_char = produced = produced_char = 0;
6093    while (1)    while (1)
6094      {      {
6095        result = encode_coding (coding, XSTRING (str)->data + from + consumed,        result = encode_coding (coding, SDATA (str) + from + consumed,
6096                                buf.data + produced, to_byte - from - consumed,                                buf.data + produced, to_byte - from - consumed,
6097                                buf.size - produced);                                buf.size - produced);
6098        consumed += coding->consumed;        consumed += coding->consumed;
# Line 6114  encode_coding_string (str, coding, nocop Line 6114  encode_coding_string (str, coding, nocop
6114    
6115    newstr = make_uninit_string (produced + shrinked_bytes);    newstr = make_uninit_string (produced + shrinked_bytes);
6116    if (from > 0)    if (from > 0)
6117      bcopy (XSTRING (str)->data, XSTRING (newstr)->data, from);      bcopy (SDATA (str), SDATA (newstr), from);
6118    bcopy (buf.data, XSTRING (newstr)->data + from, produced);    bcopy (buf.data, SDATA (newstr) + from, produced);
6119    if (shrinked_bytes > from)    if (shrinked_bytes > from)
6120      bcopy (XSTRING (str)->data + to_byte,      bcopy (SDATA (str) + to_byte,
6121             XSTRING (newstr)->data + from + produced,             SDATA (newstr) + from + produced,
6122             shrinked_bytes - from);             shrinked_bytes - from);
6123    
6124    free_conversion_buffer (&buf);    free_conversion_buffer (&buf);
# Line 6160  DEFUN ("read-non-nil-coding-system", Fre Line 6160  DEFUN ("read-non-nil-coding-system", Fre
6160        val = Fcompleting_read (prompt, Vcoding_system_alist, Qnil,        val = Fcompleting_read (prompt, Vcoding_system_alist, Qnil,
6161                                Qt, Qnil, Qcoding_system_history, Qnil, Qnil);                                Qt, Qnil, Qcoding_system_history, Qnil, Qnil);
6162      }      }
6163    while (XSTRING (val)->size == 0);    while (SCHARS (val) == 0);
6164    return (Fintern (val, Qnil));    return (Fintern (val, Qnil));
6165  }  }
6166    
# Line 6176  If the user enters null input, return se Line 6176  If the user enters null input, return se
6176    val = Fcompleting_read (prompt, Vcoding_system_alist, Qnil,    val = Fcompleting_read (prompt, Vcoding_system_alist, Qnil,
6177                            Qt, Qnil, Qcoding_system_history,                            Qt, Qnil, Qcoding_system_history,
6178                            default_coding_system, Qnil);                            default_coding_system, Qnil);
6179    return (XSTRING (val)->size == 0 ? Qnil : Fintern (val, Qnil));    return (SCHARS (val) == 0 ? Qnil : Fintern (val, Qnil));
6180  }  }
6181    
6182  DEFUN ("check-coding-system", Fcheck_coding_system, Scheck_coding_system,  DEFUN ("check-coding-system", Fcheck_coding_system, Scheck_coding_system,
# Line 6318  highest priority.  */) Line 6318  highest priority.  */)
6318  {  {
6319    CHECK_STRING (string);    CHECK_STRING (string);
6320    
6321    return detect_coding_system (XSTRING (string)->data,    return detect_coding_system (SDATA (string),
6322                                 /* "+ 1" is to include the anchor byte                                 /* "+ 1" is to include the anchor byte
6323                                    `\0'.  With this, code detectors can                                    `\0'.  With this, code detectors can
6324                                    handle the tailing bytes more                                    handle the tailing bytes more
6325                                    accurately.  */                                    accurately.  */
6326                                 STRING_BYTES (XSTRING (string)) + 1,                                 SBYTES (string) + 1,
6327                                 !NILP (highest),                                 !NILP (highest),
6328                                 STRING_MULTIBYTE (string));                                 STRING_MULTIBYTE (string));
6329  }  }
# Line 6420  DEFUN ("find-coding-systems-region-inter Line 6420  DEFUN ("find-coding-systems-region-inter
6420      {      {
6421        if (!STRING_MULTIBYTE (start))        if (!STRING_MULTIBYTE (start))
6422          return Qt;          return Qt;
6423        p1 = XSTRING (start)->data, p1end = p1 + STRING_BYTES (XSTRING (start));        p1 = SDATA (start), p1end = p1 + SBYTES (start);
6424        p2 = p2end = p1end;        p2 = p2end = p1end;
6425        if (XSTRING (start)->size != STRING_BYTES (XSTRING (start)))        if (SCHARS (start) != SBYTES (start))
6426          non_ascii_p = 1;          non_ascii_p = 1;
6427      }      }
6428    else    else
# Line 6508  code_convert_region1 (start, end, coding Line 6508  code_convert_region1 (start, end, coding
6508      return make_number (to - from);      return make_number (to - from);
6509    
6510    if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0)    if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0)
6511      error ("Invalid coding system: %s", XSTRING (SYMBOL_NAME (coding_system))->data);      error ("Invalid coding system: %s", SDATA (SYMBOL_NAME (coding_system)));
6512    
6513    coding.mode |= CODING_MODE_LAST_BLOCK;    coding.mode |= CODING_MODE_LAST_BLOCK;
6514    coding.src_multibyte = coding.dst_multibyte    coding.src_multibyte = coding.dst_multibyte
# Line 6563  code_convert_string1 (string, coding_sys Line 6563  code_convert_string1 (string, coding_sys
6563      return (NILP (nocopy) ? Fcopy_sequence (string) : string);      return (NILP (nocopy) ? Fcopy_sequence (string) : string);
6564    
6565    if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0)    if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0)
6566      error ("Invalid coding system: %s", XSTRING (SYMBOL_NAME (coding_system))->data);      error ("Invalid coding system: %s", SDATA (SYMBOL_NAME (coding_system)));
6567    
6568    coding.mode |= CODING_MODE_LAST_BLOCK;    coding.mode |= CODING_MODE_LAST_BLOCK;
6569    string = (encodep    string = (encodep
# Line 6622  code_convert_string_norecord (string, co Line 6622  code_convert_string_norecord (string, co
6622      return string;      return string;
6623    
6624    if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0)    if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0)
6625      error ("Invalid coding system: %s", XSTRING (SYMBOL_NAME (coding_system))->data);      error ("Invalid coding system: %s", SDATA (SYMBOL_NAME (coding_system)));
6626    
6627    coding.composing = COMPOSITION_DISABLED;    coding.composing = COMPOSITION_DISABLED;
6628    coding.mode |= CODING_MODE_LAST_BLOCK;    coding.mode |= CODING_MODE_LAST_BLOCK;
# Line 6867  usage: (find-operation-coding-system OPE Line 6867  usage: (find-operation-coding-system OPE
6867      error ("Invalid first argument");      error ("Invalid first argument");
6868    if (nargs < 1 + XINT (target_idx))    if (nargs < 1 + XINT (target_idx))
6869      error ("Too few arguments for operation: %s",      error ("Too few arguments for operation: %s",
6870             XSTRING (SYMBOL_NAME (operation))->data);             SDATA (SYMBOL_NAME (operation)));
6871    target = args[XINT (target_idx) + 1];    target = args[XINT (target_idx) + 1];
6872    if (!(STRINGP (target)    if (!(STRINGP (target)
6873          || (EQ (operation, Qopen_network_stream) && INTEGERP (target))))          || (EQ (operation, Qopen_network_stream) && INTEGERP (target))))
# Line 7430  emacs_strerror (error_number) Line 7430  emacs_strerror (error_number)
7430        Lisp_Object dec = code_convert_string_norecord (build_string (str),        Lisp_Object dec = code_convert_string_norecord (build_string (str),
7431                                                        Vlocale_coding_system,                                                        Vlocale_coding_system,
7432                                                        0);                                                        0);
7433        str = (char *) XSTRING (dec)->data;        str = (char *) SDATA (dec);
7434      }      }
7435    
7436    return str;    return str;

Legend:
Removed from v.1.248  
changed lines
  Added in v.1.249

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26