mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
Merge a handful of old and new fixes for the build on Solaris
Note that it does not successfully compile yet due to missing flock() on this platform.
This commit is contained in:
commit
a4e81d3978
15 changed files with 198 additions and 46 deletions
|
@ -11,6 +11,8 @@ Functions used for implementing the set_color builtin.
|
|||
|
||||
#if HAVE_NCURSES_H
|
||||
#include <ncurses.h>
|
||||
#elif HAVE_NCURSES_CURSES_H
|
||||
#include <ncurses/curses.h>
|
||||
#else
|
||||
#include <curses.h>
|
||||
#endif
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
bool rgb_color_t::try_parse_special(const wcstring &special)
|
||||
{
|
||||
bzero(&data, sizeof data);
|
||||
memset(&data, 0, sizeof data);
|
||||
const wchar_t *name = special.c_str();
|
||||
if (! wcscasecmp(name, L"normal"))
|
||||
{
|
||||
|
@ -102,7 +102,7 @@ static unsigned char convert_color(const unsigned char rgb[3], const uint32_t *c
|
|||
|
||||
bool rgb_color_t::try_parse_rgb(const wcstring &name)
|
||||
{
|
||||
bzero(&data, sizeof data);
|
||||
memset(&data, 0, sizeof data);
|
||||
/* We support the following style of rgb formats (case insensitive):
|
||||
#FA3
|
||||
#F3A035
|
||||
|
@ -184,7 +184,7 @@ wcstring_list_t rgb_color_t::named_color_names(void)
|
|||
|
||||
bool rgb_color_t::try_parse_named(const wcstring &str)
|
||||
{
|
||||
bzero(&data, sizeof data);
|
||||
memset(&data, 0, sizeof data);
|
||||
size_t max = sizeof named_colors / sizeof *named_colors;
|
||||
for (size_t idx=0; idx < max; idx++)
|
||||
{
|
||||
|
@ -333,7 +333,7 @@ void rgb_color_t::parse(const wcstring &str)
|
|||
if (! success) success = try_parse_rgb(str);
|
||||
if (! success)
|
||||
{
|
||||
bzero(&this->data, sizeof this->data);
|
||||
memset(&this->data, 0, sizeof this->data);
|
||||
this->type = type_none;
|
||||
}
|
||||
}
|
||||
|
|
11
common.cpp
11
common.cpp
|
@ -45,9 +45,10 @@ parts of fish.
|
|||
#include <execinfo.h>
|
||||
#endif
|
||||
|
||||
|
||||
#if HAVE_NCURSES_H
|
||||
#include <ncurses.h>
|
||||
#elif HAVE_NCURSES_CURSES_H
|
||||
#include <ncurses/curses.h>
|
||||
#else
|
||||
#include <curses.h>
|
||||
#endif
|
||||
|
@ -216,14 +217,14 @@ static wcstring str2wcs_internal(const char *in, const size_t in_len)
|
|||
wc = ENCODE_DIRECT_BASE + (unsigned char)in[in_pos];
|
||||
result.push_back(wc);
|
||||
in_pos++;
|
||||
bzero(&state, sizeof state);
|
||||
memset(&state, 0, sizeof state);
|
||||
}
|
||||
else if (ret == 0)
|
||||
{
|
||||
/* Embedded null byte! */
|
||||
result.push_back(L'\0');
|
||||
in_pos++;
|
||||
bzero(&state, sizeof state);
|
||||
memset(&state, 0, sizeof state);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -314,7 +315,7 @@ std::string wcs2string(const wcstring &input)
|
|||
}
|
||||
else
|
||||
{
|
||||
bzero(converted, sizeof converted);
|
||||
memset(converted, 0, sizeof converted);
|
||||
size_t len = wcrtomb(converted, wc, &state);
|
||||
if (len == (size_t)(-1))
|
||||
{
|
||||
|
@ -1995,7 +1996,7 @@ void format_size_safe(char buff[128], unsigned long long sz)
|
|||
{
|
||||
const size_t buff_size = 128;
|
||||
const size_t max_len = buff_size - 1; //need to leave room for a null terminator
|
||||
bzero(buff, buff_size);
|
||||
memset(buff, 0, buff_size);
|
||||
size_t idx = 0;
|
||||
const char * const sz_name[]=
|
||||
{
|
||||
|
|
129
configure.ac
129
configure.ac
|
@ -301,35 +301,6 @@ case $target_os in
|
|||
;;
|
||||
esac
|
||||
|
||||
# Check for Solaris curses tputs having fixed length parameter list.
|
||||
AC_MSG_CHECKING([if we are using non varargs tparm.])
|
||||
AC_COMPILE_IFELSE(
|
||||
[
|
||||
AC_LANG_PROGRAM(
|
||||
[
|
||||
#include <curses.h>
|
||||
#include <term.h>
|
||||
],
|
||||
[
|
||||
tparm( "" );
|
||||
]
|
||||
)
|
||||
],
|
||||
[tparm_solaris_kludge=no],
|
||||
[tparm_solaris_kludge=yes]
|
||||
)
|
||||
if test "x$tparm_solaris_kludge" = "xyes"; then
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(
|
||||
[TPARM_SOLARIS_KLUDGE],
|
||||
[1],
|
||||
[Define to 1 if tparm accepts a fixed amount of paramters.]
|
||||
)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# BSD-specific flags go here
|
||||
#
|
||||
|
@ -366,6 +337,9 @@ AC_DEFINE(
|
|||
[Define to 1 if the wgettext function should be used for translating strings.]
|
||||
)
|
||||
|
||||
# Disable curses macros that conflict with the STL
|
||||
AC_DEFINE([NCURSES_NOMACROS], [1], [Define to 1 to disable ncurses macros that conflict with the STL])
|
||||
AC_DEFINE([NOMACROS], [1], [Define to 1 to disable curses macros that conflict with the STL])
|
||||
|
||||
#
|
||||
# Check presense of various libraries. This is done on a per-binary
|
||||
|
@ -390,7 +364,7 @@ fi
|
|||
# Check presense of various header files
|
||||
#
|
||||
|
||||
AC_CHECK_HEADERS([getopt.h termios.h sys/resource.h term.h ncurses/term.h ncurses.h curses.h stropts.h siginfo.h sys/select.h sys/ioctl.h execinfo.h spawn.h sys/sysctl.h])
|
||||
AC_CHECK_HEADERS([getopt.h termios.h sys/resource.h term.h ncurses/term.h ncurses.h ncurses/curses.h curses.h stropts.h siginfo.h sys/select.h sys/ioctl.h execinfo.h spawn.h sys/sysctl.h])
|
||||
|
||||
if test x$local_gettext != xno; then
|
||||
AC_CHECK_HEADERS([libintl.h])
|
||||
|
@ -476,6 +450,10 @@ for i in "" "-D_POSIX_C_SOURCE=200112L" "-D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=2
|
|||
/* As above (under at least Linux and FreeBSD). */
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TERMIOS_H
|
||||
#include <termios.h>
|
||||
#endif
|
||||
],
|
||||
[
|
||||
/* Avert high-level optimisation, by making the program's
|
||||
|
@ -528,6 +506,10 @@ fi
|
|||
AC_CHECK_MEMBERS([struct stat.st_mtimespec.tv_nsec])
|
||||
AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec])
|
||||
|
||||
#
|
||||
# Check for D_TYPE in dirent, only on BSD and Linux
|
||||
#
|
||||
AC_STRUCT_DIRENT_D_TYPE
|
||||
|
||||
#
|
||||
# Check for presense of various functions used by fish
|
||||
|
@ -712,6 +694,56 @@ else
|
|||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
# Check for sys_errlist
|
||||
AC_MSG_CHECKING([for sys_errlist array])
|
||||
AC_TRY_LINK(
|
||||
[
|
||||
#include <stdio.h>
|
||||
],
|
||||
[
|
||||
const char *p;
|
||||
p = sys_errlist[sys_nerr];
|
||||
],
|
||||
have_sys_errlist=yes,
|
||||
have_sys_errlist=no
|
||||
)
|
||||
if test "$have_sys_errlist" = yes; then
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(
|
||||
[HAVE_SYS_ERRLIST],
|
||||
[1],
|
||||
[Define to 1 if the sys_errlist array is available.]
|
||||
)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
# Check for _sys_errs
|
||||
AC_MSG_CHECKING([for _sys_errs array])
|
||||
AC_TRY_LINK(
|
||||
[
|
||||
#include <string>
|
||||
],
|
||||
[
|
||||
std::string p;
|
||||
extern const char _sys_errs[];
|
||||
extern const int _sys_index[];
|
||||
p = _sys_errs[_sys_index[0]];
|
||||
],
|
||||
have__sys__errs=yes,
|
||||
have__sys__errs=no
|
||||
)
|
||||
if test "$have__sys__errs" = yes; then
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(
|
||||
[HAVE__SYS__ERRS],
|
||||
[1],
|
||||
[Define to 1 if the _sys_errs array is available.]
|
||||
)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
# Check if getopt_long exists and works
|
||||
AC_MSG_CHECKING([if getopt_long exists and works])
|
||||
AC_TRY_LINK(
|
||||
|
@ -748,6 +780,43 @@ else
|
|||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
# Check for Solaris curses tputs having fixed length parameter list.
|
||||
AC_MSG_CHECKING([if we are using non varargs tparm.])
|
||||
AC_COMPILE_IFELSE(
|
||||
[
|
||||
AC_LANG_PROGRAM(
|
||||
[
|
||||
#if HAVE_NCURSES_H
|
||||
#include <ncurses.h>
|
||||
#else
|
||||
#include <curses.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_TERM_H
|
||||
#include <term.h>
|
||||
#elif HAVE_NCURSES_TERM_H
|
||||
#include <ncurses/term.h>
|
||||
#endif
|
||||
],
|
||||
[
|
||||
tparm( "" );
|
||||
]
|
||||
)
|
||||
],
|
||||
[tparm_solaris_kludge=no],
|
||||
[tparm_solaris_kludge=yes]
|
||||
)
|
||||
if test "x$tparm_solaris_kludge" = "xyes"; then
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(
|
||||
[TPARM_SOLARIS_KLUDGE],
|
||||
[1],
|
||||
[Define to 1 if tparm accepts a fixed amount of paramters.]
|
||||
)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
# Tell the world what we know
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
AC_OUTPUT
|
||||
|
|
2
env.cpp
2
env.cpp
|
@ -21,6 +21,8 @@
|
|||
|
||||
#if HAVE_NCURSES_H
|
||||
#include <ncurses.h>
|
||||
#elif HAVE_NCURSES_CURSES_H
|
||||
#include <ncurses/curses.h>
|
||||
#else
|
||||
#include <curses.h>
|
||||
#endif
|
||||
|
|
|
@ -36,6 +36,13 @@
|
|||
#include <notify.h>
|
||||
#endif
|
||||
|
||||
// NAME_MAX is not defined on Solaris and suggests the use of pathconf()
|
||||
// There is no obvious sensible pathconf() for shared memory and _XPG_NAME_MAX
|
||||
// seems a reasonable choice.
|
||||
#if !defined(NAME_MAX) && defined(_XOPEN_NAME_MAX)
|
||||
#define NAME_MAX _XOPEN_NAME_MAX
|
||||
#endif
|
||||
|
||||
/**
|
||||
The set command
|
||||
*/
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
|
||||
#if HAVE_NCURSES_H
|
||||
#include <ncurses.h>
|
||||
#elif HAVE_NCURSES_CURSES_H
|
||||
#include <ncurses/curses.h>
|
||||
#else
|
||||
#include <curses.h>
|
||||
#endif
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
#if HAVE_NCURSES_H
|
||||
#include <ncurses.h>
|
||||
#elif HAVE_NCURSES_CURSES_H
|
||||
#include <ncurses/curses.h>
|
||||
#else
|
||||
#include <curses.h>
|
||||
#endif
|
||||
|
|
2
io.cpp
2
io.cpp
|
@ -24,6 +24,8 @@ Utilities for io redirection.
|
|||
|
||||
#if HAVE_NCURSES_H
|
||||
#include <ncurses.h>
|
||||
#elif HAVE_NCURSES_CURSES_H
|
||||
#include <ncurses/curses.h>
|
||||
#else
|
||||
#include <curses.h>
|
||||
#endif
|
||||
|
|
33
osx/config.h
33
osx/config.h
|
@ -19,6 +19,10 @@
|
|||
/* Define to 1 if you have the `dcgettext' function. */
|
||||
/* #undef HAVE_DCGETTEXT */
|
||||
|
||||
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
|
||||
*/
|
||||
#define HAVE_DIRENT_H 1
|
||||
|
||||
/* Define to 1 if you have the <execinfo.h> header file. */
|
||||
#define HAVE_EXECINFO_H 1
|
||||
|
||||
|
@ -61,12 +65,18 @@
|
|||
/* Define to 1 if you have the nan function */
|
||||
#define HAVE_NAN 1
|
||||
|
||||
/* Define to 1 if you have the <ncurses/curses.h> header file. */
|
||||
/* #undef HAVE_NCURSES_CURSES_H */
|
||||
|
||||
/* Define to 1 if you have the <ncurses.h> header file. */
|
||||
#define HAVE_NCURSES_H 1
|
||||
|
||||
/* Define to 1 if you have the <ncurses/term.h> header file. */
|
||||
/* #undef HAVE_NCURSES_TERM_H */
|
||||
|
||||
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
|
||||
/* #undef HAVE_NDIR_H */
|
||||
|
||||
/* Define to 1 if realpath accepts null for its second argument. */
|
||||
#define HAVE_REALPATH_NULL 1
|
||||
|
||||
|
@ -94,12 +104,26 @@
|
|||
/* Define to 1 if you have the <stropts.h> header file. */
|
||||
/* #undef HAVE_STROPTS_H */
|
||||
|
||||
/* Define to 1 if `d_type' is a member of `struct dirent'. */
|
||||
#define HAVE_STRUCT_DIRENT_D_TYPE 1
|
||||
|
||||
/* Define to 1 if you have the `sysconf' function. */
|
||||
#define HAVE_SYSCONF 1
|
||||
|
||||
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
|
||||
*/
|
||||
/* #undef HAVE_SYS_DIR_H */
|
||||
|
||||
/* Define to 1 if the sys_errlist array is available. */
|
||||
#define HAVE_SYS_ERRLIST 1
|
||||
|
||||
/* Define to 1 if you have the <sys/ioctl.h> header file. */
|
||||
#define HAVE_SYS_IOCTL_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
|
||||
*/
|
||||
/* #undef HAVE_SYS_NDIR_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/resource.h> header file. */
|
||||
#define HAVE_SYS_RESOURCE_H 1
|
||||
|
||||
|
@ -173,9 +197,18 @@
|
|||
/* Define to 1 if you have the file `/proc/self/stat'. */
|
||||
/* #undef HAVE__PROC_SELF_STAT */
|
||||
|
||||
/* Define to 1 if the _sys_errs array is available. */
|
||||
/* #undef HAVE__SYS__ERRS */
|
||||
|
||||
/* Define to 1 if the __environ symbol is exported. */
|
||||
/* #undef HAVE___ENVIRON */
|
||||
|
||||
/* Define to 1 to disable ncurses macros that conflict with the STL */
|
||||
#define NCURSES_NOMACROS 1
|
||||
|
||||
/* Define to 1 to disable curses macros that conflict with the STL */
|
||||
#define NOMACROS 1
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "fish-users@lists.sf.net"
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
#if HAVE_NCURSES_H
|
||||
#include <ncurses.h>
|
||||
#elif HAVE_NCURSES_CURSES_H
|
||||
#include <ncurses/curses.h>
|
||||
#else
|
||||
#include <curses.h>
|
||||
#endif
|
||||
|
|
2
proc.cpp
2
proc.cpp
|
@ -33,6 +33,8 @@ Some of the code in this file is based on code from the Glibc manual.
|
|||
|
||||
#if HAVE_NCURSES_H
|
||||
#include <ncurses.h>
|
||||
#elif HAVE_NCURSES_CURSES_H
|
||||
#include <ncurses/curses.h>
|
||||
#else
|
||||
#include <curses.h>
|
||||
#endif
|
||||
|
|
|
@ -45,6 +45,8 @@ commence.
|
|||
|
||||
#if HAVE_NCURSES_H
|
||||
#include <ncurses.h>
|
||||
#elif HAVE_NCURSES_CURSES_H
|
||||
#include <ncurses/curses.h>
|
||||
#else
|
||||
#include <curses.h>
|
||||
#endif
|
||||
|
|
|
@ -20,6 +20,8 @@ efficient way for transforming that to the desired screen content.
|
|||
|
||||
#if HAVE_NCURSES_H
|
||||
#include <ncurses.h>
|
||||
#elif HAVE_NCURSES_CURSES_H
|
||||
#include <ncurses/curses.h>
|
||||
#else
|
||||
#include <curses.h>
|
||||
#endif
|
||||
|
|
38
wutil.cpp
38
wutil.cpp
|
@ -77,14 +77,32 @@ bool wreaddir_resolving(DIR *dir, const std::wstring &dir_path, std::wstring &ou
|
|||
if (out_is_dir)
|
||||
{
|
||||
/* The caller cares if this is a directory, so check */
|
||||
bool is_dir;
|
||||
bool is_dir = false;
|
||||
|
||||
/* We may be able to skip stat, if the readdir can tell us the file type directly */
|
||||
bool check_with_stat = true;
|
||||
#ifdef HAVE_STRUCT_DIRENT_D_TYPE
|
||||
if (d->d_type == DT_DIR)
|
||||
{
|
||||
/* Known directory */
|
||||
is_dir = true;
|
||||
check_with_stat = false;
|
||||
}
|
||||
else if (d->d_type == DT_LNK || d->d_type == DT_UNKNOWN)
|
||||
{
|
||||
/* We want to treat symlinks to directories as directories. Use stat to resolve it. */
|
||||
check_with_stat = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Regular file */
|
||||
is_dir = false;
|
||||
check_with_stat = false;
|
||||
}
|
||||
#endif // HAVE_STRUCT_DIRENT_D_TYPE
|
||||
if (check_with_stat)
|
||||
{
|
||||
/* We couldn't determine the file type from the dirent; check by stat'ing it */
|
||||
cstring fullpath = wcs2string(dir_path);
|
||||
fullpath.push_back('/');
|
||||
fullpath.append(d->d_name);
|
||||
|
@ -98,10 +116,6 @@ bool wreaddir_resolving(DIR *dir, const std::wstring &dir_path, std::wstring &ou
|
|||
is_dir = !!(S_ISDIR(buf.st_mode));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
is_dir = false;
|
||||
}
|
||||
*out_is_dir = is_dir;
|
||||
}
|
||||
return true;
|
||||
|
@ -309,12 +323,23 @@ const char *safe_strerror(int err)
|
|||
// uClibc does not have sys_errlist, however, its strerror is believed to be async-safe
|
||||
// See #808
|
||||
return strerror(err);
|
||||
#else
|
||||
#elif defined(HAVE__SYS__ERRS) || defined(HAVE_SYS_ERRLIST)
|
||||
#ifdef HAVE_SYS_ERRLIST
|
||||
if (err >= 0 && err < sys_nerr && sys_errlist[err] != NULL)
|
||||
{
|
||||
return sys_errlist[err];
|
||||
}
|
||||
#elif defined(HAVE__SYS__ERRS)
|
||||
extern const char _sys_errs[];
|
||||
extern const int _sys_index[];
|
||||
extern int _sys_num_err;
|
||||
|
||||
if (err >= 0 && err < _sys_num_err) {
|
||||
return &_sys_errs[_sys_index[err]];
|
||||
}
|
||||
#endif // either HAVE__SYS__ERRS or HAVE_SYS_ERRLIST
|
||||
else
|
||||
#endif // defined(HAVE__SYS__ERRS) || defined(HAVE_SYS_ERRLIST)
|
||||
{
|
||||
int saved_err = errno;
|
||||
|
||||
|
@ -331,7 +356,6 @@ const char *safe_strerror(int err)
|
|||
errno = saved_err;
|
||||
return buff;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void safe_perror(const char *message)
|
||||
|
|
Loading…
Reference in a new issue