comparison src/c/urweb.c @ 885:e6070333d8a8

demo/sql works with SQLite
author Adam Chlipala <adamc@hcoop.net>
date Fri, 17 Jul 2009 16:29:36 -0400
parents b2a175a0f2ef
children 8e540df3294d
comparison
equal deleted inserted replaced
884:ced093080e17 885:e6070333d8a8
1988 for (; *s; s++) { 1988 for (; *s; s++) {
1989 char c = *s; 1989 char c = *s;
1990 1990
1991 switch (c) { 1991 switch (c) {
1992 case '\'': 1992 case '\'':
1993 strcpy(s2, "\\'"); 1993 if (uw_Estrings)
1994 strcpy(s2, "\\'");
1995 else
1996 strcpy(s2, "''");
1994 s2 += 2; 1997 s2 += 2;
1995 break; 1998 break;
1996 case '\\': 1999 case '\\':
1997 strcpy(s2, "\\\\"); 2000 if (uw_Estrings) {
1998 s2 += 2; 2001 strcpy(s2, "\\\\");
2002 s2 += 2;
2003 } else
2004 *s2++ = '\\';
1999 break; 2005 break;
2000 default: 2006 default:
2001 if (isprint(c)) 2007 if (isprint(c))
2002 *s2++ = c; 2008 *s2++ = c;
2003 else if (uw_Estrings) { 2009 else if (uw_Estrings) {
2031 for (i = 0; i < b.size; ++i) { 2037 for (i = 0; i < b.size; ++i) {
2032 char c = b.data[i]; 2038 char c = b.data[i];
2033 2039
2034 switch (c) { 2040 switch (c) {
2035 case '\'': 2041 case '\'':
2036 strcpy(s2, "\\'"); 2042 if (uw_Estrings)
2043 strcpy(s2, "\\'");
2044 else
2045 strcpy(s2, "''");
2037 s2 += 2; 2046 s2 += 2;
2038 break; 2047 break;
2039 case '\\': 2048 case '\\':
2040 strcpy(s2, "\\\\\\\\"); 2049 if (uw_Estrings) {
2041 s2 += 4; 2050 strcpy(s2, "\\\\\\\\");
2051 s2 += 4;
2052 } else
2053 *s2++ = '\\';
2042 break; 2054 break;
2043 default: 2055 default:
2044 if (isprint(c)) 2056 if (isprint(c))
2045 *s2++ = c; 2057 *s2++ = c;
2046 else if (uw_Estrings) { 2058 else if (uw_Estrings) {
2547 ctx->transactionals[i].free(ctx->transactionals[i].data); 2559 ctx->transactionals[i].free(ctx->transactionals[i].data);
2548 } 2560 }
2549 2561
2550 int uw_rollback(uw_context ctx) { 2562 int uw_rollback(uw_context ctx) {
2551 size_t i; 2563 size_t i;
2564 cleanup *cl;
2552 2565
2553 if (ctx->client) 2566 if (ctx->client)
2554 release_client(ctx->client); 2567 release_client(ctx->client);
2568
2569 for (cl = ctx->cleanup; cl < ctx->cleanup_front; ++cl)
2570 cl->func(cl->arg);
2571
2572 ctx->cleanup_front = ctx->cleanup;
2555 2573
2556 for (i = 0; i < ctx->used_transactionals; ++i) 2574 for (i = 0; i < ctx->used_transactionals; ++i)
2557 if (ctx->transactionals[i].rollback != NULL) 2575 if (ctx->transactionals[i].rollback != NULL)
2558 ctx->transactionals[i].rollback(ctx->transactionals[i].data); 2576 ctx->transactionals[i].rollback(ctx->transactionals[i].data);
2559 2577