Detect stdbool.h and add conformant shims if it isn't available

Charybdis requires C99 already, so it's high time we start using
stdbool. I've converted a few pieces of code already.

A lot of the old code that uses YES/NO should probably be updated too
because that's fucking hideous.
This commit is contained in:
Elizabeth Myers 2016-03-08 04:52:31 -06:00
parent b3b7401f13
commit 07554369bd
12 changed files with 34 additions and 23 deletions

View file

@ -120,6 +120,7 @@ AC_DEFINE_DIR([PKGLIBEXECDIR], [pkglibexecdir], [Directory where binaries the IR
dnl Checks for header files.
AC_HEADER_STDC
AC_HEADER_STDBOOL
AC_CHECK_HEADERS([crypt.h sys/resource.h sys/param.h errno.h sys/syslog.h stddef.h sys/wait.h wait.h sys/epoll.h sys/uio.h machine/endian.h])

View file

@ -31,6 +31,8 @@
#define MAXMODEPARAMS 4
#define MAXMODEPARAMSSERV 10
#include <setup.h>
struct Client;
/* mode structure for channels */
@ -258,7 +260,7 @@ void resv_chan_forcepart(const char *name, const char *reason, int temp_time);
extern void set_channel_mode(struct Client *client_p, struct Client *source_p,
struct Channel *chptr, struct membership *msptr, int parc, const char *parv[]);
extern void set_channel_mlock(struct Client *client_p, struct Client *source_p,
struct Channel *chptr, const char *newmlock, int propagate);
struct Channel *chptr, const char *newmlock, bool propagate);
extern struct ChannelMode chmode_table[256];

View file

@ -30,17 +30,6 @@
#define NULL 0
#endif
#ifdef TRUE
#undef TRUE
#endif
#ifdef FALSE
#undef FALSE
#endif
#define FALSE 0
#define TRUE 1
#define HIDEME 2
/* Blah. I use these a lot. -Dianora */
#ifdef YES

View file

@ -169,6 +169,9 @@
/* Define to 1 if you have the `socketpair' function. */
#undef HAVE_SOCKETPAIR
/* Define to 1 if you have the <stdbool.h> header file. */
#undef HAVE_STDBOOL_H
/* Define to 1 if you have the <stddef.h> header file. */
#undef HAVE_STDDEF_H

View file

@ -71,6 +71,22 @@ char *alloca ();
#endif
#ifdef HAVE_STDBOOL_H
# include <stdbool.h>
#else
# ifndef HAVE__BOOL
# ifdef __cplusplus
typedef bool _Bool;
# else
# define _Bool signed char
# endif
# endif
# define bool _Bool
# define false 0
# define true 1
# define __bool_true_false_are_defined 1
#endif
#include <stdio.h>
#include <assert.h>

View file

@ -109,7 +109,7 @@ blwarn:
static void blacklist_dns_callback(const char *result, int status, int aftype, void *vptr)
{
struct BlacklistClient *blcptr = (struct BlacklistClient *) vptr;
int listed = 0;
bool listed = false;
if (blcptr == NULL || blcptr->client_p == NULL)
return;
@ -125,7 +125,7 @@ static void blacklist_dns_callback(const char *result, int status, int aftype, v
if (result != NULL && status)
{
if (blacklist_check_reply(blcptr, result))
listed = TRUE;
listed = true;
}
/* they have a blacklist entry for this client */

View file

@ -1833,7 +1833,7 @@ set_channel_mode(struct Client *client_p, struct Client *source_p,
*/
void
set_channel_mlock(struct Client *client_p, struct Client *source_p,
struct Channel *chptr, const char *newmlock, int propagate)
struct Channel *chptr, const char *newmlock, bool propagate)
{
rb_free(chptr->mode_lock);
chptr->mode_lock = newmlock ? rb_strdup(newmlock) : NULL;

View file

@ -1288,7 +1288,7 @@ exit_remote_client(struct Client *client_p, struct Client *source_p, struct Clie
}
/*
* This assumes IsUnknown(source_p) == TRUE and MyConnect(source_p) == TRUE
* This assumes IsUnknown(source_p) == true and MyConnect(source_p) == true
*/
static int
@ -1466,7 +1466,7 @@ exit_local_server(struct Client *client_p, struct Client *source_p, struct Clien
/*
* This assumes IsPerson(source_p) == TRUE && MyConnect(source_p) == TRUE
* This assumes IsPerson(source_p) == true && MyConnect(source_p) == true
*/
static int

View file

@ -261,7 +261,7 @@ try_connections(void *unused)
struct server_conf *tmp_p;
struct Class *cltmp;
rb_dlink_node *ptr;
int connecting = FALSE;
bool connecting = false;
int confrq = 0;
time_t next = 0;
@ -306,7 +306,7 @@ try_connections(void *unused)
server_p = tmp_p;
/* We connect only one at time... */
connecting = TRUE;
connecting = true;
}
if((next > tmp_p->hold) || (next == 0))

View file

@ -488,7 +488,7 @@ ms_join(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
*modebuf = *parabuf = '\0';
/* since we're dropping our modes, we want to clear the mlock as well. --nenolod */
set_channel_mlock(client_p, source_p, chptr, NULL, FALSE);
set_channel_mlock(client_p, source_p, chptr, NULL, false);
}
if(!IsMember(source_p, chptr))
@ -754,7 +754,7 @@ ms_sjoin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
strcpy(chptr->chname, parv[2]);
/* since we're dropping our modes, we want to clear the mlock as well. --nenolod */
set_channel_mlock(client_p, source_p, chptr, NULL, FALSE);
set_channel_mlock(client_p, source_p, chptr, NULL, false);
}
if(*modebuf != '\0')

View file

@ -235,7 +235,7 @@ ms_mlock(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
return 0;
if(IsServer(source_p))
set_channel_mlock(client_p, source_p, chptr, parv[3], TRUE);
set_channel_mlock(client_p, source_p, chptr, parv[3], true);
return 0;
}

View file

@ -34,7 +34,7 @@
/* List of ircd includes from ../include/ */
#include "stdinc.h"
#include "client.h"
#include "common.h" /* FALSE bleah */
#include "common.h"
#include "ircd.h"
#include "match.h"
#include "numeric.h"