Mercurial > urweb
comparison src/c/urweb.c @ 280:fdd7a698be01
Compiling a parametrized query the inefficient way
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Tue, 02 Sep 2008 17:31:45 -0400 |
parents | 137744c5b1ae |
children | 7d5860add50f |
comparison
equal
deleted
inserted
replaced
279:8bb46d87b074 | 280:fdd7a698be01 |
---|---|
587 strcpy(s, s1); | 587 strcpy(s, s1); |
588 ctx->heap_front += len; | 588 ctx->heap_front += len; |
589 | 589 |
590 return s; | 590 return s; |
591 } | 591 } |
592 | |
593 | |
594 lw_Basis_string lw_Basis_sqlifyString(lw_context ctx, lw_Basis_string s) { | |
595 char *r, *s2; | |
596 | |
597 lw_check_heap(ctx, strlen(s) * 2 + 4); | |
598 | |
599 r = s2 = ctx->heap_front; | |
600 *s2++ = 'E'; | |
601 *s2++ = '\''; | |
602 | |
603 for (; *s; s++) { | |
604 char c = *s; | |
605 | |
606 switch (c) { | |
607 case '\'': | |
608 strcpy(s2, "\\'"); | |
609 s2 += 2; | |
610 break; | |
611 case '\\': | |
612 strcpy(s2, "\\\\"); | |
613 s2 += 2; | |
614 break; | |
615 default: | |
616 if (isprint(c)) | |
617 *s2++ = c; | |
618 else { | |
619 sprintf(s2, "\\%3o", c); | |
620 s2 += 4; | |
621 } | |
622 } | |
623 } | |
624 | |
625 *s2++ = '\''; | |
626 *s2++ = 0; | |
627 ctx->heap_front = s2; | |
628 return r; | |
629 } |