Diff options
Diffstat (limited to 'source')
-rw-r--r--source/cgit.c8
-rw-r--r--source/html.c12
-rw-r--r--source/html.h3
-rw-r--r--source/ui-commit.c2
-rw-r--r--source/ui-patch.c2
-rw-r--r--source/ui-plain.c4
-rw-r--r--source/ui-shared.c14
7 files changed, 15 insertions, 30 deletions
diff --git a/source/cgit.c b/source/cgit.c
index e98210f..e0b6adb 100644
--- a/source/cgit.c
+++ b/source/cgit.c
@@ -963,7 +963,7 @@ static void parse_readme(const char *readme, char **filename, char **ref, struct
}
if (!(*ref) && readme[0] != '/')
- *filename = cgit_fmtalloc("%s/%s", repo->path, readme);
+ *filename = xstrfmt("%s/%s", repo->path, readme);
else
*filename = xstrdup(readme);
}
@@ -1046,7 +1046,7 @@ static int prepare_repo_cmd(int nongit, int err, int clone)
if (nongit) {
const char *name = ctx.repo->name;
- ctx.page.title = cgit_fmtalloc("%s - %s", ctx.cfg.root_title, "config error");
+ ctx.page.title = xstrfmt("%s - %s", ctx.cfg.root_title, "config error");
ctx.repo = NULL;
cgit_print_error_page(
404, "Not Found", "Failed to open %s: %s", name,
@@ -1054,7 +1054,7 @@ static int prepare_repo_cmd(int nongit, int err, int clone)
);
return 1;
}
- ctx.page.title = cgit_fmtalloc("%s - %s", ctx.repo->name, ctx.cfg.root_title);
+ ctx.page.title = xstrfmt("%s - %s", ctx.repo->name, ctx.cfg.root_title);
if (!ctx.repo->defbranch)
ctx.repo->defbranch = guess_defbranch();
@@ -1272,7 +1272,7 @@ int cmd_main(int argc, const char **argv)
path++;
ctx.qry.url = xstrdup(path);
if (ctx.qry.raw) {
- char *path_and_query = cgit_fmtalloc("%s?%s", path, ctx.qry.raw);
+ char *path_and_query = xstrfmt("%s?%s", path, ctx.qry.raw);
free(ctx.qry.raw);
ctx.qry.raw = path_and_query;
} else {
diff --git a/source/html.c b/source/html.c
index 7d2e668..ec82ff4 100644
--- a/source/html.c
+++ b/source/html.c
@@ -126,18 +126,6 @@ char *cgit_fmt(const char *format, ...)
return buf[slot];
}
-char *cgit_fmtalloc(const char *format, ...)
-{
- struct strbuf sb = STRBUF_INIT;
- va_list args;
-
- va_start(args, format);
- strbuf_vaddf(&sb, format, args);
- va_end(args);
-
- return strbuf_detach(&sb, NULL);
-}
-
void html_flush(void)
{
size_t len = out_len;
diff --git a/source/html.h b/source/html.h
index 77f84b4..cc87566 100644
--- a/source/html.h
+++ b/source/html.h
@@ -92,9 +92,6 @@ extern void html_hidden(const char *name, const char *value);
__attribute__((format (printf,1,2)))
extern char *cgit_fmt(const char *format, ...);
-__attribute__((format (printf,1,2)))
-extern char *cgit_fmtalloc(const char *format, ...);
-
extern void html_option(const char *value, const char *text, const char *selected_value);
extern void html_intoption(int value, const char *text, int selected_value);
extern void html_link_open(const char *url, const char *title, const char *class);
diff --git a/source/ui-commit.c b/source/ui-commit.c
index c6071ff..9b2f8b9 100644
--- a/source/ui-commit.c
+++ b/source/ui-commit.c
@@ -266,7 +266,7 @@ void cgit_print_commit(char *hex, const char *prefix)
load_ref_decorations(NULL, DECORATE_FULL_REFS);
- ctx.page.title = cgit_fmtalloc("%s - %s", info->subject, ctx.page.title);
+ ctx.page.title = xstrfmt("%s - %s", info->subject, ctx.page.title);
cgit_print_layout_start();
// An octopus merge draws no diff, so it has no options to offer.
if (commit_list_count(commit->parents) < OCTOPUS_PARENTS)
diff --git a/source/ui-patch.c b/source/ui-patch.c
index 0163e25..9cf61c0 100644
--- a/source/ui-patch.c
+++ b/source/ui-patch.c
@@ -104,7 +104,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, const char *pref
// the path comes from the request and a long one would abort the
// process.
if (prefix)
- rev.diffopt.stat_sep = cgit_fmtalloc("(limited to '%s')\n\n", prefix);
+ rev.diffopt.stat_sep = xstrfmt("(limited to '%s')\n\n", prefix);
setup_revisions(rev_argv.nr, rev_argv.v, &rev, NULL);
// A single commit resolves to a range starting at its parent, so this
// only ever cuts an explicit range short and keeps one request from
diff --git a/source/ui-plain.c b/source/ui-plain.c
index 5bfc41e..f97b80c 100644
--- a/source/ui-plain.c
+++ b/source/ui-plain.c
@@ -93,9 +93,9 @@ static void print_object(const struct object_id *oid, const char *path)
static char *build_path(const char *base, int baselen, const char *path)
{
if (path[0])
- return cgit_fmtalloc("%.*s%s/", baselen, base, path);
+ return xstrfmt("%.*s%s/", baselen, base, path);
else
- return cgit_fmtalloc("%.*s/", baselen, base);
+ return xstrfmt("%.*s/", baselen, base);
}
static void print_dir(const char *base, int baselen, const char *path)
diff --git a/source/ui-shared.c b/source/ui-shared.c
index b2b7245..7c198ea 100644
--- a/source/ui-shared.c
+++ b/source/ui-shared.c
@@ -674,7 +674,7 @@ char *cgit_hosturl(void)
return NULL;
if (!ctx.env.server_port || atoi(ctx.env.server_port) == DEFAULT_HTTP_PORT)
return xstrdup(ctx.env.server_name);
- return cgit_fmtalloc("%s:%s", ctx.env.server_name, ctx.env.server_port);
+ return xstrfmt("%s:%s", ctx.env.server_name, ctx.env.server_port);
}
char *cgit_currenturl(void)
@@ -684,8 +684,8 @@ char *cgit_currenturl(void)
if (!ctx.qry.url)
return xstrdup(root);
if (root[0] && root[strlen(root) - 1] == '/')
- return cgit_fmtalloc("%s%s", root, ctx.qry.url);
- return cgit_fmtalloc("%s/%s", root, ctx.qry.url);
+ return xstrfmt("%s%s", root, ctx.qry.url);
+ return xstrfmt("%s/%s", root, ctx.qry.url);
}
char *cgit_currentquery(void)
@@ -722,7 +722,7 @@ char *cgit_currentfullurl(void)
{
char *url = cgit_currenturl();
char *query = cgit_currentquery();
- char *ret = cgit_fmtalloc("%s%s", url, query);
+ char *ret = xstrfmt("%s%s", url, query);
free(url);
free(query);
@@ -734,7 +734,7 @@ const char *cgit_loginurl(void)
static const char *login_url;
if (!login_url)
- login_url = cgit_fmtalloc("%s?p=login", ctx.cfg.virtual_root);
+ login_url = xstrfmt("%s?p=login", ctx.cfg.virtual_root);
return login_url;
}
@@ -1089,7 +1089,7 @@ static void gitmodules_link(const char *path, const char *rev, char **module,
target = repo_serving_url(url);
if (target) {
- char *query = cgit_fmtalloc("id=%s", rev);
+ char *query = xstrfmt("id=%s", rev);
*module = cgit_pageurl(target->url, "tree", query);
*commit = cgit_pageurl(target->url, "commit", query);
@@ -1858,6 +1858,6 @@ void cgit_set_title_from_path(const char *path)
void cgit_prefix_title(const char *name)
{
- ctx.page.title = cgit_fmtalloc("%s - %s", name,
+ ctx.page.title = xstrfmt("%s - %s", name,
ctx.page.title ? ctx.page.title : ctx.cfg.root_title);
}