dnl CF_AWK_BIGSTRING version: 3 updated: 2010/10/23 15:52:32
dnl ----------------
dnl Check if awk can handle big strings.
dnl
dnl mawk often can handle longer strings than its nominal limit (obtained via
dnl the "-W version" option), but will dump core in this ad hoc test, hence the
dnl odd workaround.
dnl
dnl $1 = desired string size
dnl $2 = variable to set with result
AC_DEFUN([CF_AWK_BIGSTRING],
[
    case x$AWK in #(vi
    x)
        eval $2=no
        ;;
    x*mawk*) #(vi
        cf_awk_bigstring=`$AWK -W version 2>&1 |fgrep sprintf |sed -e 's/[[ ]]*$//' -e 's/^.*[[ ]]//'`
        if test -z $cf_awk_bigstring ; then
            eval $2=no
        elif ( expr $1 \<= $cf_awk_bigstring 2>/dev/null >/dev/null ) ; then
            eval $2=yes
        else
            eval $2=no
        fi
        ;;
    *) #(vi
        if ( ${AWK:-awk} 'BEGIN { xx = "xx"; while (length(xx) < $1) { xx = xx xx; }; yy = sprintf("%s\n", xx); if (length(yy) < $1) exit 1; }' 2>/dev/null >/dev/null ); then
            eval $2=yes
        else
            eval $2=no
        fi
        ;;
    esac
])dnl
