autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fix AS_HELP_STRING (AC_HELP_STRING) with quadrigraphs


From: Ralf Wildenhues
Subject: Re: Fix AS_HELP_STRING (AC_HELP_STRING) with quadrigraphs
Date: Wed, 11 Jan 2006 09:05:34 +0100
User-agent: Mutt/1.5.11

* Paul Eggert wrote on Wed, Jan 11, 2006 at 07:41:04AM CET:
> Ralf Wildenhues <address@hidden> writes:
> 
> > OK to apply (including copyright year updates)?
> 
> Looks good to me.

Thanks.  Applied as below.  I took liberty to also add a NEWS entry.

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.
        * NEWS: Updated.
        Reported by numerous people, numerous times.

Index: NEWS
===================================================================
RCS file: /cvsroot/autoconf/autoconf/NEWS,v
retrieving revision 1.349
diff -u -r1.349 NEWS
--- NEWS        1 Nov 2005 06:24:53 -0000       1.349
+++ NEWS        11 Jan 2006 08:04:46 -0000
@@ -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 @@
 -----
 
 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.
 
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 11 Jan 2006 08:04:04 -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      11 Jan 2006 08:04:04 -0000
@@ -3,7 +3,7 @@
 # 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 @@
 # 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       11 Jan 2006 08:04:04 -0000
@@ -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 @@
 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]