diff --git a/ChangeLog b/ChangeLog index e1d183d9..2819b9ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2006-01-11 Ralf Wildenhues + + * lib/m4sugar/m4sugar.m4 (m4_text_wrap): Handle quadrigraphs + correctly: pad with spaces after FIRST_PREFIX if necessary, + and compute string lenghts with `m4_qlen' instead of `m4_len'. + * lib/m4sugar/m4sh.m4 (AS_HELP_STRING): Comments updated. + * tests/m4sh.at (AS_HELP_STRING): Test extended. + * NEWS: Updated. + Reported by numerous people, numerous times. + 2006-01-05 Paul Eggert * bin/autoconf.as, bin/autoheader.in, bin/autom4te.in diff --git a/NEWS b/NEWS index 75753a2a..58770272 100644 --- a/NEWS +++ b/NEWS @@ -61,6 +61,9 @@ New macro which is defined to the name of the first declared config header or undefined if no config headers have been declared yet. +** AS_HELP_STRING + The macro correctly handles quadrigraphs now. + ** AT_COPYRIGHT New macro for copyright notices in testsuite files. @@ -1266,7 +1269,7 @@ Various bug fixes. ----- Copyright (C) 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, -2003, 2004, 2005 Free Software Foundation, Inc. +2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Autoconf. diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4 index 4dc65610..fda56cfd 100644 --- a/lib/m4sugar/m4sh.m4 +++ b/lib/m4sugar/m4sh.m4 @@ -1171,16 +1171,8 @@ esac[]dnl # column 0 column 26 # # -# FIXME: Handle quadrigraphs in LHS correctly. -# another one: -# FIXME: the m4_text_wrap interface design seems to be wrong. I see two ways: -# 1) m4_text_wrap could pad the FIRST_PREFIX to the length of PREFIX; then -# there would be no need to handle quadrigraphs in AS_HELP_STRING. -# 2) The special case when FIRST_PREFIX is longer than PREFIX could be moved -# from m4_text_wrap here; then one could call -# m4_text_wrap(TEXT, [], [ ]) -# to get an indented paragraph. -# My first impression is that 2) is better. --kasal 19apr05 +# m4_text_wrap hacks^Wworks around the fact that m4_format does not +# know quadrigraphs. # m4_define([AS_HELP_STRING], [m4_pushdef([AS_Prefix], m4_default([$3], [ ]))dnl diff --git a/lib/m4sugar/m4sugar.m4 b/lib/m4sugar/m4sugar.m4 index ad184c25..cc45c257 100644 --- a/lib/m4sugar/m4sugar.m4 +++ b/lib/m4sugar/m4sugar.m4 @@ -3,7 +3,7 @@ divert(-1)# -*- Autoconf -*- # Base M4 layer. # Requires GNU M4. # -# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software # Foundation, Inc. # # This program is free software; you can redistribute it and/or modify @@ -1559,9 +1559,6 @@ m4_define([m4_append_uniq], # we really want to bother with people trying each single corner # of a software? # -# more important: -# FIXME: handle quadrigraphs correctly, both in TEXT and in FIRST_PREFIX. -# # This macro does not leave a trailing space behind the last word, # what complicates it a bit. The algorithm is stupid simple: all the # words are preceded by m4_Separator which is defined to empty for the @@ -1570,19 +1567,25 @@ m4_define([m4_text_wrap], [m4_pushdef([m4_Prefix], [$2])dnl m4_pushdef([m4_Prefix1], m4_default([$3], [m4_Prefix]))dnl m4_pushdef([m4_Width], m4_default([$4], 79))dnl -m4_pushdef([m4_Cursor], m4_len(m4_Prefix1))dnl +m4_pushdef([m4_Cursor], m4_qlen(m4_Prefix1))dnl m4_pushdef([m4_Separator], [])dnl m4_Prefix1[]dnl -m4_if(m4_eval(m4_Cursor > m4_len(m4_Prefix)), +m4_if(m4_eval(m4_qlen(m4_Prefix1) > m4_len(m4_Prefix)), 1, [m4_define([m4_Cursor], m4_len(m4_Prefix)) -m4_Prefix])[]dnl +m4_Prefix], + m4_if(m4_eval(m4_qlen(m4_Prefix1) < m4_len(m4_Prefix)), + [0], [], + [m4_define([m4_Cursor], m4_len(m4_Prefix))[]dnl +m4_for(m4_Space, m4_qlen(m4_Prefix1), m4_eval(m4_len(m4_Prefix) - 1), + [], [ ])])[]dnl +)[]dnl m4_foreach_w([m4_Word], [$1], -[m4_define([m4_Cursor], m4_eval(m4_Cursor + m4_len(m4_defn([m4_Word])) + 1))dnl +[m4_define([m4_Cursor], m4_eval(m4_Cursor + m4_qlen(m4_defn([m4_Word])) + 1))dnl dnl New line if too long, else insert a space unless it is the first dnl of the words. m4_if(m4_eval(m4_Cursor > m4_Width), 1, [m4_define([m4_Cursor], - m4_eval(m4_len(m4_Prefix) + m4_len(m4_defn([m4_Word])) + 1))] + m4_eval(m4_len(m4_Prefix) + m4_qlen(m4_defn([m4_Word])) + 1))] m4_Prefix, [m4_Separator])[]dnl m4_defn([m4_Word])[]dnl diff --git a/tests/m4sh.at b/tests/m4sh.at index 3e784723..be124ff1 100644 --- a/tests/m4sh.at +++ b/tests/m4sh.at @@ -2,7 +2,7 @@ AT_BANNER([M4sh.]) -# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software +# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software # Foundation, Inc. # # This program is free software; you can redistribute it and/or modify @@ -457,14 +457,79 @@ _AS_LINENO_PREPARE echo "AS_HELP_STRING([--an-option],[some text])" echo "AS_HELP_STRING([--another-much-longer-option], [some other text which should wrap at our default of 80 characters.])" +echo "AS_HELP_STRING([--fooT=barT], [foo bar])" +echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@], [foo bar])" +echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789], [foo bar])" +echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890], [foo bar])" +echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@12345678901], [foo bar])" +echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789012], [foo bar])" +echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890123], [foo bar])" +echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@], +[some other text which should wrap at our default of 80 characters.])" +echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789], +[some other text which should wrap at our default of 80 characters.])" +echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890], +[some other text which should wrap at our default of 80 characters.])" +echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@12345678901], +[some other text which should wrap at our default of 80 characters.])" +echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789012], +[some other text which should wrap at our default of 80 characters.])" +echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890123], +[some other text which should wrap at our default of 80 characters.])" +echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@], +[some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])" +echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789], +[some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])" +echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890], +[some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])" +echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@12345678901], +[some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])" +echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789012], +[some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])" +echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890123], +[some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])" ]]) AT_CHECK_M4SH AT_CHECK([./script], [0], -[ --an-option some text +[[ --an-option some text --another-much-longer-option some other text which should wrap at our default of 80 characters. -]) + --fooT=barT foo bar + --foo[=bar] foo bar + --foo[=bar]123456789 foo bar + --foo[=bar]1234567890 foo bar + --foo[=bar]12345678901 foo bar + --foo[=bar]123456789012 foo bar + --foo[=bar]1234567890123 + foo bar + --foo[=bar] some other text which should wrap at our default of + 80 characters. + --foo[=bar]123456789 some other text which should wrap at our default of + 80 characters. + --foo[=bar]1234567890 some other text which should wrap at our default of + 80 characters. + --foo[=bar]12345678901 some other text which should wrap at our default of + 80 characters. + --foo[=bar]123456789012 some other text which should wrap at our default of + 80 characters. + --foo[=bar]1234567890123 + some other text which should wrap at our default of + 80 characters. + --foo[=bar] some other [ex] which should wrap at our default of + 80 characters. + --foo[=bar]123456789 some other [ex] which should wrap at our default of + 80 characters. + --foo[=bar]1234567890 some other [ex] which should wrap at our default of + 80 characters. + --foo[=bar]12345678901 some other [ex] which should wrap at our default of + 80 characters. + --foo[=bar]123456789012 some other [ex] which should wrap at our default of + 80 characters. + --foo[=bar]1234567890123 + some other [ex] which should wrap at our default of + 80 characters. +]]) AT_CLEANUP