/* Record indices of function doc strings stored in a file.
Copyright (C) 1985, 1986, 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2001,
- 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+ 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc.
This file is part of GNU Emacs.
#include <sys/file.h> /* Must be after sys/types.h for USG*/
#include <ctype.h>
#include <setjmp.h>
-
-#ifdef HAVE_FCNTL_H
#include <fcntl.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
#include <unistd.h>
-#endif
-
-#ifndef O_RDONLY
-#define O_RDONLY 0
-#endif
#include "lisp.h"
#include "buffer.h"
#include "keymap.h"
#include "buildobj.h"
-#ifdef HAVE_INDEX
-extern char *index (const char *, int);
-#endif
-
-Lisp_Object Vdoc_file_name;
-
Lisp_Object Qfunction_documentation;
-/* A list of files used to build this Emacs binary. */
-static Lisp_Object Vbuild_files;
-
-extern Lisp_Object Voverriding_local_map;
-
-extern Lisp_Object Qremap;
-
/* Buffer used for reading from documentation file. */
static char *get_doc_string_buffer;
static int get_doc_string_buffer_size;
register int fd;
register char *name;
register char *p, *p1;
- int minsize;
- int offset, position;
+ EMACS_INT minsize;
+ EMACS_INT offset, position;
Lisp_Object file, tem;
if (INTEGERP (filepos))
}
else
{
- name = (char *) SDATA (file);
+ name = SSDATA (file);
}
fd = emacs_open (name, O_RDONLY, 0);
p = get_doc_string_buffer;
while (1)
{
- int space_left = (get_doc_string_buffer_size
- - (p - get_doc_string_buffer));
+ EMACS_INT space_left = (get_doc_string_buffer_size
+ - (p - get_doc_string_buffer));
int nread;
/* Allocate or grow the buffer if we need to. */
if (space_left == 0)
{
- int in_buffer = p - get_doc_string_buffer;
+ EMACS_INT in_buffer = p - get_doc_string_buffer;
get_doc_string_buffer_size += 16 * 1024;
get_doc_string_buffer
= (char *) xrealloc (get_doc_string_buffer,
if (!nread)
break;
if (p == get_doc_string_buffer)
- p1 = (char *) index (p + offset, '\037');
+ p1 = strchr (p + offset, '\037');
else
- p1 = (char *) index (p, '\037');
+ p1 = strchr (p, '\037');
if (p1)
{
*p1 = 0;
to - (get_doc_string_buffer + offset));
else
{
- /* Let the data determine whether the string is multibyte,
- even if Emacs is running in --unibyte mode. */
- int nchars = multibyte_chars_in_text (get_doc_string_buffer + offset,
- to - (get_doc_string_buffer + offset));
+ /* The data determines whether the string is multibyte. */
+ EMACS_INT nchars = multibyte_chars_in_text (get_doc_string_buffer + offset,
+ to - (get_doc_string_buffer + offset));
return make_string_from_bytes (get_doc_string_buffer + offset,
nchars,
to - (get_doc_string_buffer + offset));
{
int fd;
char buf[1024 + 1];
- register int filled;
- register int pos;
+ register EMACS_INT filled;
+ register EMACS_INT pos;
register char *p, *end;
Lisp_Object sym;
char *name;
for (beg = buildobj; *beg; beg = end)
{
- int len;
+ EMACS_INT len;
while (*beg && isspace (*beg)) ++beg;
p = buf;
end = buf + (filled < 512 ? filled : filled - 128);
while (p != end && *p != '\037') p++;
- /* p points to ^_Ffunctionname\n or ^_Vvarname\n. */
+ /* p points to ^_Ffunctionname\n or ^_Vvarname\n or ^_Sfilename\n. */
if (p != end)
{
- end = (char *) index (p, '\n');
+ end = strchr (p, '\n');
/* See if this is a file name, and if it is a file in build-files. */
- if (p[1] == 'S' && end - p > 4 && end[-2] == '.'
- && (end[-1] == 'o' || end[-1] == 'c'))
+ if (p[1] == 'S')
{
- int len = end - p - 2;
- char *fromfile = alloca (len + 1);
- strncpy (fromfile, &p[2], len);
- fromfile[len] = 0;
- if (fromfile[len-1] == 'c')
- fromfile[len-1] = 'o';
-
- skip_file = NILP (Fmember (build_string (fromfile),
- Vbuild_files));
+ skip_file = 0;
+ if (end - p > 4 && end[-2] == '.'
+ && (end[-1] == 'o' || end[-1] == 'c'))
+ {
+ EMACS_INT len = end - p - 2;
+ char *fromfile = alloca (len + 1);
+ strncpy (fromfile, &p[2], len);
+ fromfile[len] = 0;
+ if (fromfile[len-1] == 'c')
+ fromfile[len-1] = 'o';
+
+ skip_file = NILP (Fmember (build_string (fromfile),
+ Vbuild_files));
+ }
}
sym = oblookup (Vobarray, p + 2,
}
pos += end - buf;
filled -= end - buf;
- memcpy (buf, end, filled);
+ memmove (buf, end, filled);
}
emacs_close (fd);
return Qnil;
int changed = 0;
register unsigned char *strp;
register unsigned char *bufp;
- int idx;
- int bsize;
+ EMACS_INT idx;
+ EMACS_INT bsize;
Lisp_Object tem;
Lisp_Object keymap;
unsigned char *start;
- int length, length_byte;
+ EMACS_INT length, length_byte;
Lisp_Object name;
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
int multibyte;
- int nchars;
+ EMACS_INT nchars;
if (NILP (string))
return Qnil;
}
else if (strp[0] == '\\' && strp[1] == '[')
{
- int start_idx;
+ EMACS_INT start_idx;
int follow_remap = 1;
changed = 1;
if (NILP (tem)) /* but not on any keys */
{
- int offset = bufp - buf;
+ EMACS_INT offset = bufp - buf;
buf = (unsigned char *) xrealloc (buf, bsize += 4);
bufp = buf + offset;
memcpy (bufp, "M-x ", 4);
else if (strp[0] == '\\' && (strp[1] == '{' || strp[1] == '<'))
{
struct buffer *oldbuf;
- int start_idx;
+ EMACS_INT start_idx;
/* This is for computing the SHADOWS arg for describe_map_tree. */
Lisp_Object active_maps = Fcurrent_active_maps (Qnil, Qnil);
Lisp_Object earlier_maps;
length_byte = SBYTES (tem);
subst:
{
- int offset = bufp - buf;
+ EMACS_INT offset = bufp - buf;
buf = (unsigned char *) xrealloc (buf, bsize += length_byte);
bufp = buf + offset;
memcpy (bufp, start, length_byte);
bufp += length_byte;
nchars += length;
/* Check STRING again in case gc relocated it. */
- strp = (unsigned char *) SDATA (string) + idx;
+ strp = SDATA (string) + idx;
}
}
else if (! multibyte) /* just copy other chars */
Qfunction_documentation = intern_c_string ("function-documentation");
staticpro (&Qfunction_documentation);
- DEFVAR_LISP ("internal-doc-file-name", &Vdoc_file_name,
+ DEFVAR_LISP ("internal-doc-file-name", Vdoc_file_name,
doc: /* Name of file containing documentation strings of built-in symbols. */);
Vdoc_file_name = Qnil;
- DEFVAR_LISP ("build-files", &Vbuild_files,
+ DEFVAR_LISP ("build-files", Vbuild_files,
doc: /* A list of files used to build this Emacs binary. */);
Vbuild_files = Qnil;
defsubr (&Ssnarf_documentation);
defsubr (&Ssubstitute_command_keys);
}
-
-/* arch-tag: 56281d4d-6949-43e2-be2e-f6517de744ba
- (do not change this comment) */