1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Apply patches to build on DragonFly BSD and (older) FreeBSD

This now makes ksh build on DragonFly BSD.

bin/package, src/cmd/INIT/package.sh:
- DragonFly also needs the -lm hack for LDFLAGS.

src/cmd/ksh93/sh/main.c, src/cmd/ksh93/tests/basic.sh:
- fixargs() doesn't work on DragonFly either
  (re: 9b7c392a, 159fb9ee, cefe087d).

The following are backported from:
https://github.com/att/ast/issues/26#issuecomment-313927854
https://github.com/att/ast/pull/19

src/lib/libast/comp/setlocale.c:
- Add missing #include <errno.h> since errno is used.

src/lib/libast/features/standards:
- Do not set any standards macros (_POSIX_SOURCE etc) on FreeBSD or
  DragonflyBSD; they disable too much functionality on those.

src/lib/libast/features/wchar:
- Set _STDFILE_DECLARED on DragonFly, too.

src/lib/libast/include/sfio.h, src/lib/libast/include/sfio_t.h,
src/lib/libast/sfio/_sfopen.c, src/lib/libast/sfio/sfclrlock.c,
src/lib/libast/sfio/sfhdr.h, src/lib/libast/sfio/sfnew.c,
src/lib/libast/sfio/sfset.c:
- Rename SF_* macros to SFIO_* to avoid a conflict with system
  headers.

src/lib/libast/string/strexpr.c:
- Rename error() to err() to avoid a conflict.
This commit is contained in:
Martijn Dekker 2021-01-18 09:08:48 +00:00
parent 8633290e63
commit 4dcf5c5066
15 changed files with 45 additions and 30 deletions

View file

@ -1407,7 +1407,7 @@ esac
# Hack to build on some systems that need an explicit link with libm due to a bug in the build system
case `uname` in
NetBSD | SunOS)
NetBSD | SunOS | DragonFly)
case " $LDFLAGS " in
*" -m "*)
;;

View file

@ -1406,7 +1406,7 @@ esac
# Hack to build on some systems that need an explicit link with libm due to a bug in the build system
case `uname` in
NetBSD | SunOS)
NetBSD | SunOS | DragonFly)
case " $LDFLAGS " in
*" -m "*)
;;

View file

@ -52,7 +52,7 @@
/* These routines are referenced by this module */
static void exfile(Shell_t*, Sfio_t*,int);
static void chkmail(Shell_t *shp, char*);
#if defined(_lib_fork) && !defined(_NEXT_SOURCE) && !defined(__FreeBSD__) && !defined(__sun)
#if defined(_lib_fork) && !defined(_NEXT_SOURCE) && !defined(__FreeBSD__) && !defined(__DragonFly__) && !defined(__sun)
static void fixargs(char**,int);
#else
# define fixargs(a,b)
@ -697,7 +697,7 @@ static void chkmail(Shell_t *shp, char *files)
# define PSTAT 1
#endif
#if defined(_lib_fork) && !defined(_NEXT_SOURCE) && !defined(__FreeBSD__) && !defined(__sun)
#if defined(_lib_fork) && !defined(_NEXT_SOURCE) && !defined(__FreeBSD__) && !defined(__DragonFly__) && !defined(__sun)
/*
* fix up command line for ps command
*

View file

@ -711,7 +711,7 @@ getPsOutput() {
while [[ $actual == [[:space:]]* ]]; do actual=${actual#?}; done
while [[ $actual == *[[:space:]] ]]; do actual=${actual%?}; done
}
if [[ ! $(uname -s) =~ ^(FreeBSD|SunOS)$ ]] &&
if [[ ! $(uname -s) =~ ^(FreeBSD|DragonFly|SunOS)$ ]] &&
getPsOutput "$$" &&
[[ "$SHELL $0" == "$actual"* ]] # "$SHELL $0" is how shtests invokes this script
then expect='./atest 1 2'

View file

@ -36,6 +36,7 @@
#include <ctype.h>
#include <mc.h>
#include <namval.h>
#include <errno.h>
#if ( _lib_wcwidth || _lib_wctomb ) && _hdr_wctype
#include <wctype.h>

View file

@ -1,5 +1,19 @@
set stdio
if tst note{ _ALL_SOURCE & _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works }end compile{
# In FreeBSD, definitions like _POSIX_SOURCE and such are used to *limit*
# functionality to known API; they don't enable anything. The general intent in
# BSD is to enable everything by default (effectively, providing the
# _KITCHEN_SINK_SOURCE mentioned below). So we look for that here, but stay
# careful that we don't get fooled by presence of FreeBSD that underpins some
# subsystems in Mac OS X; there are other Apple-specific portability hacks
# elsewhere we should not interfere with.
if tst note{ FreeBSD or DragonFly BSD }end compile{
#include <sys/param.h>
#if (!defined(__FreeBSD__) && !defined(__DragonFly__)) || defined(APPLE)
#error not a FreeBSD or DragonFly BSD system
#endif
}end {
}
elif tst note{ _ALL_SOURCE & _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works }end compile{
#define _ALL_SOURCE 1
#define _POSIX_SOURCE 1
#define _POSIX_C_SOURCE 21000101L

View file

@ -6,7 +6,7 @@ set include .
cat{
#ifndef _AST_WCHAR_H
#define _AST_WCHAR_H 1
#ifdef __FreeBSD__
#if defined(__FreeBSD__) || defined(__DragonFly__)
#define _STDFILE_DECLARED 1
#endif
}end

View file

@ -150,7 +150,7 @@ struct _sffmt_s
#define SF_IOINTR 0040000 /* return on interrupts */
#define SF_WCWIDTH 0100000 /* wcwidth display stream */
#define SF_FLAGS 0177177 /* PUBLIC FLAGS PASSABLE TO SFNEW() */
#define SFIO_FLAGS 0177177 /* PUBLIC FLAGS PASSABLE TO SFNEW() */
#ifdef _typ_struct_sf_hdtr
#define _SF_HIDESFFLAGS 1
#endif
@ -458,7 +458,7 @@ __INLINE__ ssize_t sfmaxr(ssize_t n, int s) { return __sf_maxr(n,s); }
#endif /* _SFSTR_H */
#ifdef _SF_HIDESFFLAGS
#undef SF_FLAGS
#define SF_FLAGS 0177177 /* PUBLIC FLAGS PASSABLE TO SFNEW() */
#undef SFIO_FLAGS
#define SFIO_FLAGS 0177177 /* PUBLIC FLAGS PASSABLE TO SFNEW() */
#endif
#endif /* _SFIO_H */

View file

@ -75,7 +75,7 @@
(unsigned char*)(data), /* endr */ \
(unsigned char*)(data), /* endb */ \
(Sfio_t*)0, /* push */ \
(unsigned short)((type)&SF_FLAGS), /* flags */ \
(unsigned short)((type)&SFIO_FLAGS), /* flags */ \
(short)(file), /* file */ \
(unsigned char*)(data), /* data */ \
(ssize_t)(size), /* size */ \

View file

@ -55,7 +55,7 @@ char* mode; /* mode of the stream */
{ SFMTXENTER(f, NIL(Sfio_t*));
if(f->mode&SF_INIT ) /* stream uninitialized, ok to set flags */
{ f->flags |= (sflags & (SF_FLAGS & ~SF_RDWR));
{ f->flags |= (sflags & (SFIO_FLAGS & ~SF_RDWR));
if((sflags &= SF_RDWR) != 0) /* reset read/write modes */
{ f->flags = (f->flags & ~SF_RDWR) | sflags;

View file

@ -57,7 +57,7 @@ Sfio_t *f;
/* throw away all lock bits except for stacking state SF_PUSH */
f->mode &= (SF_RDWR|SF_INIT|SF_POOL|SF_PUSH|SF_SYNCED|SF_STDIO);
rv = (f->mode&SF_PUSH) ? 0 : (f->flags&SF_FLAGS);
rv = (f->mode&SF_PUSH) ? 0 : (f->flags&SFIO_FLAGS);
SFMTXRETURN(f, rv);
}

View file

@ -1306,8 +1306,8 @@ extern int poll _ARG_((ulong, struct pollfd*, int));
_END_EXTERNS_
#ifdef _SF_HIDESFFLAGS
#undef SF_FLAGS
#define SF_FLAGS 0177177 /* PUBLIC FLAGS PASSABLE TO SFNEW() */
#undef SFIO_FLAGS
#define SFIO_FLAGS 0177177 /* PUBLIC FLAGS PASSABLE TO SFNEW() */
#endif
#endif /*_SFHDR_H*/

View file

@ -106,7 +106,7 @@ int flags; /* type of file stream */
/* stream type */
f->mode = (flags&SF_READ) ? SF_READ : SF_WRITE;
f->flags = (flags&SF_FLAGS) | (sflags&(SF_MALLOC|SF_STATIC));
f->flags = (flags&SFIO_FLAGS) | (sflags&(SF_MALLOC|SF_STATIC));
f->bits = (flags&SF_RDWR) == SF_RDWR ? SF_BOTH : 0;
f->file = file;
f->here = f->extent = 0;

View file

@ -41,7 +41,7 @@ int set;
SFMTXENTER(f,0);
if(flags == 0 && set == 0)
SFMTXRETURN(f, (f->flags&SF_FLAGS));
SFMTXRETURN(f, (f->flags&SFIO_FLAGS));
if((oflags = (f->mode&SF_RDWR)) != (int)f->mode)
{ /* avoid sfsetbuf() isatty() call if user sets (SF_LINE|SF_WCWIDTH) */
@ -57,7 +57,7 @@ int set;
SFMTXRETURN(f, 0);
}
if(flags == 0)
SFMTXRETURN(f, (f->flags&SF_FLAGS));
SFMTXRETURN(f, (f->flags&SFIO_FLAGS));
SFLOCK(f,0);
@ -95,5 +95,5 @@ int set;
f->flags &= ~SF_PUBLIC;
SFOPEN(f,0);
SFMTXRETURN(f, (oflags&SF_FLAGS));
SFMTXRETURN(f, (oflags&SFIO_FLAGS));
}

View file

@ -44,7 +44,7 @@
#define peekchr(ex) (*(ex)->nextchr)
#define ungetchr(ex) ((ex)->nextchr--)
#define error(ex,msg) return(seterror(ex,msg))
#define err(ex,msg) return(seterror(ex,msg))
typedef struct /* expression handle */
{
@ -87,7 +87,7 @@ expr(register Expr_t* ex, register int precedence)
case 0:
ungetchr(ex);
if (!precedence) return(0);
error(ex, "more tokens expected");
err(ex, "more tokens expected");
case '-':
n = -expr(ex, 13);
break;
@ -113,17 +113,17 @@ expr(register Expr_t* ex, register int precedence)
case 0:
goto done;
case ')':
if (!precedence) error(ex, "too many )'s");
if (!precedence) err(ex, "too many )'s");
goto done;
case '(':
n = expr(ex, 1);
if (getchr(ex) != ')')
{
ungetchr(ex);
error(ex, "closing ) expected");
err(ex, "closing ) expected");
}
gotoperand:
if (operand) error(ex, "operator expected");
if (operand) err(ex, "operator expected");
operand = 1;
continue;
case '?':
@ -140,7 +140,7 @@ expr(register Expr_t* ex, register int precedence)
if (getchr(ex) != ':')
{
ungetchr(ex);
error(ex, ": expected for ? operator");
err(ex, ": expected for ? operator");
}
if (n)
{
@ -189,7 +189,7 @@ expr(register Expr_t* ex, register int precedence)
break;
case '=':
case '!':
if (peekchr(ex) != '=') error(ex, "operator syntax error");
if (peekchr(ex) != '=') err(ex, "operator syntax error");
if (precedence > 7) goto done;
getchr(ex);
x = expr(ex, 8);
@ -237,7 +237,7 @@ expr(register Expr_t* ex, register int precedence)
if (precedence > 11) goto done;
x = expr(ex, 12);
if (c == '*') n *= x;
else if (x == 0) error(ex, "divide by zero");
else if (x == 0) err(ex, "divide by zero");
else if (c == '/') n /= x;
else n %= x;
break;
@ -246,15 +246,15 @@ expr(register Expr_t* ex, register int precedence)
pos = --ex->nextchr;
if (isdigit(c)) n = strton(ex->nextchr, &ex->nextchr, NiL, 0);
else if (ex->convert) n = (*ex->convert)(ex->nextchr, &ex->nextchr, ex->handle);
if (ex->nextchr == pos) error(ex, "syntax error");
if (ex->nextchr == pos) err(ex, "syntax error");
goto gotoperand;
}
if (ex->errmsg) return(0);
if (!operand) error(ex, "operand expected");
if (!operand) err(ex, "operand expected");
}
done:
ungetchr(ex);
if (!operand) error(ex, "operand expected");
if (!operand) err(ex, "operand expected");
return(n);
}