Mercurial > urweb
comparison src/c/urweb.c @ 995:166ea3944b91
Versioned1 demo working
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Tue, 06 Oct 2009 17:36:45 -0400 |
parents | 7932d577cf78 |
children | 5a0f6ec208ce |
comparison
equal
deleted
inserted
replaced
994:7932d577cf78 | 995:166ea3944b91 |
---|---|
2158 char *r, *s; | 2158 char *r, *s; |
2159 struct tm stm; | 2159 struct tm stm; |
2160 | 2160 |
2161 if (localtime_r(&t, &stm)) { | 2161 if (localtime_r(&t, &stm)) { |
2162 s = uw_malloc(ctx, TIMES_MAX); | 2162 s = uw_malloc(ctx, TIMES_MAX); |
2163 --stm.tm_hour; | |
2163 len = strftime(s, TIMES_MAX, TIME_FMT, &stm); | 2164 len = strftime(s, TIMES_MAX, TIME_FMT, &stm); |
2164 r = uw_malloc(ctx, len + 14); | 2165 r = uw_malloc(ctx, len + 14); |
2165 sprintf(r, "'%s'::timestamp", s); | 2166 sprintf(r, "'%s'::timestamp", s); |
2166 return r; | 2167 return r; |
2167 } else | 2168 } else |
2174 struct tm stm; | 2175 struct tm stm; |
2175 | 2176 |
2176 if (localtime_r(&t, &stm)) { | 2177 if (localtime_r(&t, &stm)) { |
2177 uw_check_heap(ctx, TIMES_MAX); | 2178 uw_check_heap(ctx, TIMES_MAX); |
2178 r = ctx->heap.front; | 2179 r = ctx->heap.front; |
2179 --stm.tm_hour; | |
2180 len = strftime(r, TIMES_MAX, TIME_FMT, &stm); | 2180 len = strftime(r, TIMES_MAX, TIME_FMT, &stm); |
2181 ctx->heap.front += len+1; | 2181 ctx->heap.front += len+1; |
2182 return r; | 2182 return r; |
2183 } else | 2183 } else |
2184 return "<Invalid time>"; | 2184 return "<Invalid time>"; |
2427 | 2427 |
2428 if (dot) { | 2428 if (dot) { |
2429 *dot = 0; | 2429 *dot = 0; |
2430 if (strptime(s, TIME_FMT_PG, &stm)) { | 2430 if (strptime(s, TIME_FMT_PG, &stm)) { |
2431 *dot = '.'; | 2431 *dot = '.'; |
2432 --stm.tm_hour; | |
2433 return mktime(&stm); | 2432 return mktime(&stm); |
2434 } | 2433 } |
2435 else { | 2434 else { |
2436 *dot = '.'; | 2435 *dot = '.'; |
2437 uw_error(ctx, FATAL, "Can't parse time: %s", s); | 2436 uw_error(ctx, FATAL, "Can't parse time: %s", s); |
2438 } | 2437 } |
2439 } | 2438 } |
2440 else { | 2439 else { |
2441 if (strptime(s, TIME_FMT_PG, &stm) == end) { | 2440 if (strptime(s, TIME_FMT_PG, &stm) == end) { |
2442 --stm.tm_hour; | |
2443 return mktime(&stm); | 2441 return mktime(&stm); |
2444 } else if (strptime(s, TIME_FMT, &stm) == end) { | 2442 } else if (strptime(s, TIME_FMT, &stm) == end) { |
2445 --stm.tm_hour; | |
2446 return mktime(&stm); | 2443 return mktime(&stm); |
2447 } else | 2444 } else |
2448 uw_error(ctx, FATAL, "Can't parse time: %s", s); | 2445 uw_error(ctx, FATAL, "Can't parse time: %s", s); |
2449 } | 2446 } |
2450 } | 2447 } |
2600 | 2597 |
2601 for (i = 0; i < ctx->used_transactionals; ++i) | 2598 for (i = 0; i < ctx->used_transactionals; ++i) |
2602 ctx->transactionals[i].free(ctx->transactionals[i].data); | 2599 ctx->transactionals[i].free(ctx->transactionals[i].data); |
2603 | 2600 |
2604 // Splice script data into appropriate part of page | 2601 // Splice script data into appropriate part of page |
2605 if (ctx->returning_blob || ctx->script_header[0] == 0) | 2602 if (ctx->returning_blob || ctx->script_header[0] == 0) { |
2606 ; | 2603 char *start = strstr(ctx->page.start, "<sc>"); |
2607 else if (buf_used(&ctx->script) == 0) { | 2604 if (start) { |
2605 memmove(start, start + 4, buf_used(&ctx->page) - (start - ctx->page.start) - 4); | |
2606 ctx->page.front -= 4; | |
2607 } | |
2608 } else if (buf_used(&ctx->script) == 0) { | |
2608 size_t len = strlen(ctx->script_header); | 2609 size_t len = strlen(ctx->script_header); |
2609 char *start = strstr(ctx->page.start, "<sc>"); | 2610 char *start = strstr(ctx->page.start, "<sc>"); |
2610 if (start) { | 2611 if (start) { |
2611 buf_check(&ctx->page, buf_used(&ctx->page) - 4 + len); | 2612 buf_check(&ctx->page, buf_used(&ctx->page) - 4 + len); |
2612 start = strstr(ctx->page.start, "<sc>"); | 2613 start = strstr(ctx->page.start, "<sc>"); |