dnl CF_AWK_BIGSTRING version: 4 updated: 2015/02/10 04:30:14
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 ( test "$1" -le "$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
