comparison src/file-coding.c @ 867:804517e16990

[xemacs-hg @ 2002-06-05 09:54:39 by ben] Textual renaming: text/char names abbrev.c, alloc.c, buffer.c, buffer.h, bytecode.c, callint.c, casefiddle.c, casetab.c, charset.h, chartab.c, chartab.h, cmds.c, console-gtk.h, console-msw.c, console-msw.h, console-stream.c, console-tty.c, console-x.c, console-x.h, console.h, data.c, device-msw.c, device-x.c, dialog-msw.c, dired-msw.c, dired.c, doc.c, doprnt.c, editfns.c, eldap.c, emodules.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, event-unixoid.c, events.c, events.h, file-coding.c, file-coding.h, fileio.c, filelock.c, fns.c, font-lock.c, frame-gtk.c, frame-msw.c, frame-x.c, frame.c, glyphs-eimage.c, glyphs-msw.c, glyphs-x.c, glyphs.c, glyphs.h, gpmevent.c, gui-x.c, gui-x.h, gui.c, gui.h, hpplay.c, indent.c, insdel.c, insdel.h, intl-win32.c, keymap.c, line-number.c, line-number.h, lisp-disunion.h, lisp-union.h, lisp.h, lread.c, lrecord.h, lstream.c, lstream.h, md5.c, menubar-msw.c, menubar-x.c, menubar.c, minibuf.c, mule-ccl.c, mule-charset.c, mule-coding.c, mule-wnnfns.c, ndir.h, nt.c, objects-gtk.c, objects-gtk.h, objects-msw.c, objects-tty.c, objects-x.c, objects.c, objects.h, postgresql.c, print.c, process-nt.c, process-unix.c, process.c, procimpl.h, realpath.c, redisplay-gtk.c, redisplay-msw.c, redisplay-output.c, redisplay-tty.c, redisplay-x.c, redisplay.c, redisplay.h, regex.c, search.c, select-common.h, select-gtk.c, select-x.c, sound.h, symbols.c, syntax.c, syntax.h, sysdep.c, sysdep.h, sysdir.h, sysfile.h, sysproc.h, syspwd.h, systime.h, syswindows.h, termcap.c, tests.c, text.c, text.h, toolbar-common.c, tooltalk.c, ui-gtk.c, unexnt.c, unicode.c, win32.c: Text/char naming rationalization. [a] distinguish between "charptr" when it refers to operations on the pointer itself and when it refers to operations on text; and [b] use consistent naming for everything referring to internal format, i.e. Itext == text in internal format Ibyte == a byte in such text Ichar == a char as represented in internal character format thus e.g. set_charptr_emchar -> set_itext_ichar The pre and post tags on either side of this change are: pre-internal-format-textual-renaming post-internal-format-textual-renaming See the Internals Manual for details of exactly how this was done, how to handle the change in your workspace, etc.
author ben
date Wed, 05 Jun 2002 09:58:45 +0000
parents e7ee5f8bde58
children c925bacdda60
comparison
equal deleted inserted replaced
866:613552a02607 867:804517e16990
1016 /* kludge */ 1016 /* kludge */
1017 static void 1017 static void
1018 setup_eol_coding_systems (Lisp_Object codesys) 1018 setup_eol_coding_systems (Lisp_Object codesys)
1019 { 1019 {
1020 int len = XSTRING_LENGTH (XSYMBOL (XCODING_SYSTEM_NAME (codesys))->name); 1020 int len = XSTRING_LENGTH (XSYMBOL (XCODING_SYSTEM_NAME (codesys))->name);
1021 Intbyte *codesys_name = (Intbyte *) ALLOCA (len + 7); 1021 Ibyte *codesys_name = (Ibyte *) ALLOCA (len + 7);
1022 int mlen = -1; 1022 int mlen = -1;
1023 Intbyte *codesys_mnemonic = 0; 1023 Ibyte *codesys_mnemonic = 0;
1024 Lisp_Object codesys_name_sym, sub_codesys; 1024 Lisp_Object codesys_name_sym, sub_codesys;
1025 int i; 1025 int i;
1026 1026
1027 memcpy (codesys_name, 1027 memcpy (codesys_name,
1028 XSTRING_DATA (XSYMBOL (XCODING_SYSTEM_NAME (codesys))->name), len); 1028 XSTRING_DATA (XSYMBOL (XCODING_SYSTEM_NAME (codesys))->name), len);
1029 1029
1030 if (STRINGP (XCODING_SYSTEM_MNEMONIC (codesys))) 1030 if (STRINGP (XCODING_SYSTEM_MNEMONIC (codesys)))
1031 { 1031 {
1032 mlen = XSTRING_LENGTH (XCODING_SYSTEM_MNEMONIC (codesys)); 1032 mlen = XSTRING_LENGTH (XCODING_SYSTEM_MNEMONIC (codesys));
1033 codesys_mnemonic = (Intbyte *) ALLOCA (mlen + 7); 1033 codesys_mnemonic = (Ibyte *) ALLOCA (mlen + 7);
1034 memcpy (codesys_mnemonic, 1034 memcpy (codesys_mnemonic,
1035 XSTRING_DATA (XCODING_SYSTEM_MNEMONIC (codesys)), mlen); 1035 XSTRING_DATA (XCODING_SYSTEM_MNEMONIC (codesys)), mlen);
1036 } 1036 }
1037 1037
1038 /* Create three "subsidiary" coding systems, decoding data encoded using 1038 /* Create three "subsidiary" coding systems, decoding data encoded using
1142 type = Qundecided; 1142 type = Qundecided;
1143 meths = decode_coding_system_type (type, ERROR_ME); 1143 meths = decode_coding_system_type (type, ERROR_ME);
1144 1144
1145 if (prefix) 1145 if (prefix)
1146 { 1146 {
1147 Intbyte *newname = 1147 Ibyte *newname =
1148 emacs_sprintf_malloc (NULL, "%s-%s-%d", 1148 emacs_sprintf_malloc (NULL, "%s-%s-%d",
1149 prefix, 1149 prefix,
1150 NILP (name_or_existing) ? (Intbyte *) "nil" : 1150 NILP (name_or_existing) ? (Ibyte *) "nil" :
1151 XSTRING_DATA (Fsymbol_name (XCODING_SYSTEM_NAME 1151 XSTRING_DATA (Fsymbol_name (XCODING_SYSTEM_NAME
1152 (name_or_existing))), 1152 (name_or_existing))),
1153 ++coding_system_tick); 1153 ++coding_system_tick);
1154 name_or_existing = intern_int (newname); 1154 name_or_existing = intern_int (newname);
1155 xfree (newname); 1155 xfree (newname);
1260 we do it the obvious way, because when `chain' creates its 1260 we do it the obvious way, because when `chain' creates its
1261 substreams, the substream containing the coding system we're 1261 substreams, the substream containing the coding system we're
1262 creating will have canonicalization expansion done on it, 1262 creating will have canonicalization expansion done on it,
1263 leading to infinite recursion. So we have to generate a new, 1263 leading to infinite recursion. So we have to generate a new,
1264 internal coding system with the previous value of CANONICAL. */ 1264 internal coding system with the previous value of CANONICAL. */
1265 Intbyte *newname = 1265 Ibyte *newname =
1266 emacs_sprintf_malloc 1266 emacs_sprintf_malloc
1267 (NULL, "internal-eol-copy-%s-%d", 1267 (NULL, "internal-eol-copy-%s-%d",
1268 XSTRING_DATA (Fsymbol_name (name_or_existing)), 1268 XSTRING_DATA (Fsymbol_name (name_or_existing)),
1269 ++coding_system_tick); 1269 ++coding_system_tick);
1270 Lisp_Object newnamesym = intern_int (newname); 1270 Lisp_Object newnamesym = intern_int (newname);
2948 { 2948 {
2949 assert (ch == 0); 2949 assert (ch == 0);
2950 Dynarr_add (dst, c); 2950 Dynarr_add (dst, c);
2951 } 2951 }
2952 #ifdef MULE 2952 #ifdef MULE
2953 else if (intbyte_leading_byte_p (c)) 2953 else if (ibyte_leading_byte_p (c))
2954 { 2954 {
2955 assert (ch == 0); 2955 assert (ch == 0);
2956 if (c == LEADING_BYTE_LATIN_ISO8859_1 || 2956 if (c == LEADING_BYTE_LATIN_ISO8859_1 ||
2957 c == LEADING_BYTE_CONTROL_1) 2957 c == LEADING_BYTE_CONTROL_1)
2958 ch = c; 2958 ch = c;
3108 CODING_STREAM_TYPE_DATA (str, convert_eol); 3108 CODING_STREAM_TYPE_DATA (str, convert_eol);
3109 data->actual = XCODING_SYSTEM_CONVERT_EOL_SUBTYPE (str->codesys); 3109 data->actual = XCODING_SYSTEM_CONVERT_EOL_SUBTYPE (str->codesys);
3110 } 3110 }
3111 3111
3112 static Bytecount 3112 static Bytecount
3113 convert_eol_convert (struct coding_stream *str, const Intbyte *src, 3113 convert_eol_convert (struct coding_stream *str, const Ibyte *src,
3114 unsigned_char_dynarr *dst, Bytecount n) 3114 unsigned_char_dynarr *dst, Bytecount n)
3115 { 3115 {
3116 if (str->direction == CODING_DECODE) 3116 if (str->direction == CODING_DECODE)
3117 { 3117 {
3118 struct convert_eol_coding_stream *data = 3118 struct convert_eol_coding_stream *data =
3119 CODING_STREAM_TYPE_DATA (str, convert_eol); 3119 CODING_STREAM_TYPE_DATA (str, convert_eol);
3120 3120
3121 if (data->actual == EOL_AUTODETECT) 3121 if (data->actual == EOL_AUTODETECT)
3122 { 3122 {
3123 Bytecount n2 = n; 3123 Bytecount n2 = n;
3124 const Intbyte *src2 = src; 3124 const Ibyte *src2 = src;
3125 3125
3126 for (; n2; n2--) 3126 for (; n2; n2--)
3127 { 3127 {
3128 Intbyte c = *src2++; 3128 Ibyte c = *src2++;
3129 if (c == '\n') 3129 if (c == '\n')
3130 { 3130 {
3131 data->actual = EOL_LF; 3131 data->actual = EOL_LF;
3132 break; 3132 break;
3133 } 3133 }
3162 if (data->actual == EOL_LF || data->actual == EOL_AUTODETECT || 3162 if (data->actual == EOL_LF || data->actual == EOL_AUTODETECT ||
3163 (str->eof)) 3163 (str->eof))
3164 Dynarr_add_many (dst, src, n); 3164 Dynarr_add_many (dst, src, n);
3165 else 3165 else
3166 { 3166 {
3167 const Intbyte *end = src + n; 3167 const Ibyte *end = src + n;
3168 while (1) 3168 while (1)
3169 { 3169 {
3170 /* Find the next section with no \r and add it. */ 3170 /* Find the next section with no \r and add it. */
3171 const Intbyte *runstart = src; 3171 const Ibyte *runstart = src;
3172 src = (Intbyte *) memchr (src, '\r', end - src); 3172 src = (Ibyte *) memchr (src, '\r', end - src);
3173 if (!src) 3173 if (!src)
3174 src = end; 3174 src = end;
3175 Dynarr_add_many (dst, runstart, src - runstart); 3175 Dynarr_add_many (dst, runstart, src - runstart);
3176 /* Stop if at end ... */ 3176 /* Stop if at end ... */
3177 if (src == end) 3177 if (src == end)
3199 } 3199 }
3200 else 3200 else
3201 { 3201 {
3202 enum eol_type subtype = 3202 enum eol_type subtype =
3203 XCODING_SYSTEM_CONVERT_EOL_SUBTYPE (str->codesys); 3203 XCODING_SYSTEM_CONVERT_EOL_SUBTYPE (str->codesys);
3204 const Intbyte *end = src + n; 3204 const Ibyte *end = src + n;
3205 3205
3206 /* We try to be relatively efficient here. */ 3206 /* We try to be relatively efficient here. */
3207 if (subtype == EOL_LF) 3207 if (subtype == EOL_LF)
3208 Dynarr_add_many (dst, src, n); 3208 Dynarr_add_many (dst, src, n);
3209 else 3209 else
3210 { 3210 {
3211 while (1) 3211 while (1)
3212 { 3212 {
3213 /* Find the next section with no \n and add it. */ 3213 /* Find the next section with no \n and add it. */
3214 const Intbyte *runstart = src; 3214 const Ibyte *runstart = src;
3215 src = (Intbyte *) memchr (src, '\n', end - src); 3215 src = (Ibyte *) memchr (src, '\n', end - src);
3216 if (!src) 3216 if (!src)
3217 src = end; 3217 src = end;
3218 Dynarr_add_many (dst, runstart, src - runstart); 3218 Dynarr_add_many (dst, runstart, src - runstart);
3219 /* Stop if at end ... */ 3219 /* Stop if at end ... */
3220 if (src == end) 3220 if (src == end)
3787 || (*(p-1) == ' ' || 3787 || (*(p-1) == ' ' ||
3788 *(p-1) == '\t' || 3788 *(p-1) == '\t' ||
3789 *(p-1) == ';'))) 3789 *(p-1) == ';')))
3790 { 3790 {
3791 Bytecount n; 3791 Bytecount n;
3792 Intbyte *name; 3792 Ibyte *name;
3793 3793
3794 p += LENGTH ("coding:"); 3794 p += LENGTH ("coding:");
3795 while (*p == ' ' || *p == '\t') p++; 3795 while (*p == ' ' || *p == '\t') p++;
3796 name = alloca_intbytes (suffix - p + 1); 3796 name = alloca_ibytes (suffix - p + 1);
3797 memcpy (name, p, suffix - p); 3797 memcpy (name, p, suffix - p);
3798 name[suffix - p] = '\0'; 3798 name[suffix - p] = '\0';
3799 3799
3800 /* Get coding system name */ 3800 /* Get coding system name */
3801 /* Characters valid in a MIME charset name (rfc 1521), 3801 /* Characters valid in a MIME charset name (rfc 1521),