equal
deleted
inserted
replaced
38 count = s.len + 1 - index; |
38 count = s.len + 1 - index; |
39 } |
39 } |
40 |
40 |
41 memcpy(result.str, s.str + index - 1, count); |
41 memcpy(result.str, s.str + index - 1, count); |
42 |
42 |
43 result.str[count] = 0; |
43 result.len = count; |
|
44 |
|
45 return result; |
|
46 } |
|
47 |
|
48 astring fpcrtl_copyA(astring s, Integer index, Integer count) { |
|
49 astring result; |
|
50 |
|
51 result.len = 0; |
|
52 |
|
53 if (count < 1) { |
|
54 return result; |
|
55 } |
|
56 |
|
57 if (index < 1) { |
|
58 index = 1; |
|
59 } |
|
60 |
|
61 if (index > s.len) { |
|
62 return result; |
|
63 } |
|
64 |
|
65 if (index + count > s.len + 1) { |
|
66 count = s.len + 1 - index; |
|
67 } |
|
68 |
|
69 memcpy(result.s + 1, s.s + index - 1, count); |
|
70 |
44 result.len = count; |
71 result.len = count; |
45 |
72 |
46 return result; |
73 return result; |
47 } |
74 } |
48 |
75 |
100 |
127 |
101 Integer __attribute__((overloadable)) fpcrtl_pos(string255 substr, string255 str) { |
128 Integer __attribute__((overloadable)) fpcrtl_pos(string255 substr, string255 str) { |
102 |
129 |
103 char* p; |
130 char* p; |
104 |
131 |
|
132 if (str.len == 0) { |
|
133 return 0; |
|
134 } |
|
135 |
|
136 if (substr.len == 0) { |
|
137 return 0; |
|
138 } |
|
139 |
105 FIX_STRING(substr); |
140 FIX_STRING(substr); |
106 FIX_STRING(str); |
141 FIX_STRING(str); |
107 |
142 |
|
143 p = strstr(str.str, substr.str); |
|
144 |
|
145 if (p == NULL) { |
|
146 return 0; |
|
147 } |
|
148 |
|
149 return strlen(str.str) - strlen(p) + 1; |
|
150 } |
|
151 |
|
152 Integer __attribute__((overloadable)) fpcrtl_pos(string255 substr, astring str) { |
|
153 |
|
154 char* p; |
|
155 |
108 if (str.len == 0) { |
156 if (str.len == 0) { |
109 return 0; |
157 return 0; |
110 } |
158 } |
111 |
159 |
112 if (substr.len == 0) { |
160 if (substr.len == 0) { |
113 return 0; |
161 return 0; |
114 } |
162 } |
115 |
163 |
116 str.str[str.len] = 0; |
164 FIX_STRING(substr); |
117 substr.str[substr.len] = 0; |
165 str.s[str.len] = 0; |
118 |
166 |
119 p = strstr(str.str, substr.str); |
167 p = strstr(str.s + 1, substr.str); |
120 |
168 |
121 if (p == NULL) { |
169 if (p == NULL) { |
122 return 0; |
170 return 0; |
123 } |
171 } |
124 |
172 |
125 return strlen(str.str) - strlen(p) + 1; |
173 return str.len - strlen(p) + 1; |
126 } |
174 } |
127 |
175 |
128 Integer fpcrtl_length(string255 s) { |
176 Integer fpcrtl_length(string255 s) { |
129 return s.len; |
177 return s.len; |
130 } |
178 } |
|
179 |
|
180 Integer fpcrtl_lengthA(astring s) |
|
181 { |
|
182 return s.len; |
|
183 } |
|
184 |
131 |
185 |
132 string255 fpcrtl_lowerCase(string255 s) { |
186 string255 fpcrtl_lowerCase(string255 s) { |
133 int i; |
187 int i; |
134 |
188 |
135 for (i = 0; i < s.len; i++) { |
189 for (i = 0; i < s.len; i++) { |