From c9bad331e63f96dd4f17276c069a38ff10765ed7 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sat, 26 May 2018 07:19:18 +0100 Subject: [PATCH] Centralise TRUE and FALSE definitions into defs.h. This removes a lot of pointless duplications of those constants. Of course, _ideally_, I should upgrade to C99 bool throughout the code base, replacing TRUE and FALSE with true and false and tagging variables explicitly as bool when that's what they semantically are. But that's a much bigger piece of work, and shouldn't block this trivial cleanup! --- defs.h | 7 +++++++ misc.h | 7 ------- portfwd.c | 7 ------- raw.c | 7 ------- rlogin.c | 7 ------- ssh.c | 7 ------- sshzlib.c | 14 +++++++++----- telnet.c | 7 ------- unix/uxpty.c | 7 ------- 9 files changed, 16 insertions(+), 54 deletions(-) diff --git a/defs.h b/defs.h index 4a8351fe..27062774 100644 --- a/defs.h +++ b/defs.h @@ -11,6 +11,13 @@ #ifndef PUTTY_DEFS_H #define PUTTY_DEFS_H +#ifndef FALSE +#define FALSE 0 +#endif +#ifndef TRUE +#define TRUE 1 +#endif + typedef struct conf_tag Conf; typedef struct backend_tag Backend; typedef struct terminal_tag Terminal; diff --git a/misc.h b/misc.h index 271d34f1..c4da3d6d 100644 --- a/misc.h +++ b/misc.h @@ -13,13 +13,6 @@ #include /* for va_list */ #include /* for struct tm */ -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef TRUE -#define TRUE 1 -#endif - unsigned long parse_blocksize(const char *bs); char ctrlparse(char *s, char **next); diff --git a/portfwd.c b/portfwd.c index 2512415c..f2652557 100644 --- a/portfwd.c +++ b/portfwd.c @@ -8,13 +8,6 @@ #include "putty.h" #include "ssh.h" -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef TRUE -#define TRUE 1 -#endif - struct PortForwarding { const struct plug_function_table *fn; /* the above variable absolutely *must* be the first in this structure */ diff --git a/raw.c b/raw.c index fbc9018d..d0840a1a 100644 --- a/raw.c +++ b/raw.c @@ -8,13 +8,6 @@ #include "putty.h" -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef TRUE -#define TRUE 1 -#endif - #define RAW_MAX_BACKLOG 4096 typedef struct raw_backend_data { diff --git a/rlogin.c b/rlogin.c index cd6260d2..ccb75119 100644 --- a/rlogin.c +++ b/rlogin.c @@ -9,13 +9,6 @@ #include "putty.h" -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef TRUE -#define TRUE 1 -#endif - #define RLOGIN_MAX_BACKLOG 4096 typedef struct rlogin_tag { diff --git a/ssh.c b/ssh.c index b4482753..f220d5df 100644 --- a/ssh.c +++ b/ssh.c @@ -25,13 +25,6 @@ #define GSS_CTXT_MAYFAIL (1<<3) /* Context may expire during handshake */ #endif -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef TRUE -#define TRUE 1 -#endif - /* * Packet type contexts, so that ssh2_pkt_type can correctly decode * the ambiguous type numbers back into the correct type strings. diff --git a/sshzlib.c b/sshzlib.c index 60447fdf..855ddd86 100644 --- a/sshzlib.c +++ b/sshzlib.c @@ -41,6 +41,8 @@ #include #include +#include "defs.h" + #ifdef ZLIB_STANDALONE /* @@ -57,13 +59,15 @@ #define sresize(x, n, type) ( (type *) realloc((x), (n) * sizeof(type)) ) #define sfree(x) ( free((x)) ) -#else -#include "ssh.h" -#endif - #ifndef FALSE #define FALSE 0 -#define TRUE (!FALSE) +#endif +#ifndef TRUE +#define TRUE 1 +#endif + +#else +#include "ssh.h" #endif /* ---------------------------------------------------------------------- diff --git a/telnet.c b/telnet.c index 8d03cb7b..0857113c 100644 --- a/telnet.c +++ b/telnet.c @@ -8,13 +8,6 @@ #include "putty.h" -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef TRUE -#define TRUE 1 -#endif - #define IAC 255 /* interpret as command: */ #define DONT 254 /* you are not to use option */ #define DO 253 /* please, you use option */ diff --git a/unix/uxpty.c b/unix/uxpty.c index a6069ce6..7aaad8ac 100644 --- a/unix/uxpty.c +++ b/unix/uxpty.c @@ -29,13 +29,6 @@ #include #endif -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef TRUE -#define TRUE 1 -#endif - /* updwtmpx() needs the name of the wtmp file. Try to find it. */ #ifndef WTMPX_FILE #ifdef _PATH_WTMPX