MCPcopy Create free account
hub / github.com/IoLanguage/io / UArray_unescape

Function UArray_unescape

libs/basekit/source/UArray_string.c:379–437  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

377}
378
379void UArray_unescape(UArray *self) {
380 size_t getIndex = 0;
381 size_t putIndex = 0;
382
383 while (getIndex < self->size) {
384 long c = UArray_longAt_(self, getIndex);
385 long nextChar = UArray_longAt_(self, getIndex + 1);
386
387 if (c != '\\') {
388 if (getIndex != putIndex) {
389 UArray_at_putLong_(self, putIndex, c);
390 }
391
392 putIndex++;
393 } else {
394 c = nextChar;
395
396 switch (c) {
397 case 'a':
398 c = '\a';
399 break;
400 case 'b':
401 c = '\b';
402 break;
403 case 'f':
404 c = '\f';
405 break;
406 case 'n':
407 c = '\n';
408 break;
409 case 'r':
410 c = '\r';
411 break;
412 case 't':
413 c = '\t';
414 break;
415 case 'v':
416 c = '\v';
417 break;
418 case '\0':
419 c = '\\';
420 break;
421 default:
422 if (isdigit((int)c)) {
423 c -= 48;
424 }
425 }
426
427 UArray_at_putLong_(self, putIndex, c);
428 getIndex++;
429 putIndex++;
430 }
431
432 getIndex++;
433 }
434
435 UArray_setSize_(self, putIndex);
436 UArray_changed(self);

Callers 2

IoSeq_mutable.cFile · 0.85

Calls 4

UArray_longAt_Function · 0.85
UArray_at_putLong_Function · 0.85
UArray_setSize_Function · 0.85
UArray_changedFunction · 0.85

Tested by

no test coverage detected