Commit f5d9e83a authored by Paul Eggert's avatar Paul Eggert

Use bool for Emacs Lisp booleans.

This is more natural, and on my platform (GCC 4.7.1 x86-64) it
makes Emacs's text size .03% smaller and presumably a bit faster.
* admin/merge-gnulib (GNULIB_MODULES): Add stdbool.  This documents a
new direct dependency; stdbool was already being used indirectly
via other gnulib modules.
* lib-src/make-docfile.c (enum global_type): Sort values roughly in
decreasing alignment, except put functions last.
(compare_globals): Use this new property of enum global_type.
(write_globals): Use bool, not int, for booleans.
* src/lisp.h: Include <stdbool.h>.
(struct Lisp_Boolfwd, defvar_bool):
* src/lread.c (defvar_bool): Use bool, not int, for Lisp booleans.
* src/regex.c [!emacs]: Include <stdbool.h>.
(false, true): Remove; <stdbool.h> does this for us now.
parent 4abcdac8
2012-08-14 Paul Eggert <eggert@cs.ucla.edu>
Use bool for Emacs Lisp booleans.
* merge-gnulib (GNULIB_MODULES): Add stdbool. This documents a
new direct dependency; stdbool was already being used indirectly
via other gnulib modules.
2012-08-11 Glenn Morris <rgm@gnu.org> 2012-08-11 Glenn Morris <rgm@gnu.org>
* bzrmerge.el (bzrmerge-resolve): Disable local eval:. * bzrmerge.el (bzrmerge-resolve): Disable local eval:.
......
...@@ -32,7 +32,7 @@ GNULIB_MODULES=' ...@@ -32,7 +32,7 @@ GNULIB_MODULES='
filemode getloadavg getopt-gnu gettime gettimeofday filemode getloadavg getopt-gnu gettime gettimeofday
ignore-value intprops largefile lstat ignore-value intprops largefile lstat
manywarnings mktime pselect pthread_sigmask readlink manywarnings mktime pselect pthread_sigmask readlink
socklen stat-time stdalign stdarg stdio socklen stat-time stdalign stdarg stdbool stdio
strftime strtoimax strtoumax symlink sys_stat strftime strtoimax strtoumax symlink sys_stat
sys_time time timespec-add timespec-sub utimens sys_time time timespec-add timespec-sub utimens
warnings warnings
......
2012-08-14 Paul Eggert <eggert@cs.ucla.edu>
* make-docfile.c (enum global_type): Sort values roughly in
decreasing alignment, except put functions last.
(compare_globals): Use this new property of enum global_type.
(write_globals): Use bool, not int, for booleans.
2012-08-10 Glenn Morris <rgm@gnu.org> 2012-08-10 Glenn Morris <rgm@gnu.org>
* make-docfile.c (IF_LINT): * make-docfile.c (IF_LINT):
......
...@@ -545,14 +545,15 @@ write_c_args (FILE *out, char *func, char *buf, int minargs, int maxargs) ...@@ -545,14 +545,15 @@ write_c_args (FILE *out, char *func, char *buf, int minargs, int maxargs)
putc (')', out); putc (')', out);
} }
/* The types of globals. */ /* The types of globals. These are sorted roughly in decreasing alignment
order to avoid allocation gaps, except that functions are last. */
enum global_type enum global_type
{ {
FUNCTION, INVALID,
LISP_OBJECT,
EMACS_INTEGER, EMACS_INTEGER,
BOOLEAN, BOOLEAN,
LISP_OBJECT, FUNCTION,
INVALID
}; };
/* A single global. */ /* A single global. */
...@@ -601,13 +602,8 @@ compare_globals (const void *a, const void *b) ...@@ -601,13 +602,8 @@ compare_globals (const void *a, const void *b)
const struct global *ga = a; const struct global *ga = a;
const struct global *gb = b; const struct global *gb = b;
if (ga->type == FUNCTION) if (ga->type != gb->type)
{ return ga->type - gb->type;
if (gb->type != FUNCTION)
return 1;
}
else if (gb->type == FUNCTION)
return -1;
return strcmp (ga->name, gb->name); return strcmp (ga->name, gb->name);
} }
...@@ -634,7 +630,7 @@ write_globals (void) ...@@ -634,7 +630,7 @@ write_globals (void)
type = "EMACS_INT"; type = "EMACS_INT";
break; break;
case BOOLEAN: case BOOLEAN:
type = "int"; type = "bool";
break; break;
case LISP_OBJECT: case LISP_OBJECT:
type = "Lisp_Object"; type = "Lisp_Object";
......
2012-08-14 Paul Eggert <eggert@cs.ucla.edu>
Use bool, not int, for Lisp booleans.
This is more natural, and on my platform (GCC 4.7.1 x86-64) it
makes Emacs a bit smaller and presumably a bit faster.
* lisp.h: Include <stdbool.h>.
(struct Lisp_Boolfwd, defvar_bool):
* lread.c (defvar_bool): Use bool, not int, for Lisp booleans.
* regex.c [!emacs]: Include <stdbool.h>.
(false, true): Remove; <stdbool.h> does this for us now.
2012-08-14 Chong Yidong <cyd@gnu.org> 2012-08-14 Chong Yidong <cyd@gnu.org>
* character.c (Fcharacterp): Doc fix (Bug#12076). * character.c (Fcharacterp): Doc fix (Bug#12076).
......
...@@ -22,6 +22,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ ...@@ -22,6 +22,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <stdalign.h> #include <stdalign.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdbool.h>
#include <stddef.h> #include <stddef.h>
#include <inttypes.h> #include <inttypes.h>
#include <limits.h> #include <limits.h>
...@@ -1394,7 +1395,7 @@ struct Lisp_Intfwd ...@@ -1394,7 +1395,7 @@ struct Lisp_Intfwd
struct Lisp_Boolfwd struct Lisp_Boolfwd
{ {
enum Lisp_Fwd_Type type; /* = Lisp_Fwd_Bool */ enum Lisp_Fwd_Type type; /* = Lisp_Fwd_Bool */
int *boolvar; bool *boolvar;
}; };
/* Forwarding pointer to a Lisp_Object variable. /* Forwarding pointer to a Lisp_Object variable.
...@@ -1929,7 +1930,7 @@ enum maxargs ...@@ -1929,7 +1930,7 @@ enum maxargs
extern void defvar_lisp (struct Lisp_Objfwd *, const char *, Lisp_Object *); extern void defvar_lisp (struct Lisp_Objfwd *, const char *, Lisp_Object *);
extern void defvar_lisp_nopro (struct Lisp_Objfwd *, const char *, Lisp_Object *); extern void defvar_lisp_nopro (struct Lisp_Objfwd *, const char *, Lisp_Object *);
extern void defvar_bool (struct Lisp_Boolfwd *, const char *, int *); extern void defvar_bool (struct Lisp_Boolfwd *, const char *, bool *);
extern void defvar_int (struct Lisp_Intfwd *, const char *, EMACS_INT *); extern void defvar_int (struct Lisp_Intfwd *, const char *, EMACS_INT *);
extern void defvar_kboard (struct Lisp_Kboard_Objfwd *, const char *, int); extern void defvar_kboard (struct Lisp_Kboard_Objfwd *, const char *, int);
......
...@@ -3987,7 +3987,7 @@ defvar_int (struct Lisp_Intfwd *i_fwd, ...@@ -3987,7 +3987,7 @@ defvar_int (struct Lisp_Intfwd *i_fwd,
nil if address contains 0. */ nil if address contains 0. */
void void
defvar_bool (struct Lisp_Boolfwd *b_fwd, defvar_bool (struct Lisp_Boolfwd *b_fwd,
const char *namestring, int *address) const char *namestring, bool *address)
{ {
Lisp_Object sym; Lisp_Object sym;
sym = intern_c_string (namestring); sym = intern_c_string (namestring);
......
...@@ -248,6 +248,7 @@ xrealloc (void *block, size_t size) ...@@ -248,6 +248,7 @@ xrealloc (void *block, size_t size)
# endif # endif
# define realloc xrealloc # define realloc xrealloc
# include <stdbool.h>
# include <string.h> # include <string.h>
/* Define the syntax stuff for \<, \>, etc. */ /* Define the syntax stuff for \<, \>, etc. */
...@@ -535,8 +536,6 @@ typedef const unsigned char re_char; ...@@ -535,8 +536,6 @@ typedef const unsigned char re_char;
#endif #endif
typedef char boolean; typedef char boolean;
#define false 0
#define true 1
static regoff_t re_match_2_internal (struct re_pattern_buffer *bufp, static regoff_t re_match_2_internal (struct re_pattern_buffer *bufp,
re_char *string1, size_t size1, re_char *string1, size_t size1,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment