Missing dependencies added.
[AROS-Contrib.git] / rexx / lstring / changest.c
blobbde35a63bd6304206d41991b1f0cba626d09b6de
1 /*
2 * $Header$
3 * $Log$
4 * Revision 1.1 2001/04/04 05:43:37 wang
5 * First commit: compiles on Linux, Amiga, Windows, Windows CE, generic gcc
7 * Revision 1.3 2000/09/28 15:52:19 bnv
8 * Corrected a bug if the input string had repeated targets.
10 * Revision 1.2 2000/02/07 11:21:35 bnv
11 * Corrected: The case where the old string has length equal to ZERO.
13 * Revision 1.1 1998/07/02 17:17:00 bnv
14 * Initial revision
18 #include <lstring.h>
20 /* ----------------- Lchagestr ------------------- */
21 void
22 Lchangestr( const PLstr to, const PLstr oldstr,
23 const PLstr str, const PLstr newstr)
25 size_t pos, foundpos;
26 Lstr tmp;
28 if (LLEN(*oldstr)==0) {
29 Lstrcpy(to,str);
30 return;
33 Lfx(to,LLEN(*str));
34 LZEROSTR(*to);
36 LINITSTR(tmp);
38 pos = 1;
39 for (;;) {
40 foundpos = Lindex(str,oldstr,pos);
41 if (foundpos==0) break;
42 if (foundpos!=pos) {
43 _Lsubstr(&tmp,str,pos,foundpos-pos);
44 Lstrcat(to,&tmp);
46 Lstrcat(to,newstr);
47 pos = foundpos + LLEN(*oldstr);
49 _Lsubstr(&tmp,str,pos,0);
50 Lstrcat(to,&tmp);
51 LFREESTR(tmp);
52 } /* Lchagestr */