[PATCH] HISTFILESIZE environment variable support in ash
Denys Vlasenko
vda.linux at googlemail.com
Tue Mar 22 16:20:11 UTC 2011
On Wed, Mar 16, 2011 at 3:47 PM, Alexey Fomenko
<ext-alexey.fomenko at nokia.com> wrote:
> This patch adds support of environment variable HISTFILESIZE in *_history
> functions so the history length could be changed not only during compilation
> time. Default value is 256 lines.
>
> Alexey Fomenko (1):
> Add support of environment variable HISTFILESIZE to history
>
> include/libbb.h | 7 ++++
> include/variables.h | 16 ++++++++++
> libbb/Config.src | 8 +++++
> libbb/lineedit.c | 63 +++++++++++++++++++++++++++++++++--------
> shell/ash.c | 66 +++++++++++++++++++++++++++++++++++++++++++-
> 5 files changed, 146 insertions(+), 14 deletions(-)
> create mode 100644 include/variables.h
$ make
...
History size environment variable (FEATURE_HISTFILESIZE_VAR) [256] (NEW)
What does it ask me about?
With CONFIG_WERROR=y:
$ make
...
make
CC libbb/lineedit.o
cc1: warnings being treated as errors
In file included from libbb/lineedit.c:44:
include/variables.h:12: error: function declaration isn't a prototype
include/variables.h:13: error: function declaration isn't a prototype
include/variables.h:14: error: function declaration isn't a prototype
libbb/lineedit.c: In function 'load_history':
libbb/lineedit.c:1302: error: suggest explicit braces to avoid ambiguous 'else'
libbb/lineedit.c:1306: error: ISO C90 forbids mixed declarations and code
libbb/lineedit.c: In function 'save_history':
libbb/lineedit.c:1378: error: suggest explicit braces to avoid ambiguous 'else'
libbb/lineedit.c:1382: error: ISO C90 forbids mixed declarations and code
libbb/lineedit.c:1382: error: unused variable 'temp_h'
libbb/lineedit.c: In function 'remember_in_history':
libbb/lineedit.c:1441: error: suggest explicit braces to avoid ambiguous 'else'
libbb/lineedit.c:1445: error: ISO C90 forbids mixed declarations and code
libbb/lineedit.c:1445: error: unused variable 'temp_h'
make[1]: *** [libbb/lineedit.o] Error 1
make: *** [libbb] Error 2
With CONFIG_ASH not set and CONFIG_HUSH=y:
$ make
...
LINK busybox_unstripped
Trying libraries: crypt m
Failed: -Wl,--start-group -lcrypt -lm -Wl,--end-group
Output of:
i486-linux-uclibc-gcc -Wall -Wshadow -Wwrite-strings -Wundef
-Wstrict-prototypes -Wunused -Wunused-parameter -Wunused-function
-Wunused-value -Wmissing-prototypes -Wmissing-declarations
-Wdeclaration-after-statement -Wold-style-definition
-fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer
-ffunction-sections -fdata-sections -fno-guess-branch-probability
-funsigned-char -static-libgcc -falign-functions=1 -falign-jumps=1
-falign-labels=1 -falign-loops=1 -Os -march=i386
-mpreferred-stack-boundary=2 -static -o busybox_unstripped
-Wl,--sort-common -Wl,--sort-section,alignment -Wl,--gc-sections
-Wl,--start-group applets/built-in.o archival/lib.a
archival/libarchive/lib.a console-tools/lib.a coreutils/lib.a
coreutils/libcoreutils/lib.a debianutils/lib.a e2fsprogs/lib.a
editors/lib.a findutils/lib.a init/lib.a libbb/lib.a libpwdgrp/lib.a
loginutils/lib.a mailutils/lib.a miscutils/lib.a modutils/lib.a
networking/lib.a networking/libiproute/lib.a networking/udhcp/lib.a
printutils/lib.a procps/lib.a runit/lib.a selinux/lib.a shell/lib.a
sysklogd/lib.a util-linux/lib.a util-linux/volume_id/lib.a
archival/built-in.o archival/libarchive/built-in.o
console-tools/built-in.o coreutils/built-in.o
coreutils/libcoreutils/built-in.o debianutils/built-in.o
e2fsprogs/built-in.o editors/built-in.o findutils/built-in.o
init/built-in.o libbb/built-in.o libpwdgrp/built-in.o
loginutils/built-in.o mailutils/built-in.o miscutils/built-in.o
modutils/built-in.o networking/built-in.o
networking/libiproute/built-in.o networking/udhcp/built-in.o
printutils/built-in.o procps/built-in.o runit/built-in.o
selinux/built-in.o shell/built-in.o sysklogd/built-in.o
util-linux/built-in.o util-linux/volume_id/built-in.o -Wl,--end-group
-Wl,--start-group -lcrypt -lm -Wl,--end-group
==========
archival/lib.a(bbunzip.o): In function `bbunpack':
bbunzip.c:(.text.bbunpack+0x15e): warning: the use of LEGACY `utimes'
is discouraged, use `utime'
libbb/lib.a(lineedit.o): In function `load_history':
lineedit.c:(.text.load_history+0xd): undefined reference to
`lookupvar_histfilesize'
lineedit.c:(.text.load_history+0x19): undefined reference to
`setvar_histfilesize_def_safe'
lineedit.c:(.text.load_history+0x29): undefined reference to
`lookupvar_histfilesize'
libbb/lib.a(lineedit.o): In function `save_history':
lineedit.c:(.text.save_history+0xf): undefined reference to
`lookupvar_histfilesize'
lineedit.c:(.text.save_history+0x1a): undefined reference to
`setvar_histfilesize_def_safe'
lineedit.c:(.text.save_history+0x28): undefined reference to
`lookupvar_histfilesize'
libbb/lib.a(lineedit.o): In function `remember_in_history':
lineedit.c:(.text.remember_in_history+0x10): undefined reference to
`lookupvar_histfilesize'
lineedit.c:(.text.remember_in_history+0x1b): undefined reference to
`setvar_histfilesize_def_safe'
lineedit.c:(.text.remember_in_history+0x29): undefined reference to
`lookupvar_histfilesize'
collect2: ld returned 1 exit status
make: *** [busybox_unstripped] Error 1
+# if ENABLE_FEATURE_HISTFILESIZE_VAR
+ char *history[MAX_HISTFILESIZE + 1];
+# else <-----------------------------------------------------------------
trailing space here
char *history[MAX_HISTORY + 1];
+# endif
--- /dev/null
+++ b/include/variables.h
Please put any additional stuff you need into libbb.h
+/*
+ * Busybx support of variables in history
+ * 2011 March
+ */
What are this file licensing conditions?
+int FAST_FUNC setvar_histfilesize_def();
+int FAST_FUNC setvar_histfilesize_def_safe();
"def" - is it "default"? "define"? "safe" in what sense?
+config FEATURE_HISTFILESIZE_VAR
+ int "History size environment variable"
+ range 0 99999
+ default 256
+ depends on FEATURE_EDITING
+ help
+ Specify environment variable HISTFILESIZE default value
And if I dont want to have $HISTFILESIZE support at all?
+ if ( hist_max_size < 0)
+ if (setvar_histfilesize_def_safe()) <--- space here
+ hist_max_size = MAX_HISTFILESIZE;
+ else hist_max_size = lookupvar_histfilesize();
This should look like this (style-wise):
if (hist_max_size < 0) <--- no space inside (abc)
if (setvar_histfilesize_def_safe()) <--- no trailing space here
hist_max_size = MAX_HISTFILESIZE;
else
hist_max_size = lookupvar_histfilesize();
+# if ENABLE_FEATURE_HISTFILESIZE_VAR
+ setvar_histfilesize_def_safe();
+# endif
}
Bad indentation.
--
vda
More information about the busybox
mailing list