diff --git a/src/cmd/builtin/builtin.c b/src/cmd/builtin/builtin.c index 437f129bc..c77ce3c7a 100644 --- a/src/cmd/builtin/builtin.c +++ b/src/cmd/builtin/builtin.c @@ -25,3 +25,8 @@ */ #include + +// @lkoutsofios added to prevent this file from being optimized out +int _do_not_opt_out (void) { + sfprintf (sfstderr, "unreachable"); +} diff --git a/src/cmd/ksh93/edit/emacs.c b/src/cmd/ksh93/edit/emacs.c index 60700a44c..bf13af68c 100644 --- a/src/cmd/ksh93/edit/emacs.c +++ b/src/cmd/ksh93/edit/emacs.c @@ -1007,7 +1007,7 @@ static int escape(register Emacs_t* ep,register genchar *out,int count) else if(i=='=' || (i=='\\' && out[cur-1]=='/')) { draw(ep,REFRESH); - if(count>0) + if(count>0 || i=='\\') ep->ed->e_tabcount=0; else { diff --git a/src/cmd/pax/file.c b/src/cmd/pax/file.c index c3c6b2343..6c2c05d0c 100644 --- a/src/cmd/pax/file.c +++ b/src/cmd/pax/file.c @@ -1183,14 +1183,19 @@ setfile(register Archive_t* ap, register File_t* f) int m; struct stat st; - if (lchmod(f->name, f->perm & state.modemask)) - error(1, "%s: cannot chmod to %s", f->name, fmtmode(f->perm & state.modemask, 0) + 1); - else if (m = f->perm & (S_ISUID|S_ISGID|S_ISVTX)) + if (lstat(f->name, &st)) + error(1, "%s: not found", f->name); + else if ((f->perm ^ st.st_mode) & state.modemask & (S_ISUID|S_ISGID|S_ISVTX|S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH)) { - if (lstat(f->name, &st)) - error(1, "%s: not found", f->name); - else if (m ^= (st.st_mode & (S_ISUID|S_ISGID|S_ISVTX))) - error(1, "%s: mode %s not set", f->name, fmtmode(m, 0) + 1); + if (lchmod(f->name, f->perm & state.modemask)) + error(1, "%s: cannot chmod to %s", f->name, fmtmode(f->perm & state.modemask, 0) + 1); + else if (m = f->perm & (S_ISUID|S_ISGID|S_ISVTX)) + { + if (lstat(f->name, &st)) + error(1, "%s: not found", f->name); + else if (m ^= (st.st_mode & (S_ISUID|S_ISGID|S_ISVTX))) + error(1, "%s: mode %s not set", f->name, fmtmode(m, 0) + 1); + } } } #endif diff --git a/src/lib/libast/comp/realpath.c b/src/lib/libast/comp/realpath.c index 54c87033c..3ecf6cd41 100644 --- a/src/lib/libast/comp/realpath.c +++ b/src/lib/libast/comp/realpath.c @@ -44,5 +44,10 @@ extern int resolvepath(const char*, char*, size_t); extern char* realpath(const char* file, char* path) { + // @lkoutsofios path may be NULL + if (!path) { + if (!(path = malloc (PATH_MAX))) + return NULL; + } return resolvepath(file, path, PATH_MAX) > 0 ? path : (char*)0; } diff --git a/src/lib/libast/features/stdio b/src/lib/libast/features/stdio index 075638342..b32389399 100644 --- a/src/lib/libast/features/stdio +++ b/src/lib/libast/features/stdio @@ -6,8 +6,6 @@ cat{ #define _FILE_DEFINED 1 #define _FILE_defined 1 #define _FILEDEFED 1 - #define __FILE_defined 1 - #define ____FILE_defined 1 #ifndef __FILE_TAG #define __FILE_TAG _sfio_s diff --git a/src/lib/libast/features/vmalloc b/src/lib/libast/features/vmalloc index b3cc2d0d2..787ccb8b6 100644 --- a/src/lib/libast/features/vmalloc +++ b/src/lib/libast/features/vmalloc @@ -191,7 +191,7 @@ tst malloc_hook note{ gnu malloc hooks work }end execute{ __realloc_hook = test_realloc_hook; } - void (*__malloc_initialize_hook)(void) = test_initialize_hook; + typeof (__malloc_initialize_hook) __malloc_initialize_hook = test_initialize_hook; int main() { diff --git a/src/lib/libast/include/ast.h b/src/lib/libast/include/ast.h index db7ee1987..d8cc9d314 100644 --- a/src/lib/libast/include/ast.h +++ b/src/lib/libast/include/ast.h @@ -58,21 +58,9 @@ struct _sfio_s; #ifndef __FILE_typedef #define __FILE_typedef 1 #endif -#ifndef _FILE_DEFINED -#define _FILE_DEFINED 1 -#endif -#ifndef _FILE_defined -#define _FILE_defined 1 -#endif #ifndef _FILEDEFED #define _FILEDEFED 1 #endif -#ifndef __FILE_defined -#define __FILE_defined 1 -#endif -#ifndef ____FILE_defined -#define ____FILE_defined 1 -#endif #endif /* diff --git a/src/lib/libast/include/ast_std.h b/src/lib/libast/include/ast_std.h index c50fd5462..5250c2f01 100644 --- a/src/lib/libast/include/ast_std.h +++ b/src/lib/libast/include/ast_std.h @@ -76,6 +76,25 @@ struct _sfio_s; #undef FILE #endif +#ifndef FILE +#ifndef _SFIO_H +struct _sfio_s; +#endif +#define FILE struct _sfio_s +#ifndef __FILE_typedef +#define __FILE_typedef 1 +#endif +#ifndef _FILEDEFED +#define _FILEDEFED 1 +#endif +#ifndef ____FILE_defined +#define ____FILE_defined 1 +#endif +#ifndef __FILE_defined +#define __FILE_defined 1 +#endif +#endif + /* locale stuff */ #if !_hdr_locale diff --git a/src/lib/libast/sfio/sfflsbuf.c b/src/lib/libast/sfio/sfflsbuf.c index 36d78dc58..c68a3e872 100644 --- a/src/lib/libast/sfio/sfflsbuf.c +++ b/src/lib/libast/sfio/sfflsbuf.c @@ -96,7 +96,7 @@ int c; /* if c>=0, c is also written out */ isall = SFISALL(f,isall); if((w = SFWR(f,data,n,f->disc)) > 0) { if((n -= w) > 0) /* save unwritten data, then resume */ - memcpy((char*)f->data,(char*)data+w,n); + memmove((char*)f->data,(char*)data+w,n); written += w; f->next = f->data+n; if(c < 0 && (!isall || n == 0)) diff --git a/src/lib/libast/sfio/sfmove.c b/src/lib/libast/sfio/sfmove.c index 9e3965750..3b2f0cd28 100644 --- a/src/lib/libast/sfio/sfmove.c +++ b/src/lib/libast/sfio/sfmove.c @@ -190,7 +190,7 @@ reg int rc; /* record separator */ { /* move left-over to read stream */ if(w > fr->size) w = fr->size; - memcpy((Void_t*)fr->data,(Void_t*)cp,w); + memmove((Void_t*)fr->data,(Void_t*)cp,w); fr->endb = fr->data+w; if((w = endb - (cp+w)) > 0) (void)SFSK(fr,(Sfoff_t)(-w),SEEK_CUR,fr->disc); @@ -200,7 +200,7 @@ reg int rc; /* record separator */ { if(direct == SF_WRITE) fw->next += r; else if(r <= (fw->endb-fw->next) ) - { memcpy((Void_t*)fw->next,(Void_t*)next,r); + { memmove((Void_t*)fw->next,(Void_t*)next,r); fw->next += r; } else if((w = SFWRITE(fw,(Void_t*)next,r)) != r) diff --git a/src/lib/libast/sfio/sfpool.c b/src/lib/libast/sfio/sfpool.c index dbfc045d4..2efb5710f 100644 --- a/src/lib/libast/sfio/sfpool.c +++ b/src/lib/libast/sfio/sfpool.c @@ -138,7 +138,7 @@ int n; /* current position in pool */ else /* write failed, recover buffer then quit */ { if(w > 0) { v -= w; - memcpy(head->data,(head->data+w),v); + memmove(head->data,(head->data+w),v); } head->next = head->data+v; goto done; @@ -147,7 +147,7 @@ int n; /* current position in pool */ /* move data from head to f */ if((head->data+k) != f->data ) - memcpy(f->data,(head->data+k),v); + memmove(f->data,(head->data+k),v); f->next = f->data+v; } diff --git a/src/lib/libast/sfio/sfrd.c b/src/lib/libast/sfio/sfrd.c index 09a493ca2..e82b7d6c8 100644 --- a/src/lib/libast/sfio/sfrd.c +++ b/src/lib/libast/sfio/sfrd.c @@ -201,7 +201,7 @@ Sfdisc_t* disc; if(buf) { if(n > (size_t)(r-a)) n = (ssize_t)(r-a); - memcpy(buf,f->next,n); + memmove(buf,f->next,n); f->next += n; } else n = f->endb - f->next; diff --git a/src/lib/libast/sfio/sfread.c b/src/lib/libast/sfio/sfread.c index a3aed9776..662889430 100644 --- a/src/lib/libast/sfio/sfread.c +++ b/src/lib/libast/sfio/sfread.c @@ -92,7 +92,7 @@ size_t n; /* number of bytes to be read. */ { if(r > (ssize_t)n) r = (ssize_t)n; if(s != f->next) - memcpy(s, f->next, r); + memmove(s, f->next, r); f->next += r; s += r; n -= r; diff --git a/src/lib/libast/sfio/sfvscanf.c b/src/lib/libast/sfio/sfvscanf.c index a757c2f91..24276d621 100644 --- a/src/lib/libast/sfio/sfvscanf.c +++ b/src/lib/libast/sfio/sfvscanf.c @@ -247,7 +247,7 @@ Void_t* mbs; /* multibyte parsing state */ /* shift left data so that there will be more room to back up on error. this won't help streams with small buffers - c'est la vie! */ if(sc->d > sc->f->data && (n = sc->endd - sc->d) > 0 && n < SFMBMAX) - { memcpy(sc->f->data, sc->d, n); + { memmove(sc->f->data, sc->d, n); if(sc->f->endr == sc->f->endb) sc->f->endr = sc->f->data+n; if(sc->f->endw == sc->f->endb) diff --git a/src/lib/libast/vmalloc/malloc.c b/src/lib/libast/vmalloc/malloc.c index ae77a2212..90b0336ab 100644 --- a/src/lib/libast/vmalloc/malloc.c +++ b/src/lib/libast/vmalloc/malloc.c @@ -823,7 +823,7 @@ static void vm_initialize_hook(void) __realloc_hook = vm_realloc_hook; } -void (*__malloc_initialize_hook)(void) = vm_initialize_hook; +typeof (__malloc_initialize_hook) __malloc_initialize_hook = vm_initialize_hook; #if 0 /* 2012-02-29 this may be needed to cover shared libs */ diff --git a/src/lib/libcmd/tail.c b/src/lib/libcmd/tail.c index ce52f9f3d..c8df4ba3b 100644 --- a/src/lib/libcmd/tail.c +++ b/src/lib/libcmd/tail.c @@ -28,7 +28,7 @@ */ static const char usage[] = -"+[-?\n@(#)$Id: tail (AT&T Research) 2012-06-19 $\n]" +"+[-?\n@(#)$Id: tail (AT&T Research) 2012-10-10 $\n]" USAGE_LICENSE "[+NAME?tail - output trailing portion of one or more files ]" "[+DESCRIPTION?\btail\b copies one or more input files to standard output " @@ -424,7 +424,7 @@ b_tail(int argc, char** argv, Shbltin_t* context) Tail_t* files; Tv_t tv; - cmdinit(argc, argv, context, ERROR_CATALOG, 0); + cmdinit(argc, argv, context, ERROR_CATALOG, ERROR_NOTIFY); for (;;) { switch (n = optget(argv, usage)) @@ -639,7 +639,7 @@ b_tail(int argc, char** argv, Shbltin_t* context) { if (n) n = 0; - else if (sh_checksig(context) || tvsleep(&tv, NiL)) + else if (sh_checksig(context) || tvsleep(&tv, NiL) && sh_checksig(context)) { error_info.errors++; break; @@ -686,11 +686,13 @@ b_tail(int argc, char** argv, Shbltin_t* context) { i = 3; while (--i && stat(fp->name, &st)) - if (sh_checksig(context) || tvsleep(&tv, NiL)) + if (sh_checksig(context)) { error_info.errors++; goto done; } + else + tvsleep(&tv, NiL); if (i && (fp->dev != st.st_dev || fp->ino != st.st_ino) && !init(fp, 0, 0, flags, &format)) { if (!(flags & SILENT)) diff --git a/src/lib/libexpr/expr.h b/src/lib/libexpr/expr.h index d5ec61b43..24fda222b 100644 --- a/src/lib/libexpr/expr.h +++ b/src/lib/libexpr/expr.h @@ -49,6 +49,10 @@ #include #if defined(YYSTYPE) || defined(yystype) #define EXSTYPE YYSTYPE +#else +#if defined(YYSTYPE) || defined(YYSTYPE_IS_DECLARED) +#define EXSTYPE YYSTYPE +#endif #endif #endif