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.1 1998/07/02 17:18:00 bnv
15 /* --------------------------- Lsubstr -------------------------------- */
18 * start - an integer, can take values from [1,from length] *
19 * if start<1 then start = 1 *
20 * length - negative value means rest of string (default) *
21 * [1 - nnn] cuts string and pad's it if necessary. *
22 * pad - pad character *
23 * -------------------------------------------------------------------- */
25 Lsubstr(const PLstr to
, const PLstr from
,
26 long start
, long length
, const char pad
)
33 if (start
<0) start
= 0;
36 if (length
==0 || start
>=LLEN(*from
)) {
40 length
= LLEN(*from
) - start
;
43 Lfx(to
,(size_t)length
);
45 if (start
<LLEN(*from
)) {
46 if (length
+start
>LLEN(*from
)) {
47 l
= LLEN(*from
) - (size_t)start
;
48 MEMMOVE( LSTR(*to
), LSTR(*from
)+start
, l
);
49 MEMSET( LSTR(*to
)+l
, pad
, (size_t)length
-l
);
51 MEMMOVE( LSTR(*to
), LSTR(*from
)+start
, (size_t)length
);
53 MEMSET(LSTR(*to
),pad
,(size_t)length
);
55 LTYPE(*to
) = LSTRING_TY
;
56 LLEN(*to
) = (size_t)length
;