Solaris fixes, mostly from Dagobert Michelsen.

pull/829/head
Nicholas Marriott 2017-03-09 15:39:13 +00:00
parent 5d3296c53b
commit 514a723f74
8 changed files with 126 additions and 1 deletions

View File

@ -204,6 +204,9 @@ endif
if NO_IMSG
nodist_tmux_SOURCES += compat/imsg.c compat/imsg-buffer.c
endif
if NO_ERR_H
nodist_tmux_SOURCES += compat/err.c
endif
if NO_CLOSEFROM
nodist_tmux_SOURCES += compat/closefrom.c
endif

View File

@ -22,6 +22,7 @@
#include <limits.h>
#include <stdio.h>
#include <termios.h>
#include <wchar.h>
#ifndef __GNUC__
@ -57,6 +58,15 @@ typedef uint32_t u_int32_t;
typedef uint64_t u_int64_t;
#endif
#ifdef HAVE_ERR_H
#include <err.h>
#else
void err(int, const char *, ...);
void errx(int, const char *, ...);
void warn(const char *, ...);
void warnx(const char *, ...);
#endif
#ifndef HAVE_PATHS_H
#define _PATH_BSHELL "/bin/sh"
#define _PATH_TMP "/tmp/"

View File

@ -15,7 +15,10 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/types.h>
#include <string.h>
#include <termios.h>
#include "compat.h"

97
compat/err.c Normal file
View File

@ -0,0 +1,97 @@
/*
* Copyright (c) 2017 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* 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.
*/
#include <sys/types.h>
#include <errno.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "compat.h"
void
err(int eval, const char *fmt, ...)
{
va_list ap;
int saved_errno = errno;
fprintf(stderr, "%s: ", getprogname());
va_start(ap, fmt);
if (fmt != NULL) {
vfprintf(stderr, fmt, ap);
fprintf(stderr, ": ");
}
va_end(ap);
fprintf(stderr, "%s\n", strerror(saved_errno));
exit(eval);
}
void
errx(int eval, const char *fmt, ...)
{
va_list ap;
fprintf(stderr, "%s: ", getprogname());
va_start(ap, fmt);
if (fmt != NULL) {
vfprintf(stderr, fmt, ap);
fprintf(stderr, ": ");
}
va_end(ap);
putc('\n', stderr);
exit(eval);
}
void
warn(const char *fmt, ...)
{
va_list ap;
int saved_errno = errno;
fprintf(stderr, "%s: ", getprogname());
va_start(ap, fmt);
if (fmt != NULL) {
vfprintf(stderr, fmt, ap);
fprintf(stderr, ": ");
}
va_end(ap);
fprintf(stderr, "%s\n", strerror(saved_errno));
}
void
warnx(const char *fmt, ...)
{
va_list ap;
fprintf(stderr, "%s: ", getprogname());
va_start(ap, fmt);
if (fmt != NULL) {
vfprintf(stderr, fmt, ap);
fprintf(stderr, ": ");
}
va_end(ap);
putc('\n', stderr);
}

View File

@ -21,6 +21,7 @@
#include <stdlib.h>
#include <strings.h>
#include <stropts.h>
#include <termios.h>
#include <unistd.h>
#include "compat.h"

View File

@ -350,6 +350,16 @@ if test "x$found_cmsg_data" = xno; then
fi
AC_SUBST(XOPEN_DEFINES)
# Look for err and friends in err.h.
AC_CHECK_FUNC(err, found_err_h=yes, found_err_h=no)
AC_CHECK_FUNC(errx, , found_err_h=no)
AC_CHECK_FUNC(warn, , found_err_h=no)
AC_CHECK_FUNC(warnx, , found_err_h=no)
if test "x$found_err_h" = xyes; then
AC_CHECK_HEADER(err.h, , found_err_h=no)
fi
AM_CONDITIONAL(NO_ERR_H, [test "x$found_err_h" = xno])
# Look for imsg in libutil. compat/imsg.c is linked by Makefile.am if missing.
AC_SEARCH_LIBS(imsg_init, util, found_imsg_init=yes, found_imsg_init=no)
if test "x$found_imsg_init" = xyes; then

1
tmux.c
View File

@ -19,7 +19,6 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <err.h>
#include <errno.h>
#include <event.h>
#include <fcntl.h>

2
tmux.h
View File

@ -55,7 +55,9 @@ struct tmuxpeer;
struct tmuxproc;
/* Default global configuration file. */
#ifndef TMUX_CONF
#define TMUX_CONF "/etc/tmux.conf"
#endif
/*
* Minimum layout cell size, NOT including separator line. The scroll region