From 456e015fb02f0f0c1b86c863c62417c7d245558e Mon Sep 17 00:00:00 2001 From: Timothy Stack Date: Fri, 13 May 2011 18:27:33 -0700 Subject: [PATCH] Add support for bzip2; fix some performance bugs; and display the log file type in the top status bar. --- Makefile.in | 17 +-- aclocal.m4 | 10 +- configure | 241 ++++++++++++++++++++++++++------------- configure.in | 3 +- src/Makefile.in | 2 +- src/config.h.in | 3 + src/line_buffer.cc | 148 +++++++++++++++++++----- src/line_buffer.hh | 4 + src/lnav.cc | 11 +- src/top_status_source.hh | 18 ++- test/Makefile.in | 2 +- 11 files changed, 327 insertions(+), 132 deletions(-) diff --git a/Makefile.in b/Makefile.in index c35ec1e5..86f1511a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.11 from Makefile.am. +# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -271,7 +271,7 @@ TESTS_ENVIRONMENT: $(top_builddir)/config.status $(srcdir)/TESTS_ENVIRONMENT.in # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): - @failcom='exit 1'; \ + @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ @@ -296,7 +296,7 @@ $(RECURSIVE_TARGETS): fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): - @failcom='exit 1'; \ + @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ @@ -460,7 +460,8 @@ distdir: $(DISTFILES) fi; \ done -test -n "$(am__skip_mode_fix)" \ - || find "$(distdir)" -type d ! -perm -777 -exec chmod a+rwx {} \; -o \ + || find "$(distdir)" -type d ! -perm -755 \ + -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ @@ -504,17 +505,17 @@ dist dist-all: distdir distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ - GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ + GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ - bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ + bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lzma*) \ - unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\ + lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ - GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ + GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac diff --git a/aclocal.m4 b/aclocal.m4 index edc915af..8e17f3bc 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,4 +1,4 @@ -# generated automatically by aclocal 1.11 -*- Autoconf -*- +# generated automatically by aclocal 1.11.1 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. @@ -13,8 +13,8 @@ m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.64],, -[m4_warning([this file was generated for autoconf 2.64. +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.65],, +[m4_warning([this file was generated for autoconf 2.65. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) @@ -34,7 +34,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.11' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.11], [], +m4_if([$1], [1.11.1], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -50,7 +50,7 @@ m4_define([_AM_AUTOCONF_VERSION], []) # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.11])dnl +[AM_AUTOMAKE_VERSION([1.11.1])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) diff --git a/configure b/configure index 486f2a64..b788deb3 100755 --- a/configure +++ b/configure @@ -1,12 +1,14 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.64 for lnav 0.4.0. +# Generated by GNU Autoconf 2.65 for lnav 0.4.0. # # Report bugs to . # +# # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software -# Foundation, Inc. +# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. @@ -527,7 +529,8 @@ as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" -exec 7<&0 &1 +test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, Linux) returns a bogus exit status, @@ -1372,7 +1375,7 @@ Some influential environment variables: LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l - CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CC C compiler command CFLAGS C compiler flags @@ -1445,7 +1448,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF lnav configure 0.4.0 -generated by GNU Autoconf 2.64 +generated by GNU Autoconf 2.65 Copyright (C) 2009 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation @@ -1492,7 +1495,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - return $ac_retval + as_fn_set_status $ac_retval } # ac_fn_cxx_try_compile @@ -1530,7 +1533,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - return $ac_retval + as_fn_set_status $ac_retval } # ac_fn_c_try_compile @@ -1572,7 +1575,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - return $ac_retval + as_fn_set_status $ac_retval } # ac_fn_c_try_run @@ -1750,7 +1753,7 @@ rm -f conftest.val fi eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - return $ac_retval + as_fn_set_status $ac_retval } # ac_fn_c_compute_int @@ -1787,7 +1790,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - return $ac_retval + as_fn_set_status $ac_retval } # ac_fn_c_try_cpp @@ -1864,7 +1867,7 @@ fi # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - return $ac_retval + as_fn_set_status $ac_retval } # ac_fn_c_try_link @@ -1965,7 +1968,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by lnav $as_me 0.4.0, which was -generated by GNU Autoconf 2.64. Invocation command line was +generated by GNU Autoconf 2.65. Invocation command line was $ $0 $@ @@ -2218,7 +2221,7 @@ fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue - if test -r "$ac_site_file"; then + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 @@ -2227,9 +2230,9 @@ $as_echo "$as_me: loading site script $ac_site_file" >&6;} done if test -r "$cache_file"; then - # Some versions of bash will fail to source /dev/null (special - # files actually), so we avoid doing that. - if test -f "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special files + # actually), so we avoid doing that. DJGPP emulates it as a regular file. + if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in @@ -2649,6 +2652,7 @@ IFS=$as_save_IFS fi + test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else @@ -2656,7 +2660,6 @@ fi # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. - test -d ./--version && rmdir ./--version MKDIR_P="$ac_install_sh -d" fi fi @@ -3031,32 +3034,30 @@ $as_echo "$ac_try_echo"; } >&5 ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 - rm -f conftest.er1 conftest.err fi + rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include + int main () { -FILE *f = fopen ("conftest.out", "w"); - return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out conftest.out" +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler default output file name" >&5 -$as_echo_n "checking for C++ compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C++ compiler works" >&5 +$as_echo_n "checking whether the C++ compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: @@ -3118,10 +3119,10 @@ test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 -$as_echo "$ac_file" >&6; } if test -z "$ac_file"; then : - $as_echo "$as_me: failed program was:" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 @@ -3129,51 +3130,18 @@ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { as_fn_set_status 77 as_fn_error "C++ compiler cannot create executables See \`config.log' for more details." "$LINENO" 5; }; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler default output file name" >&5 +$as_echo_n "checking for C++ compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C++ compiler works" >&5 -$as_echo_n "checking whether the C++ compiler works... " >&6; } -# If not cross compiling, check that we can run a simple program. -if test "$cross_compiling" != yes; then - if { ac_try='./$ac_file' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot run C++ compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." "$LINENO" 5; } - fi - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - -rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out conftest.out +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 -$as_echo_n "checking whether we are cross compiling... " >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 -$as_echo "$cross_compiling" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" @@ -3206,13 +3174,72 @@ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." "$LINENO" 5; } fi -rm -f conftest$ac_cv_exeext +rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "cannot run C++ compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." "$LINENO" 5; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if test "${ac_cv_objext+set}" = set; then : @@ -4066,8 +4093,8 @@ $as_echo "$ac_try_echo"; } >&5 ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 - rm -f conftest.er1 conftest.err fi + rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done @@ -5058,6 +5085,62 @@ else as_fn_error "libz required to build" "$LINENO" 5 fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing BZ2_bzopen" >&5 +$as_echo_n "checking for library containing BZ2_bzopen... " >&6; } +if test "${ac_cv_search_BZ2_bzopen+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char BZ2_bzopen (); +int +main () +{ +return BZ2_bzopen (); + ; + return 0; +} +_ACEOF +for ac_lib in '' bz2; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_BZ2_bzopen=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if test "${ac_cv_search_BZ2_bzopen+set}" = set; then : + break +fi +done +if test "${ac_cv_search_BZ2_bzopen+set}" = set; then : + +else + ac_cv_search_BZ2_bzopen=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_BZ2_bzopen" >&5 +$as_echo "$ac_cv_search_BZ2_bzopen" >&6; } +ac_res=$ac_cv_search_BZ2_bzopen +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlopen" >&5 $as_echo_n "checking for library containing dlopen... " >&6; } if test "${ac_cv_search_dlopen+set}" = set; then : @@ -5114,7 +5197,7 @@ if test "$ac_res" != no; then : fi -for ac_header in pty.h util.h zlib.h libutil.h +for ac_header in pty.h util.h zlib.h bzlib.h libutil.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" @@ -6182,7 +6265,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # values after options handling. ac_log=" This file was extended by lnav $as_me 0.4.0, which was -generated by GNU Autoconf 2.64. Invocation command line was +generated by GNU Autoconf 2.65. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -6222,6 +6305,7 @@ Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit + --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files @@ -6244,10 +6328,11 @@ Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ lnav config.status 0.4.0 -configured by $0, generated by GNU Autoconf 2.64, - with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" +configured by $0, generated by GNU Autoconf 2.65, + with options \\"\$ac_cs_config\\" Copyright (C) 2009 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation @@ -6285,6 +6370,8 @@ do ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) @@ -6475,7 +6562,7 @@ s/'"$ac_delim"'$// t delim :nl h -s/\(.\{148\}\).*/\1/ +s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p @@ -6489,7 +6576,7 @@ s/.\{148\}// t nl :delim h -s/\(.\{148\}\).*/\1/ +s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p diff --git a/configure.in b/configure.in index f014e166..ab40f0eb 100644 --- a/configure.in +++ b/configure.in @@ -75,8 +75,9 @@ AC_SUBST(OBJ_FORMAT) AC_SEARCH_LIBS(openpty, util) AC_SEARCH_LIBS(gzseek, z, [], [AC_MSG_ERROR([libz required to build])]) +AC_SEARCH_LIBS(BZ2_bzopen, bz2) AC_SEARCH_LIBS(dlopen, dl) -AC_CHECK_HEADERS(pty.h util.h zlib.h libutil.h) +AC_CHECK_HEADERS(pty.h util.h zlib.h bzlib.h libutil.h) MP_WITH_CURSES() AX_PATH_LIB_PCRE([], [AC_MSG_ERROR([pcre required to build])]) diff --git a/src/Makefile.in b/src/Makefile.in index f67f0ed2..7dc44b35 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.11 from Makefile.am. +# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, diff --git a/src/config.h.in b/src/config.h.in index 0d54eeca..6e675bb2 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -1,5 +1,8 @@ /* src/config.h.in. Generated from configure.in by autoheader. */ +/* Define to 1 if you have the header file. */ +#undef HAVE_BZLIB_H + /* curses library */ #undef HAVE_CURSES_H diff --git a/src/line_buffer.cc b/src/line_buffer.cc index 7cd2c551..e6e67acb 100644 --- a/src/line_buffer.cc +++ b/src/line_buffer.cc @@ -19,6 +19,7 @@ using namespace std; static const size_t DEFAULT_LINE_BUFFER_SIZE = 256 * 1024; static const size_t MAX_LINE_BUFFER_SIZE = 2 * DEFAULT_LINE_BUFFER_SIZE; static const size_t DEFAULT_INCREMENT = 1024; +static const size_t MAX_COMPRESSED_BUFFER_SIZE = 32 * 1024 * 1024; /* * XXX REMOVE ME @@ -74,6 +75,7 @@ private: line_buffer::line_buffer() : lb_gz_file(NULL), + lb_bz_file(false), lb_file_size((size_t) - 1), lb_file_offset(0), lb_buffer_size(0), @@ -104,6 +106,10 @@ throw (error) this->lb_gz_file = NULL; } + if (this->lb_bz_file) { + this->lb_bz_file = false; + } + if (fd != -1) { /* Sync the fd's offset with the object. */ newoff = lseek(fd, 0, SEEK_CUR); @@ -130,6 +136,15 @@ throw (error) } this->lb_gz_offset = lseek(this->lb_fd, 0, SEEK_CUR); } + else if (gz_id[0] == 'B' && gz_id[1] == 'Z') { + lseek(fd, 0, SEEK_SET); + this->lb_bz_file = true; + /* + * Loading data from a bzip2 file is pretty slow, so we try + * to keep as much in memory as possible. + */ + this->resize_buffer(MAX_COMPRESSED_BUFFER_SIZE); + } } this->lb_seekable = true; } @@ -141,6 +156,25 @@ throw (error) assert(this->invariant()); } +void line_buffer::resize_buffer(size_t new_max) + throw (error) +{ + char *tmp, *old; + + /* Still need more space, try a realloc. */ + old = this->lb_buffer.release(); + tmp = (char *)realloc(old, new_max); + if (tmp != NULL) { + this->lb_buffer = tmp; + this->lb_buffer_max = new_max; + } + else { + this->lb_buffer = old; + + throw error(ENOMEM); + } +} + void line_buffer::ensure_available(off_t start, size_t max_length) throw (error) { @@ -152,13 +186,24 @@ throw (error) } if (start < this->lb_file_offset || - start >= (off_t)(this->lb_file_offset + this->lb_buffer_size)) { + start > (off_t)(this->lb_file_offset + this->lb_buffer_size)) { /* * The request is outside the cached range, need to reload the * whole thing. */ prefill = 0; - this->lb_file_offset = start; + if ((this->lb_file_size != (size_t)-1) && + (start + this->lb_buffer_max > this->lb_file_size)) { + /* + * If the start is near the end of the file, move the offset back a + * bit so we can get more of the file in the cache. + */ + this->lb_file_offset = this->lb_file_size - + std::min(this->lb_file_size, this->lb_buffer_max); + } + else { + this->lb_file_offset = start; + } this->lb_buffer_size = 0; } else { @@ -184,22 +229,7 @@ throw (error) available = this->lb_buffer_max - this->lb_buffer_size; if (max_length > available) { - char *tmp, *old; - - /* Still need more space, try a realloc. */ - old = this->lb_buffer.release(); - tmp = (char *)realloc(old, - this->lb_buffer_max + - DEFAULT_LINE_BUFFER_SIZE); - if (tmp != NULL) { - this->lb_buffer = tmp; - this->lb_buffer_max += DEFAULT_LINE_BUFFER_SIZE; - } - else { - this->lb_buffer = old; - - throw error(ENOMEM); - } + this->resize_buffer(this->lb_buffer_max + DEFAULT_LINE_BUFFER_SIZE); } } } @@ -221,16 +251,64 @@ throw (error) /* ... read in the new data. */ if (this->lb_gz_file) { - lock_hack::guard guard; - - lseek(this->lb_fd, this->lb_gz_offset, SEEK_SET); - gzseek(this->lb_gz_file, - this->lb_file_offset + this->lb_buffer_size, - SEEK_SET); - rc = gzread(this->lb_gz_file, - &this->lb_buffer[this->lb_buffer_size], - this->lb_buffer_max - this->lb_buffer_size); - this->lb_gz_offset = lseek(this->lb_fd, 0, SEEK_CUR); + if (this->lb_file_size != (size_t)-1 && + this->in_range(start) && + this->in_range(this->lb_file_size - 1)) { + rc = 0; + } + else { + lock_hack::guard guard; + + lseek(this->lb_fd, this->lb_gz_offset, SEEK_SET); + gzseek(this->lb_gz_file, + this->lb_file_offset + this->lb_buffer_size, + SEEK_SET); + rc = gzread(this->lb_gz_file, + &this->lb_buffer[this->lb_buffer_size], + this->lb_buffer_max - this->lb_buffer_size); + this->lb_gz_offset = lseek(this->lb_fd, 0, SEEK_CUR); + } + } + else if (this->lb_bz_file) { + if (this->lb_file_size != (size_t)-1 && + ((start >= this->lb_file_size) || + (this->in_range(start) && + this->in_range(this->lb_file_size - 1)))) { + rc = 0; + } + else { + lock_hack::guard guard; + char scratch[32 * 1024]; + BZFILE *bz_file; + off_t seek_to; + + /* + * Unfortunately, there is no bzseek, so we need to reopen the + * file every time we want to do a read. + */ + lseek(this->lb_fd, 0, SEEK_SET); + if ((bz_file = BZ2_bzdopen(dup(this->lb_fd), "r")) == NULL) { + if (errno == 0) + throw bad_alloc(); + else + throw error(errno); + } + + seek_to = this->lb_file_offset + this->lb_buffer_size; + while (seek_to > 0) { + int count; + + count = BZ2_bzread(bz_file, + scratch, + std::min((unsigned long)seek_to, + sizeof(scratch))); + seek_to -= count; + } + rc = BZ2_bzread(bz_file, + &this->lb_buffer[this->lb_buffer_size], + this->lb_buffer_max - this->lb_buffer_size); + BZ2_bzclose(bz_file); + } } else if (this->lb_seekable) { rc = pread(this->lb_fd, @@ -249,6 +327,16 @@ throw (error) if (start < (off_t) this->lb_file_size) { retval = true; } + + if (this->lb_gz_file || this->lb_bz_file) { + /* + * For compressed files, increase the buffer size so we don't + * have to spend as much time uncompressing the data. + */ + this->resize_buffer(std::min(this->lb_file_size + + DEFAULT_INCREMENT, + MAX_COMPRESSED_BUFFER_SIZE)); + } break; case - 1: @@ -290,8 +378,8 @@ throw (error) line_start = this->get_range(offset, len_out); /* ... look for the end-of-line or end-of-file. */ if (((lf = (char *)memchr(line_start, delim, len_out)) != NULL) || - ((request_size >= (MAX_LINE_BUFFER_SIZE - DEFAULT_INCREMENT)) && - (offset + len_out) == this->lb_file_size)) { + (request_size >= (MAX_LINE_BUFFER_SIZE - DEFAULT_INCREMENT)) || + (((offset + len_out) == this->lb_file_size) && len_out > 0)) { if (lf != NULL) { len_out = lf - line_start; offset += 1; /* Skip the delimiter. */ diff --git a/src/line_buffer.hh b/src/line_buffer.hh index cf45daf0..23f9b7ee 100644 --- a/src/line_buffer.hh +++ b/src/line_buffer.hh @@ -10,6 +10,7 @@ #include #include #include +#include #include @@ -120,6 +121,8 @@ private: off < (int)(this->lb_file_offset + this->lb_buffer_size); }; + void resize_buffer(size_t new_max) throw (error); + /** * Ensure there is enough room in the buffer to cache a range of data from * the file. First, this method will check to see if there is enough room @@ -169,6 +172,7 @@ private: auto_fd lb_fd; /*< The file to read data from. */ gzFile lb_gz_file; + bool lb_bz_file; off_t lb_gz_offset; auto_mem lb_buffer; /*< The internal buffer where data is cached */ diff --git a/src/lnav.cc b/src/lnav.cc index 0c407198..b886ac05 100644 --- a/src/lnav.cc +++ b/src/lnav.cc @@ -396,7 +396,7 @@ static void rebuild_indexes(bool force) text_view.get_dimensions(height, width); old_bottom = text_view.get_top() + height; scroll_down = (size_t)old_bottom > tss->text_line_count(); - + for (iter = tss->tss_files.begin(); iter != tss->tss_files.end();) { (*iter)->rebuild_index(&obs); @@ -415,8 +415,8 @@ static void rebuild_indexes(bool force) text_view.reload_data(); new_count = tss->text_line_count(); - if (scroll_down && new_count >= (size_t)height) { - text_view.set_top(vis_line_t(new_count - height + 1)); + if (scroll_down && new_count >= old_bottom) { + text_view.set_top(vis_line_t(new_count - height + 1)); } } @@ -437,7 +437,7 @@ static void rebuild_indexes(bool force) log_view.reload_data(); - if (scroll_down && new_count >= (size_t)height) { + if (scroll_down && new_count >= old_bottom) { log_view.set_top(vis_line_t(new_count - height + 1)); } else if (!scroll_down && force) { @@ -2202,6 +2202,7 @@ static void looper(void) lnav_data.ld_log_source.text_line_count() == 0 && lnav_data.ld_text_source.text_line_count() > 0) { toggle_view(&lnav_data.ld_views[LNV_TEXT]); + lnav_data.ld_views[LNV_TEXT].set_top(vis_line_t(0)); } initial_build = true; } @@ -2286,7 +2287,7 @@ public: alt_regex("([\\w\\.-]+) [\\w\\.-]+ ([\\w\\.-]+) " "\\[[^\\]]+\\] \"(\\w+) ([^ \\?]+)(\\?[^ ]+)? " "([\\w/\\.]+)\" (\\d+) " - "(\\d+|-) \"([^\"]+)\" \"([^\"]+)\".*") { + "(\\d+|-)(?: \"([^\"]+)\" \"([^\"]+)\")?.*") { }; void get_columns(vector &cols) { diff --git a/src/top_status_source.hh b/src/top_status_source.hh index 0c01cb32..5d0a54ce 100644 --- a/src/top_status_source.hh +++ b/src/top_status_source.hh @@ -22,6 +22,7 @@ public: TSF_TIME, TSF_WARNINGS, TSF_ERRORS, + TSF_FORMAT, TSF_FILENAME, TSF__MAX @@ -34,6 +35,8 @@ public: this->tss_fields[TSF_WARNINGS].set_width(10); this->tss_fields[TSF_ERRORS].set_width(10); this->tss_fields[TSF_ERRORS].set_role(view_colors::VCR_ALERT_STATUS); + this->tss_fields[TSF_FORMAT].set_width(15); + this->tss_fields[TSF_FORMAT].right_justify(true); this->tss_fields[TSF_FILENAME].set_width(35); // XXX this->tss_fields[TSF_FILENAME].right_justify(true); }; @@ -92,7 +95,8 @@ public: void update_filename(listview_curses *lc) { if (lc->get_inner_height() > 0) { - status_field &sf = this->tss_fields[TSF_FILENAME]; + status_field &sf_format = this->tss_fields[TSF_FORMAT]; + status_field &sf_filename = this->tss_fields[TSF_FILENAME]; struct line_range lr = { 0, -1 }; attrs_map_t::iterator iter; string_attrs_t sa; @@ -104,11 +108,17 @@ public: iter = sa[lr].find("file"); if (iter != sa[lr].end()) { logfile *lf = (logfile *)iter->second.sa_ptr; - - sf.set_value(lf->get_filename()); + + if (lf->get_format()) + sf_format.set_value("(%s)", + lf->get_format()->get_name().c_str()); + else + sf_format.set_value("(unknown)"); + sf_filename.set_value(lf->get_filename()); } else { - sf.clear(); + sf_format.set_value("(unknown)"); + sf_filename.clear(); } } }; diff --git a/test/Makefile.in b/test/Makefile.in index 5b0b856c..497f98a3 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.11 from Makefile.am. +# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,