commit e01336e656582ed0a235b30b549dd8f5e69e860b
parent 2ab268d5b1c6da916e3e03d547e39711c2f4fd87
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Sun, 20 Dec 2015 17:10:07 +0100
improve fopen flag: remove b and r+ in some case
don't require rw rights for just reading
Diffstat:
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/urmoms.c b/urmoms.c
@@ -337,7 +337,7 @@ printshowfile(struct commitinfo *ci)
if (!access(path, F_OK))
return;
- fp = efopen(path, "w+b");
+ fp = efopen(path, "w");
writeheader(fp);
fputs("<pre>\n", fp);
printcommit(fp, ci);
@@ -590,7 +590,7 @@ writeblob(const git_index_entry *entry)
}
relpath = tmp;
- fp = efopen(fpath, "w+b");
+ fp = efopen(fpath, "w");
writeheader(fp);
fprintf(fp, "<p>%s (%" PRIu32 "b)</p><hr/>", entry->path, entry->file_size);
if (git_blob_is_binary((git_blob *)obj)) {
@@ -676,10 +676,10 @@ main(int argc, char *argv[])
/* read description or .git/description */
snprintf(path, sizeof(path), "%s%s%s",
repodir, repodir[strlen(repodir)] == '/' ? "" : "/", "description");
- if (!(fpread = fopen(path, "r+b"))) {
+ if (!(fpread = fopen(path, "r"))) {
snprintf(path, sizeof(path), "%s%s%s",
repodir, repodir[strlen(repodir)] == '/' ? "" : "/", ".git/description");
- fpread = fopen(path, "r+b");
+ fpread = fopen(path, "r");
}
if (fpread) {
if (!fgets(description, sizeof(description), fpread))
@@ -694,20 +694,20 @@ main(int argc, char *argv[])
hasreadme = !git_revparse_single(&obj, repo, "HEAD:README");
git_object_free(obj);
- fp = efopen("log.html", "w+b");
+ fp = efopen("log.html", "w");
writeheader(fp);
writelog(fp);
writefooter(fp);
fclose(fp);
- fp = efopen("files.html", "w+b");
+ fp = efopen("files.html", "w");
writeheader(fp);
writefiles(fp);
writefooter(fp);
fclose(fp);
/* Atom feed */
- fp = efopen("atom.xml", "w+b");
+ fp = efopen("atom.xml", "w");
writeatom(fp);
fclose(fp);