| 273 | } |
| 274 | |
| 275 | LString *VM::ResizeString(LString *s, intp size, int c, bool back) { |
| 276 | auto ns = NewString(size); |
| 277 | auto sdest = (char *)ns->data(); |
| 278 | auto cdest = sdest; |
| 279 | auto remain = size - s->len; |
| 280 | if (back) sdest += remain; |
| 281 | else cdest += s->len; |
| 282 | memcpy(sdest, s->data(), s->len); |
| 283 | memset(cdest, c, remain); |
| 284 | s->Dec(*this); |
| 285 | return ns; |
| 286 | } |
| 287 | |
| 288 | // This function is now way less important than it was when the language was still dynamically |
| 289 | // typed. But ok to leave it as-is for "index out of range" and other errors that are still dynamic. |