summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2009-06-25 16:47:00 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2009-06-25 16:47:00 +0000
commita9e3d5c56aa515a4a63212ced6433f4612f62e57 (patch)
treeee3a9faad1477f9e1e63f79efc16213c38862d33
parentbb459beb032cfa9473cdef21ef645b350d61728c (diff)
More diff-to-OpenBSD reduction. Move a lot of compat stuff into compat.h.
-rw-r--r--cmd-set-password.c6
-rw-r--r--compat.h211
-rw-r--r--names.c5
-rw-r--r--tmux.c6
-rw-r--r--tmux.h128
-rw-r--r--tty-term.c3
-rw-r--r--tty-write.c3
-rw-r--r--window.c20
-rw-r--r--xmalloc.c24
9 files changed, 222 insertions, 184 deletions
diff --git a/cmd-set-password.c b/cmd-set-password.c
index 3b81d529..b4ea90f3 100644
--- a/cmd-set-password.c
+++ b/cmd-set-password.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-set-password.c,v 1.4 2009-05-14 07:49:23 nicm Exp $ */
+/* $Id: cmd-set-password.c,v 1.5 2009-06-25 16:47:00 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -23,10 +23,6 @@
#include "tmux.h"
-#ifdef HAVE_CRYPT_H
-#include <crypt.h>
-#endif
-
/*
* Set server password.
*/
diff --git a/compat.h b/compat.h
new file mode 100644
index 00000000..5aa3d4f9
--- /dev/null
+++ b/compat.h
@@ -0,0 +1,211 @@
+/* $Id: compat.h,v 1.1 2009-06-25 16:47:00 nicm Exp $ */
+
+/*
+ * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
+ * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef INFTIM
+#define INFTIM -1
+#endif
+
+#ifndef WAIT_ANY
+#define WAIT_ANY -1
+#endif
+
+#ifndef SUN_LEN
+#define SUN_LEN(sun) (sizeof (sun)->sun_path)
+#endif
+
+#ifndef __dead
+#define __dead __attribute__ ((__noreturn__))
+#endif
+#ifndef __packed
+#define __packed __attribute__ ((__packed__))
+#endif
+
+#ifndef timercmp
+#define timercmp(tvp, uvp, cmp) \
+ (((tvp)->tv_sec == (uvp)->tv_sec) ? \
+ ((tvp)->tv_usec cmp (uvp)->tv_usec) : \
+ ((tvp)->tv_sec cmp (uvp)->tv_sec))
+#endif
+
+#ifndef timeradd
+#define timeradd(tvp, uvp, vvp) \
+ do { \
+ (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
+ (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
+ if ((vvp)->tv_usec >= 1000000) { \
+ (vvp)->tv_sec++; \
+ (vvp)->tv_usec -= 1000000; \
+ } \
+ } while (0)
+#endif
+
+#ifndef TTY_NAME_MAX
+#define TTY_NAME_MAX 32
+#endif
+
+#ifndef HAVE_PATHS_H
+#define _PATH_BSHELL "/bin/sh"
+#define _PATH_TMP "/tmp/"
+#define _PATH_DEVNULL "/dev/null"
+#define _PATH_TTY "/dev/tty"
+#endif
+
+#ifdef HAVE_QUEUE_H
+ #include <sys/queue.h>
+#else
+#include "compat/queue.h"
+#endif
+
+#ifdef HAVE_TREE_H
+ #include <sys/tree.h>
+#else
+#include "compat/tree.h"
+#endif
+
+#ifdef HAVE_POLL
+#include <poll.h>
+#else
+#include "compat/bsdpoll.h"
+#endif
+
+#ifdef HAVE_GETOPT
+#include <getopt.h>
+#endif
+
+#ifdef HAVE_CRYPT_H
+#include <crypt.h>
+#endif
+
+#ifdef HAVE_PATHS_H
+#include <paths.h>
+#endif
+
+#ifdef HAVE_FORKPTY
+#ifdef HAVE_LIBUTIL_H
+#include <libutil.h>
+#endif
+#ifdef HAVE_PTY_H
+#include <pty.h>
+#endif
+#ifdef HAVE_UTIL_H
+#include <util.h>
+#endif
+#endif
+
+#ifndef HAVE_STRTONUM
+/* strtonum.c */
+long long strtonum(const char *, long long, long long, const char **);
+#endif
+
+#ifndef HAVE_STRLCPY
+/* strlcpy.c */
+size_t strlcpy(char *, const char *, size_t);
+#endif
+
+#ifndef HAVE_STRLCAT
+/* strlcat.c */
+size_t strlcat(char *, const char *, size_t);
+#endif
+
+#ifndef HAVE_DAEMON
+/* daemon.c */
+int daemon(int, int);
+#endif
+
+#ifndef HAVE_FORKPTY
+/* forkpty.c */
+pid_t forkpty(int *, char *, struct termios *, struct winsize *);
+#endif
+
+#ifndef HAVE_ASPRINTF
+/* asprintf.c */
+int asprintf(char **, const char *, ...);
+int vasprintf(char **, const char *, va_list);
+#endif
+
+#ifndef HAVE_FGETLN
+/* fgetln.c */
+char *fgetln(FILE *, size_t *);
+#endif
+
+#ifndef HAVE_GETOPT
+/* getopt.c */
+extern int BSDopterr;
+extern int BSDoptind;
+extern int BSDoptopt;
+extern int BSDoptreset;
+extern char *BSDoptarg;
+int BSDgetopt(int, char *const *, const char *);
+#define getopt(ac, av, o) BSDgetopt(ac, av, o)
+#define opterr BSDopterr
+#define optind BSDoptind
+#define optopt BSDoptopt
+#define optreset BSDoptreset
+#define optarg BSDoptarg
+#endif
+#ifndef HAVE_STRTONUM
+/* strtonum.c */
+long long strtonum(const char *, long long, long long, const char **);
+#endif
+
+#ifndef HAVE_STRLCPY
+/* strlcpy.c */
+size_t strlcpy(char *, const char *, size_t);
+#endif
+
+#ifndef HAVE_STRLCAT
+/* strlcat.c */
+size_t strlcat(char *, const char *, size_t);
+#endif
+
+#ifndef HAVE_DAEMON
+/* daemon.c */
+int daemon(int, int);
+#endif
+
+#ifndef HAVE_FORKPTY
+/* forkpty.c */
+pid_t forkpty(int *, char *, struct termios *, struct winsize *);
+#endif
+
+#ifndef HAVE_ASPRINTF
+/* asprintf.c */
+int asprintf(char **, const char *, ...);
+int vasprintf(char **, const char *, va_list);
+#endif
+
+#ifndef HAVE_FGETLN
+/* fgetln.c */
+char *fgetln(FILE *, size_t *);
+#endif
+
+#ifndef HAVE_GETOPT
+/* getopt.c */
+extern int BSDopterr;
+extern int BSDoptind;
+extern int BSDoptopt;
+extern int BSDoptreset;
+extern char *BSDoptarg;
+int BSDgetopt(int, char *const *, const char *);
+#define getopt(ac, av, o) BSDgetopt(ac, av, o)
+#define opterr BSDopterr
+#define optind BSDoptind
+#define optopt BSDoptopt
+#define optreset BSDoptreset
+#define optarg BSDoptarg
+#endif
diff --git a/names.c b/names.c
index 02be77aa..293a0c4a 100644
--- a/names.c
+++ b/names.c
@@ -1,4 +1,4 @@
-/* $Id: names.c,v 1.7 2009-06-25 16:21:32 nicm Exp $ */
+/* $Id: names.c,v 1.8 2009-06-25 16:47:00 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -101,9 +101,8 @@ parse_window_name(const char *in)
}
if (*name == '/')
- name = xbasename(name);
+ name = basename(name);
name = xstrdup(name);
xfree(copy);
return (name);
}
-
diff --git a/tmux.c b/tmux.c
index d20bd62a..8fd8e4be 100644
--- a/tmux.c
+++ b/tmux.c
@@ -1,4 +1,4 @@
-/* $Id: tmux.c,v 1.135 2009-06-25 16:34:50 nicm Exp $ */
+/* $Id: tmux.c,v 1.136 2009-06-25 16:47:00 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -29,10 +29,6 @@
#include "tmux.h"
-#ifdef HAVE_PATHS_H
-#include <paths.h>
-#endif
-
#ifdef DEBUG
/* DragonFly uses an OpenBSD-like malloc() since 1.6 */
#if defined(__OpenBSD__) || defined(__DragonFly__)
diff --git a/tmux.h b/tmux.h
index 794220d1..c15c2810 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1,4 +1,4 @@
-/* $Id: tmux.h,v 1.342 2009-06-25 16:34:50 nicm Exp $ */
+/* $Id: tmux.h,v 1.343 2009-06-25 16:47:00 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -20,34 +20,13 @@
#define TMUX_H
#include "config.h"
+#include "compat.h"
#define PROTOCOL_VERSION -13
#include <sys/param.h>
#include <sys/time.h>
-#ifdef HAVE_QUEUE_H
-#include <sys/queue.h>
-#else
-#include "compat/queue.h"
-#endif
-
-#ifdef HAVE_TREE_H
-#include <sys/tree.h>
-#else
-#include "compat/tree.h"
-#endif
-
-#ifdef HAVE_POLL
-#include <poll.h>
-#else
-#include "compat/bsd-poll.h"
-#endif
-
-#ifdef HAVE_GETOPT
-#include <getopt.h>
-#endif
-
#include <bitstring.h>
#include <limits.h>
#include <signal.h>
@@ -60,55 +39,6 @@
extern const char *__progname;
-#ifndef INFTIM
-#define INFTIM -1
-#endif
-
-#ifndef WAIT_ANY
-#define WAIT_ANY -1
-#endif
-
-#ifndef SUN_LEN
-#define SUN_LEN(sun) (sizeof (sun)->sun_path)
-#endif
-
-#ifndef __dead
-#define __dead __attribute__ ((__noreturn__))
-#endif
-#ifndef __packed
-#define __packed __attribute__ ((__packed__))
-#endif
-
-#ifndef timercmp
-#define timercmp(tvp, uvp, cmp) \
- (((tvp)->tv_sec == (uvp)->tv_sec) ? \
- ((tvp)->tv_usec cmp (uvp)->tv_usec) : \
- ((tvp)->tv_sec cmp (uvp)->tv_sec))
-#endif
-
-#ifndef timeradd
-#define timeradd(tvp, uvp, vvp) \
- do { \
- (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
- (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
- if ((vvp)->tv_usec >= 1000000) { \
- (vvp)->tv_sec++; \
- (vvp)->tv_usec -= 1000000; \
- } \
- } while (0)
-#endif
-
-#ifndef TTY_NAME_MAX
-#define TTY_NAME_MAX 32
-#endif
-
-#ifndef HAVE_PATHS_H
-#define _PATH_BSHELL "/bin/sh"
-#define _PATH_TMP "/tmp/"
-#define _PATH_DEVNULL "/dev/null"
-#define _PATH_TTY "/dev/tty"
-#endif
-
/* Default configuration file. */
#define DEFAULT_CFG ".tmux.conf"
@@ -1005,58 +935,6 @@ extern const struct set_option_entry set_window_option_table[];
#define NSETOPTION 25
#define NSETWINDOWOPTION 19
-#ifndef HAVE_STRTONUM
-/* strtonum.c */
-long long strtonum(const char *, long long, long long, const char **);
-#endif
-
-#ifndef HAVE_STRLCPY
-/* strlcpy.c */
-size_t strlcpy(char *, const char *, size_t);
-#endif
-
-#ifndef HAVE_STRLCAT
-/* strlcat.c */
-size_t strlcat(char *, const char *, size_t);
-#endif
-
-#ifndef HAVE_DAEMON
-/* daemon.c */
-int daemon(int, int);
-#endif
-
-#ifndef HAVE_FORKPTY
-/* forkpty.c */
-pid_t forkpty(int *, char *, struct termios *, struct winsize *);
-#endif
-
-#ifndef HAVE_ASPRINTF
-/* asprintf.c */
-int asprintf(char **, const char *, ...);
-int vasprintf(char **, const char *, va_list);
-#endif
-
-#ifndef HAVE_FGETLN
-/* fgetln.c */
-char *fgetln(FILE *, size_t *);
-#endif
-
-#ifndef HAVE_GETOPT
-/* getopt.c */
-extern int BSDopterr;
-extern int BSDoptind;
-extern int BSDoptopt;
-extern int BSDoptreset;
-extern char *BSDoptarg;
-int BSDgetopt(int, char *const *, const char *);
-#define getopt(ac, av, o) BSDgetopt(ac, av, o)
-#define opterr BSDopterr
-#define optind BSDoptind
-#define optopt BSDoptopt
-#define optreset BSDoptreset
-#define optarg BSDoptarg
-#endif
-
/* tmux.c */
extern volatile sig_atomic_t sigwinch;
extern volatile sig_atomic_t sigterm;
@@ -1681,7 +1559,5 @@ int xvasprintf(char **, const char *, va_list);
int printflike3 xsnprintf(char *, size_t, const char *, ...);
int xvsnprintf(char *, size_t, const char *, va_list);
int printflike3 printpath(char *, size_t, const char *, ...);
-char *xdirname(const char *);
-char *xbasename(const char *);
#endif /* TMUX_H */
diff --git a/tty-term.c b/tty-term.c
index 1cb6010f..4a3961c0 100644
--- a/tty-term.c
+++ b/tty-term.c
@@ -1,4 +1,4 @@
-/* $Id: tty-term.c,v 1.20 2009-05-15 12:57:36 nicm Exp $ */
+/* $Id: tty-term.c,v 1.21 2009-06-25 16:47:00 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -390,4 +390,3 @@ tty_term_flag(struct tty_term *term, enum tty_code_code code)
log_fatalx("not a flag: %d", code);
return (term->codes[code].value.flag);
}
-
diff --git a/tty-write.c b/tty-write.c
index def979ad..14c0ec3d 100644
--- a/tty-write.c
+++ b/tty-write.c
@@ -1,4 +1,4 @@
-/* $Id: tty-write.c,v 1.17 2009-06-25 16:21:32 nicm Exp $ */
+/* $Id: tty-write.c,v 1.18 2009-06-25 16:47:00 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -63,4 +63,3 @@ tty_vwrite_cmd(struct window_pane *wp, enum tty_cmd cmd, va_list ap)
}
}
}
-
diff --git a/window.c b/window.c
index 4e917488..240a5ffa 100644
--- a/window.c
+++ b/window.c
@@ -1,4 +1,4 @@
-/* $Id: window.c,v 1.84 2009-06-25 16:21:32 nicm Exp $ */
+/* $Id: window.c,v 1.85 2009-06-25 16:47:00 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -31,22 +31,6 @@
#include "tmux.h"
-#ifdef HAVE_PATHS_H
-#include <paths.h>
-#endif
-
-#ifdef HAVE_FORKPTY
-#ifdef HAVE_LIBUTIL_H
-#include <libutil.h>
-#endif
-#ifdef HAVE_PTY_H
-#include <pty.h>
-#endif
-#ifdef HAVE_UTIL_H
-#include <util.h>
-#endif
-#endif
-
/*
* Each window is attached to one or two panes, each of which is a pty. This
* file contains code to handle them.
@@ -586,7 +570,7 @@ window_pane_mouse(
} else
input_mouse(wp, b, x, y);
}
-
+
char *
window_pane_search(struct window_pane *wp, const char *searchstr, u_int *lineno)
{
diff --git a/xmalloc.c b/xmalloc.c
index d71bec08..2028848d 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -1,4 +1,4 @@
-/* $Id: xmalloc.c,v 1.9 2009-06-25 16:34:50 nicm Exp $ */
+/* $Id: xmalloc.c,v 1.10 2009-06-25 16:47:00 nicm Exp $ */
/*
* Copyright (c) 2004 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -142,25 +142,3 @@ xvsnprintf(char *buf, size_t len, const char *fmt, va_list ap)
return (i);
}
-
-/*
- * Some systems modify the path in place. This function and xbasename below
- * avoid that by using a temporary buffer.
- */
-char *
-xdirname(const char *src)
-{
- static char dst[MAXPATHLEN];
-
- strlcpy(dst, src, sizeof dst);
- return (dirname(dst));
-}
-
-char *
-xbasename(const char *src)
-{
- static char dst[MAXPATHLEN];
-
- strlcpy(dst, src, sizeof dst);
- return (basename(dst));
-}