aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDan Nicolaescu2009-11-06 06:07:46 +0000
committerDan Nicolaescu2009-11-06 06:07:46 +0000
commit5e2327cf928d947328b01c87baa79cdaa18c823b (patch)
tree20814f88060de3ef00425d9b3b5a3ce10b4a10c3 /src
parenta56eaaef7c9e641ecf6cc1cfb4cd3341e5118690 (diff)
downloademacs-5e2327cf928d947328b01c87baa79cdaa18c823b.tar.gz
emacs-5e2327cf928d947328b01c87baa79cdaa18c823b.zip
* 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.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog23
-rw-r--r--src/character.h2
-rw-r--r--src/emacs.c6
-rw-r--r--src/font.c9
-rw-r--r--src/lisp.h32
-rw-r--r--src/lread.c51
-rw-r--r--src/process.c6
7 files changed, 74 insertions, 55 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index f79489fe4fa..cde49c410b9 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,26 @@
12009-11-06 Dan Nicolaescu <dann@ics.uci.edu>
2
3 * process.c (socket_options): Make it const.
4 (set_socket_option, init_process): Use a const pointer.
5
6 * lread.c (intern_c_string): New function.
7 (defvar_kboard, defvar_lisp, defvar_lisp_nopro, defvar_bool)
8 (defvar_int): Uset it. Make the name const char*.
9
10 * lisp.h (defvar_kboard, defvar_lisp, defvar_lisp_nopro, defvar_bool)
11 (defvar_int): Update prototypes.
12 (DEFUN, EXFUN): Support for prototypes is now required.
13 (intern_c_string): New prototype.
14 (struct Lisp_Subr): Make symbol_name constant.
15
16 * font.c (struct table_entry): Remove unused member. Make NAMES
17 constant.
18 (weight_table, slant_table, width_table): Make constant.
19
20 * emacs.c (struct standard_args): Make name and longname constant.
21
22 * character.h (DEFSYM): Use intern_c_string.
23
12009-11-06 Stefan Monnier <monnier@iro.umontreal.ca> 242009-11-06 Stefan Monnier <monnier@iro.umontreal.ca>
2 25
3 * alloc.c (make_pure_c_string): New function. 26 * alloc.c (make_pure_c_string): New function.
diff --git a/src/character.h b/src/character.h
index 7b6bcd1a5ae..78065597532 100644
--- a/src/character.h
+++ b/src/character.h
@@ -672,7 +672,7 @@ extern Lisp_Object Vscript_representative_chars;
672 } while (0) 672 } while (0)
673 673
674#define DEFSYM(sym, name) \ 674#define DEFSYM(sym, name) \
675 do { (sym) = intern ((name)); staticpro (&(sym)); } while (0) 675 do { (sym) = intern_c_string ((name)); staticpro (&(sym)); } while (0)
676 676
677#endif /* EMACS_CHARACTER_H */ 677#endif /* EMACS_CHARACTER_H */
678 678
diff --git a/src/emacs.c b/src/emacs.c
index 3f43904fa0c..ce34f11591b 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -1836,13 +1836,13 @@ main (int argc, char **argv)
1836 1836
1837struct standard_args 1837struct standard_args
1838{ 1838{
1839 char *name; 1839 const char *name;
1840 char *longname; 1840 const char *longname;
1841 int priority; 1841 int priority;
1842 int nargs; 1842 int nargs;
1843}; 1843};
1844 1844
1845struct standard_args standard_args[] = 1845const struct standard_args standard_args[] =
1846{ 1846{
1847 { "-version", "--version", 150, 0 }, 1847 { "-version", "--version", 150, 0 },
1848#ifdef HAVE_SHM 1848#ifdef HAVE_SHM
diff --git a/src/font.c b/src/font.c
index 6e33b9bec55..dd9b6d374be 100644
--- a/src/font.c
+++ b/src/font.c
@@ -79,14 +79,13 @@ struct table_entry
79 int numeric; 79 int numeric;
80 /* The first one is a valid name as a face attribute. 80 /* The first one is a valid name as a face attribute.
81 The second one (if any) is a typical name in XLFD field. */ 81 The second one (if any) is a typical name in XLFD field. */
82 char *names[5]; 82 const char *names[5];
83 Lisp_Object *symbols;
84}; 83};
85 84
86/* Table of weight numeric values and their names. This table must be 85/* Table of weight numeric values and their names. This table must be
87 sorted by numeric values in ascending order. */ 86 sorted by numeric values in ascending order. */
88 87
89static struct table_entry weight_table[] = 88static const struct table_entry weight_table[] =
90{ 89{
91 { 0, { "thin" }}, 90 { 0, { "thin" }},
92 { 20, { "ultra-light", "ultralight" }}, 91 { 20, { "ultra-light", "ultralight" }},
@@ -103,7 +102,7 @@ static struct table_entry weight_table[] =
103/* Table of slant numeric values and their names. This table must be 102/* Table of slant numeric values and their names. This table must be
104 sorted by numeric values in ascending order. */ 103 sorted by numeric values in ascending order. */
105 104
106static struct table_entry slant_table[] = 105static const struct table_entry slant_table[] =
107{ 106{
108 { 0, { "reverse-oblique", "ro" }}, 107 { 0, { "reverse-oblique", "ro" }},
109 { 10, { "reverse-italic", "ri" }}, 108 { 10, { "reverse-italic", "ri" }},
@@ -115,7 +114,7 @@ static struct table_entry slant_table[] =
115/* Table of width numeric values and their names. This table must be 114/* Table of width numeric values and their names. This table must be
116 sorted by numeric values in ascending order. */ 115 sorted by numeric values in ascending order. */
117 116
118static struct table_entry width_table[] = 117static const struct table_entry width_table[] =
119{ 118{
120 { 50, { "ultra-condensed", "ultracondensed" }}, 119 { 50, { "ultra-condensed", "ultracondensed" }},
121 { 63, { "extra-condensed", "extracondensed" }}, 120 { 63, { "extra-condensed", "extracondensed" }},
diff --git a/src/lisp.h b/src/lisp.h
index 19950f79055..95759c18f51 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -922,7 +922,7 @@ struct Lisp_Subr
922 EMACS_UINT size; 922 EMACS_UINT size;
923 Lisp_Object (*function) (); 923 Lisp_Object (*function) ();
924 short min_args, max_args; 924 short min_args, max_args;
925 char *symbol_name; 925 const char *symbol_name;
926 char *intspec; 926 char *intspec;
927 char *doc; 927 char *doc;
928 }; 928 };
@@ -1701,17 +1701,6 @@ typedef struct {
1701 A null string means call interactively with no arguments. 1701 A null string means call interactively with no arguments.
1702 `doc' is documentation for the user. */ 1702 `doc' is documentation for the user. */
1703 1703
1704#if (!defined (__STDC__) && !defined (PROTOTYPES))
1705
1706#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \
1707 Lisp_Object fnname (); \
1708 DECL_ALIGN (struct Lisp_Subr, sname) = \
1709 { PVEC_SUBR | (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)), \
1710 fnname, minargs, maxargs, lname, intspec, 0}; \
1711 Lisp_Object fnname
1712
1713#else
1714
1715/* This version of DEFUN declares a function prototype with the right 1704/* This version of DEFUN declares a function prototype with the right
1716 arguments, so we can catch errors with maxargs at compile-time. */ 1705 arguments, so we can catch errors with maxargs at compile-time. */
1717#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \ 1706#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \
@@ -1738,8 +1727,6 @@ typedef struct {
1738 Lisp_Object, Lisp_Object, Lisp_Object) 1727 Lisp_Object, Lisp_Object, Lisp_Object)
1739#define DEFUN_ARGS_8 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, \ 1728#define DEFUN_ARGS_8 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, \
1740 Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object) 1729 Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object)
1741#endif
1742
1743/* Non-zero if OBJ is a Lisp function. */ 1730/* Non-zero if OBJ is a Lisp function. */
1744 1731
1745#define FUNCTIONP(OBJ) \ 1732#define FUNCTIONP(OBJ) \
@@ -1755,11 +1742,11 @@ extern void defsubr P_ ((struct Lisp_Subr *));
1755#define MANY -2 1742#define MANY -2
1756#define UNEVALLED -1 1743#define UNEVALLED -1
1757 1744
1758extern void defvar_lisp P_ ((char *, Lisp_Object *)); 1745extern void defvar_lisp (const char *, Lisp_Object *);
1759extern void defvar_lisp_nopro P_ ((char *, Lisp_Object *)); 1746extern void defvar_lisp_nopro (const char *, Lisp_Object *);
1760extern void defvar_bool P_ ((char *, int *)); 1747extern void defvar_bool (const char *, int *);
1761extern void defvar_int P_ ((char *, EMACS_INT *)); 1748extern void defvar_int (const char *, EMACS_INT *);
1762extern void defvar_kboard P_ ((char *, int)); 1749extern void defvar_kboard (const char *, int);
1763 1750
1764/* Macros we use to define forwarded Lisp variables. 1751/* Macros we use to define forwarded Lisp variables.
1765 These are used in the syms_of_FILENAME functions. */ 1752 These are used in the syms_of_FILENAME functions. */
@@ -2185,15 +2172,10 @@ void staticpro P_ ((Lisp_Object *));
2185 2172
2186/* Declare a Lisp-callable function. The MAXARGS parameter has the same 2173/* Declare a Lisp-callable function. The MAXARGS parameter has the same
2187 meaning as in the DEFUN macro, and is used to construct a prototype. */ 2174 meaning as in the DEFUN macro, and is used to construct a prototype. */
2188#if (!defined (__STDC__) && !defined (PROTOTYPES))
2189#define EXFUN(fnname, maxargs) \
2190 extern Lisp_Object fnname ()
2191#else
2192/* We can use the same trick as in the DEFUN macro to generate the 2175/* We can use the same trick as in the DEFUN macro to generate the
2193 appropriate prototype. */ 2176 appropriate prototype. */
2194#define EXFUN(fnname, maxargs) \ 2177#define EXFUN(fnname, maxargs) \
2195 extern Lisp_Object fnname DEFUN_ARGS_ ## maxargs 2178 extern Lisp_Object fnname DEFUN_ARGS_ ## maxargs
2196#endif
2197 2179
2198/* Forward declarations for prototypes. */ 2180/* Forward declarations for prototypes. */
2199struct window; 2181struct window;
@@ -2654,6 +2636,7 @@ extern Lisp_Object make_string_from_bytes P_ ((const char *, int, int));
2654extern Lisp_Object make_specified_string P_ ((const char *, int, int, int)); 2636extern Lisp_Object make_specified_string P_ ((const char *, int, int, int));
2655EXFUN (Fpurecopy, 1); 2637EXFUN (Fpurecopy, 1);
2656extern Lisp_Object make_pure_string P_ ((char *, int, int, int)); 2638extern Lisp_Object make_pure_string P_ ((char *, int, int, int));
2639extern Lisp_Object make_pure_c_string (const char *data);
2657extern Lisp_Object pure_cons P_ ((Lisp_Object, Lisp_Object)); 2640extern Lisp_Object pure_cons P_ ((Lisp_Object, Lisp_Object));
2658extern Lisp_Object make_pure_vector P_ ((EMACS_INT)); 2641extern Lisp_Object make_pure_vector P_ ((EMACS_INT));
2659EXFUN (Fgarbage_collect, 0); 2642EXFUN (Fgarbage_collect, 0);
@@ -2752,6 +2735,7 @@ extern Lisp_Object read_filtered_event P_ ((int, int, int, int, Lisp_Object));
2752EXFUN (Feval_region, 4); 2735EXFUN (Feval_region, 4);
2753extern Lisp_Object check_obarray P_ ((Lisp_Object)); 2736extern Lisp_Object check_obarray P_ ((Lisp_Object));
2754extern Lisp_Object intern P_ ((const char *)); 2737extern Lisp_Object intern P_ ((const char *));
2738extern Lisp_Object intern_c_string (const char *);
2755extern Lisp_Object make_symbol P_ ((char *)); 2739extern Lisp_Object make_symbol P_ ((char *));
2756extern Lisp_Object oblookup P_ ((Lisp_Object, const char *, int, int)); 2740extern Lisp_Object oblookup P_ ((Lisp_Object, const char *, int, int));
2757#define LOADHIST_ATTACH(x) \ 2741#define LOADHIST_ATTACH(x) \
diff --git a/src/lread.c b/src/lread.c
index ada447f7c50..517f14baf56 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -3622,6 +3622,29 @@ intern (str)
3622 return Fintern (make_string (str, len), obarray); 3622 return Fintern (make_string (str, len), obarray);
3623} 3623}
3624 3624
3625Lisp_Object
3626intern_c_string (const char *str)
3627{
3628 Lisp_Object tem;
3629 int len = strlen (str);
3630 Lisp_Object obarray;
3631
3632 obarray = Vobarray;
3633 if (!VECTORP (obarray) || XVECTOR (obarray)->size == 0)
3634 obarray = check_obarray (obarray);
3635 tem = oblookup (obarray, str, len, len);
3636 if (SYMBOLP (tem))
3637 return tem;
3638
3639 if (NILP (Vpurify_flag))
3640 /* Creating a non-pure string from a string literal not
3641 implemented yet. We could just use make_string here and live
3642 with the extra copy. */
3643 abort ();
3644
3645 return Fintern (make_pure_c_string (str), obarray);
3646}
3647
3625/* Create an uninterned symbol with name STR. */ 3648/* Create an uninterned symbol with name STR. */
3626 3649
3627Lisp_Object 3650Lisp_Object
@@ -3956,12 +3979,10 @@ defalias (sname, string)
3956 to a C variable of type int. Sample call: 3979 to a C variable of type int. Sample call:
3957 DEFVAR_INT ("emacs-priority", &emacs_priority, "Documentation"); */ 3980 DEFVAR_INT ("emacs-priority", &emacs_priority, "Documentation"); */
3958void 3981void
3959defvar_int (namestring, address) 3982defvar_int (const char *namestring, EMACS_INT *address)
3960 char *namestring;
3961 EMACS_INT *address;
3962{ 3983{
3963 Lisp_Object sym, val; 3984 Lisp_Object sym, val;
3964 sym = intern (namestring); 3985 sym = intern_c_string (namestring);
3965 val = allocate_misc (); 3986 val = allocate_misc ();
3966 XMISCTYPE (val) = Lisp_Misc_Intfwd; 3987 XMISCTYPE (val) = Lisp_Misc_Intfwd;
3967 XINTFWD (val)->intvar = address; 3988 XINTFWD (val)->intvar = address;
@@ -3971,12 +3992,10 @@ defvar_int (namestring, address)
3971/* Similar but define a variable whose value is t if address contains 1, 3992/* Similar but define a variable whose value is t if address contains 1,
3972 nil if address contains 0. */ 3993 nil if address contains 0. */
3973void 3994void
3974defvar_bool (namestring, address) 3995defvar_bool (const char *namestring, int *address)
3975 char *namestring;
3976 int *address;
3977{ 3996{
3978 Lisp_Object sym, val; 3997 Lisp_Object sym, val;
3979 sym = intern (namestring); 3998 sym = intern_c_string (namestring);
3980 val = allocate_misc (); 3999 val = allocate_misc ();
3981 XMISCTYPE (val) = Lisp_Misc_Boolfwd; 4000 XMISCTYPE (val) = Lisp_Misc_Boolfwd;
3982 XBOOLFWD (val)->boolvar = address; 4001 XBOOLFWD (val)->boolvar = address;
@@ -3990,12 +4009,10 @@ defvar_bool (namestring, address)
3990 gc-marked for some other reason, since marking the same slot twice 4009 gc-marked for some other reason, since marking the same slot twice
3991 can cause trouble with strings. */ 4010 can cause trouble with strings. */
3992void 4011void
3993defvar_lisp_nopro (namestring, address) 4012defvar_lisp_nopro (const char *namestring, Lisp_Object *address)
3994 char *namestring;
3995 Lisp_Object *address;
3996{ 4013{
3997 Lisp_Object sym, val; 4014 Lisp_Object sym, val;
3998 sym = intern (namestring); 4015 sym = intern_c_string (namestring);
3999 val = allocate_misc (); 4016 val = allocate_misc ();
4000 XMISCTYPE (val) = Lisp_Misc_Objfwd; 4017 XMISCTYPE (val) = Lisp_Misc_Objfwd;
4001 XOBJFWD (val)->objvar = address; 4018 XOBJFWD (val)->objvar = address;
@@ -4003,9 +4020,7 @@ defvar_lisp_nopro (namestring, address)
4003} 4020}
4004 4021
4005void 4022void
4006defvar_lisp (namestring, address) 4023defvar_lisp (const char *namestring, Lisp_Object *address)
4007 char *namestring;
4008 Lisp_Object *address;
4009{ 4024{
4010 defvar_lisp_nopro (namestring, address); 4025 defvar_lisp_nopro (namestring, address);
4011 staticpro (address); 4026 staticpro (address);
@@ -4015,12 +4030,10 @@ defvar_lisp (namestring, address)
4015 at a particular offset in the current kboard object. */ 4030 at a particular offset in the current kboard object. */
4016 4031
4017void 4032void
4018defvar_kboard (namestring, offset) 4033defvar_kboard (const char *namestring, int offset)
4019 char *namestring;
4020 int offset;
4021{ 4034{
4022 Lisp_Object sym, val; 4035 Lisp_Object sym, val;
4023 sym = intern (namestring); 4036 sym = intern_c_string (namestring);
4024 val = allocate_misc (); 4037 val = allocate_misc ();
4025 XMISCTYPE (val) = Lisp_Misc_Kboard_Objfwd; 4038 XMISCTYPE (val) = Lisp_Misc_Kboard_Objfwd;
4026 XKBOARD_OBJFWD (val)->offset = offset; 4039 XKBOARD_OBJFWD (val)->offset = offset;
diff --git a/src/process.c b/src/process.c
index c2fe343ee2d..7cb85d73aad 100644
--- a/src/process.c
+++ b/src/process.c
@@ -2607,7 +2607,7 @@ Returns nil upon error setting address, ADDRESS otherwise. */)
2607#endif 2607#endif
2608 2608
2609 2609
2610static struct socket_options { 2610static const struct socket_options {
2611 /* The name of this option. Should be lowercase version of option 2611 /* The name of this option. Should be lowercase version of option
2612 name without SO_ prefix. */ 2612 name without SO_ prefix. */
2613 char *name; 2613 char *name;
@@ -2658,7 +2658,7 @@ set_socket_option (s, opt, val)
2658 Lisp_Object opt, val; 2658 Lisp_Object opt, val;
2659{ 2659{
2660 char *name; 2660 char *name;
2661 struct socket_options *sopt; 2661 const struct socket_options *sopt;
2662 int ret = 0; 2662 int ret = 0;
2663 2663
2664 CHECK_SYMBOL (opt); 2664 CHECK_SYMBOL (opt);
@@ -7314,7 +7314,7 @@ init_process ()
7314#ifdef HAVE_SOCKETS 7314#ifdef HAVE_SOCKETS
7315 { 7315 {
7316 Lisp_Object subfeatures = Qnil; 7316 Lisp_Object subfeatures = Qnil;
7317 struct socket_options *sopt; 7317 const struct socket_options *sopt;
7318 7318
7319#define ADD_SUBFEATURE(key, val) \ 7319#define ADD_SUBFEATURE(key, val) \
7320 subfeatures = Fcons (Fcons (key, Fcons (val, Qnil)), subfeatures) 7320 subfeatures = Fcons (Fcons (key, Fcons (val, Qnil)), subfeatures)