improve fopen flag: remove b and r+ in some case
don't require rw rights for just reading
1 files changed, 7 insertions(+), 7 deletions(-) | |||
---|---|---|---|
M | urmoms.c | +7 | -7 |
1@@ -337,7 +337,7 @@ printshowfile(struct commitinfo *ci)
2 if (!access(path, F_OK))
3 return;
4
5- fp = efopen(path, "w+b");
6+ fp = efopen(path, "w");
7 writeheader(fp);
8 fputs("<pre>\n", fp);
9 printcommit(fp, ci);
10@@ -590,7 +590,7 @@ writeblob(const git_index_entry *entry)
11 }
12 relpath = tmp;
13
14- fp = efopen(fpath, "w+b");
15+ fp = efopen(fpath, "w");
16 writeheader(fp);
17 fprintf(fp, "<p>%s (%" PRIu32 "b)</p><hr/>", entry->path, entry->file_size);
18 if (git_blob_is_binary((git_blob *)obj)) {
19@@ -676,10 +676,10 @@ main(int argc, char *argv[])
20 /* read description or .git/description */
21 snprintf(path, sizeof(path), "%s%s%s",
22 repodir, repodir[strlen(repodir)] == '/' ? "" : "/", "description");
23- if (!(fpread = fopen(path, "r+b"))) {
24+ if (!(fpread = fopen(path, "r"))) {
25 snprintf(path, sizeof(path), "%s%s%s",
26 repodir, repodir[strlen(repodir)] == '/' ? "" : "/", ".git/description");
27- fpread = fopen(path, "r+b");
28+ fpread = fopen(path, "r");
29 }
30 if (fpread) {
31 if (!fgets(description, sizeof(description), fpread))
32@@ -694,20 +694,20 @@ main(int argc, char *argv[])
33 hasreadme = !git_revparse_single(&obj, repo, "HEAD:README");
34 git_object_free(obj);
35
36- fp = efopen("log.html", "w+b");
37+ fp = efopen("log.html", "w");
38 writeheader(fp);
39 writelog(fp);
40 writefooter(fp);
41 fclose(fp);
42
43- fp = efopen("files.html", "w+b");
44+ fp = efopen("files.html", "w");
45 writeheader(fp);
46 writefiles(fp);
47 writefooter(fp);
48 fclose(fp);
49
50 /* Atom feed */
51- fp = efopen("atom.xml", "w+b");
52+ fp = efopen("atom.xml", "w");
53 writeatom(fp);
54 fclose(fp);
55