changeset 105872:89183b6f6e9d

* 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.
author Dan Nicolaescu <dann@ics.uci.edu>
date Fri, 06 Nov 2009 06:07:46 +0000
parents 1fa408e42f53
children 5626ccae11ed
files src/ChangeLog src/character.h src/emacs.c src/font.c src/lisp.h src/lread.c src/process.c
diffstat 7 files changed, 74 insertions(+), 55 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Fri Nov 06 05:24:28 2009 +0000
+++ b/src/ChangeLog	Fri Nov 06 06:07:46 2009 +0000
@@ -1,3 +1,26 @@
+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.
--- a/src/character.h	Fri Nov 06 05:24:28 2009 +0000
+++ b/src/character.h	Fri Nov 06 06:07:46 2009 +0000
@@ -672,7 +672,7 @@
   } 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 */
 
--- a/src/emacs.c	Fri Nov 06 05:24:28 2009 +0000
+++ b/src/emacs.c	Fri Nov 06 06:07:46 2009 +0000
@@ -1836,13 +1836,13 @@
 
 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
--- a/src/font.c	Fri Nov 06 05:24:28 2009 +0000
+++ b/src/font.c	Fri Nov 06 06:07:46 2009 +0000
@@ -79,14 +79,13 @@
   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" }},
@@ -103,7 +102,7 @@
 /* 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" }},
@@ -115,7 +114,7 @@
 /* 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" }},
--- a/src/lisp.h	Fri Nov 06 05:24:28 2009 +0000
+++ b/src/lisp.h	Fri Nov 06 06:07:46 2009 +0000
@@ -922,7 +922,7 @@
     EMACS_UINT size;
     Lisp_Object (*function) ();
     short min_args, max_args;
-    char *symbol_name;
+    const char *symbol_name;
     char *intspec;
     char *doc;
   };
@@ -1701,17 +1701,6 @@
     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)	\
@@ -1738,8 +1727,6 @@
 			 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)					\
@@ -1755,11 +1742,11 @@
 #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.  */
@@ -2185,15 +2172,10 @@
 
 /* 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;
@@ -2654,6 +2636,7 @@
 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);
@@ -2752,6 +2735,7 @@
 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) \
--- a/src/lread.c	Fri Nov 06 05:24:28 2009 +0000
+++ b/src/lread.c	Fri Nov 06 06:07:46 2009 +0000
@@ -3622,6 +3622,29 @@
   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
@@ -3956,12 +3979,10 @@
    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;
@@ -3971,12 +3992,10 @@
 /* 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;
@@ -3990,12 +4009,10 @@
    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;
@@ -4003,9 +4020,7 @@
 }
 
 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);
@@ -4015,12 +4030,10 @@
    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;
--- a/src/process.c	Fri Nov 06 05:24:28 2009 +0000
+++ b/src/process.c	Fri Nov 06 06:07:46 2009 +0000
@@ -2607,7 +2607,7 @@
 #endif
 
 
-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;
@@ -2658,7 +2658,7 @@
      Lisp_Object opt, val;
 {
   char *name;
-  struct socket_options *sopt;
+  const struct socket_options *sopt;
   int ret = 0;
 
   CHECK_SYMBOL (opt);
@@ -7314,7 +7314,7 @@
 #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)