src/string.c

changeset 1679
4a08dabe5e8f
parent 1677
1d73c7302fbc
equal deleted inserted replaced
1678:6cf10bb137c5 1679:4a08dabe5e8f
463 memcpy(result.ptr, string.ptr, string.length); 463 memcpy(result.ptr, string.ptr, string.length);
464 result.ptr[string.length] = '\0'; 464 result.ptr[string.length] = '\0';
465 return result; 465 return result;
466 } 466 }
467 467
468 cxstring cx_strtrim(cxstring string) { 468 cxstring cx_strtrim_(cxstring string) {
469 cxstring result = string; 469 cxstring result = string;
470 while (isspace((unsigned char)cx_strat(result, 0))) { 470 while (isspace((unsigned char)cx_strat(result, 0))) {
471 result.ptr++; 471 result.ptr++;
472 result.length--; 472 result.length--;
473 } 473 }
474 while (isspace((unsigned char)cx_strat(result, -1))) { 474 while (isspace((unsigned char)cx_strat(result, -1))) {
475 result.length--; 475 result.length--;
476 } 476 }
477 return result; 477 return result;
478 }
479
480 cxmutstr cx_strtrim_m(cxmutstr string) {
481 cxstring result = cx_strtrim(cx_strcast(string));
482 return (cxmutstr) {(char *) result.ptr, result.length};
483 } 478 }
484 479
485 bool cx_strprefix_( 480 bool cx_strprefix_(
486 cxstring string, 481 cxstring string,
487 cxstring prefix 482 cxstring prefix

mercurial