From 8ff653d8c3f2d15717cd522b31c1a6105fb42dd7 Mon Sep 17 00:00:00 2001 From: Marc Espie Date: Thu, 25 Mar 2010 18:52:30 +0000 Subject: conform to gnum4 AND traditional m4 (solaris) behavior, namely, translit(`ab',`aa',`cd') -> `cb' (first occurrence matches) okay miod@, sthen@ fixes minor autoconf issues, like HAVE_VOID__ instead of HAVE_VOID_P --- usr.bin/m4/eval.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/usr.bin/m4/eval.c b/usr.bin/m4/eval.c index 1968ad35413..c920e8b73af 100644 --- a/usr.bin/m4/eval.c +++ b/usr.bin/m4/eval.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eval.c,v 1.66 2008/08/21 21:01:47 espie Exp $ */ +/* $OpenBSD: eval.c,v 1.67 2010/03/25 18:52:29 espie Exp $ */ /* $NetBSD: eval.c,v 1.7 1996/11/10 21:21:29 pk Exp $ */ /* @@ -907,6 +907,8 @@ map(char *dest, const char *src, const char *from, const char *to) unsigned char sch, dch; static char frombis[257]; static char tobis[257]; + int i; + char seen[256]; static unsigned char mapvec[256] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, @@ -941,9 +943,17 @@ map(char *dest, const char *src, const char *from, const char *to) * create a mapping between "from" and * "to" */ - while (*from) - mapvec[(unsigned char)(*from++)] = (*to) ? - (unsigned char)(*to++) : 0; + for (i = 0; i < 256; i++) + seen[i] = 0; + while (*from) { + if (!seen[(unsigned char)(*from)]) { + mapvec[(unsigned char)(*from)] = (unsigned char)(*to); + seen[(unsigned char)(*from)] = 1; + } + from++; + if (*to) + to++; + } while (*src) { sch = (unsigned char)(*src++); -- cgit v1.2.3