From 53e90c10859e25ddb299e411d24a8897dd315493 Mon Sep 17 00:00:00 2001 From: Bob Krzaczek Date: Wed, 13 Jul 2016 23:26:12 +0000 Subject: [PATCH 1/3] patches to restore FreeBSD port From the ast-open post on 3 Apr 2014: Below are a small set of patches that should restore a full build of ast-open to FreeBSD 9. I'm still quite new to iffe, though, so if there are better ways to do what I've done below, please don't hesitate to let me know. So much of my work (both professional and personal) uses ast-open heavily, and this seems like the very least I can do. To be clear, the build succeeds, but they don't cleanly pass all regression tests --- .gitignore | 2 ++ src/cmd/proto/proto.c | 9 +++++++++ src/cmd/std/features/procfs | 10 +++++++--- src/cmd/std/pss-kvm.c | 3 +++ src/lib/libast/comp/setlocale.c | 1 + src/lib/libast/features/standards | 16 +++++++++++++++- src/lib/libast/features/wchar | 1 + src/lib/libast/string/strexpr.c | 22 +++++++++++----------- 8 files changed, 49 insertions(+), 15 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000000..6ffab9ad2958 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.orig +*.rej diff --git a/src/cmd/proto/proto.c b/src/cmd/proto/proto.c index 0693f5859e3d..d6409e1de066 100644 --- a/src/cmd/proto/proto.c +++ b/src/cmd/proto/proto.c @@ -396,6 +396,15 @@ proto(char* file, char* license, char* options, char* package, char* copy, char* #if !PROTO_STANDALONE #undef error +void +error( int xit, const char *msg, ... ) +{ + va_list ap; + va_start( ap, msg ); + vfprintf( stderr, msg, ap ); + va_end( ap ); + exit( xit ); +} #endif typedef struct Sufcom_s diff --git a/src/cmd/std/features/procfs b/src/cmd/std/features/procfs index 0119fcc74c50..71d51a31e90e 100644 --- a/src/cmd/std/features/procfs +++ b/src/cmd/std/features/procfs @@ -1,6 +1,6 @@ hdr kvm,procinfo,pstat,asm/param -sys procfs,sysctl +sys procfs,sysctl,user lib getprocs lib kvm_open,kvm_getprocs kvm.h sys/time.h sys/param.h sys/proc.h sys/sysctl.h -lkvm @@ -10,7 +10,11 @@ mem extern_proc.p_pid,extern_proc.p_starttime,extern_proc.p_wchan,extern_proc.p_ mem procsinfo64.pi_pri procinfo.h mem prpsinfo.pr_clname,prpsinfo.pr_cstime,prpsinfo.pr_cstime.tv_sec,prpsinfo.pr_ctime,prpsinfo.pr_cutime,prpsinfo.pr_gid,prpsinfo.pr_lttydev,prpsinfo.pr_ntpid,prpsinfo.pr_pgid,prpsinfo.pr_pgrp,prpsinfo.pr_psargs,prpsinfo.pr_refcount,prpsinfo.pr_rssize,prpsinfo.pr_sid,prpsinfo.pr_sonproc,prpsinfo.pr_start,prpsinfo.pr_start.tv_sec,prpsinfo.pr_starttime,prpsinfo.pr_starttime.tv_sec,prpsinfo.pr_state,prpsinfo.pr_stime,prpsinfo.pr_tgrp,prpsinfo.pr_time,prpsinfo.pr_time.tv_sec,prpsinfo.pr_utime,prpsinfo.pr_zomb,prpsinfo.pr_pctcpu,prpsinfo.pr_cpu,prpsinfo.pr_lwp.pr_pctcpu,prpsinfo.pr_lwp.pr_cpu -D_STRUCTURED_PROC -Dprpsinfo=psinfo sys/types.h sys/procfs.h +num PIOCPSINFO + typ struct.prpsinfo -D_STRUCTURED_PROC -Dprpsinfo=psinfo sys/types.h sys/procfs.h +typ struct.kinfo_proc sys/types.h sys/procfs.h sys/user.h +typ struct.kp_proc sys/types.h sys/procfs.h sys/user.h tst lib_info note{ info(2) kernel table api }end link{ #include @@ -587,11 +591,11 @@ cat{ #define PSS_METHOD PSS_METHOD_getprocs #endif -#if !PSS_METHOD && defined(_PS_dir) +#if !PSS_METHOD && defined(_PS_dir) && (_PS_scan_binary || _num_PIOCPSINFO) #define PSS_METHOD PSS_METHOD_procfs #endif -#if !PSS_METHOD && _hdr_kvm && _sys_sysctl && _lib_kvm_open && _lib_kvm_getprocs +#if !PSS_METHOD && _hdr_kvm && _sys_sysctl && _lib_kvm_open && _lib_kvm_getprocs && _typ_struct_kinfo_proc && _typ_struct_kp_proc #define PSS_METHOD PSS_METHOD_kvm #endif diff --git a/src/cmd/std/pss-kvm.c b/src/cmd/std/pss-kvm.c index 3fd0309dcb6f..08c6f0d182e8 100644 --- a/src/cmd/std/pss-kvm.c +++ b/src/cmd/std/pss-kvm.c @@ -43,6 +43,9 @@ NoN(pss_kvm) #if _sys_proc #include #endif +#if _sys_user +#include +#endif #include #include diff --git a/src/lib/libast/comp/setlocale.c b/src/lib/libast/comp/setlocale.c index fe072a53b1aa..194c7c4f2b10 100644 --- a/src/lib/libast/comp/setlocale.c +++ b/src/lib/libast/comp/setlocale.c @@ -38,6 +38,7 @@ #include #include #include +#include #if ( _lib_wcwidth || _lib_wctomb ) && _hdr_wctype #include diff --git a/src/lib/libast/features/standards b/src/lib/libast/features/standards index c20f2f094fb4..378b92574860 100644 --- a/src/lib/libast/features/standards +++ b/src/lib/libast/features/standards @@ -1,5 +1,19 @@ set stdio -if tst note{ _GNU_SOURCE 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 }end compile{ + #include + #if !defined(__FreeBSD__) || defined(APPLE) + #error not a FreeBSD system + #endif + }end { + } +elif tst note{ _GNU_SOURCE works }end compile{ #define _GNU_SOURCE 1 #include #include diff --git a/src/lib/libast/features/wchar b/src/lib/libast/features/wchar index f6e90c9769e4..c93678759d03 100644 --- a/src/lib/libast/features/wchar +++ b/src/lib/libast/features/wchar @@ -6,6 +6,7 @@ set include . cat{ #ifndef _AST_WCHAR_H #define _AST_WCHAR_H 1 + #define _STDFILE_DECLARED }end lib mbstowcs,wctomb,wcscmp,wcscoll,wcslen,wcstombs,wcsxfrm,wcwidth stdlib.h stdio.h wchar.h diff --git a/src/lib/libast/string/strexpr.c b/src/lib/libast/string/strexpr.c index 2803279e66a1..a949d51ff3d2 100644 --- a/src/lib/libast/string/strexpr.c +++ b/src/lib/libast/string/strexpr.c @@ -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); } From ee33815e68456a97e40f292948668f3b24105834 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Cie=C5=9Blak?= Date: Wed, 13 Jul 2016 23:50:28 +0000 Subject: [PATCH 2/3] non-void function 'ls' should return a value --- src/lib/libcmd/ls.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/libcmd/ls.c b/src/lib/libcmd/ls.c index 50b95f4be1fe..4bed90ab5ec7 100644 --- a/src/lib/libcmd/ls.c +++ b/src/lib/libcmd/ls.c @@ -1257,7 +1257,7 @@ ls(State_t* state, register FTSENT* ent) if (!VISIBLE(state, ent)) { fts_set(NiL, ent, FTS_SKIP); - return; + return 0; } switch (ent->fts_info) { @@ -1265,17 +1265,17 @@ ls(State_t* state, register FTSENT* ent) if (ent->fts_parent->fts_info == FTS_DNX) break; error(2, "%s: not found", ent->fts_path); - return; + return 1; case FTS_DC: if (state->lsflags & LS_DIRECTORY) break; error(2, "%s: directory causes cycle", ent->fts_path); - return; + return 1; case FTS_DNR: if (state->lsflags & LS_DIRECTORY) break; error(2, "%s: cannot read directory", ent->fts_path); - return 0; + return 1; case FTS_DOT: #if 0 fts_set(NiL, ent, FTS_SKIP); From f39dab056d5a732ae734f7181a2a7aa12e4c554c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Cie=C5=9Blak?= Date: Sat, 16 Jul 2016 23:19:19 +0000 Subject: [PATCH 3/3] 93v- 2016-07-16 --- lib/package/ast-ksh.ver | 2 +- src/cmd/ksh93/RELEASE | 4 +++- src/cmd/ksh93/include/version.h | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/package/ast-ksh.ver b/lib/package/ast-ksh.ver index d50fafbefb6e..f5d9851ccf82 100644 --- a/lib/package/ast-ksh.ver +++ b/lib/package/ast-ksh.ver @@ -1 +1 @@ -ast-ksh 2014-12-24 2014-12-24 1 +ast-ksh 2016-06-16 2016-06-16 1 diff --git a/src/cmd/ksh93/RELEASE b/src/cmd/ksh93/RELEASE index d28fe237cdc4..db2c673bc703 100644 --- a/src/cmd/ksh93/RELEASE +++ b/src/cmd/ksh93/RELEASE @@ -1,4 +1,6 @@ -14-12-24 --- Release ksh93v- --- +16-07-17 --- Release ksh93v- --- +16-07-17 A fix to avoid "non-void function 'ls' should return a value" error. +16-07-17 Some patches for compilation on FreeBSD have been added. 14-12-24 A bug which occurred when the undocumented alarm builtin received an alarm timeout while in the read builtin has been fixed. 14-12-24 A bug in the startup of interactive restricted ksh which give a diff --git a/src/cmd/ksh93/include/version.h b/src/cmd/ksh93/include/version.h index a5aecf4884d5..3de5b159cb09 100644 --- a/src/cmd/ksh93/include/version.h +++ b/src/cmd/ksh93/include/version.h @@ -17,4 +17,4 @@ * David Korn * * * ***********************************************************************/ -#define SH_RELEASE "93v- 2014-12-24" +#define SH_RELEASE "93v- 2016-07-16"