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.
This commit is contained in:
Paul Eggert 2012-08-14 10:45:25 -07:00
parent 4abcdac823
commit f5d9e83a70
8 changed files with 39 additions and 18 deletions

View file

@ -1,3 +1,10 @@
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>
* bzrmerge.el (bzrmerge-resolve): Disable local eval:.

View file

@ -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

View file

@ -1,3 +1,10 @@
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>
* make-docfile.c (IF_LINT):

View file

@ -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";

View file

@ -1,3 +1,14 @@
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>
* character.c (Fcharacterp): Doc fix (Bug#12076).

View file

@ -22,6 +22,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <stdalign.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <inttypes.h>
#include <limits.h>
@ -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);

View file

@ -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);

View file

@ -248,6 +248,7 @@ xrealloc (void *block, size_t size)
# endif
# define realloc xrealloc
# include <stdbool.h>
# include <string.h>
/* 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,