Add simple fallback implementation of seq command, installed automatically on systems which lack the regular seq command

darcs-hash:20060122210756-ac50b-f09a50f61137acef18f0d2be16e2556b2cdea921.gz
This commit is contained in:
axel 2006-01-23 07:07:56 +10:00
parent a824646d61
commit 3e3541a05a
5 changed files with 50 additions and 10 deletions

View file

@ -47,6 +47,9 @@ fishfile = @fishfile@
fishinputfile = @fishinputfile@
docdir = @docdir@
#Init files to install
INIT_DIR_INSTALL = init/fish_interactive.fish init/fish_function.fish init/fish_complete.fish
HAVE_GETTEXT=@HAVE_GETTEXT@
# All objects used by fish, that are compiled from an ordinary .c file
@ -134,7 +137,7 @@ MAIN_DIR_FILES := Doxyfile Doxyfile.user Makefile.in configure \
$(COMMON_OBJS:.o=.h) $(COMMON_OBJS_WITH_CODE:.o=.c) \
$(COMMON_OBJS:.o=.c) builtin_help.hdr fish.spec.in INSTALL README \
user_doc.head.html xsel-0.9.6.tar ChangeLog config.sub \
config.guess fish_tests.c main.c fish_pager.c fishd.c
config.guess fish_tests.c main.c fish_pager.c fishd.c seq.in
# Files in ./init/
INIT_DIR_FILES :=init/fish.in init/fish_complete.fish.in \
@ -148,7 +151,7 @@ TESTS_DIR_FILES := $(TEST_IN) $(TEST_IN:.in=.out) $(TEST_IN:.in=.err) \
COMPLETIONS_DIR_FILES := $(wildcard init/completions/*.fish)
# Programs to build
PROGRAMS:=fish set_color @XSEL@ mimedb count fish_pager fishd
PROGRAMS:=fish set_color @XSEL@ @SEQ_FALLBACK@ mimedb count fish_pager fishd
# Manuals to install
MANUALS:=doc_src/fish.1 @XSEL_MAN_PATH@ \
@ -311,7 +314,7 @@ install: all install-translations
$(INSTALL) -m 755 -d $(DESTDIR)$(sysconfdir)$(fishdir)
$(INSTALL) -m 755 -d $(DESTDIR)$(sysconfdir)$(fishdir)/completions
$(INSTALL) -m 644 init/fish $(DESTDIR)$(sysconfdir)$(fishfile)
for i in init/fish_interactive.fish init/fish_function.fish init/fish_complete.fish ; do \
for i in $(INIT_DIR_INSTALL); do \
$(INSTALL) -m 644 $$i $(DESTDIR)$(sysconfdir)$(fishdir); \
done;
for i in $(COMPLETIONS_DIR_FILES); do \

View file

@ -32,6 +32,9 @@ if ! test $has_doxygen = "true"; then
exit 1
fi
# Check for seq program. If missing, install fallback shellscript implementation
AC_CHECK_PROG( SEQ_FALLBACK, seq, [ ], [seq])
# Optionally drop xsel
AC_ARG_WITH( xsel,
AC_HELP_STRING([--without-xsel],
@ -183,7 +186,7 @@ AC_CHECK_HEADERS([ncurses.h],[AC_SUBST(CURSESLIB,[ncurses]) AC_DEFINE(HAVE_NCURS
# does not properly support terminfo.
AC_CHECK_FILE([/usr/pkg/include/ncurses.h],[AC_SUBST(CURSESLIB,[ncurses]) AC_DEFINE(HAVE_NCURSES_H)])
AC_CONFIG_FILES([Makefile fish.spec doc_src/fish.1 doc_src/Doxyfile init/fish init/fish_interactive.fish init/fish_complete.fish])
AC_CONFIG_FILES([Makefile fish.spec doc_src/fish.1 doc_src/Doxyfile init/fish init/fish_interactive.fish init/fish_complete.fish seq])
AC_OUTPUT
echo "Now run 'make' and 'make install' to built and install fish."

5
env.c
View file

@ -432,7 +432,7 @@ static void setup_path()
sb_destroy( &b );
al_foreach( &l, &free );
al_foreach( &l, (void (*)(const void *))&free );
path = env_get( L"PATH" );
al_truncate( &l, 0 );
expand_variable_array( path, &l );
@ -740,7 +740,8 @@ void env_set( const wchar_t *key,
else
{
/*
New variable with unspecified scope. The default scope is the innermost scope that is shadowing
New variable with unspecified scope. The default
scope is the innermost scope that is shadowing
*/
node = top;
while( node->next && !node->new_scope )

37
seq.in Executable file
View file

@ -0,0 +1,37 @@
#!@prefix@/bin/fish
function seq -d "Print a sequnce of numbers"
set -l from 1
set -l step 1
set -l to 1
switch (count $argv)
case 1
set to $argv[1]
case 2
set from $argv[1]
set to $argv[2]
case 3
set from $argv[1]
set step $argv[2]
set to $argv[3]
case '*'
printf (_ "%s: Expected 1, 2 or 3 arguments, got %d\n") seq (count $argv)
return 1
end
for i in $from $step $to
if not echo $i | grep '^-\?[0-9]*\(\|.[0-9]\+\)$' >/dev/null
printf (_ "%s: '%s' is not a number\n") seq $i
return 1
end
end
echo "for( i=$from; i<$to ; i+=$step ) i;" | bc
end

4
util.c
View file

@ -168,10 +168,6 @@ int q_empty( dyn_queue_t *q )
return q->put_pos == q->get_pos;
}
/* Stack functions */
/* Hash table functions */