=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/m4/eval.c,v retrieving revision 1.66 retrieving revision 1.67 diff -u -r1.66 -r1.67 --- src/usr.bin/m4/eval.c 2008/08/21 21:01:47 1.66 +++ src/usr.bin/m4/eval.c 2010/03/25 18:52:29 1.67 @@ -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 @@ 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 @@ * 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++);