@@ -152,59 +152,37 @@ LPSTR _ReplaceItems(LPCSTR src, int idx_start, int idx_end, LPCSTR new_items, LP
152152 return dst;
153153}
154154
155- LPSTR _ReplaceItem (LPCSTR src, int index, LPCSTR new_item, LPSTR dst, char separator)
155+ xr_string& _ReplaceItems (pcstr src, int idx_start, int idx_end, pcstr new_items, xr_string& dst, char separator)
156156{
157- LPSTR n = dst ;
157+ dst = " " ;
158158 int level = 0 ;
159159 bool bCopy = true ;
160- for (LPCSTR p = src; *p != 0 ; p++)
160+ for (pcstr p = src; *p != 0 ; p++)
161161 {
162- if (level == index )
162+ if (( level >= idx_start) && (level < idx_end) )
163163 {
164164 if (bCopy)
165165 {
166- for (LPCSTR itm = new_item ; *itm != 0 ;)
167- *n++ = *itm++;
166+ for (pcstr itm = new_items ; *itm != 0 ;)
167+ dst + = *itm++;
168168 bCopy = false ;
169169 }
170170 if (*p == separator)
171- *n++ = separator;
171+ dst + = separator;
172172 }
173173 else
174174 {
175- *n++ = *p;
175+ dst + = *p;
176176 }
177177 if (*p == separator)
178178 level++;
179179 }
180- *n = ' \0 ' ;
181180 return dst;
182181}
183182
184- LPSTR _ChangeSymbol (LPSTR name, char src, char dest)
185- {
186- char * sTmpName = name;
187- while (sTmpName [0 ])
188- {
189- if (sTmpName [0 ] == src)
190- sTmpName [0 ] = dest;
191- sTmpName ++;
192- }
193- return name;
194- }
195-
196- xr_string& _ChangeSymbol (xr_string& name, char src, char dest)
197- {
198- for (xr_string::iterator it = name.begin (); it != name.end (); it++)
199- if (*it == src)
200- *it = xr_string::value_type (dest);
201- return name;
202- }
203-
204- #ifdef M_BORLAND
205- AnsiString& _ReplaceItem (LPCSTR src, int index, LPCSTR new_item, AnsiString& dst, char separator)
183+ LPSTR _ReplaceItem (LPCSTR src, int index, LPCSTR new_item, LPSTR dst, char separator)
206184{
207- dst = " " ;
185+ LPSTR n = dst ;
208186 int level = 0 ;
209187 bool bCopy = true ;
210188 for (LPCSTR p = src; *p != 0 ; p++)
@@ -214,34 +192,35 @@ AnsiString& _ReplaceItem(LPCSTR src, int index, LPCSTR new_item, AnsiString& dst
214192 if (bCopy)
215193 {
216194 for (LPCSTR itm = new_item; *itm != 0 ;)
217- dst + = *itm++;
195+ *n++ = *itm++;
218196 bCopy = false ;
219197 }
220198 if (*p == separator)
221- dst + = separator;
199+ *n++ = separator;
222200 }
223201 else
224202 {
225- dst + = *p;
203+ *n++ = *p;
226204 }
227205 if (*p == separator)
228206 level++;
229207 }
208+ *n = ' \0 ' ;
230209 return dst;
231210}
232211
233- AnsiString& _ReplaceItems (LPCSTR src, int idx_start, int idx_end, LPCSTR new_items, AnsiString & dst, char separator)
212+ xr_string& _ReplaceItem (pcstr src, int index, pcstr new_item, xr_string & dst, char separator)
234213{
235214 dst = " " ;
236215 int level = 0 ;
237216 bool bCopy = true ;
238- for (LPCSTR p = src; *p != 0 ; p++)
217+ for (pcstr p = src; *p != 0 ; p++)
239218 {
240- if (( level >= idx_start) && (level < idx_end) )
219+ if (level == index )
241220 {
242221 if (bCopy)
243222 {
244- for (LPCSTR itm = new_items ; *itm != 0 ;)
223+ for (pcstr itm = new_item ; *itm != 0 ;)
245224 dst += *itm++;
246225 bCopy = false ;
247226 }
@@ -258,6 +237,27 @@ AnsiString& _ReplaceItems(LPCSTR src, int idx_start, int idx_end, LPCSTR new_ite
258237 return dst;
259238}
260239
240+ LPSTR _ChangeSymbol (LPSTR name, char src, char dest)
241+ {
242+ char * sTmpName = name;
243+ while (sTmpName [0 ])
244+ {
245+ if (sTmpName [0 ] == src)
246+ sTmpName [0 ] = dest;
247+ sTmpName ++;
248+ }
249+ return name;
250+ }
251+
252+ xr_string& _ChangeSymbol (xr_string& name, char src, char dest)
253+ {
254+ for (xr_string::iterator it = name.begin (); it != name.end (); it++)
255+ if (*it == src)
256+ *it = xr_string::value_type (dest);
257+ return name;
258+ }
259+
260+ #ifdef M_BORLAND
261261AnsiString& _Trim (AnsiString& str) { return str = str.Trim (); }
262262LPCSTR _CopyVal (LPCSTR src, AnsiString& dst, char separator)
263263{
0 commit comments