From f5d9e83a70335308d5c6d18d62a7ac94f4bd431c Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 14 Aug 2012 10:45:25 -0700 Subject: [PATCH] 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 . (struct Lisp_Boolfwd, defvar_bool): * src/lread.c (defvar_bool): Use bool, not int, for Lisp booleans. * src/regex.c [!emacs]: Include . (false, true): Remove; does this for us now. --- admin/ChangeLog | 7 +++++++ admin/merge-gnulib | 2 +- lib-src/ChangeLog | 7 +++++++ lib-src/make-docfile.c | 20 ++++++++------------ src/ChangeLog | 11 +++++++++++ src/lisp.h | 5 +++-- src/lread.c | 2 +- src/regex.c | 3 +-- 8 files changed, 39 insertions(+), 18 deletions(-) diff --git a/admin/ChangeLog b/admin/ChangeLog index 18bb44491a1..c579930d2bf 100644 --- a/admin/ChangeLog +++ b/admin/ChangeLog @@ -1,3 +1,10 @@ +2012-08-14 Paul Eggert + + 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 * bzrmerge.el (bzrmerge-resolve): Disable local eval:. diff --git a/admin/merge-gnulib b/admin/merge-gnulib index 49d194c8033..c5b9eba5ee6 100755 --- a/admin/merge-gnulib +++ b/admin/merge-gnulib @@ -32,7 +32,7 @@ GNULIB_MODULES=' filemode getloadavg getopt-gnu gettime gettimeofday ignore-value intprops largefile lstat 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 sys_time time timespec-add timespec-sub utimens warnings diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 98a7b2529b9..01248e59256 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog @@ -1,3 +1,10 @@ +2012-08-14 Paul Eggert + + * 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 * make-docfile.c (IF_LINT): diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c index dafb7c0afd9..2654387fb37 100644 --- a/lib-src/make-docfile.c +++ b/lib-src/make-docfile.c @@ -545,14 +545,15 @@ write_c_args (FILE *out, char *func, char *buf, int minargs, int maxargs) 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 { - FUNCTION, + INVALID, + LISP_OBJECT, EMACS_INTEGER, BOOLEAN, - LISP_OBJECT, - INVALID + FUNCTION, }; /* A single global. */ @@ -601,13 +602,8 @@ compare_globals (const void *a, const void *b) const struct global *ga = a; const struct global *gb = b; - if (ga->type == FUNCTION) - { - if (gb->type != FUNCTION) - return 1; - } - else if (gb->type == FUNCTION) - return -1; + if (ga->type != gb->type) + return ga->type - gb->type; return strcmp (ga->name, gb->name); } @@ -634,7 +630,7 @@ write_globals (void) type = "EMACS_INT"; break; case BOOLEAN: - type = "int"; + type = "bool"; break; case LISP_OBJECT: type = "Lisp_Object"; diff --git a/src/ChangeLog b/src/ChangeLog index 956d6922d2e..ed711b3a663 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,14 @@ +2012-08-14 Paul Eggert + + 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 . + (struct Lisp_Boolfwd, defvar_bool): + * lread.c (defvar_bool): Use bool, not int, for Lisp booleans. + * regex.c [!emacs]: Include . + (false, true): Remove; does this for us now. + 2012-08-14 Chong Yidong * character.c (Fcharacterp): Doc fix (Bug#12076). diff --git a/src/lisp.h b/src/lisp.h index f6aa46d3f41..a0d47b3895e 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -22,6 +22,7 @@ along with GNU Emacs. If not, see . */ #include #include +#include #include #include #include @@ -1394,7 +1395,7 @@ struct Lisp_Intfwd struct Lisp_Boolfwd { enum Lisp_Fwd_Type type; /* = Lisp_Fwd_Bool */ - int *boolvar; + bool *boolvar; }; /* Forwarding pointer to a Lisp_Object variable. @@ -1929,7 +1930,7 @@ enum maxargs 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_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_kboard (struct Lisp_Kboard_Objfwd *, const char *, int); diff --git a/src/lread.c b/src/lread.c index 3dd13c37f44..72991e92bae 100644 --- a/src/lread.c +++ b/src/lread.c @@ -3987,7 +3987,7 @@ defvar_int (struct Lisp_Intfwd *i_fwd, nil if address contains 0. */ void defvar_bool (struct Lisp_Boolfwd *b_fwd, - const char *namestring, int *address) + const char *namestring, bool *address) { Lisp_Object sym; sym = intern_c_string (namestring); diff --git a/src/regex.c b/src/regex.c index afe3751ea5e..472ef727979 100644 --- a/src/regex.c +++ b/src/regex.c @@ -248,6 +248,7 @@ xrealloc (void *block, size_t size) # endif # define realloc xrealloc +# include # include /* Define the syntax stuff for \<, \>, etc. */ @@ -535,8 +536,6 @@ typedef const unsigned char re_char; #endif typedef char boolean; -#define false 0 -#define true 1 static regoff_t re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, size_t size1, -- 2.11.4.GIT