aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2015-08-22 14:36:29 -0300
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2015-08-22 14:36:29 -0300
commitdf702f712af38ad50ebc686a184ac0ffc3212f00 (patch)
tree60faa66c22aa9ce5267f0d01f7fe6adf5fc61f7e /src/main.c
parentc95283fc93eca650aab66b1118296c9ba774eb58 (diff)
downloadblogc-df702f712af38ad50ebc686a184ac0ffc3212f00.tar.gz
blogc-df702f712af38ad50ebc686a184ac0ffc3212f00.tar.bz2
blogc-df702f712af38ad50ebc686a184ac0ffc3212f00.zip
main: style fixes
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c43
1 files changed, 25 insertions, 18 deletions
diff --git a/src/main.c b/src/main.c
index cf0fcd2..06b8714 100644
--- a/src/main.c
+++ b/src/main.c
@@ -40,7 +40,8 @@ blogc_print_help(void)
{
printf(
"usage:\n"
- " blogc [-h] [-v] [-l] [-D KEY=VALUE ...] [-p KEY] [-t TEMPLATE] [-o OUTPUT] SOURCE [SOURCE ...] - A blog compiler.\n"
+ " blogc [-h] [-v] [-l] [-D KEY=VALUE ...] [-p KEY] [-t TEMPLATE]\n"
+ " [-o OUTPUT] SOURCE [SOURCE ...] - A blog compiler.\n"
"\n"
"positional arguments:\n"
" SOURCE source file(s)\n"
@@ -50,7 +51,8 @@ blogc_print_help(void)
" -v show version and exit\n"
" -l build listing page, from multiple source files\n"
" -D KEY=VALUE set global configuration parameter\n"
- " -p KEY show the value of a global configuration parameter after source parsing and exit\n"
+ " -p KEY show the value of a global configuration parameter\n"
+ " after source parsing and exit\n"
" -t TEMPLATE template file\n"
" -o OUTPUT output file\n");
}
@@ -59,7 +61,9 @@ blogc_print_help(void)
static void
blogc_print_usage(void)
{
- printf("usage: blogc [-h] [-v] [-l] [-D KEY=VALUE ...] [-p KEY] [-t TEMPLATE] [-o OUTPUT] SOURCE [SOURCE ...]\n");
+ printf(
+ "usage: blogc [-h] [-v] [-l] [-D KEY=VALUE ...] [-p KEY] [-t TEMPLATE]\n"
+ " [-o OUTPUT] SOURCE [SOURCE ...]\n");
}
@@ -75,24 +79,27 @@ blogc_mkdir_recursive(const char *filename)
char *fname = b_strdup(filename);
for (char *tmp = fname; *tmp != '\0'; tmp++) {
- if (*tmp == '/' || *tmp == '\\') {
+ if (*tmp != '/' && *tmp != '\\')
+ continue;
#if defined(HAVE_SYS_STAT_H) && defined(HAVE_SYS_TYPES_H)
- char bkp = *tmp;
- *tmp = '\0';
- if ((strlen(fname) > 0) && (-1 == mkdir(fname, mode)) && (errno != EEXIST)) {
- fprintf(stderr, "blogc: error: failed to create output "
- "directory (%s): %s\n", fname, strerror(errno));
- free(fname);
- exit(2);
- }
- *tmp = bkp;
+ char bkp = *tmp;
+ *tmp = '\0';
+ if ((strlen(fname) > 0) &&
+ (-1 == mkdir(fname, mode)) &&
+ (errno != EEXIST))
+ {
+ fprintf(stderr, "blogc: error: failed to create output "
+ "directory (%s): %s\n", fname, strerror(errno));
+ free(fname);
+ exit(2);
+ }
+ *tmp = bkp;
#else
- // FIXME: show this warning only if actually trying to create a directory.
- fprintf(stderr, "blogc: warning: can't create output directories "
- "for your platform. please create the directories yourself.\n");
- break;
+ // FIXME: show this warning only if actually trying to create a directory.
+ fprintf(stderr, "blogc: warning: can't create output directories "
+ "for your platform. please create the directories yourself.\n");
+ break;
#endif
- }
}
free(fname);
}