#include <config.h>
+#include <errno.h>
#include <sys/types.h>
#include <sys/file.h> /* Must be after sys/types.h for USG. */
#include <fcntl.h>
int offset;
EMACS_INT position;
Lisp_Object file, tem, pos;
+ ptrdiff_t count;
USE_SAFE_ALLOCA;
if (INTEGERP (filepos))
}
#endif
if (fd < 0)
- return concat3 (build_string ("Cannot open doc string file \""),
- file, build_string ("\"\n"));
+ {
+ SAFE_FREE ();
+ return concat3 (build_string ("Cannot open doc string file \""),
+ file, build_string ("\"\n"));
+ }
}
+ count = SPECPDL_INDEX ();
+ record_unwind_protect_int (close_file_unwind, fd);
/* Seek only to beginning of disk block. */
/* Make sure we read at least 1024 bytes before `position'
offset = min (position, max (1024, position % (8 * 1024)));
if (TYPE_MAXIMUM (off_t) < position
|| lseek (fd, position - offset, 0) < 0)
- {
- emacs_close (fd);
- error ("Position %"pI"d out of range in doc string file \"%s\"",
- position, name);
- }
-
- SAFE_FREE ();
+ error ("Position %"pI"d out of range in doc string file \"%s\"",
+ position, name);
/* Read the doc string into get_doc_string_buffer.
P points beyond the data just read. */
space_left = 1024 * 8;
nread = emacs_read (fd, p, space_left);
if (nread < 0)
- {
- emacs_close (fd);
- error ("Read error on documentation file");
- }
+ report_file_error ("Read error on documentation file", file);
p[nread] = 0;
if (!nread)
break;
}
p += nread;
}
- emacs_close (fd);
+ unbind_to (count, Qnil);
+ SAFE_FREE ();
/* Sanity checking. */
if (CONSP (filepos))
Lisp_Object sym;
char *p, *name;
bool skip_file = 0;
+ ptrdiff_t count;
CHECK_STRING (filename);
fd = emacs_open (name, O_RDONLY, 0);
if (fd < 0)
- report_file_error ("Opening doc string file", build_string (name));
+ {
+ int open_errno = errno;
+ report_file_errno ("Opening doc string file", build_string (name),
+ open_errno);
+ }
+ count = SPECPDL_INDEX ();
+ record_unwind_protect_int (close_file_unwind, fd);
Vdoc_file_name = filename;
filled = 0;
pos = 0;
filled -= end - buf;
memmove (buf, end, filled);
}
- emacs_close (fd);
- return Qnil;
+ return unbind_to (count, Qnil);
}
\f
DEFUN ("substitute-command-keys", Fsubstitute_command_keys,
If this one's not active, get nil. */
earlier_maps = Fcdr (Fmemq (tem, Freverse (active_maps)));
describe_map_tree (tem, 1, Fnreverse (earlier_maps),
- Qnil, (char *)0, 1, 0, 0, 1);
+ Qnil, 0, 1, 0, 0, 1);
}
tem = Fbuffer_string ();
Ferase_buffer ();