comparison src/c/urweb.c @ 696:79a49c509007

Avoid generating empty <script> blocks
author Adam Chlipala <adamc@hcoop.net>
date Sun, 05 Apr 2009 09:26:00 -0400
parents 500e93aa436f
children 9b29ce0babb8
comparison
equal deleted inserted replaced
695:500e93aa436f 696:79a49c509007
690 } 690 }
691 691
692 const char *uw_Basis_get_script(uw_context ctx, uw_unit u) { 692 const char *uw_Basis_get_script(uw_context ctx, uw_unit u) {
693 if (ctx->script_header[0] == 0) 693 if (ctx->script_header[0] == 0)
694 return ""; 694 return "";
695 else if (buf_used(&ctx->script) == 0)
696 return ctx->script_header;
695 else { 697 else {
696 char *r = uw_malloc(ctx, strlen(ctx->script_header) + 42 + buf_used(&ctx->script)); 698 char *r = uw_malloc(ctx, strlen(ctx->script_header) + 42 + buf_used(&ctx->script));
697 sprintf(r, "%s<script type=\"text/javascript\">%s</script>", 699 sprintf(r, "%s<script type=\"text/javascript\">%s</script>",
698 ctx->script_header, 700 ctx->script_header,
699 ctx->script.start); 701 ctx->script.start);