aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1998-01-09 23:12:05 +0000
committerRichard M. Stallman1998-01-09 23:12:05 +0000
commit60d67b83f26f9fd6d852bada09ecd77301cedff4 (patch)
treeb9addea9c06d65a9a7a3c5e4f07c908d3c5279a5
parentf6fe7bb508d02cd4847d099bee289ccf03015f57 (diff)
downloademacs-60d67b83f26f9fd6d852bada09ecd77301cedff4.tar.gz
emacs-60d67b83f26f9fd6d852bada09ecd77301cedff4.zip
(Fdo_auto_save): Save and restore multibyteness of minibuffer.
(Fwrite_region): Use message_with_string. (auto_save_error, Fdo_auto_save): Likewise. (Ffile_name_directory): Maybe use make_unibyte_string. (Ffile_name_nondirectory): Likewise. (Fsubstitute_in_file_name): Convert substituted envvars to multibyte if necessary. Otherwise use make_unibyte_string. (Finsert_file_contents): Use make_unibyte_string. (double_dollars): Use make_uninit_multibyte_string.
-rw-r--r--src/fileio.c82
1 files changed, 61 insertions, 21 deletions
diff --git a/src/fileio.c b/src/fileio.c
index 50c9662eea3..97691a41d3e 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -409,11 +409,14 @@ on VMS, perhaps instead a string ending in `:', `]' or `>'.")
409 } 409 }
410 CORRECT_DIR_SEPS (beg); 410 CORRECT_DIR_SEPS (beg);
411#endif /* DOS_NT */ 411#endif /* DOS_NT */
412 return make_string (beg, p - beg); 412
413 if (STRING_MULTIBYTE (filename))
414 return make_string (beg, p - beg);
415 return make_unibyte_string (beg, p - beg);
413} 416}
414 417
415DEFUN ("file-name-nondirectory", Ffile_name_nondirectory, Sfile_name_nondirectory, 418DEFUN ("file-name-nondirectory", Ffile_name_nondirectory,
416 1, 1, 0, 419 Sfile_name_nondirectory, 1, 1, 0,
417 "Return file name FILENAME sans its directory.\n\ 420 "Return file name FILENAME sans its directory.\n\
418For example, in a Unix-syntax file name,\n\ 421For example, in a Unix-syntax file name,\n\
419this is everything after the last slash,\n\ 422this is everything after the last slash,\n\
@@ -443,12 +446,16 @@ or the entire name if it contains no slash.")
443 /* only recognise drive specifier at beginning */ 446 /* only recognise drive specifier at beginning */
444 && !(p[-1] == ':' && p == beg + 2) 447 && !(p[-1] == ':' && p == beg + 2)
445#endif 448#endif
446 ) p--; 449 )
450 p--;
447 451
448 return make_string (p, end - p); 452 if (STRING_MULTIBYTE (filename))
453 return make_string (p, end - p);
454 return make_unibyte_string (p, end - p);
449} 455}
450 456
451DEFUN ("unhandled-file-name-directory", Funhandled_file_name_directory, Sunhandled_file_name_directory, 1, 1, 0, 457DEFUN ("unhandled-file-name-directory", Funhandled_file_name_directory,
458 Sunhandled_file_name_directory, 1, 1, 0,
452 "Return a directly usable directory name somehow associated with FILENAME.\n\ 459 "Return a directly usable directory name somehow associated with FILENAME.\n\
453A `directly usable' directory name is one that may be used without the\n\ 460A `directly usable' directory name is one that may be used without the\n\
454intervention of any file handler.\n\ 461intervention of any file handler.\n\
@@ -1932,8 +1939,33 @@ duplicates what `expand-file-name' does.")
1932 if (!o) 1939 if (!o)
1933 goto badvar; 1940 goto badvar;
1934 1941
1935 strcpy (x, o); 1942 if (STRING_MULTIBYTE (filename))
1936 x += strlen (o); 1943 {
1944 /* If the original string is multibyte,
1945 convert what we substitute into multibyte. */
1946 unsigned char workbuf[4], *str;
1947 int len;
1948 extern int nonascii_insert_offset;
1949
1950 while (*o)
1951 {
1952 int c = *o++;
1953 if (c >= 0200)
1954 {
1955 c += nonascii_insert_offset;
1956 len = CHAR_STRING (c, workbuf, str);
1957 bcopy (str, x, len);
1958 x += len;
1959 }
1960 else
1961 *x++ = c;
1962 }
1963 }
1964 else
1965 {
1966 strcpy (x, o);
1967 x += strlen (o);
1968 }
1937 } 1969 }
1938 1970
1939 *x = 0; 1971 *x = 0;
@@ -1956,7 +1988,9 @@ duplicates what `expand-file-name' does.")
1956 xnm = p; 1988 xnm = p;
1957#endif 1989#endif
1958 1990
1959 return make_string (xnm, x - xnm); 1991 if (STRING_MULTIBYTE (filename))
1992 return make_string (xnm, x - xnm);
1993 return make_unibyte_string (xnm, x - xnm);
1960 1994
1961 badsubst: 1995 badsubst:
1962 error ("Bad format environment-variable substitution"); 1996 error ("Bad format environment-variable substitution");
@@ -3260,8 +3294,11 @@ This does code conversion according to the value of\n\
3260 XSTRING (orig_filename)->data, strerror (errno)); 3294 XSTRING (orig_filename)->data, strerror (errno));
3261 else if (nread > 0) 3295 else if (nread > 0)
3262 { 3296 {
3263 val = call1 (Vset_auto_coding_function, 3297 Lisp_Object tem;
3264 make_string (read_buf, nread)); 3298 /* Always make this a unibyte string
3299 because we have not yet decoded it. */
3300 tem = make_unibyte_string (read_buf, nread);
3301 val = call1 (Vset_auto_coding_function, tem);
3265 /* Rewind the file for the actual read done later. */ 3302 /* Rewind the file for the actual read done later. */
3266 if (lseek (fd, 0, 0) < 0) 3303 if (lseek (fd, 0, 0) < 0)
3267 report_file_error ("Setting file position", 3304 report_file_error ("Setting file position",
@@ -4331,7 +4368,7 @@ to the file, instead of any buffer contents, and END is ignored.")
4331 return Qnil; 4368 return Qnil;
4332 4369
4333 if (!auto_saving) 4370 if (!auto_saving)
4334 message ("Wrote %s", XSTRING (visit_file)->data); 4371 message_with_string ("Wrote %s", visit_file, 1);
4335 4372
4336 return Qnil; 4373 return Qnil;
4337} 4374}
@@ -4624,11 +4661,11 @@ Lisp_Object
4624auto_save_error () 4661auto_save_error ()
4625{ 4662{
4626 ring_bell (); 4663 ring_bell ();
4627 message ("Autosaving...error for %s", XSTRING (current_buffer->name)->data); 4664 message_with_string ("Autosaving...error for %s", current_buffer->name, 1);
4628 Fsleep_for (make_number (1), Qnil); 4665 Fsleep_for (make_number (1), Qnil);
4629 message ("Autosaving...error!for %s", XSTRING (current_buffer->name)->data); 4666 message_with_string ("Autosaving...error for %s", current_buffer->name, 0);
4630 Fsleep_for (make_number (1), Qnil); 4667 Fsleep_for (make_number (1), Qnil);
4631 message ("Autosaving...error for %s", XSTRING (current_buffer->name)->data); 4668 message_with_string ("Autosaving...error for %s", current_buffer->name, 0);
4632 Fsleep_for (make_number (1), Qnil); 4669 Fsleep_for (make_number (1), Qnil);
4633 return Qnil; 4670 return Qnil;
4634} 4671}
@@ -4689,6 +4726,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer.")
4689 int auto_saved = 0; 4726 int auto_saved = 0;
4690 char *omessage = echo_area_glyphs; 4727 char *omessage = echo_area_glyphs;
4691 int omessage_length = echo_area_glyphs_length; 4728 int omessage_length = echo_area_glyphs_length;
4729 int oldmultibyte = message_enable_multibyte;
4692 int do_handled_files; 4730 int do_handled_files;
4693 Lisp_Object oquit; 4731 Lisp_Object oquit;
4694 FILE *stream; 4732 FILE *stream;
@@ -4808,8 +4846,8 @@ A non-nil CURRENT-ONLY argument means save only current buffer.")
4808 { 4846 {
4809 /* It has shrunk too much; turn off auto-saving here. */ 4847 /* It has shrunk too much; turn off auto-saving here. */
4810 minibuffer_auto_raise = orig_minibuffer_auto_raise; 4848 minibuffer_auto_raise = orig_minibuffer_auto_raise;
4811 message ("Buffer %s has shrunk a lot; auto save turned off there", 4849 message_with_string ("Buffer %s has shrunk a lot; auto save turned off there",
4812 XSTRING (b->name)->data); 4850 b->name, 1);
4813 minibuffer_auto_raise = 0; 4851 minibuffer_auto_raise = 0;
4814 /* Turn off auto-saving until there's a real save, 4852 /* Turn off auto-saving until there's a real save,
4815 and prevent any more warnings. */ 4853 and prevent any more warnings. */
@@ -4843,7 +4881,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer.")
4843 if (omessage) 4881 if (omessage)
4844 { 4882 {
4845 sit_for (1, 0, 0, 0, 0); 4883 sit_for (1, 0, 0, 0, 0);
4846 message2 (omessage, omessage_length); 4884 message2 (omessage, omessage_length, oldmultibyte);
4847 } 4885 }
4848 else 4886 else
4849 message1 ("Auto-saving...done"); 4887 message1 ("Auto-saving...done");
@@ -4897,14 +4935,16 @@ double_dollars (val)
4897 register int n; 4935 register int n;
4898 int osize, count; 4936 int osize, count;
4899 4937
4900 osize = XSTRING (val)->size; 4938 osize = XSTRING (val)->size_byte;
4901 /* Quote "$" as "$$" to get it past substitute-in-file-name */ 4939
4940 /* Count the number of $ characters. */
4902 for (n = osize, count = 0, old = XSTRING (val)->data; n > 0; n--) 4941 for (n = osize, count = 0, old = XSTRING (val)->data; n > 0; n--)
4903 if (*old++ == '$') count++; 4942 if (*old++ == '$') count++;
4904 if (count > 0) 4943 if (count > 0)
4905 { 4944 {
4906 old = XSTRING (val)->data; 4945 old = XSTRING (val)->data;
4907 val = Fmake_string (make_number (osize + count), make_number (0)); 4946 val = make_uninit_multibyte_string (XSTRING (val)->size + count,
4947 osize + count);
4908 new = XSTRING (val)->data; 4948 new = XSTRING (val)->data;
4909 for (n = osize; n > 0; n--) 4949 for (n = osize; n > 0; n--)
4910 if (*old != '$') 4950 if (*old != '$')