/* Buffer manipulation primitives for GNU Emacs.
Copyright (C) 1985, 1986, 1987, 1988, 1989, 1993, 1994,
1995, 1997, 1998, 1999, 2000, 2001, 2002,
- 2003, 2004, 2005 Free Software Foundation, Inc.
+ 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Emacs.
#include "keymap.h"
#include "frame.h"
-extern char * get_current_dir_name ();
-
struct buffer *current_buffer; /* the current buffer */
/* First buffer in chain of all buffers (in reverse order of creation).
clone_per_buffer_values (from, to)
struct buffer *from, *to;
{
- Lisp_Object to_buffer, tem;
+ Lisp_Object to_buffer;
int offset;
XSETBUFFER (to_buffer, to);
/* First run the query functions; if any query is answered no,
don't kill the buffer. */
arglist[0] = Qkill_buffer_query_functions;
- if (NILP (Frun_hook_with_args_until_failure (1, arglist)))
+ tem = Frun_hook_with_args_until_failure (1, arglist);
+ if (NILP (tem))
return unbind_to (count, Qnil);
/* Then run the hooks. */
}
}
Fset_buffer (buf);
- if (NILP (norecord))
- /* Why bother ? Fselect_window will do it for us anyway. -stef */
- record_buffer (buf);
Fselect_window (Fdisplay_buffer (buf, other_window, Qnil), norecord);
return buf;
}
init_buffer ()
{
char *pwd;
- struct stat dotstat, pwdstat;
Lisp_Object temp;
- int rc;
+ int len;
#ifdef USE_MMAP_FOR_BUFFERS
{
Fset_buffer_multibyte (Qnil);
pwd = get_current_dir_name ();
-
- if(!pwd)
- fatal ("`get_cwd' failed: %s\n", strerror (errno));
+
+ if (!pwd)
+ fatal ("`get_current_dir_name' failed: %s\n", strerror (errno));
#ifndef VMS
/* Maybe this should really use some standard subroutine
whose definition is filename syntax dependent. */
- rc = strlen (pwd);
- if (!(IS_DIRECTORY_SEP (pwd[rc - 1])))
+ len = strlen (pwd);
+ if (!(IS_DIRECTORY_SEP (pwd[len - 1])))
{
- pwd[rc] = DIRECTORY_SEP;
- pwd[rc + 1] = '\0';
+ /* Grow buffer to add directory separator and '\0'. */
+ pwd = (char *) xrealloc (pwd, len + 2);
+ pwd[len] = DIRECTORY_SEP;
+ pwd[len + 1] = '\0';
}
#endif /* not VMS */
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
+ /* At this moment, we still don't know how to decode the
+ 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);