mirtoconf the checks if to use persistent history support

This commit is contained in:
tg 2007-03-03 21:36:08 +00:00
parent f6ff09ccbe
commit e31b852abc
5 changed files with 26 additions and 22 deletions

View File

@ -1,5 +1,5 @@
#!/bin/sh
# $MirOS: src/bin/mksh/Build.sh,v 1.153 2007/02/27 00:31:17 tg Exp $
# $MirOS: src/bin/mksh/Build.sh,v 1.154 2007/03/03 21:36:06 tg Exp $
#-
# Env: CC, CFLAGS, CPP, CPPFLAGS, LDFLAGS, LIBS, NOWARN, NROFF, TARGET_OS
# CPPFLAGS recognised: MKSH_SMALL MKSH_ASSUME_UTF8 MKSH_NEED_MKNOD MKSH_NOPWNAM
@ -459,8 +459,6 @@ ac_test flock_ex '' 'flock and LOCK_EX' <<-'EOF'
#include <fcntl.h>
int main(void) { return (flock(0, LOCK_EX)); }
EOF
test 11 = $HAVE_FLOCK_EX$HAVE_MKSH_FULL || \
check_categories=$check_categories,no-histfile
ac_test setlocale_ctype '!' mksh_defutf8 0 'setlocale(LC_CTYPE, "")' <<-'EOF'
#include <locale.h>
@ -525,6 +523,15 @@ ac_test multi_idstring '' 'if we can use __RCSID(x) multiple times' <<-'EOF'
int main(void) { return (0); }
EOF
ac_test persistent_history mksh_full 0 'if to use persistent history' <<-'EOF'
#if !HAVE_FLOCK_EX || defined(MKSH_SMALL)
#error No, some prerequisites are missing.
#endif
int main(void) { return (0); }
EOF
test 1 = $HAVE_PERSISTENT_HISTORY || \
check_categories=$check_categories,no-histfile
#
# Compiler: Praeprocessor (only if needed)
#

View File

@ -3,12 +3,12 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.42 2007/02/27 15:03:28 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.43 2007/03/03 21:36:07 tg Exp $");
Trap sigtraps[NSIG + 1];
static struct sigaction Sigact_ign, Sigact_trap;
#ifdef V_HISTFILE
#if HAVE_PERSISTENT_HISTORY
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);
@ -28,7 +28,7 @@ static char **current; /* current position in history[] */
static int hstarted; /* set after hist_init() called */
static Source *hist_source;
#ifdef V_HISTFILE
#if HAVE_PERSISTENT_HISTORY
static char *hname; /* current name of history file */
static int histfd;
static int hsize;
@ -501,7 +501,7 @@ sethistsize(int n)
}
}
#ifdef V_HISTFILE
#if HAVE_PERSISTENT_HISTORY
/*
* set history file
* This can mean reloading/resetting/starting history file
@ -573,7 +573,7 @@ histsave(int lno __unused, const char *cmd, int dowrite __unused)
if ((cp = strchr(c, '\n')) != NULL)
*cp = '\0';
#ifdef V_HISTFILE
#if HAVE_PERSISTENT_HISTORY
if (histfd && dowrite)
writehistfile(lno, c);
#endif
@ -616,7 +616,7 @@ histsave(int lno __unused, const char *cmd, int dowrite __unused)
void
hist_init(Source *s)
{
#ifdef V_HISTFILE
#if HAVE_PERSISTENT_HISTORY
unsigned char *base;
int lines;
int fd;
@ -629,7 +629,7 @@ hist_init(Source *s)
hist_source = s;
#ifdef V_HISTFILE
#if HAVE_PERSISTENT_HISTORY
hname = str_val(global("HISTFILE"));
if (hname == NULL)
return;
@ -689,7 +689,7 @@ hist_init(Source *s)
#endif
}
#ifdef V_HISTFILE
#if HAVE_PERSISTENT_HISTORY
typedef enum state {
shdr, /* expecting a header */
sline, /* looking for a null byte to end the line */

4
main.c
View File

@ -13,7 +13,7 @@
#include <locale.h>
#endif
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.70 2007/02/13 13:36:18 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.71 2007/03/03 21:36:07 tg Exp $");
extern char **environ;
@ -615,7 +615,7 @@ quitenv(struct shf *shf)
*/
if (ep->oenv == NULL) {
if (ep->type == E_NONE) { /* Main shell exiting? */
#ifdef V_HISTFILE
#if HAVE_PERSISTENT_HISTORY
if (Flag(FTALKING))
hist_finish();
#endif

9
sh.h
View File

@ -8,7 +8,7 @@
/* $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 $ */
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.112 2007/02/16 17:46:42 tg Exp $"
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.113 2007/03/03 21:36:07 tg Exp $"
#define MKSH_VERSION "R29 2007/02/16"
#if HAVE_SYS_PARAM_H
@ -739,10 +739,7 @@ extern const struct builtin shbuiltins [], kshbuiltins [];
#define V_OPTIND 4
#define V_RANDOM 8
#define V_HISTSIZE 9
/* this is defined when we support persistent history, undefined otherwise */
#if HAVE_FLOCK_EX && !defined(MKSH_SMALL)
#define V_HISTFILE 10
#endif
#define V_COLUMNS 13
#define V_TMOUT 15
#define V_TMPDIR 16
@ -1173,13 +1170,13 @@ int c_test(char **);
/* histrap.c */
void init_histvec(void);
void hist_init(Source *);
#ifdef V_HISTFILE
#if HAVE_PERSISTENT_HISTORY
void hist_finish(void);
#endif
void histsave(int, const char *, int);
int c_fc(char **);
void sethistsize(int);
#ifdef V_HISTFILE
#if HAVE_PERSISTENT_HISTORY
void sethistfile(const char *);
#endif
char **histpos(void);

6
var.c
View File

@ -2,7 +2,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.34 2007/01/15 02:48:28 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.35 2007/03/03 21:36:08 tg Exp $");
/*
* Variables
@ -88,7 +88,7 @@ initvar(void)
{ "OPTIND", V_OPTIND },
{ "PATH", V_PATH },
{ "TMPDIR", V_TMPDIR },
#ifdef V_HISTFILE
#if HAVE_PERSISTENT_HISTORY
{ "HISTFILE", V_HISTFILE },
#endif
{ "HISTSIZE", V_HISTSIZE },
@ -987,7 +987,7 @@ setspec(struct tbl *vp)
sethistsize((int) intval(vp));
vp->flag |= SPECIAL;
break;
#ifdef V_HISTFILE
#if HAVE_PERSISTENT_HISTORY
case V_HISTFILE:
sethistfile(str_val(vp));
break;