[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fix AS_HELP_STRING (AC_HELP_STRING) with quadrigraphs
From: |
Ralf Wildenhues |
Subject: |
Fix AS_HELP_STRING (AC_HELP_STRING) with quadrigraphs |
Date: |
Tue, 10 Jan 2006 18:56:08 +0100 |
User-agent: |
Mutt/1.5.11 |
A bit ugly. But works for AS_HELP_STRING. :-)
OK to apply (including copyright year updates)?
Does this break any other m4_text_wrap uses?
If yes, are they important enough to worry about? I could only find
the autoheader one, which should not be impacted by the patch below.
Cheers,
Ralf
* 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.
Reported by numerous people, numerous times.
Index: lib/m4sugar/m4sh.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/m4sugar/m4sh.m4,v
retrieving revision 1.154
diff -u -r1.154 m4sh.m4
--- lib/m4sugar/m4sh.m4 6 Jan 2006 00:02:26 -0000 1.154
+++ lib/m4sugar/m4sh.m4 10 Jan 2006 19:05:20 -0000
@@ -1171,16 +1171,8 @@
# 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
Index: lib/m4sugar/m4sugar.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/m4sugar/m4sugar.m4,v
retrieving revision 2.95
diff -u -r2.95 m4sugar.m4
--- lib/m4sugar/m4sugar.m4 5 Oct 2005 21:27:44 -0000 2.95
+++ lib/m4sugar/m4sugar.m4 10 Jan 2006 19:05:21 -0000
@@ -1559,9 +1559,6 @@
# 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_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
Index: tests/m4sh.at
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/m4sh.at,v
retrieving revision 1.42
diff -u -r1.42 m4sh.at
--- tests/m4sh.at 16 Jun 2005 21:03:47 -0000 1.42
+++ tests/m4sh.at 10 Jan 2006 19:05:22 -0000
@@ -457,14 +457,79 @@
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
- Fix AS_HELP_STRING (AC_HELP_STRING) with quadrigraphs,
Ralf Wildenhues <=