diff --git a/NEWS b/NEWS index e917f75cb..3d2667af1 100644 --- a/NEWS +++ b/NEWS @@ -17,7 +17,7 @@ To be released as ELinks 0.12.0. ////////////////////////////////////////////////////////////////////// This list now contains all the important changes from ELinks 0.11.0 to -ELinks 0.12.GIT (0cf15ca9d9dbc00c10f23440674fcdb832dffd75) and related +ELinks 0.12.GIT (98260f7970bcd940f2d2146ac7b5a980a7586082) and related bug numbers. Each section is sorted by severity and grouped by topic. The list no doubt includes several changes that are not really @@ -71,6 +71,7 @@ Miscellaneous: * gzip_read: always call gzclearerr * bug 816: convert entity references in input/@value only once * bug 916: if a mailcap entry has no %s, provide the file as stdin +* bug 766: speed up CSS * bug 355: add documents displayed via ``What to do'' dialog to the global history * encode and decode filenames in FSP URLs @@ -281,6 +282,8 @@ To be released as 0.11.4. * critical bug 755: fix crashes due to dangling pointers to struct form_state +* critical bugs 613, 714, 961: ``assertion list_empty(form_controls) + failed'' * critical bug 945: don't crash if a Lua script calls e.g. error(nil) * major bug 956: don't reuse pointers to SpiderMonkey objects that may have been collected as garbage. This fix causes bug 954. @@ -306,6 +309,7 @@ To be released as 0.11.4. on SunOS * build bug 936: fix errors about undefined off_t (autoheader incompatibility) +* build bug 959: test in configure whether -lX11 works * build: update SpiderMonkey configure check Debian compatibility * build: use $(CPPFLAGS) rather than $(AM_CFLAGS) * minor build bug 960: fix errors in loadmsgcat.c if mmap() exists but diff --git a/config/m4/codeset.m4 b/config/m4/codeset.m4 index 863c9cfa7..a54e02d5d 100644 --- a/config/m4/codeset.m4 +++ b/config/m4/codeset.m4 @@ -5,10 +5,7 @@ dnl From Bruno Haible. AC_DEFUN([AM_LANGINFO_CODESET], [ AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset, - [AC_TRY_LINK([#include ], - [char* cs = nl_langinfo(CODESET);], - am_cv_langinfo_codeset=yes, - am_cv_langinfo_codeset=no) + [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[char* cs = nl_langinfo(CODESET);]])],[am_cv_langinfo_codeset=yes],[am_cv_langinfo_codeset=no]) ]) if test $am_cv_langinfo_codeset = yes; then AC_DEFINE(HAVE_LANGINFO_CODESET, 1, diff --git a/config/m4/features.m4 b/config/m4/features.m4 index 79e332a49..df87a70a5 100644 --- a/config/m4/features.m4 +++ b/config/m4/features.m4 @@ -125,7 +125,7 @@ AC_DEFUN([EL_CHECK_CODE], [ $2=yes; AC_MSG_CHECKING([for $1]) - AC_TRY_COMPILE([$3], [$4], [EL_DEFINE($2, [$1])], $2=no) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$3]], [[$4]])],[EL_DEFINE($2, [$1])],[$2=no]) AC_MSG_RESULT([$]$2) ]) @@ -134,10 +134,9 @@ AC_DEFUN([EL_CHECK_TYPE], [ EL_CHECK_TYPE_LOCAL=yes; AC_MSG_CHECKING([for $1]) - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include - ], [int a = sizeof($1);], - [EL_CHECK_TYPE_LOCAL=yes], [EL_CHECK_TYPE_LOCAL=no]) + ]], [[int a = sizeof($1);]])],[EL_CHECK_TYPE_LOCAL=yes],[EL_CHECK_TYPE_LOCAL=no]) AC_MSG_RESULT([$]EL_CHECK_TYPE_LOCAL) if test "x[$]EL_CHECK_TYPE_LOCAL" != "xyes"; then AC_DEFINE($1, $2, [Define to $2 if doesn't define.]) diff --git a/config/m4/iconv.m4 b/config/m4/iconv.m4 index 6d411bb3c..8019f37a3 100644 --- a/config/m4/iconv.m4 +++ b/config/m4/iconv.m4 @@ -20,22 +20,18 @@ AC_DEFUN([AM_ICONV], AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [ am_cv_func_iconv="no, consider installing GNU libiconv" am_cv_lib_iconv=no - AC_TRY_LINK([#include -#include ], - [iconv_t cd = iconv_open("",""); + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include +#include ]], [[iconv_t cd = iconv_open("",""); iconv(cd,NULL,NULL,NULL,NULL); - iconv_close(cd);], - am_cv_func_iconv=yes) + iconv_close(cd);]])],[am_cv_func_iconv=yes],[]) if test "$am_cv_func_iconv" != yes; then am_save_LIBS="$LIBS" LIBS="$LIBS -liconv" - AC_TRY_LINK([#include -#include ], - [iconv_t cd = iconv_open("",""); + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include +#include ]], [[iconv_t cd = iconv_open("",""); iconv(cd,NULL,NULL,NULL,NULL); - iconv_close(cd);], - am_cv_lib_iconv=yes - am_cv_func_iconv=yes) + iconv_close(cd);]])],[am_cv_lib_iconv=yes + am_cv_func_iconv=yes],[]) LIBS="$am_save_LIBS" fi ]) @@ -43,7 +39,7 @@ AC_DEFUN([AM_ICONV], AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.]) AC_MSG_CHECKING([for iconv declaration]) AC_CACHE_VAL(am_cv_proto_iconv, [ - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #include extern @@ -55,7 +51,7 @@ size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, si #else size_t iconv(); #endif -], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const") +]], [[]])],[am_cv_proto_iconv_arg1=""],[am_cv_proto_iconv_arg1="const"]) am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"]) am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` AC_MSG_RESULT([$]{ac_t:- diff --git a/config/m4/isc-posix.m4 b/config/m4/isc-posix.m4 index 99c899ce5..99f59f566 100644 --- a/config/m4/isc-posix.m4 +++ b/config/m4/isc-posix.m4 @@ -4,8 +4,8 @@ # because gettext's gettext.m4 (distributed in the automake package) # still uses it. Otherwise, the use in gettext.m4 makes autoheader # give these diagnostics: -# configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX -# configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX +# configure.in:556: AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[],[]) was called before AC_ISC_POSIX +# configure.in:556: AC_RUN_IFELSE([AC_LANG_SOURCE([[]])],[],[],[]) was called before AC_ISC_POSIX undefine([AC_ISC_POSIX]) diff --git a/config/m4/lcmessage.m4 b/config/m4/lcmessage.m4 index acfd3ace1..a4e4bcf87 100644 --- a/config/m4/lcmessage.m4 +++ b/config/m4/lcmessage.m4 @@ -13,8 +13,7 @@ AC_DEFUN([AM_LC_MESSAGES], [if test $ac_cv_header_locale_h = yes; then AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES, - [AC_TRY_LINK([#include ], [return LC_MESSAGES], - am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)]) + [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[return LC_MESSAGES]])],[am_cv_val_LC_MESSAGES=yes],[am_cv_val_LC_MESSAGES=no])]) if test $am_cv_val_LC_MESSAGES = yes; then AC_DEFINE(HAVE_LC_MESSAGES, 1, [Define if your file defines LC_MESSAGES.]) diff --git a/config/m4/os2.m4 b/config/m4/os2.m4 index 7e3bd8214..148401f9c 100644 --- a/config/m4/os2.m4 +++ b/config/m4/os2.m4 @@ -6,8 +6,7 @@ AC_DEFUN([EL_CONFIG_OS_OS2], EL_SAVE_FLAGS CFLAGS="$CFLAGS -Zmt" - AC_TRY_LINK([#include ], - [_beginthread(NULL, NULL, 0, NULL)], cf_result=yes, cf_result=no) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[_beginthread(NULL, NULL, 0, NULL)]])],[cf_result=yes],[cf_result=no]) AC_MSG_RESULT($cf_result) if test "$cf_result" = yes; then @@ -28,14 +27,10 @@ AC_DEFUN([EL_CONFIG_OS_OS2], if test -n "$X11ROOT"; then CFLAGS="$CFLAGS_X -I$X11ROOT/XFree86/include" LIBS="$LIBS_X -L$X11ROOT/XFree86/lib -lxf86_gcc" - AC_TRY_LINK([#include ], - [struct winsize win;ptioctl(1, TIOCGWINSZ, &win)], - cf_result=yes, cf_result=no) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[struct winsize win;ptioctl(1, TIOCGWINSZ, &win)]])],[cf_result=yes],[cf_result=no]) if test "$cf_result" = no; then LIBS="$LIBS_X -L$X11ROOT/XFree86/lib -lxf86" - AC_TRY_LINK([#include ], - [struct winsize win;ptioctl(1, TIOCGWINSZ, &win)], - cf_result=yes, cf_result=no) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[struct winsize win;ptioctl(1, TIOCGWINSZ, &win)]])],[cf_result=yes],[cf_result=no]) fi fi diff --git a/config/m4/ruby.m4 b/config/m4/ruby.m4 index 1effb1e58..398392065 100644 --- a/config/m4/ruby.m4 +++ b/config/m4/ruby.m4 @@ -78,9 +78,7 @@ if test "$CONFIG_SCRIPTING_RUBY" = "yes"; then CFLAGS="$RUBY_CFLAGS $CFLAGS" CPPFLAGS="$CPPFLAGS $RUBY_CFLAGS" - AC_TRY_LINK([#include ], - [ruby_init();], - CONFIG_SCRIPTING_RUBY=yes, CONFIG_SCRIPTING_RUBY=no) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ruby_init();]])],[CONFIG_SCRIPTING_RUBY=yes],[CONFIG_SCRIPTING_RUBY=no]) else AC_MSG_RESULT([Ruby header files not found]) fi diff --git a/config/m4/win32.m4 b/config/m4/win32.m4 index cb9ce1b03..d673041dc 100644 --- a/config/m4/win32.m4 +++ b/config/m4/win32.m4 @@ -5,8 +5,7 @@ AC_DEFUN([EL_CONFIG_OS_WIN32], EL_SAVE_FLAGS - AC_TRY_LINK([#include ], - [_beginthread(NULL, NULL, 0, NULL)], cf_result=yes, cf_result=no) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[_beginthread(NULL, NULL, 0, NULL)]])],[cf_result=yes],[cf_result=no]) AC_MSG_RESULT($cf_result) if test "$cf_result" = yes; then diff --git a/configure.in b/configure.in index 5e1f6bb9a..ee52d0e5d 100644 --- a/configure.in +++ b/configure.in @@ -1,10 +1,11 @@ dnl Process this file with autoconf to produce a configure script. dnl Autoconf 2.13 generates an incomplete config.h.in; see ELinks bug 936. -dnl Autoconf 2.59 is installed in the computer that generates our daily +dnl Autoconf 2.59 is installed in the computer that generates our nightly dnl snapshots, so we need to be compatible with that. AC_PREREQ(2.59) -AC_INIT(src/main/main.c) +AC_INIT +AC_CONFIG_SRCDIR([src/main/main.c]) AC_CONFIG_AUX_DIR(config) PACKAGE=elinks @@ -107,7 +108,7 @@ EL_CONFIG_DEPENDS(CONFIG_MANUAL, [MANUAL_ASCIIDOC MANUAL_XMLTO MANUAL_JW], [Manu EL_CONFIG_DEPENDS(CONFIG_MANPAGE, [MAN_ASCIIDOC MAN_XMLTO], [Man Page Formats]) dnl gcc specific options (to be continued at the bottom of configure) -if test "x$ac_cv_prog_gcc" = "xyes"; then +if test "x$ac_cv_c_compiler_gnu" = "xyes"; then dnl We want to see all warnings and live with none. dnl We can't set up -Werror here as there may be some warnings in test dnl suite of configure, and we don't want to fail them. @@ -124,9 +125,9 @@ AC_DEFUN([EL_CHECK_COMPILER_MACROS], AC_MSG_CHECKING([for $2]) for flag in $3; do - AC_TRY_COMPILE(, [#ifndef $flag + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[#ifndef $flag kill me! -#endif ], $1=yes, $1=no) +#endif ]])],[$1=yes],[$1=no]) if test "[$]$1" = yes; then EL_CONFIG([$1], [$2]) break @@ -262,7 +263,7 @@ dnl happily ignoring it and stderr not being checked for error messages. AC_MSG_CHECKING([for -rdynamic]) LDFLAGS_X="$LDFLAGS" LDFLAGS="$LDFLAGS -rdynamic" -AC_TRY_LINK([], [], have_rdynamic=yes, have_rdynamic=no) +AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[have_rdynamic=yes],[have_rdynamic=no]) test "$have_rdynamic" = no && LDFLAGS="$LDFLAGS_X" AC_MSG_RESULT($have_rdynamic) @@ -289,7 +290,7 @@ AC_CHECK_FUNCS(getifaddrs getpwnam inet_pton inet_ntop) AC_CHECK_FUNCS(fflush fsync fseeko ftello sigaction) AC_CHECK_FUNCS(gettimeofday clock_gettime) -AC_HAVE_FUNCS(cygwin_conv_to_full_win32_path) +AC_CHECK_FUNCS([cygwin_conv_to_full_win32_path]) AC_CHECK_FUNCS(setenv putenv, HAVE_SETENV_OR_PUTENV=yes) AC_CHECK_FUNCS(getuid, HAVE_GETUID=yes) @@ -305,28 +306,26 @@ AC_CHECK_FUNCS(kill, HAVE_KILL=yes) if test x"$HAVE_RAISE" = x; then if test x"$HAVE_KILL" = x || test x"$HAVE_GETPID" = x; then - AC_ERROR([Unable to emulate raise()]) + AC_MSG_ERROR([Unable to emulate raise()]) fi fi AC_CACHE_CHECK([for __va_copy],el_cv_HAVE_VA_COPY,[ -AC_TRY_LINK([#include -va_list ap1,ap2;], [__va_copy(ap1,ap2);], -el_cv_HAVE_VA_COPY=yes,el_cv_HAVE_VA_COPY=no)]) +AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include +va_list ap1,ap2;]], [[__va_copy(ap1,ap2);]])],[el_cv_HAVE_VA_COPY=yes],[el_cv_HAVE_VA_COPY=no])]) if test x"$el_cv_HAVE_VA_COPY" = x"yes"; then EL_DEFINE(HAVE_VA_COPY, __va_copy) fi AC_CACHE_CHECK([for sysconf(_SC_PAGE_SIZE)],el_cv_HAVE_SC_PAGE_SIZE,[ -AC_TRY_LINK([#include -], [int page_size = sysconf(_SC_PAGE_SIZE);], -el_cv_HAVE_SC_PAGE_SIZE=yes,el_cv_HAVE_SC_PAGE_SIZE=no)]) +AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include +]], [[int page_size = sysconf(_SC_PAGE_SIZE);]])],[el_cv_HAVE_SC_PAGE_SIZE=yes],[el_cv_HAVE_SC_PAGE_SIZE=no])]) if test x"$el_cv_HAVE_SC_PAGE_SIZE" = x"yes"; then EL_DEFINE(HAVE_SC_PAGE_SIZE, _SC_PAGE_SIZE) fi AC_CACHE_CHECK([for C99 vsnprintf],el_cv_HAVE_C99_VSNPRINTF,[ -AC_TRY_RUN([ +AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include #include @@ -358,8 +357,7 @@ void foo(const char *format, ...) { exit(0); } main() { foo("hello\n"); } -], -el_cv_HAVE_C99_VSNPRINTF=yes,el_cv_HAVE_C99_VSNPRINTF=no,el_cv_HAVE_C99_VSNPRINTF=cross)]) +]])],[el_cv_HAVE_C99_VSNPRINTF=yes],[el_cv_HAVE_C99_VSNPRINTF=no],[el_cv_HAVE_C99_VSNPRINTF=cross])]) if test x"$el_cv_HAVE_C99_VSNPRINTF" = x"yes"; then EL_DEFINE(HAVE_C99_VSNPRINTF, [C99 compliant vsnprintf()]) fi @@ -592,10 +590,10 @@ if test "$enable_see" = "yes"; then SEE_CFLAGS="`$SEE_CONFIG --cppflags`" CPPFLAGS="$SEE_CFLAGS $CPPFLAGS" LIBS="$SEE_LIBS $LIBS_X" - AC_TRY_LINK([#include ],[#if SEE_VERSION_API_MAJOR < 2 + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[#if SEE_VERSION_API_MAJOR < 2 #error SEE too old #endif - ], cf_result=yes, cf_result=no) + ]])],[cf_result=yes],[cf_result=no]) EL_RESTORE_FLAGS if test "$cf_result" = yes; then LIBS="$SEE_LIBS $LIBS" @@ -630,22 +628,17 @@ if test -z "$disable_spidermonkey"; then for spidermonkeydir in "$withval" "" /usr /usr/local /opt/spidermonkey /opt/js; do for spidermonkeyinclude in "/include" "/include/js" "/include/smjs" "/include/mozjs"; do for spidermonkeylib in js smjs mozjs; do - if test "$cf_result" = no; then - SPIDERMONKEY_LIBS="-l$spidermonkeylib" - - if test ! -z "$spidermonkeydir"; then - SPIDERMONKEY_LIBS="-L$spidermonkeydir/lib $SPIDERMONKEY_LIBS" - SPIDERMONKEY_CFLAGS="-I$spidermonkeydir$spidermonkeyinclude" - fi + if test "$cf_result" = no && + test -f "$spidermonkeydir$spidermonkeyinclude/jsapi.h"; then + SPIDERMONKEY_LIBS="-L$spidermonkeydir/lib -l$spidermonkeylib" + SPIDERMONKEY_CFLAGS="-I$spidermonkeydir$spidermonkeyinclude" LIBS="$SPIDERMONKEY_LIBS $LIBS_X" CFLAGS="$CFLAGS_X $SPIDERMONKEY_CFLAGS" CPPFLAGS="$CPPFLAGS_X $SPIDERMONKEY_CFLAGS" - AC_TRY_LINK([#define XP_UNIX - #include ], - [JS_GetReservedSlot(NULL, NULL, 0, NULL)], - cf_result=yes, cf_result=no) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#define XP_UNIX + #include ]], [[JS_GetReservedSlot(NULL, NULL, 0, NULL)]])],[cf_result=yes],[cf_result=no]) fi done done @@ -776,29 +769,24 @@ if test "$enable_perl" = "yes"; then LIBS="$PERL_LIBS $LIBS" CFLAGS="$PERL_CFLAGS $CFLAGS" CPPFLAGS="$CPPFLAGS $PERL_CFLAGS" - AC_TRY_LINK([ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include #include #include -], - [PerlInterpreter *my_perl = perl_alloc();], - cf_result=yes, cf_result=no) +]], [[PerlInterpreter *my_perl = perl_alloc();]])],[cf_result=yes],[cf_result=no]) fi if test "$cf_result"; then AC_MSG_RESULT($cf_result); fi AC_MSG_CHECKING([whether POPpx works without an n_a variable]) -AC_TRY_COMPILE([ +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #include extern PerlInterpreter *my_perl; -], - [dSP; (void) POPpx;], - [AC_MSG_RESULT([yes]) +]], [[dSP; (void) POPpx;]])],[AC_MSG_RESULT([yes]) AC_DEFINE([CONFIG_PERL_POPPX_WITHOUT_N_A], [1], [Define if using Perl 5.8.8 or later, where the "POPpx" macro -no longer needs an "n_a" variable like it did in 5.8.7])], - [AC_MSG_RESULT([no])]) +no longer needs an "n_a" variable like it did in 5.8.7])],[AC_MSG_RESULT([no])]) if test "$cf_result" != "yes"; then EL_RESTORE_FLAGS @@ -842,9 +830,7 @@ if test "$enable_python" = "yes"; then PYTHON_LIBS="`$PYTHON -c 'from distutils import sysconfig; var = sysconfig.get_config_var; print "%s %s %s -L%s -lpython%s" % (var("LINKFORSHARED"), var("LIBS"), var("SYSLIBS"), var("LIBPL"), var("VERSION"))'`" LIBS="$PYTHON_LIBS $LIBS" CPPFLAGS="$CPPFLAGS $PYTHON_CFLAGS" - AC_TRY_LINK([#include ], - [Py_Initialize();], - cf_result=yes, cf_result=no) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[Py_Initialize();]])],[cf_result=yes],[cf_result=no]) if test "$cf_result" != "yes"; then EL_RESTORE_FLAGS @@ -894,30 +880,25 @@ if test -z "$disable_lua"; then fi for luadir in "$withval" "" /usr /usr/local; do for suffix in "" 50 51; do - if test "$cf_result" = no; then - LUA_LIBS="-llua$suffix -llualib$suffix -lm" - - if test ! -z "$luadir"; then - LUA_LIBS="-L$luadir/lib $LUA_LIBS" - LUA_CFLAGS="-I$luadir/include -I$luadir/include/lua$suffix" - fi + if test "$cf_result" = no && ( test -f "$luadir/include/lua.h" || \ + test -f "$luadir/include/lua$suffix/lua.h" ) ; then + LUA_LIBS="-L$luadir/lib -llua$suffix -llualib$suffix -lm" + LUA_CFLAGS="-I$luadir/include -I$luadir/include/lua$suffix" LIBS="$LUA_LIBS $LIBS_X" CFLAGS="$CFLAGS_X $LUA_CFLAGS" CPPFLAGS="$CPPFLAGS_X $LUA_CFLAGS" # Check that it is a compatible Lua version - AC_TRY_LINK([ #include - #include ], - [ lua_State *L = lua_open(); + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include + #include ]], [[ lua_State *L = lua_open(); luaopen_base(L); luaopen_table(L); luaopen_io(L); luaopen_string(L); luaopen_math(L); lua_pushboolean(L, 1); - lua_close(L);], - cf_result=yes, cf_result=no) + lua_close(L);]])],[cf_result=yes],[cf_result=no]) fi done done @@ -1015,13 +996,9 @@ else else LIBS="-lssl -lcrypto $LIBS_X" fi - AC_TRY_LINK([#include ], - [OpenSSL_add_all_algorithms()], - cf_result=yes, cf_result=no) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[OpenSSL_add_all_algorithms()]])],[cf_result=yes],[cf_result=no]) if test "$cf_result" != yes; then - AC_TRY_LINK([#include ], - [SSLeay_add_ssl_algorithms()], - cf_result=yes, cf_result=no) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[SSLeay_add_ssl_algorithms()]])],[cf_result=yes],[cf_result=no]) fi fi done @@ -1079,10 +1056,8 @@ else # Verify if it's really usable. gnutls_session was # renamed to gnutls_session_t before GNU TLS 1.2.0 # (on 2004-06-13); ELinks now requires this. - AC_TRY_LINK([#include ], - [gnutls_session_t dummy; - gnutls_check_version(NULL)], - cf_result=yes, cf_result=no) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[gnutls_session_t dummy; + gnutls_check_version(NULL)]])],[cf_result=yes],[cf_result=no]) fi if test "$cf_result" = yes; then @@ -1144,15 +1119,26 @@ dnl =================================================================== AC_PATH_X if test x"$no_x" != xyes; then + EL_SAVE_FLAGS if test -n "$x_includes"; then X_CFLAGS="-I$x_includes" + CPPFLAGS="$CPPLAGS $X_CFLAGS" + CFLAGS="$CFLAGS $X_CFLAGS" fi if test -n "$x_libraries"; then LDFLAGS="$LDFLAGS -L$x_libraries" fi LIBS="-lX11 $LIBS" - EL_DEFINE(HAVE_X11, [X11 for restoring window titles]) - AC_SUBST(X_CFLAGS) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[XrmInitialize()]])],[cf_result=yes],[cf_result=no]) + EL_RESTORE_FLAGS + if test "$cf_result" = yes; then + if test -n "$x_libraries"; then + LDFLAGS="$LDFLAGS -L$x_libraries" + fi + LIBS="-lX11 $LIBS" + EL_DEFINE(HAVE_X11, [X11 for restoring window titles]) + AC_SUBST(X_CFLAGS) + fi fi @@ -1401,7 +1387,7 @@ dnl =================================================================== dnl A little fine tuning of gcc specific options (continued) dnl =================================================================== -if test "x$ac_cv_prog_gcc" = "xyes"; then +if test "x$ac_cv_c_compiler_gnu" = "xyes"; then if test "$CONFIG_DEBUG" = "yes"; then dnl We want to see all warnings and live with none (in debug mode). CFLAGS="$CFLAGS -Werror" @@ -1438,9 +1424,7 @@ if test "x$ac_cv_prog_gcc" = "xyes"; then AC_MSG_CHECKING([whether $CC accepts -Wno-always-true]) EL_SAVE_FLAGS CFLAGS="$CFLAGS -Wno-always-true" - AC_TRY_COMPILE([], [], - [AC_MSG_RESULT([yes])], - [EL_RESTORE_FLAGS + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[AC_MSG_RESULT([yes])],[EL_RESTORE_FLAGS AC_MSG_RESULT([no])]) fi @@ -1462,7 +1446,7 @@ dnl =================================================================== dnl Generated files dnl =================================================================== -AC_OUTPUT([ \ +AC_CONFIG_FILES([ \ Makefile.config \ contrib/elinks.spec \ contrib/lua/hooks.lua \ @@ -1471,6 +1455,7 @@ AC_OUTPUT([ \ src/intl/gettext/ref-add.sed \ src/intl/gettext/ref-del.sed ]) +AC_OUTPUT abs_srcdir="$(cd "$srcdir" && pwd)" # builddir is always absolute! diff --git a/src/dialogs/menu.c b/src/dialogs/menu.c index 0707b9807..172965ca2 100644 --- a/src/dialogs/menu.c +++ b/src/dialogs/menu.c @@ -759,7 +759,7 @@ do_pass_uri_to_command(struct terminal *term, void *command_, void *xxx) { unsigned char *command = command_; - exec_on_terminal(term, command, "", 0); + exec_on_terminal(term, command, "", TERM_EXEC_BG); mem_free(command); } diff --git a/src/document/css/apply.c b/src/document/css/apply.c index f39e84a07..c3b9fd748 100644 --- a/src/document/css/apply.c +++ b/src/document/css/apply.c @@ -27,8 +27,6 @@ /* XXX: Some strange dependency makes it necessary to this include last. */ #include "document/html/internal.h" -/* #define DEBUG_CSS */ - /* TODO: A way to disable CSS completely, PLUS a way to stop various property * groups from taking effect. (Ie. way to turn out effect of 'display: none' @@ -122,12 +120,18 @@ examine_element(struct html_context *html_context, struct css_selector *base, struct list_head *selectors, struct html_element *element) { struct css_selector *selector; - unsigned char *code; #ifdef DEBUG_CSS + /* Cannot use list_empty() inside the arglist of DBG() because + * GCC 4.1 "warning: operation on `errfile' may be undefined" + * breaks the build with -Werror. */ + int dbg_has_leaves, dbg_has_properties; + DBG("examine_element(%p, %s, %d, %d, %p, %.*s);", html_context, base->name, seltype, rel, selectors, element->namelen, element->name); #define dbginfo(sel, type_, base) \ - DBG("Matched selector %s (rel %d type %d [m%d])! Children %p !!%d, props !!%d", sel->name, sel->relation, sel->type, sel->type == type_, &sel->leaves, !list_empty(sel->leaves), !list_empty(sel->properties)) + dbg_has_leaves = !list_empty(sel->leaves), \ + dbg_has_properties = !list_empty(sel->properties), \ + DBG("Matched selector %s (rel %d type %d [m%d])! Children %p !!%d, props !!%d", sel->name, sel->relation, sel->type, sel->type == type_, &sel->leaves, dbg_has_leaves, dbg_has_properties) #else #define dbginfo(sel, type, base) #endif @@ -186,29 +190,27 @@ examine_element(struct html_context *html_context, struct css_selector *base, process_found_selector(selector, CST_PSEUDO, base); } - code = get_attr_val(element->options, "class", html_context->doc_cp); - if (code && seltype <= CST_CLASS) { - unsigned char *class = code; + if (element->attr.class && seltype <= CST_CLASS) { + const unsigned char *class = element->attr.class; - while (class) { - unsigned char *end = strchr(class, ' '); + for (;;) { + const unsigned char *begin; - if (end) - *end++ = 0; + while (*class == ' ') ++class; + if (*class == '\0') break; + begin = class; + while (*class != ' ' && *class != '\0') ++class; - selector = find_css_selector(selectors, CST_CLASS, rel, class, -1); + selector = find_css_selector(selectors, CST_CLASS, rel, + begin, class - begin); process_found_selector(selector, CST_CLASS, base); - class = end; } } - mem_free_if(code); - code = get_attr_val(element->options, "id", html_context->doc_cp); - if (code && seltype <= CST_ID) { - selector = find_css_selector(selectors, CST_ID, rel, code, -1); + if (element->attr.id && seltype <= CST_ID) { + selector = find_css_selector(selectors, CST_ID, rel, element->attr.id, -1); process_found_selector(selector, CST_ID, base); } - if (code) mem_free(code); #undef process_found_selector #undef dbginfo diff --git a/src/document/css/parser.c b/src/document/css/parser.c index 23da6dd51..9e301e0cb 100644 --- a/src/document/css/parser.c +++ b/src/document/css/parser.c @@ -21,8 +21,6 @@ #include "util/memory.h" #include "util/string.h" -/* #define DEBUG_CSS */ - void css_parse_properties(struct list_head *props, struct scanner *scanner) @@ -172,7 +170,20 @@ struct selector_pkg { struct css_selector *selector; }; -struct css_selector * +/** Move a CSS selector and its leaves into a new list. If a similar + * selector already exists in the list, merge them. + * + * \param sels + * The list to which \a selector should be moved. Must not be NULL. + * \param selector + * The selector that should be moved. Must not be NULL. If it is + * already in some list, this function removes it from there. + * \param watch + * This function updates \a *watch if it merges that selector into + * another one. \a watch must not be NULL but \a *watch may be. + * + * \return \a selector or the one into which it was merged. */ +static struct css_selector * reparent_selector(struct list_head *sels, struct css_selector *selector, struct css_selector **watch) { @@ -481,11 +492,17 @@ css_parse_ruleset(struct css_stylesheet *css, struct scanner *scanner) /* Mirror the properties to all the selectors. */ foreach (pkg, selectors) { #ifdef DEBUG_CSS + /* Cannot use list_empty() inside the arglist of DBG() + * because GCC 4.1 "warning: operation on `errfile' + * may be undefined" breaks the build with -Werror. */ + int dbg_has_properties = !list_empty(properties); + int dbg_has_leaves = !list_empty(pkg->selector->leaves); + DBG("Binding properties (!!%d) to selector %s (type %d, relation %d, children %d)", - !list_empty(properties), + dbg_has_properties, pkg->selector->name, pkg->selector->type, pkg->selector->relation, - !list_empty(pkg->selector->leaves)); + dbg_has_leaves); #endif add_selector_properties(pkg->selector, &properties); } diff --git a/src/document/css/stylesheet.c b/src/document/css/stylesheet.c index 70f6ff7b7..a590f28db 100644 --- a/src/document/css/stylesheet.c +++ b/src/document/css/stylesheet.c @@ -27,7 +27,7 @@ struct css_selector * find_css_selector(struct list_head *sels, enum css_selector_type type, enum css_selector_relation rel, - unsigned char *name, int namelen) + const unsigned char *name, int namelen) { struct css_selector *selector; diff --git a/src/document/css/stylesheet.h b/src/document/css/stylesheet.h index 37562599a..25432a691 100644 --- a/src/document/css/stylesheet.h +++ b/src/document/css/stylesheet.h @@ -4,6 +4,8 @@ #include "util/lists.h" +/* #define DEBUG_CSS */ + /* TODO: We need a memory efficient and fast way to define how properties * cascade. What we are interested in is making it fast and easy to find * all properties we need. @@ -118,7 +120,7 @@ struct css_selector *get_css_selector(struct list_head *selector_list, struct css_selector *find_css_selector(struct list_head *selector_list, enum css_selector_type type, enum css_selector_relation rel, - unsigned char *name, int namelen); + const unsigned char *name, int namelen); #define find_css_base_selector(stylesheet, type, rel, name, namelen) \ find_css_selector(&stylesheet->selectors, rel, type, name, namelen) diff --git a/src/document/html/parser.h b/src/document/html/parser.h index b73ac877f..c10cb8a82 100644 --- a/src/document/html/parser.h +++ b/src/document/html/parser.h @@ -52,6 +52,16 @@ struct text_attrib { #endif color_T image_link; +#ifdef CONFIG_CSS + /* Bug 766: CSS speedup. 56% of CPU time was going to + * get_attr_value(). Of those calls, 97% were asking for "id" + * or "class". So cache the results. start_element() sets up + * these pointers if html_context->options->css_enable; + * otherwise they remain NULL. */ + unsigned char *id; + unsigned char *class; +#endif + unsigned char *select; int select_disabled; unsigned int tabindex; diff --git a/src/document/html/parser/parse.c b/src/document/html/parser/parse.c index 79e840afd..e71dfd223 100644 --- a/src/document/html/parser/parse.c +++ b/src/document/html/parser/parse.c @@ -905,6 +905,10 @@ start_element(struct element_info *ei, * usually have type != ET_NESTABLE when we either (1) * rescan on your own from somewhere else (2) html_stack_dup() * in our own way. --pasky */ + mem_free_set(&html_top->attr.id, + get_attr_val(attr, "id", html_context->doc_cp)); + mem_free_set(&html_top->attr.class, + get_attr_val(attr, "class", html_context->doc_cp)); /* Call it now to gain some of the stuff which might affect * formatting of some elements. */ /* FIXME: The caching of the CSS selector is broken, since t can diff --git a/src/document/html/parser/stack.c b/src/document/html/parser/stack.c index 96645408e..914388054 100644 --- a/src/document/html/parser/stack.c +++ b/src/document/html/parser/stack.c @@ -107,6 +107,11 @@ kill_html_stack_item(struct html_context *html_context, struct html_element *e) mem_free_if(e->attr.title); mem_free_if(e->attr.select); +#ifdef CONFIG_CSS + mem_free_if(e->attr.id); + mem_free_if(e->attr.class); +#endif + mem_free_if(e->attr.onclick); mem_free_if(e->attr.ondblclick); mem_free_if(e->attr.onmouseover); @@ -146,6 +151,8 @@ html_stack_dup(struct html_context *html_context, enum html_element_mortality_ty if (ep->attr.title) e->attr.title = stracpy(ep->attr.title); if (ep->attr.select) e->attr.select = stracpy(ep->attr.select); + e->attr.id = e->attr.class = NULL; + /* We don't want to propagate these. */ /* XXX: For sure? --pasky */ e->attr.onclick = e->attr.ondblclick = e->attr.onmouseover = e->attr.onhover diff --git a/src/document/html/renderer.c b/src/document/html/renderer.c index 9aaa652b4..e6f3cab25 100644 --- a/src/document/html/renderer.c +++ b/src/document/html/renderer.c @@ -1858,8 +1858,8 @@ check_html_form_hierarchy(struct part *part) foreachsafe (fc, next, form_controls) { foreach (form, document->forms) { - if (fc->position < form->form_num - || form->form_end < fc->position) + if (form->form_num <= fc->position + && fc->position <= form->form_end) continue; fc->form = form; diff --git a/src/osdep/newwin.c b/src/osdep/newwin.c index 25e4fe1ad..8c92300d3 100644 --- a/src/osdep/newwin.c +++ b/src/osdep/newwin.c @@ -90,6 +90,6 @@ open_new_window(struct terminal *term, unsigned char *exe_name, (unsigned char *) NULL); if (!command) return; - exec_on_terminal(term, command, "", 2); + exec_on_terminal(term, command, "", TERM_EXEC_NEWWIN); mem_free(command); } diff --git a/src/protocol/http/http.c b/src/protocol/http/http.c index 670845c85..bf675121c 100644 --- a/src/protocol/http/http.c +++ b/src/protocol/http/http.c @@ -193,7 +193,7 @@ static struct option_info http_options[] = { "is sent to HTTP server when a document is requested. The 'textmode'\n" "token in the first field is our silent attempt to establish this as\n" "a standard for new textmode user agents, so that the webmasters can\n" - "have just a single uniform test for these if they are ie. pushing\n" + "have just a single uniform test for these if they are e.g. pushing\n" "some lite version to them automagically.\n" "%v in the string means ELinks version\n" "%s in the string means system identification\n" diff --git a/src/protocol/user.c b/src/protocol/user.c index 76b466a7f..f0bcc5dbf 100644 --- a/src/protocol/user.c +++ b/src/protocol/user.c @@ -300,7 +300,7 @@ user_protocol_handler(struct session *ses, struct uri *uri) if (prog) { unsigned char *delete = empty_string_or_(filename); - exec_on_terminal(ses->tab->term, prog, delete, 1); + exec_on_terminal(ses->tab->term, prog, delete, TERM_EXEC_FG); mem_free(prog); } else if (filename) { diff --git a/src/scripting/lua/core.c b/src/scripting/lua/core.c index bd1b8df0c..8aec3a91a 100644 --- a/src/scripting/lua/core.c +++ b/src/scripting/lua/core.c @@ -231,7 +231,8 @@ static int l_execute(LS) { if (lua_isstring(S, 1)) { - exec_on_terminal(lua_ses->tab->term, (unsigned char *) lua_tostring(S, 1), "", 0); + exec_on_terminal(lua_ses->tab->term, (unsigned char *) lua_tostring(S, 1), "", + TERM_EXEC_BG); lua_pushnumber(S, 0); return 1; } @@ -795,7 +796,7 @@ handle_ret_run(struct session *ses) unsigned char *cmd = (unsigned char *) lua_tostring(L, -1); if (cmd) { - exec_on_terminal(ses->tab->term, cmd, "", 1); + exec_on_terminal(ses->tab->term, cmd, "", TERM_EXEC_FG); return; } diff --git a/src/scripting/smjs/elinks_object.c b/src/scripting/smjs/elinks_object.c index e017723b9..55d7a2970 100644 --- a/src/scripting/smjs/elinks_object.c +++ b/src/scripting/smjs/elinks_object.c @@ -103,7 +103,7 @@ elinks_execute(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rv if (!*string) return JS_TRUE; - exec_on_terminal(smjs_ses->tab->term, string, "", 0); + exec_on_terminal(smjs_ses->tab->term, string, "", TERM_EXEC_BG); undef_to_jsval(ctx, rval); return JS_TRUE; diff --git a/src/session/download.c b/src/session/download.c index 3f3412129..376a29446 100644 --- a/src/session/download.c +++ b/src/session/download.c @@ -376,7 +376,7 @@ download_data_store(struct download *download, struct file_download *file_downlo } else { exec_on_terminal(term, file_download->external_handler, file_download->file, - !!file_download->block); + file_download->block ? TERM_EXEC_FG : TERM_EXEC_BG); file_download->delete = 0; abort_download_and_beep(file_download, term); } @@ -1100,7 +1100,8 @@ tp_open(struct type_query *type_query) read_from_popen(type_query->ses, handler, NULL); else exec_on_terminal(type_query->ses->tab->term, - handler, "", !!type_query->block); + handler, "", + type_query->block ? TERM_EXEC_FG : TERM_EXEC_BG); mem_free(handler); } diff --git a/src/terminal/kbd.c b/src/terminal/kbd.c index 16be876b0..9a7f54406 100644 --- a/src/terminal/kbd.c +++ b/src/terminal/kbd.c @@ -510,7 +510,7 @@ in_sock(struct itrm *itrm) struct string path; struct string delete; char ch; - int fg; + int fg; /* enum term_exec */ ssize_t bytes_read, i, p; unsigned char buf[ITRM_OUT_QUEUE_SIZE]; @@ -575,7 +575,7 @@ has_nul_byte: unsigned char *param; int path_len, del_len, param_len; - if (is_blocked() && fg) { + if (is_blocked() && fg != TERM_EXEC_BG) { if (*delete.source) unlink(delete.source); goto nasty_thing; } @@ -591,20 +591,20 @@ has_nul_byte: memcpy(param + 1, path.source, path_len + 1); memcpy(param + 1 + path_len + 1, delete.source, del_len + 1); - if (fg == 1) block_itrm(); + if (fg == TERM_EXEC_FG) block_itrm(); blockh = start_thread((void (*)(void *, int)) exec_thread, param, param_len); mem_free(param); if (blockh == -1) { - if (fg == 1) + if (fg == TERM_EXEC_FG) unblock_itrm(); goto nasty_thing; } - if (fg == 1) { + if (fg == TERM_EXEC_FG) { set_handlers(blockh, (select_handler_T) unblock_itrm_x, NULL, (select_handler_T) unblock_itrm_x, (void *) (long) blockh); diff --git a/src/terminal/terminal.c b/src/terminal/terminal.c index befaa0a1d..00a2854c4 100644 --- a/src/terminal/terminal.c +++ b/src/terminal/terminal.c @@ -179,7 +179,7 @@ exec_thread(unsigned char *path, int p) int plen = strlen(path + 1) + 2; #if defined(HAVE_SETPGID) && !defined(CONFIG_OS_BEOS) && !defined(HAVE_BEGINTHREAD) - if (path[0] == 2) setpgid(0, 0); + if (path[0] == TERM_EXEC_NEWWIN) setpgid(0, 0); #endif exe(path + 1); if (path[plen]) unlink(path + plen); @@ -210,7 +210,7 @@ static void exec_on_master_terminal(struct terminal *term, unsigned char *path, int plen, unsigned char *delete, int dlen, - int fg) + enum term_exec fg) { int blockh; int param_size = plen + dlen + 2 /* 2 null char */ + 1 /* fg */; @@ -222,17 +222,17 @@ exec_on_master_terminal(struct terminal *term, memcpy(param + 1, path, plen + 1); memcpy(param + 1 + plen + 1, delete, dlen + 1); - if (fg == 1) block_itrm(); + if (fg == TERM_EXEC_FG) block_itrm(); blockh = start_thread((void (*)(void *, int)) exec_thread, param, param_size); fmem_free(param); if (blockh == -1) { - if (fg == 1) unblock_itrm(); + if (fg == TERM_EXEC_FG) unblock_itrm(); return; } - if (fg == 1) { + if (fg == TERM_EXEC_FG) { term->blocked = blockh; set_handlers(blockh, (select_handler_T) unblock_terminal, @@ -253,7 +253,7 @@ static void exec_on_slave_terminal( struct terminal *term, unsigned char *path, int plen, unsigned char *delete, int dlen, - int fg) + enum term_exec fg) { int data_size = plen + dlen + 1 /* 0 */ + 1 /* fg */ + 2 /* 2 null char */; unsigned char *data = fmem_alloc(data_size); @@ -270,7 +270,7 @@ exec_on_slave_terminal( struct terminal *term, void exec_on_terminal(struct terminal *term, unsigned char *path, - unsigned char *delete, int fg) + unsigned char *delete, enum term_exec fg) { if (path) { if (!*path) return; @@ -279,7 +279,7 @@ exec_on_terminal(struct terminal *term, unsigned char *path, } #ifdef NO_FG_EXEC - fg = 0; + fg = TERM_EXEC_BG; #endif if (term->master) { @@ -288,7 +288,7 @@ exec_on_terminal(struct terminal *term, unsigned char *path, return; } - if (fg && is_blocked()) { + if (fg != TERM_EXEC_BG && is_blocked()) { unlink(delete); return; } @@ -314,7 +314,7 @@ exec_shell(struct terminal *term) sh = get_shell(); if (sh && *sh) - exec_on_terminal(term, sh, "", 1); + exec_on_terminal(term, sh, "", TERM_EXEC_FG); } @@ -328,7 +328,7 @@ do_terminal_function(struct terminal *term, unsigned char code, if (!x_data) return; x_data[0] = code; memcpy(x_data + 1, data, data_len + 1); - exec_on_terminal(term, NULL, x_data, 0); + exec_on_terminal(term, NULL, x_data, TERM_EXEC_BG); fmem_free(x_data); } diff --git a/src/terminal/terminal.h b/src/terminal/terminal.h index d95da99a2..f661e02ae 100644 --- a/src/terminal/terminal.h +++ b/src/terminal/terminal.h @@ -175,10 +175,28 @@ void destroy_all_terminals(void); void exec_thread(unsigned char *, int); void close_handle(void *); +/* Operations that can be requested with do_terminal_function(). + * The interlink protocol passes these values as one byte in a + * null-terminated string, so zero cannot be used. */ #define TERM_FN_TITLE 1 #define TERM_FN_RESIZE 2 -void exec_on_terminal(struct terminal *, unsigned char *, unsigned char *, int); +/* How to execute a program in a terminal. These values are used in + * the interlink protocol and must fit in one byte. */ +enum term_exec { + /* Execute in the background. ELinks keeps using the terminal + * and the program should not use it. */ + TERM_EXEC_BG = 0, + + /* Execute in the foreground. The program may use the terminal. + * ELinks will redraw when the program exits. */ + TERM_EXEC_FG = 1, + + /* Execute in the background and in a new process group. */ + TERM_EXEC_NEWWIN = 2 +}; + +void exec_on_terminal(struct terminal *, unsigned char *, unsigned char *, enum term_exec); void exec_shell(struct terminal *term); void set_terminal_title(struct terminal *, unsigned char *); diff --git a/src/viewer/text/textarea.c b/src/viewer/text/textarea.c index a6b739ff7..dfb446051 100644 --- a/src/viewer/text/textarea.c +++ b/src/viewer/text/textarea.c @@ -625,7 +625,7 @@ textarea_edit(int op, struct terminal *term_, struct form_state *fs_, } if (term_) term = term_; - exec_on_terminal(term, ex, "", 1); + exec_on_terminal(term, ex, "", TERM_EXEC_FG); mem_free(ex); textarea_editor = 1;