]> gitweb.ps.run Git - ps-cgit/blobdiff - ui-shared.c
ui-shared: return value of cgit_currenturl is not const
[ps-cgit] / ui-shared.c
index de06256d447da52d9af7178fedd62a1ff8bb6485..b7396756dfe1416e25d77776fac53259b34a365d 100644 (file)
@@ -65,10 +65,10 @@ const char *cgit_hosturl(void)
        return fmtalloc("%s:%s", ctx.env.server_name, ctx.env.server_port);
 }
 
-const char *cgit_currenturl(void)
+char *cgit_currenturl(void)
 {
        if (!ctx.qry.url)
-               return cgit_rooturl();
+               return xstrdup(cgit_rooturl());
        const char *root = cgit_rooturl();
        size_t len = strlen(root);
        if (len && root[len - 1] == '/')
@@ -746,16 +746,19 @@ void cgit_print_docstart(void)
                html("'/>\n");
        }
        if (host && ctx.repo && ctx.qry.head) {
+               char *fileurl;
                struct strbuf sb = STRBUF_INIT;
                strbuf_addf(&sb, "h=%s", ctx.qry.head);
 
                html("<link rel='alternate' title='Atom feed' href='");
                html(cgit_httpscheme());
                html_attr(cgit_hosturl());
-               html_attr(cgit_fileurl(ctx.repo->url, "atom", ctx.qry.vpath,
-                                      sb.buf));
+               fileurl = cgit_fileurl(ctx.repo->url, "atom", ctx.qry.vpath,
+                                      sb.buf);
+               html_attr(fileurl);
                html("' type='application/atom+xml'/>\n");
                strbuf_release(&sb);
+               free(fileurl);
        }
        if (ctx.repo)
                cgit_add_clone_urls(print_rel_vcs_link);
@@ -791,6 +794,7 @@ void cgit_print_docend(void)
 void cgit_print_error_page(int code, const char *msg, const char *fmt, ...)
 {
        va_list ap;
+       ctx.page.expires = ctx.cfg.cache_dynamic_ttl;
        ctx.page.status = code;
        ctx.page.statusmsg = msg;
        cgit_print_http_headers();
@@ -996,9 +1000,12 @@ void cgit_print_pageheader(void)
                                        ctx.qry.head, ctx.qry.vpath);
                html("</td><td class='form'>");
                html("<form class='right' method='get' action='");
-               if (ctx.cfg.virtual_root)
-                       html_url_path(cgit_fileurl(ctx.qry.repo, "log",
-                                                  ctx.qry.vpath, NULL));
+               if (ctx.cfg.virtual_root) {
+                       char *fileurl = cgit_fileurl(ctx.qry.repo, "log",
+                                                  ctx.qry.vpath, NULL);
+                       html_url_path(fileurl);
+                       free(fileurl);
+               }
                html("'>\n");
                cgit_add_hidden_formfields(1, 0, "log");
                html("<select name='qt'>\n");