(set_socket_option, init_process): Use a const pointer.
* lread.c (intern_c_string): New function.
(defvar_kboard, defvar_lisp, defvar_lisp_nopro, defvar_bool)
(defvar_int): Uset it. Make the name const char*.
* lisp.h (defvar_kboard, defvar_lisp, defvar_lisp_nopro, defvar_bool)
(defvar_int): Update prototypes.
(DEFUN, EXFUN): Support for prototypes is now required.
(intern_c_string): New prototype.
(struct Lisp_Subr): Make symbol_name constant.
* font.c (struct table_entry): Remove unused member. Make NAMES
constant.
(weight_table, slant_table, width_table): Make constant.
* emacs.c (struct standard_args): Make name and longname constant.
* character.h (DEFSYM): Use intern_c_string.
+2009-11-06 Dan Nicolaescu <dann@ics.uci.edu>
+
+ * process.c (socket_options): Make it const.
+ (set_socket_option, init_process): Use a const pointer.
+
+ * lread.c (intern_c_string): New function.
+ (defvar_kboard, defvar_lisp, defvar_lisp_nopro, defvar_bool)
+ (defvar_int): Uset it. Make the name const char*.
+
+ * lisp.h (defvar_kboard, defvar_lisp, defvar_lisp_nopro, defvar_bool)
+ (defvar_int): Update prototypes.
+ (DEFUN, EXFUN): Support for prototypes is now required.
+ (intern_c_string): New prototype.
+ (struct Lisp_Subr): Make symbol_name constant.
+
+ * font.c (struct table_entry): Remove unused member. Make NAMES
+ constant.
+ (weight_table, slant_table, width_table): Make constant.
+
+ * emacs.c (struct standard_args): Make name and longname constant.
+
+ * character.h (DEFSYM): Use intern_c_string.
+
2009-11-06 Stefan Monnier <monnier@iro.umontreal.ca>
* alloc.c (make_pure_c_string): New function.
} while (0)
#define DEFSYM(sym, name) \
- do { (sym) = intern ((name)); staticpro (&(sym)); } while (0)
+ do { (sym) = intern_c_string ((name)); staticpro (&(sym)); } while (0)
#endif /* EMACS_CHARACTER_H */
struct standard_args
{
- char *name;
- char *longname;
+ const char *name;
+ const char *longname;
int priority;
int nargs;
};
-struct standard_args standard_args[] =
+const struct standard_args standard_args[] =
{
{ "-version", "--version", 150, 0 },
#ifdef HAVE_SHM
int numeric;
/* The first one is a valid name as a face attribute.
The second one (if any) is a typical name in XLFD field. */
- char *names[5];
- Lisp_Object *symbols;
+ const char *names[5];
};
/* Table of weight numeric values and their names. This table must be
sorted by numeric values in ascending order. */
-static struct table_entry weight_table[] =
+static const struct table_entry weight_table[] =
{
{ 0, { "thin" }},
{ 20, { "ultra-light", "ultralight" }},
/* Table of slant numeric values and their names. This table must be
sorted by numeric values in ascending order. */
-static struct table_entry slant_table[] =
+static const struct table_entry slant_table[] =
{
{ 0, { "reverse-oblique", "ro" }},
{ 10, { "reverse-italic", "ri" }},
/* Table of width numeric values and their names. This table must be
sorted by numeric values in ascending order. */
-static struct table_entry width_table[] =
+static const struct table_entry width_table[] =
{
{ 50, { "ultra-condensed", "ultracondensed" }},
{ 63, { "extra-condensed", "extracondensed" }},
EMACS_UINT size;
Lisp_Object (*function) ();
short min_args, max_args;
- char *symbol_name;
+ const char *symbol_name;
char *intspec;
char *doc;
};
A null string means call interactively with no arguments.
`doc' is documentation for the user. */
-#if (!defined (__STDC__) && !defined (PROTOTYPES))
-
-#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \
- Lisp_Object fnname (); \
- DECL_ALIGN (struct Lisp_Subr, sname) = \
- { PVEC_SUBR | (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)), \
- fnname, minargs, maxargs, lname, intspec, 0}; \
- Lisp_Object fnname
-
-#else
-
/* This version of DEFUN declares a function prototype with the right
arguments, so we can catch errors with maxargs at compile-time. */
#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \
Lisp_Object, Lisp_Object, Lisp_Object)
#define DEFUN_ARGS_8 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, \
Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object)
-#endif
-
/* Non-zero if OBJ is a Lisp function. */
#define FUNCTIONP(OBJ) \
#define MANY -2
#define UNEVALLED -1
-extern void defvar_lisp P_ ((char *, Lisp_Object *));
-extern void defvar_lisp_nopro P_ ((char *, Lisp_Object *));
-extern void defvar_bool P_ ((char *, int *));
-extern void defvar_int P_ ((char *, EMACS_INT *));
-extern void defvar_kboard P_ ((char *, int));
+extern void defvar_lisp (const char *, Lisp_Object *);
+extern void defvar_lisp_nopro (const char *, Lisp_Object *);
+extern void defvar_bool (const char *, int *);
+extern void defvar_int (const char *, EMACS_INT *);
+extern void defvar_kboard (const char *, int);
/* Macros we use to define forwarded Lisp variables.
These are used in the syms_of_FILENAME functions. */
\f
/* Declare a Lisp-callable function. The MAXARGS parameter has the same
meaning as in the DEFUN macro, and is used to construct a prototype. */
-#if (!defined (__STDC__) && !defined (PROTOTYPES))
-#define EXFUN(fnname, maxargs) \
- extern Lisp_Object fnname ()
-#else
/* We can use the same trick as in the DEFUN macro to generate the
appropriate prototype. */
#define EXFUN(fnname, maxargs) \
extern Lisp_Object fnname DEFUN_ARGS_ ## maxargs
-#endif
/* Forward declarations for prototypes. */
struct window;
extern Lisp_Object make_specified_string P_ ((const char *, int, int, int));
EXFUN (Fpurecopy, 1);
extern Lisp_Object make_pure_string P_ ((char *, int, int, int));
+extern Lisp_Object make_pure_c_string (const char *data);
extern Lisp_Object pure_cons P_ ((Lisp_Object, Lisp_Object));
extern Lisp_Object make_pure_vector P_ ((EMACS_INT));
EXFUN (Fgarbage_collect, 0);
EXFUN (Feval_region, 4);
extern Lisp_Object check_obarray P_ ((Lisp_Object));
extern Lisp_Object intern P_ ((const char *));
+extern Lisp_Object intern_c_string (const char *);
extern Lisp_Object make_symbol P_ ((char *));
extern Lisp_Object oblookup P_ ((Lisp_Object, const char *, int, int));
#define LOADHIST_ATTACH(x) \
return Fintern (make_string (str, len), obarray);
}
+Lisp_Object
+intern_c_string (const char *str)
+{
+ Lisp_Object tem;
+ int len = strlen (str);
+ Lisp_Object obarray;
+
+ obarray = Vobarray;
+ if (!VECTORP (obarray) || XVECTOR (obarray)->size == 0)
+ obarray = check_obarray (obarray);
+ tem = oblookup (obarray, str, len, len);
+ if (SYMBOLP (tem))
+ return tem;
+
+ if (NILP (Vpurify_flag))
+ /* Creating a non-pure string from a string literal not
+ implemented yet. We could just use make_string here and live
+ with the extra copy. */
+ abort ();
+
+ return Fintern (make_pure_c_string (str), obarray);
+}
+
/* Create an uninterned symbol with name STR. */
Lisp_Object
to a C variable of type int. Sample call:
DEFVAR_INT ("emacs-priority", &emacs_priority, "Documentation"); */
void
-defvar_int (namestring, address)
- char *namestring;
- EMACS_INT *address;
+defvar_int (const char *namestring, EMACS_INT *address)
{
Lisp_Object sym, val;
- sym = intern (namestring);
+ sym = intern_c_string (namestring);
val = allocate_misc ();
XMISCTYPE (val) = Lisp_Misc_Intfwd;
XINTFWD (val)->intvar = address;
/* Similar but define a variable whose value is t if address contains 1,
nil if address contains 0. */
void
-defvar_bool (namestring, address)
- char *namestring;
- int *address;
+defvar_bool (const char *namestring, int *address)
{
Lisp_Object sym, val;
- sym = intern (namestring);
+ sym = intern_c_string (namestring);
val = allocate_misc ();
XMISCTYPE (val) = Lisp_Misc_Boolfwd;
XBOOLFWD (val)->boolvar = address;
gc-marked for some other reason, since marking the same slot twice
can cause trouble with strings. */
void
-defvar_lisp_nopro (namestring, address)
- char *namestring;
- Lisp_Object *address;
+defvar_lisp_nopro (const char *namestring, Lisp_Object *address)
{
Lisp_Object sym, val;
- sym = intern (namestring);
+ sym = intern_c_string (namestring);
val = allocate_misc ();
XMISCTYPE (val) = Lisp_Misc_Objfwd;
XOBJFWD (val)->objvar = address;
}
void
-defvar_lisp (namestring, address)
- char *namestring;
- Lisp_Object *address;
+defvar_lisp (const char *namestring, Lisp_Object *address)
{
defvar_lisp_nopro (namestring, address);
staticpro (address);
at a particular offset in the current kboard object. */
void
-defvar_kboard (namestring, offset)
- char *namestring;
- int offset;
+defvar_kboard (const char *namestring, int offset)
{
Lisp_Object sym, val;
- sym = intern (namestring);
+ sym = intern_c_string (namestring);
val = allocate_misc ();
XMISCTYPE (val) = Lisp_Misc_Kboard_Objfwd;
XKBOARD_OBJFWD (val)->offset = offset;
#endif
\f
-static struct socket_options {
+static const struct socket_options {
/* The name of this option. Should be lowercase version of option
name without SO_ prefix. */
char *name;
Lisp_Object opt, val;
{
char *name;
- struct socket_options *sopt;
+ const struct socket_options *sopt;
int ret = 0;
CHECK_SYMBOL (opt);
#ifdef HAVE_SOCKETS
{
Lisp_Object subfeatures = Qnil;
- struct socket_options *sopt;
+ const struct socket_options *sopt;
#define ADD_SUBFEATURE(key, val) \
subfeatures = Fcons (Fcons (key, Fcons (val, Qnil)), subfeatures)