| 248 // ============================================================================ |
248 // ============================================================================ |
| 249 void str::trim (int dellen) { |
249 void str::trim (int dellen) { |
| 250 if (!dellen) |
250 if (!dellen) |
| 251 return; |
251 return; |
| 252 |
252 |
| 253 str s; |
253 unsigned int delpos; |
| 254 // If dellen is positive, trim from the end, |
254 if (dellen > 0) { |
| 255 // if negative, trim from beginning. |
255 delpos = len()-dellen; |
| 256 if (dellen > 0) |
256 text[delpos] = 0; |
| 257 s = substr (0, len()-dellen); |
257 curs -= dellen; |
| 258 else |
258 } else { |
| 259 s = substr (-dellen, len()); |
259 str s = substr (-dellen, len()); |
| 260 |
260 clear(); |
| 261 clear(); |
261 append (s); |
| 262 append (s); |
262 } |
| 263 } |
263 } |
| 264 |
264 |
| 265 // ============================================================================ |
265 // ============================================================================ |
| 266 void str::replace (const char* o, const char* n, unsigned int a) { |
266 void str::replace (const char* o, const char* n, unsigned int a) { |
| 267 unsigned int idx; |
267 unsigned int idx; |
| 309 |
309 |
| 310 // ============================================================================ |
310 // ============================================================================ |
| 311 bool str::isnumber () { |
311 bool str::isnumber () { |
| 312 ITERATE_STRING (u) { |
312 ITERATE_STRING (u) { |
| 313 // Minus sign as the first character is allowed for negatives |
313 // Minus sign as the first character is allowed for negatives |
| 314 if (!u && text[u] == '-') { |
314 if (!u && text[u] == '-') |
| 315 printf ("%u was minus sign\n", u); |
|
| 316 continue; |
315 continue; |
| 317 } |
|
| 318 |
316 |
| 319 if (text[u] < '0' || text[u] > '9') |
317 if (text[u] < '0' || text[u] > '9') |
| 320 return false; |
318 return false; |
| 321 } |
319 } |
| 322 return true; |
320 return true; |