summaryrefslogtreecommitdiff
path: root/src/buffer.c
diff options
context:
space:
mode:
authorRomain Francoise <romain@orebokech.com>2005-09-10 19:55:28 +0000
committerRomain Francoise <romain@orebokech.com>2005-09-10 19:55:28 +0000
commit156bdb41309e1a8311190c3c92d8da4548d1e604 (patch)
treee6cc4e5407df44e1883816b90c80dcf6fd581d2b /src/buffer.c
parent2bb8b80c2099dea53d6de3b232120cfcd4bcb45a (diff)
downloademacs-156bdb41309e1a8311190c3c92d8da4548d1e604.tar.gz
(init_buffer): Grow buffer to add directory separator
and terminal zero.
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 448ef87413a..e2805a3d1c2 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -5135,7 +5135,7 @@ init_buffer ()
pwd = get_current_dir_name ();
- if(!pwd)
+ if (!pwd)
fatal ("`get_current_dir_name' failed: %s\n", strerror (errno));
#ifndef VMS
@@ -5144,6 +5144,8 @@ init_buffer ()
rc = strlen (pwd);
if (!(IS_DIRECTORY_SEP (pwd[rc - 1])))
{
+ /* Grow buffer to add directory separator and '\0'. */
+ pwd = (char *) xrealloc (pwd, rc + 2);
pwd[rc] = DIRECTORY_SEP;
pwd[rc + 1] = '\0';
}
@@ -5152,7 +5154,7 @@ init_buffer ()
current_buffer->directory = make_unibyte_string (pwd, strlen (pwd));
if (! NILP (buffer_defaults.enable_multibyte_characters))
/* At this momemnt, we still don't know how to decode the
- direcotry name. So, we keep the bytes in multibyte form so
+ directory name. So, we keep the bytes in multibyte form so
that ENCODE_FILE correctly gets the original bytes. */
current_buffer->directory
= string_to_multibyte (current_buffer->directory);