if MKSH_SMALL, disable persistent history code as well (like on Solaris,
where it can't work anyway), and fix that code to shrink saves 2071t 20d 5i
This commit is contained in:
29
histrap.c
29
histrap.c
@ -3,11 +3,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.30 2006/11/10 04:22:13 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.31 2006/11/10 05:23:12 tg Exp $");
|
||||||
|
|
||||||
#if !defined(__sun__)
|
|
||||||
#define DO_HISTORY
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef mksh_siglist
|
#ifndef mksh_siglist
|
||||||
#if defined(BSD) || defined(__APPLE__)
|
#if defined(BSD) || defined(__APPLE__)
|
||||||
@ -27,7 +23,7 @@ __RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.30 2006/11/10 04:22:13 tg Exp $");
|
|||||||
Trap sigtraps[NSIG + 1];
|
Trap sigtraps[NSIG + 1];
|
||||||
static struct sigaction Sigact_ign, Sigact_trap;
|
static struct sigaction Sigact_ign, Sigact_trap;
|
||||||
|
|
||||||
#ifdef DO_HISTORY
|
#ifdef V_HISTFILE
|
||||||
static int hist_count_lines(unsigned char *, int);
|
static int hist_count_lines(unsigned char *, int);
|
||||||
static int hist_shrink(unsigned char *, int);
|
static int hist_shrink(unsigned char *, int);
|
||||||
static unsigned char *hist_skip_back(unsigned char *,int *,int);
|
static unsigned char *hist_skip_back(unsigned char *,int *,int);
|
||||||
@ -44,12 +40,14 @@ static char **hist_get_oldest(void);
|
|||||||
static void histbackup(void);
|
static void histbackup(void);
|
||||||
|
|
||||||
static char **current; /* current position in history[] */
|
static char **current; /* current position in history[] */
|
||||||
static char *hname; /* current name of history file */
|
|
||||||
static int hstarted; /* set after hist_init() called */
|
static int hstarted; /* set after hist_init() called */
|
||||||
static Source *hist_source;
|
static Source *hist_source;
|
||||||
|
|
||||||
|
#ifdef V_HISTFILE
|
||||||
|
static char *hname; /* current name of history file */
|
||||||
static int histfd;
|
static int histfd;
|
||||||
static int hsize;
|
static int hsize;
|
||||||
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
c_fc(char **wp)
|
c_fc(char **wp)
|
||||||
@ -518,6 +516,7 @@ sethistsize(int n)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef V_HISTFILE
|
||||||
/*
|
/*
|
||||||
* set history file
|
* set history file
|
||||||
* This can mean reloading/resetting/starting history file
|
* This can mean reloading/resetting/starting history file
|
||||||
@ -551,6 +550,7 @@ sethistfile(const char *name)
|
|||||||
|
|
||||||
hist_init(hist_source);
|
hist_init(hist_source);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* initialise the history vector
|
* initialise the history vector
|
||||||
@ -589,7 +589,7 @@ histsave(int lno __attribute__((unused)), const char *cmd,
|
|||||||
if ((cp = strchr(c, '\n')) != NULL)
|
if ((cp = strchr(c, '\n')) != NULL)
|
||||||
*cp = '\0';
|
*cp = '\0';
|
||||||
|
|
||||||
#ifdef DO_HISTORY
|
#ifdef V_HISTFILE
|
||||||
if (histfd && dowrite)
|
if (histfd && dowrite)
|
||||||
writehistfile(lno, c);
|
writehistfile(lno, c);
|
||||||
#endif
|
#endif
|
||||||
@ -632,7 +632,7 @@ histsave(int lno __attribute__((unused)), const char *cmd,
|
|||||||
void
|
void
|
||||||
hist_init(Source *s)
|
hist_init(Source *s)
|
||||||
{
|
{
|
||||||
#ifdef DO_HISTORY
|
#ifdef V_HISTFILE
|
||||||
unsigned char *base;
|
unsigned char *base;
|
||||||
int lines;
|
int lines;
|
||||||
int fd;
|
int fd;
|
||||||
@ -645,7 +645,7 @@ hist_init(Source *s)
|
|||||||
|
|
||||||
hist_source = s;
|
hist_source = s;
|
||||||
|
|
||||||
#ifdef DO_HISTORY
|
#ifdef V_HISTFILE
|
||||||
hname = str_val(global("HISTFILE"));
|
hname = str_val(global("HISTFILE"));
|
||||||
if (hname == NULL)
|
if (hname == NULL)
|
||||||
return;
|
return;
|
||||||
@ -702,12 +702,10 @@ hist_init(Source *s)
|
|||||||
}
|
}
|
||||||
(void) flock(histfd, LOCK_UN);
|
(void) flock(histfd, LOCK_UN);
|
||||||
hsize = lseek(histfd, 0L, SEEK_END);
|
hsize = lseek(histfd, 0L, SEEK_END);
|
||||||
#else
|
|
||||||
hname = NULL;
|
|
||||||
histfd = 0;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef V_HISTFILE
|
||||||
typedef enum state {
|
typedef enum state {
|
||||||
shdr, /* expecting a header */
|
shdr, /* expecting a header */
|
||||||
sline, /* looking for a null byte to end the line */
|
sline, /* looking for a null byte to end the line */
|
||||||
@ -715,7 +713,6 @@ typedef enum state {
|
|||||||
sn2, sn3, sn4
|
sn2, sn3, sn4
|
||||||
} State;
|
} State;
|
||||||
|
|
||||||
#ifdef DO_HISTORY
|
|
||||||
static int
|
static int
|
||||||
hist_count_lines(unsigned char *base, int bytes)
|
hist_count_lines(unsigned char *base, int bytes)
|
||||||
{
|
{
|
||||||
@ -947,19 +944,15 @@ writehistfile(int lno, char *cmd)
|
|||||||
bad:
|
bad:
|
||||||
hist_finish();
|
hist_finish();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void
|
void
|
||||||
hist_finish(void)
|
hist_finish(void)
|
||||||
{
|
{
|
||||||
#ifdef DO_HISTORY
|
|
||||||
(void) flock(histfd, LOCK_UN);
|
(void) flock(histfd, LOCK_UN);
|
||||||
(void) close(histfd);
|
(void) close(histfd);
|
||||||
#endif
|
|
||||||
histfd = 0;
|
histfd = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DO_HISTORY
|
|
||||||
/*
|
/*
|
||||||
* add magic to the history file
|
* add magic to the history file
|
||||||
*/
|
*/
|
||||||
|
4
main.c
4
main.c
@ -13,7 +13,7 @@
|
|||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.54 2006/11/10 03:23:49 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.55 2006/11/10 05:23:12 tg Exp $");
|
||||||
|
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
|
|
||||||
@ -597,8 +597,10 @@ quitenv(struct shf *shf)
|
|||||||
*/
|
*/
|
||||||
if (ep->oenv == NULL) {
|
if (ep->oenv == NULL) {
|
||||||
if (ep->type == E_NONE) { /* Main shell exiting? */
|
if (ep->type == E_NONE) { /* Main shell exiting? */
|
||||||
|
#ifdef V_HISTFILE
|
||||||
if (Flag(FTALKING))
|
if (Flag(FTALKING))
|
||||||
hist_finish();
|
hist_finish();
|
||||||
|
#endif
|
||||||
j_exit();
|
j_exit();
|
||||||
if (ep->flags & EF_FAKE_SIGDIE) {
|
if (ep->flags & EF_FAKE_SIGDIE) {
|
||||||
int sig = exstat - 128;
|
int sig = exstat - 128;
|
||||||
|
9
mksh.1
9
mksh.1
@ -1,7 +1,7 @@
|
|||||||
.\" $MirOS: src/bin/mksh/mksh.1,v 1.64 2006/11/09 22:11:08 tg Exp $
|
.\" $MirOS: src/bin/mksh/mksh.1,v 1.65 2006/11/10 05:23:12 tg Exp $
|
||||||
.\" $OpenBSD: ksh.1,v 1.116 2006/07/26 10:13:25 jmc Exp $
|
.\" $OpenBSD: ksh.1,v 1.116 2006/07/26 10:13:25 jmc Exp $
|
||||||
.\"
|
.\"
|
||||||
.Dd November 9, 2006
|
.Dd November 10, 2006
|
||||||
.Dt MKSH 1
|
.Dt MKSH 1
|
||||||
.Os MirBSD
|
.Os MirBSD
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -5292,7 +5292,10 @@ projects and patches and suggestions from users
|
|||||||
and many other persons.
|
and many other persons.
|
||||||
.Sh BUGS
|
.Sh BUGS
|
||||||
This document attempts to describe
|
This document attempts to describe
|
||||||
.Nm "" R29 .
|
.Nm "" R29 ,
|
||||||
|
compiled without
|
||||||
|
.Dv MKSH_SMALL
|
||||||
|
or similar functionality-reducing options.
|
||||||
Please report bugs in
|
Please report bugs in
|
||||||
.Nm
|
.Nm
|
||||||
to the
|
to the
|
||||||
|
8
sh.h
8
sh.h
@ -8,7 +8,7 @@
|
|||||||
/* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */
|
/* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */
|
||||||
/* $OpenBSD: tty.h,v 1.5 2004/12/20 11:34:26 otto Exp $ */
|
/* $OpenBSD: tty.h,v 1.5 2004/12/20 11:34:26 otto Exp $ */
|
||||||
|
|
||||||
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.73 2006/11/10 03:45:57 tg Exp $"
|
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.74 2006/11/10 05:23:13 tg Exp $"
|
||||||
#define MKSH_VERSION "R29 2006/11/10"
|
#define MKSH_VERSION "R29 2006/11/10"
|
||||||
|
|
||||||
#if HAVE_SYS_PARAM_H
|
#if HAVE_SYS_PARAM_H
|
||||||
@ -688,7 +688,9 @@ extern const struct builtin shbuiltins [], kshbuiltins [];
|
|||||||
#define V_OPTIND 4
|
#define V_OPTIND 4
|
||||||
#define V_RANDOM 8
|
#define V_RANDOM 8
|
||||||
#define V_HISTSIZE 9
|
#define V_HISTSIZE 9
|
||||||
|
#if !defined(__sun__) && !defined(MKSH_SMALL)
|
||||||
#define V_HISTFILE 10
|
#define V_HISTFILE 10
|
||||||
|
#endif
|
||||||
#define V_COLUMNS 13
|
#define V_COLUMNS 13
|
||||||
#define V_TMOUT 15
|
#define V_TMOUT 15
|
||||||
#define V_TMPDIR 16
|
#define V_TMPDIR 16
|
||||||
@ -1119,11 +1121,15 @@ int c_test(char **);
|
|||||||
/* histrap.c */
|
/* histrap.c */
|
||||||
void init_histvec(void);
|
void init_histvec(void);
|
||||||
void hist_init(Source *);
|
void hist_init(Source *);
|
||||||
|
#ifdef V_HISTFILE
|
||||||
void hist_finish(void);
|
void hist_finish(void);
|
||||||
|
#endif
|
||||||
void histsave(int, const char *, int);
|
void histsave(int, const char *, int);
|
||||||
int c_fc(char **);
|
int c_fc(char **);
|
||||||
void sethistsize(int);
|
void sethistsize(int);
|
||||||
|
#ifdef V_HISTFILE
|
||||||
void sethistfile(const char *);
|
void sethistfile(const char *);
|
||||||
|
#endif
|
||||||
char **histpos(void);
|
char **histpos(void);
|
||||||
int histnum(int);
|
int histnum(int);
|
||||||
int findhist(int, int, const char *, int);
|
int findhist(int, int, const char *, int);
|
||||||
|
6
var.c
6
var.c
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.25 2006/11/10 04:22:13 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.26 2006/11/10 05:23:14 tg Exp $");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Variables
|
* Variables
|
||||||
@ -88,7 +88,9 @@ initvar(void)
|
|||||||
{ "OPTIND", V_OPTIND },
|
{ "OPTIND", V_OPTIND },
|
||||||
{ "PATH", V_PATH },
|
{ "PATH", V_PATH },
|
||||||
{ "TMPDIR", V_TMPDIR },
|
{ "TMPDIR", V_TMPDIR },
|
||||||
|
#ifdef V_HISTFILE
|
||||||
{ "HISTFILE", V_HISTFILE },
|
{ "HISTFILE", V_HISTFILE },
|
||||||
|
#endif
|
||||||
{ "HISTSIZE", V_HISTSIZE },
|
{ "HISTSIZE", V_HISTSIZE },
|
||||||
{ "RANDOM", V_RANDOM },
|
{ "RANDOM", V_RANDOM },
|
||||||
{ "SECONDS", V_SECONDS },
|
{ "SECONDS", V_SECONDS },
|
||||||
@ -991,9 +993,11 @@ setspec(struct tbl *vp)
|
|||||||
sethistsize((int) intval(vp));
|
sethistsize((int) intval(vp));
|
||||||
vp->flag |= SPECIAL;
|
vp->flag |= SPECIAL;
|
||||||
break;
|
break;
|
||||||
|
#ifdef V_HISTFILE
|
||||||
case V_HISTFILE:
|
case V_HISTFILE:
|
||||||
sethistfile(str_val(vp));
|
sethistfile(str_val(vp));
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
case V_COLUMNS:
|
case V_COLUMNS:
|
||||||
if ((x_cols = intval(vp)) <= MIN_COLS)
|
if ((x_cols = intval(vp)) <= MIN_COLS)
|
||||||
x_cols = MIN_COLS;
|
x_cols = MIN_COLS;
|
||||||
|
Reference in New Issue
Block a user