mirror of
https://github.com/tmux/tmux.git
synced 2025-01-05 23:38:48 +00:00
Solaris fixes, mostly from Dagobert Michelsen.
This commit is contained in:
parent
5d3296c53b
commit
514a723f74
@ -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
|
||||
|
10
compat.h
10
compat.h
@ -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/"
|
||||
|
@ -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
97
compat/err.c
Normal 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);
|
||||
}
|
@ -21,6 +21,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <strings.h>
|
||||
#include <stropts.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "compat.h"
|
||||
|
10
configure.ac
10
configure.ac
@ -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
1
tmux.c
@ -19,7 +19,6 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <event.h>
|
||||
#include <fcntl.h>
|
||||
|
Loading…
Reference in New Issue
Block a user