On 03/08/11 22:12, Stuart Henderson wrote:
> On 2011/03/08 21:31, Nigel Taylor wrote:
>> autoconf version should be left at 2.64, 2.65 has never worked for building
>> this, or any previous version, should now be 2.67 not available in ports.
> 
> 2.65 requires m4(1) in base to adapt to some other GNU m4 features -
> there are a few small comments in devel/autoconf/2.65/Makefile if anyone
> feels like digging in m4, it's marked as BROKEN for now.
> 
> 
Hi,

translit goes noticeably wrong in
m4_chomp in autoconf-2.65/m4sugar/m4sugar.m4

Reproduced as simple test (1st 3 lines equivalent to chomp trailing space
instead of / get converted later to _) comparing gm4 vs m4 output.

$ cat test_translit.m4
translit(`[HAVE_abc/def.h
]', `
/.', `/  ')
translit(`[HAVE_abc/def.h=]', `=/.', `/~~')
translit(`[HAVE_abc=def.h=]', `=/.', `/~~')
translit(`[HAVE_abc=def.h=]', `=/.', `/~;')
translit(`[HAVE_abc=def.h=]', `abc=/.', `ABC/~;')
translit(`[HAVE_abc=def.h=]', `abc=Z.', `ABCZL;')
translit(`0123456789', `0123456789', `ABCDEFGHIJ')
translit(`0123456789', `[0-9]', `[A-J]')
translit(`abc-0980-zyx', `abcdefghijklmnopqrstuvwxyz', 
`ABCDEFGHIJKLMNOPQRSTUVWXYZ')
translit(`abc-0980-zyx', `[a-z]', `[A-Z]')

$ cat test_translit.sh
gm4 test_translit.m4 >test_translit.out
m4 -g test_translit.m4 | sdiff -w 38 - test_translit.out

$ sh test_translit.sh
[HAVE_abc def h ] | [HAVE_abc def h/]
[HAVE_abc~def~h~] | [HAVE_abc~def~h/]
[HAVE_abc~def~h~] | [HAVE_abc/def~h/]
[HAVE_abc~def;h~] | [HAVE_abc/def;h/]
[HAVE_ABC~def;h~] | [HAVE_ABC/def;h/]
[HAVE_ABCLdef;hL] | [HAVE_ABCZdef;hZ]
ABCDEFGHIJ          ABCDEFGHIJ
ABCDEFGHIJ          ABCDEFGHIJ
ABC-0980-ZYX        ABC-0980-ZYX
ABC-0980-ZYX        ABC-0980-ZYX
$

The fault is with to from `=/.', `/~;'
= -> / but then translit goes back and sees / -> ~ so result is
= -> ~, rather than the expected /.

now if I use to/from `=/.~', '/~;='
we get = -> / -> ~ -> = -> / infinite loop in m4.

After fix to only apply translations once, the results now match.

$ sh test_translit.sh
[HAVE_abc def h/]   [HAVE_abc def h/]
[HAVE_abc~def~h/]   [HAVE_abc~def~h/]
[HAVE_abc/def~h/]   [HAVE_abc/def~h/]
[HAVE_abc/def;h/]   [HAVE_abc/def;h/]
[HAVE_ABC/def;h/]   [HAVE_ABC/def;h/]
[HAVE_ABCZdef;hZ]   [HAVE_ABCZdef;hZ]
ABCDEFGHIJ          ABCDEFGHIJ
ABCDEFGHIJ          ABCDEFGHIJ
ABC-0980-ZYX        ABC-0980-ZYX
ABC-0980-ZYX        ABC-0980-ZYX
$

autoconf 2.65 now works for this port www/libmicrohttpd.

Attached fix for m4, plus new regression test using output created using gm4.

Need to be tried with ports with different versions of autoconf. xenocara (I
think uses m4/autoconf), to ensure no problems - I started a build of xenocara
from source for amd64.

Regards

Nigel Taylor
Index: usr.bin/m4/eval.c
===================================================================
RCS file: /home/cvs/src/usr.bin/m4/eval.c,v
retrieving revision 1.68
diff -u -p -r1.68 eval.c
--- usr.bin/m4/eval.c   7 Sep 2010 19:58:09 -0000       1.68
+++ usr.bin/m4/eval.c   10 Mar 2011 14:17:00 -0000
@@ -958,10 +958,6 @@ map(char *dest, const char *src, const c
                while (*src) {
                        sch = (unsigned char)(*src++);
                        dch = mapvec[sch];
-                       while (dch != sch) {
-                               sch = dch;
-                               dch = mapvec[sch];
-                       }
                        if ((*dest = (char)dch))
                                dest++;
                }
Index: regress/usr.bin/m4/Makefile
===================================================================
RCS file: /home/cvs/src/regress/usr.bin/m4/Makefile,v
retrieving revision 1.28
diff -u -p -r1.28 Makefile
--- regress/usr.bin/m4/Makefile 23 Mar 2010 20:11:52 -0000      1.28
+++ regress/usr.bin/m4/Makefile 10 Mar 2011 14:22:45 -0000
@@ -12,7 +12,7 @@ REGRESS_TARGETS= test-ff_after_dnl test-
     test-weird test-args test-args2 test-esyscmd test-eval test-gnupatterns \
     test-gnupatterns2 test-comments test-synch1 test-synch1bis \
     test-gnuformat test-includes test-dumpdef test-gnuprefix \
-    test-translit
+    test-translit test-gnutranslit
 
 test-ff_after_dnl: ff_after_dnl.m4
        ${M4} ff_after_dnl.m4 | diff - ${.CURDIR}/ff_after_dnl.out
@@ -102,6 +102,9 @@ test-dumpdef:
 test-gnuprefix:
        ${M4} -P ${.CURDIR}/gnuprefix.m4 2>&1 | \
                diff -u - ${.CURDIR}/gnuprefix.out
+
+test-gnutranslit:
+       ${M4} -g ${.CURDIR}/gnutranslit.m4 | diff -u - 
${.CURDIR}/gnutranslit.out
 
 .PHONY:        ${REGRESS_TARGETS}
 
Index: regress/usr.bin/m4/gnutranslit.m4
===================================================================
RCS file: regress/usr.bin/m4/gnutranslit.m4
diff -N regress/usr.bin/m4/gnutranslit.m4
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ regress/usr.bin/m4/gnutranslit.m4   10 Mar 2011 14:27:38 -0000
@@ -0,0 +1,8 @@
+translit(`[HAVE_abc/def.h
+]', `
+/.', `/  ')
+translit(`[HAVE_abc/def.h=]', `=/.', `/~~')
+translit(`0123456789', `0123456789', `ABCDEFGHIJ')
+translit(`0123456789', `[0-9]', `[A-J]')
+translit(`abc-0980-zyx', `abcdefghijklmnopqrstuvwxyz', 
`ABCDEFGHIJKLMNOPQRSTUVWXYZ') 
+translit(`abc-0980-zyx', `[a-z]', `[A-Z]') 
Index: regress/usr.bin/m4/gnutranslit.out
===================================================================
RCS file: regress/usr.bin/m4/gnutranslit.out
diff -N regress/usr.bin/m4/gnutranslit.out
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ regress/usr.bin/m4/gnutranslit.out  10 Mar 2011 14:28:21 -0000
@@ -0,0 +1,6 @@
+[HAVE_abc def h/]
+[HAVE_abc~def~h/]
+ABCDEFGHIJ
+ABCDEFGHIJ
+ABC-0980-ZYX 
+ABC-0980-ZYX 

Reply via email to