tminor code-style improvements - vote - simple cgi voting system for web and gopher
(HTM) git clone git://src.adamsgaard.dk/vote
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit aa9b98e360f92e876192fd8cbe90dcc9f2da448b
(DIR) parent b0c8f6f22789317760958fec93e974faea523241
(HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Sun, 4 Oct 2020 15:53:08 +0200
minor code-style improvements
Signed-off-by: Anders Damsgaard <anders@adamsgaard.dk>
Diffstat:
M vote.c | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
---
(DIR) diff --git a/vote.c b/vote.c
t@@ -64,7 +64,7 @@ pollfile(const char *poll_name, const char *postfix)
}
void
-print_html_head()
+print_html_head(void)
{
printf("Content-type: text/html; charset=utf-8\r\n\r\n");
puts("<!DOCTYPE html>\n"
t@@ -98,7 +98,7 @@ print_html_head()
}
void
-print_html_foot()
+print_html_foot(void)
{
printf("</body>\n"
"</html>\n");
t@@ -210,7 +210,6 @@ create_poll_file(const char *name, const char *question, const char *options)
fputc('\n', fp);
for (col = 0; *options; (void)*options++) {
-
if (++col == 1 && *options != '\n' && *options != '\r')
fputs("0\t", fp);
t@@ -258,7 +257,7 @@ show_poll(const char *poll, int vote)
}
void
-list_polls()
+list_polls(void)
{
FTS *ftsp;
FTSENT *p;
t@@ -296,10 +295,10 @@ list_polls()
void
increment_option(char *poll, size_t n)
{
+ static char fname_tmp[PATH_MAX];
FILE *fp, *fp_tmp;
size_t v, lineno = 0;
char *line = NULL, *fname = NULL;
- static char fname_tmp[PATH_MAX];
size_t linesize = 0;
ssize_t linelen;
struct stat sb;
t@@ -325,7 +324,7 @@ increment_option(char *poll, size_t n)
else {
if (++lineno == n)
v++;
- fprintf(fp_tmp, "%ld\t%s\n", v, options);
+ fprintf(fp_tmp, "%zu\t%s\n", v, options);
}
}
t@@ -344,7 +343,7 @@ increment_option(char *poll, size_t n)
}
void
-print_poll_create_form()
+print_poll_create_form(void)
{
puts("<h2>Create new poll</h2>");
puts("<form method=\"get\" action=\"\">\n"
t@@ -380,14 +379,12 @@ print_poll_create_form()
}
void
-parse_query()
+parse_query(void)
{
char *query, *p;
- if (!(query = getenv("QUERY_STRING"))) {
- query = "";
+ if (!(query = getenv("QUERY_STRING")))
return;
- }
if ((p = getparam(query, "create"))) {
if (decodeparam(create, sizeof(create), p) == -1) {
t@@ -423,11 +420,10 @@ parse_query()
exit(1);
}
}
-
}
int
-main()
+main(void)
{
size_t c;
const char *errstr;