1 (* ============================================================= *)
2 (* Preliminary library module for Gardens Point Component Pascal *)
3 (* ============================================================= *)
10 (* ============================================================ *)
14 (** Check if an assignment is possible without truncation.
15 *)
16 BEGIN
22 (** Assign as much as possible of src to dst,
23 * leaving room for a terminating ASCII nul.
24 *)
27 BEGIN
34 (*
35 * We have copied up to index "hi"
36 * without finding a nul in "src"
37 *)
41 (* ============================================================ *)
47 (** Check if an extraction of "num" charcters,
48 * starting at source index "sIx" is possible.
49 *)
50 BEGIN
59 (** Extract "num" characters starting at index "sIx".
60 * Result is truncated if either there are fewer characters
61 * left in the source, or the destination is too short.
62 *)
67 BEGIN
87 (* ============================================================ *)
92 (** Check if "num" characters may be deleted starting
93 * from index "sIx", when len is the source length.
94 *)
95 BEGIN
103 (** Delete "num" characters starting from index "sIx".
104 * Less characters are deleted if there are less
105 * than "num" characters after "sIx".
106 *)
107 BEGIN
112 (* post : lim is length of str *)
125 (* ============================================================ *)
130 (** Check if "sLen" characters may be inserted into "dest"
131 * starting from index "sIdx".
132 *)
135 BEGIN
145 (** Insert "src" string into "dst" starting from index
146 * "sIx". Less characters are inserted if there is not
147 * sufficient space in the destination. The destination is
148 * unchanged if "sIx" is beyond the end of the initial string.
149 *)
152 BEGIN
158 (* skip trivial case *)
174 (* ============================================================ *)
179 (** Check if "len" characters may be replaced in "dst"
180 * starting from index "sIx".
181 *)
182 BEGIN
189 (** Insert the characters of "src" string into "dst" starting
190 * from index "sIx". Less characters are replaced if the
191 * initial length of the destination string is insufficient.
192 * The string length of "dst" is unchanged.
193 *)
195 BEGIN
206 (* ============================================================ *)
210 (** Check if "len" characters may be appended to "dst"
211 *)
214 BEGIN
222 (** Append the characters of "src" string onto "dst".
223 * Less characters are appended if the length of the
224 * destination string is insufficient.
225 *)
228 BEGIN
239 (* ============================================================ *)
243 BEGIN
247 (* ============================================================ *)
254 (** Find the first occurrence of the pattern string "pat"
255 * in "str" starting the search from index "bIx".
256 * If no match is found "fnd" is set FALSE and "pos"
257 * is set to "bIx". Empty patterns match everywhere.
258 *)
262 BEGIN
267 (* first check that string extends to bIx *)
276 REPEAT
285 (* ============================================================ *)
293 (** Find the previous occurrence of the pattern string "pat"
294 * in "str" starting the search from index "bIx".
295 * If no match is found "fnd" is set FALSE and "pos"
296 * is set to "bIx". A pattern starting from "bIx" is found.
297 * Empty patterns match everywhere.
298 *)
302 BEGIN
311 (* start searching from bIx OR sLn - pLn *)
316 REPEAT
325 (* ============================================================ *)
331 (** Find the index of the first charater of difference
332 * between the two input strings. If the strings are
333 * identical "diff" is set FALSE, and "dPos" is zero.
334 *)
336 BEGIN
349 (* ============================================================ *)