Missing dependencies added.
[AROS-Contrib.git] / rexx / lstring / translat.c
blobf658e4ab9f881b262ef8556762788e6133712e0e
1 /*
2 * $Header$
3 * $Log$
4 * Revision 1.1 2001/04/04 05:43:38 wang
5 * First commit: compiles on Linux, Amiga, Windows, Windows CE, generic gcc
7 * Revision 1.2 1999/03/01 11:07:22 bnv
8 * Added '{..}' to avoid nesting if () {} else {} errors.
10 * Revision 1.1 1998/07/02 17:18:00 bnv
11 * Initial Version
15 #include <lstring.h>
17 /* ---------------- Ltranslate ------------------- */
18 void
19 Ltranslate( const PLstr to, const PLstr from,
20 const PLstr tableout, const PLstr tablein, const char pad )
22 char table[256];
23 int i;
25 Lstrcpy(to,from); L2STR(to);
27 for (i=0; i<256; i++)
28 table[i] = i;
30 if (tableout) L2STR(tableout);
31 if (tablein) L2STR(tablein);
33 if (tablein) {
34 for (i=LLEN(*tablein)-1; i>=0; i--)
35 if (tableout) {
36 if (i>=LLEN(*tableout))
37 table[(byte)LSTR(*tablein)[i]]=pad;
38 else
39 table[(byte)LSTR(*tablein)[i]]=LSTR(*tableout)[i];
40 } else
41 table[(byte)LSTR(*tablein)[i]] = pad;
42 } else {
43 for (i=0; i<256; i++)
44 if (tableout) {
45 if (i >= LLEN(*tableout))
46 table[i] = pad;
47 else
48 table[i] = LSTR(*tableout)[i];
52 for (i=0; i<LLEN(*to); i++)
53 LSTR(*to)[i] = table[ (byte) LSTR(*to)[i] ];
54 } /* Ltranslate */