Mercurial > urweb
comparison src/c/urweb.c @ 1467:8fce85939259
Fix bug with string literals in unAs
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Mon, 30 May 2011 09:31:50 -0400 |
parents | 2f5fd248588d |
children | 67ebd30a2283 |
comparison
equal
deleted
inserted
replaced
1466:e2d7bd41f527 | 1467:8fce85939259 |
---|---|
3560 | 3560 |
3561 longjmp(ctx->jmp_buf, RETURN_INDIRECTLY); | 3561 longjmp(ctx->jmp_buf, RETURN_INDIRECTLY); |
3562 } | 3562 } |
3563 | 3563 |
3564 uw_Basis_string uw_Basis_unAs(uw_context ctx, uw_Basis_string s) { | 3564 uw_Basis_string uw_Basis_unAs(uw_context ctx, uw_Basis_string s) { |
3565 uw_Basis_string r = uw_malloc(ctx, strlen(s) + 1); | 3565 uw_Basis_string ret = uw_malloc(ctx, strlen(s) + 1), r = ret; |
3566 | 3566 |
3567 for (; *s; ++s) { | 3567 for (; *s; ++s) { |
3568 if (s[0] == '\'') { | 3568 if (s[0] == '\'') { |
3569 *r++ = '\''; | 3569 *r++ = '\''; |
3570 for (++s; *s; ++s) { | 3570 for (++s; *s; ++s) { |
3571 if (s[0] == '\'') { | 3571 if (s[0] == '\'') { |
3572 *r++ = '\''; | 3572 *r++ = '\''; |
3573 break; | 3573 break; |
3574 } else if (s[0] == '\\') { | 3574 } else if (s[0] == '\\') { |
3575 if (s[1] == '\\') { | 3575 *r++ = '\\'; |
3576 *r++ = '\\'; | 3576 *r++ = s[1]; |
3577 *r++ = '\\'; | 3577 ++s; |
3578 ++s; | |
3579 } else if (s[1] == '\'') { | |
3580 *r++ = '\\'; | |
3581 *r++ = '\''; | |
3582 ++s; | |
3583 } else | |
3584 *r++ = '\''; | |
3585 } else | 3578 } else |
3586 *r++ = s[0]; | 3579 *r++ = s[0]; |
3587 } | 3580 } |
3588 if (*s == 0) break; | 3581 if (*s == 0) break; |
3589 } else if (s[0] == 'T' && s[1] == '.') | 3582 } else if (s[0] == 'T' && s[1] == '_' && s[2] == 'T' && s[3] == '.') |
3590 ++s; | 3583 s += 3; |
3591 else | 3584 else |
3592 *r++ = s[0]; | 3585 *r++ = s[0]; |
3593 } | 3586 } |
3594 | 3587 |
3595 return r; | 3588 *r = 0; |
3589 return ret; | |
3596 } | 3590 } |
3597 | 3591 |
3598 uw_Basis_string uw_Basis_mstrcat(uw_context ctx, ...) { | 3592 uw_Basis_string uw_Basis_mstrcat(uw_context ctx, ...) { |
3599 va_list ap; | 3593 va_list ap; |
3600 size_t len = 1; | 3594 size_t len = 1; |