diff --git a/histrap.c b/histrap.c index 669b51a..98f9b6e 100644 --- a/histrap.c +++ b/histrap.c @@ -1,4 +1,4 @@ -/** $MirOS: src/bin/mksh/histrap.c,v 1.5 2005/05/23 15:09:22 tg Exp $ */ +/** $MirOS: src/bin/mksh/histrap.c,v 1.6 2005/05/23 15:36:55 tg Exp $ */ /* $OpenBSD: history.c,v 1.30 2005/03/30 17:16:37 deraadt Exp $ */ /* $OpenBSD: trap.c,v 1.22 2005/03/30 17:16:37 deraadt Exp $ */ @@ -8,18 +8,20 @@ #include #include -__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.5 2005/05/23 15:09:22 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.6 2005/05/23 15:36:55 tg Exp $"); static int histfd; static int hsize; +static void histinsert(Source *, int, unsigned char *); +#ifndef __sun__ static int hist_count_lines(unsigned char *, int); static int hist_shrink(unsigned char *, int); static unsigned char *hist_skip_back(unsigned char *,int *,int); static void histload(Source *, unsigned char *, int); -static void histinsert(Source *, int, unsigned char *); static void writehistfile(int, char *); static int sprinkle(int); +#endif static int hist_execute(char *); static int hist_replace(char **, const char *, const char *, int); @@ -595,8 +597,10 @@ histsave(int lno, const char *cmd, int dowrite) if ((cp = strchr(c, '\n')) != NULL) *cp = '\0'; +#ifndef __sun__ if (histfd && dowrite) writehistfile(lno, c); +#endif hp = histptr; @@ -636,9 +640,11 @@ histsave(int lno, const char *cmd, int dowrite) void hist_init(Source *s) { +#ifndef __sun__ unsigned char *base; int lines; int fd; +#endif if (Flag(FTALKING) == 0) return; @@ -647,6 +653,10 @@ hist_init(Source *s) hist_source = s; +#ifdef __sun__ + hname = NULL; + histfd = 0; +#else hname = str_val(global("HISTFILE")); if (hname == NULL) return; @@ -702,6 +712,7 @@ hist_init(Source *s) } (void) flock(histfd, LOCK_UN); hsize = lseek(histfd, 0L, SEEK_END); +#endif } typedef enum state { @@ -711,6 +722,7 @@ typedef enum state { sn2, sn3, sn4 } State; +#ifndef __sun__ static int hist_count_lines(unsigned char *base, int bytes) { @@ -790,7 +802,6 @@ hist_shrink(unsigned char *oldbase, int oldbytes) return 0; } - /* * find a pointer to the data 'no' back from the end of the file * return the pointer and the number of bytes left @@ -867,6 +878,7 @@ histload(Source *s, unsigned char *base, int bytes) } } } +#endif /* * Insert a line into the history at a specified number @@ -884,6 +896,7 @@ histinsert(Source *s, int lno, unsigned char *line) } } +#ifndef __sun__ /* * write a command to the end of the history file * This *MAY* seem easy but it's also necessary to check @@ -947,15 +960,19 @@ writehistfile(int lno, char *cmd) bad: hist_finish(); } +#endif void hist_finish(void) { +#ifndef __sun__ (void) flock(histfd, LOCK_UN); (void) close(histfd); +#endif histfd = 0; } +#ifndef __sun__ /* * add magic to the history file */ @@ -966,6 +983,7 @@ sprinkle(int fd) return(write(fd, mag, 2) != 2); } +#endif #ifdef NEED_MKSH_SIGNAME static const char * diff --git a/main.c b/main.c index 43f3e45..3170125 100644 --- a/main.c +++ b/main.c @@ -1,4 +1,4 @@ -/** $MirOS: src/bin/mksh/main.c,v 1.2 2005/05/23 14:22:03 tg Exp $ */ +/** $MirOS: src/bin/mksh/main.c,v 1.3 2005/05/23 15:36:55 tg Exp $ */ /* $OpenBSD: main.c,v 1.38 2005/03/30 17:16:37 deraadt Exp $ */ /* $OpenBSD: tty.c,v 1.8 2005/03/30 17:16:37 deraadt Exp $ */ /* $OpenBSD: io.c,v 1.21 2005/03/30 17:16:37 deraadt Exp $ */ @@ -10,7 +10,7 @@ #include #include -__RCSID("$MirOS: src/bin/mksh/main.c,v 1.2 2005/05/23 14:22:03 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/main.c,v 1.3 2005/05/23 15:36:55 tg Exp $"); extern char **environ; @@ -201,7 +201,7 @@ main(int argc, char *argv[]) setstr(pwd_v, current_wd, KSH_RETURN_ERROR); } ppid = getppid(); -#if !defined(__gnu_linux__) && !defined(__INTERIX) +#if !defined(__gnu_linux__) && !defined(__INTERIX) && !defined(__sun__) srand((*((long *)kshname)) ^ ((long)time(NULL) * kshpid * ppid)); #endif setint(global("PPID"), (long) ppid); diff --git a/sh.h b/sh.h index ac3bc7b..d0d8bae 100644 --- a/sh.h +++ b/sh.h @@ -1,4 +1,4 @@ -/** $MirOS: src/bin/mksh/sh.h,v 1.4 2005/05/23 15:24:43 tg Exp $ */ +/** $MirOS: src/bin/mksh/sh.h,v 1.5 2005/05/23 15:36:55 tg Exp $ */ /* $OpenBSD: sh.h,v 1.27 2005/03/28 21:33:04 deraadt Exp $ */ /* $OpenBSD: shf.h,v 1.5 2005/03/30 17:16:37 deraadt Exp $ */ /* $OpenBSD: table.h,v 1.6 2004/12/18 20:55:52 millert Exp $ */ @@ -100,6 +100,9 @@ typedef int32_t Tflag; #ifndef PATH_MAX #define PATH_MAX 1024 /* pathname size (todo: PATH_MAX/pathconf()) */ #endif +#ifndef _PATH_DEFPATH +#define _PATH_DEFPATH "/bin:/usr/bin:/sbin:/usr/sbin" +#endif EXTERN char * kshname; /* $0 */ EXTERN pid_t kshpid; /* $$, shell pid */ @@ -1301,6 +1304,10 @@ size_t strlcat(char *, const char *, size_t); size_t strlcpy(char *, const char *, size_t); #endif +#if defined(__sun__) +size_t confstr(int, char *, size_t); +#endif + #ifndef timeradd #define timeradd(tvp, uvp, vvp) \ do { \ diff --git a/var.c b/var.c index f013e45..0c5d545 100644 --- a/var.c +++ b/var.c @@ -1,4 +1,4 @@ -/** $MirOS: src/bin/mksh/var.c,v 1.2 2005/05/23 14:22:03 tg Exp $ */ +/** $MirOS: src/bin/mksh/var.c,v 1.3 2005/05/23 15:36:56 tg Exp $ */ /* $OpenBSD: var.c,v 1.26 2005/03/30 17:16:37 deraadt Exp $ */ #include "sh.h" @@ -6,7 +6,7 @@ #include #include -__RCSID("$MirOS: src/bin/mksh/var.c,v 1.2 2005/05/23 14:22:03 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/var.c,v 1.3 2005/05/23 15:36:56 tg Exp $"); /* * Variables @@ -855,7 +855,7 @@ makenv(void) * Someone has set the srand() value, therefore from now on * we return values from rand() instead of arc4random() */ -#if !defined(__gnu_linux__) && !defined(__INTERIX) +#if !defined(__gnu_linux__) && !defined(__INTERIX) && !defined(__sun__) int use_rand = 0; #else int use_rand = 1; @@ -919,7 +919,7 @@ getspec(struct tbl *vp) vp->flag &= ~SPECIAL; if (use_rand) setint(vp, (long) (rand() & 0x7fff)); -#if !defined(__gnu_linux__) && !defined(__INTERIX) +#if !defined(__gnu_linux__) && !defined(__INTERIX) && !defined(__sun__) else setint(vp, (long) (arc4random() & 0x7fff)); #endif