diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..a699815 --- /dev/null +++ b/.clang-format @@ -0,0 +1,23 @@ +TabWidth: 2 +IndentWidth: 2 +ContinuationIndentWidth: 2 +UseTab: Never +AllowShortBlocksOnASingleLine: Always +AllowShortCaseLabelsOnASingleLine: false +AllowShortEnumsOnASingleLine: true +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +PenaltyReturnTypeOnItsOwnLine: 255 +IndentCaseLabels: true +SpaceBeforeParens: ControlStatements +AlignAfterOpenBracket: AlwaysBreak +BinPackArguments: false +BinPackArguments: false +PointerAlignment: Left +BreakBeforeBraces: Attach +SortIncludes: false +AllowAllArgumentsOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: false +AlignEscapedNewlines: Left + diff --git a/main.c b/main.c index 56862d7..a6cd917 100644 --- a/main.c +++ b/main.c @@ -33,7 +33,7 @@ WITH REGARD TO THIS SOFTWARE. /* clang-format on */ -struct dirent *dir; +struct dirent* dir; typedef struct Lexicon { int len, refs[512]; @@ -57,16 +57,16 @@ char *ccat(char *dst, char c) { int len = slen(dst); dst[len] = c; dst[len + 1] /* clang-format on */ -int fpinject(FILE *f, Lexicon *l, char *filepath); +int fpinject(FILE* f, Lexicon* l, char* filepath); -int error(char *msg, char *val) { +int error(char* msg, char* val) { printf("Error: %s(%s)\n", msg, val); return 0; } -int ismetanav(char *name) { return scmp(name, "meta.nav"); } +int ismetanav(char* name) { return scmp(name, "meta.nav"); } -int findf(Lexicon *l, char *f) { +int findf(Lexicon* l, char* f) { int i; char filename[64]; scat(scsw(stlc(scpy(f, filename, 64)), ' ', '_'), ".htm"); @@ -76,7 +76,7 @@ int findf(Lexicon *l, char *f) { return -1; } -void fpedited(FILE *f, char *path) { +void fpedited(FILE* f, char* path) { struct stat attr; stat(path, &attr); fputs("", f); @@ -84,7 +84,7 @@ void fpedited(FILE *f, char *path) { fputs("", f); } -int fpportal(FILE *f, Lexicon *l, char *s, int head) { +int fpportal(FILE* f, Lexicon* l, char* s, int head) { int target; char srcpath[64], filename[64]; target = findf(l, s); @@ -94,14 +94,18 @@ int fpportal(FILE *f, Lexicon *l, char *s, int head) { filename[0] = 0; scat(scat(scat(srcpath, "inc/"), scpy(s, filename, 64)), ".htm"); if (head) - fprintf(f, "

%s

", - scsw(filename, ' ', '_'), filename, s); + fprintf( + f, + "

%s

", + scsw(filename, ' ', '_'), + filename, + s); fpinject(f, l, srcpath); l->refs[target]++; return 1; } -int fptemplate(FILE *f, Lexicon *l, char *s) { +int fptemplate(FILE* f, Lexicon* l, char* s) { int target; if (s[0] == '/') return fpportal(f, l, s + 1, 1); @@ -114,8 +118,8 @@ int fptemplate(FILE *f, Lexicon *l, char *s) { return 1; } -int fpinject(FILE *f, Lexicon *l, char *filepath) { - FILE *inc; +int fpinject(FILE* f, Lexicon* l, char* filepath) { + FILE* inc; char c, s[1024]; unsigned char t = 0; scsw(filepath, ' ', '_'); @@ -145,26 +149,28 @@ int fpinject(FILE *f, Lexicon *l, char *filepath) { return 1; } -FILE *build(FILE *f, Lexicon *l, char *name, char *srcpath) { +FILE* build(FILE* f, Lexicon* l, char* name, char* srcpath) { if (!f) return f; /* begin */ fputs("", f); fputs("", f); - fprintf(f, - "" - "" - "", - "lair of drkste aka nilix: programmer, artist, philosopher"); + fprintf( + f, + "" + "" + "", + "lair of drkste aka nilix: programmer, artist, philosopher"); if (ismetanav(name)) { fputs("", f); } else { fputs("", f); } - fprintf(f, - "" - "" NAME " — %s", - name); + fprintf( + f, + "" + "" NAME " — %s", + name); fputs("", f); fputs("", f); /* header */ @@ -196,8 +202,9 @@ FILE *build(FILE *f, Lexicon *l, char *name, char *srcpath) { /* footer */ fputs("", f); @@ -207,7 +214,7 @@ FILE *build(FILE *f, Lexicon *l, char *name, char *srcpath) { return f; } -int generate(Lexicon *l) { +int generate(Lexicon* l) { int i = 0; char srcpath[64], dstpath[64], filename[64]; for (i = 0; i < l->len; ++i) { @@ -234,7 +241,7 @@ int generate(Lexicon *l) { return 1; } -int index(Lexicon *l, DIR *d) { +int index(Lexicon* l, DIR* d) { while ((dir = readdir(d))) if (ssin(dir->d_name, ".htm") > 0) { l->refs[l->len] = 0; @@ -245,7 +252,7 @@ int index(Lexicon *l, DIR *d) { return 1; } -void inspect(Lexicon *l) { +void inspect(Lexicon* l) { int i; for (i = 0; i < l->len; ++i) if (!l->refs[i]) @@ -254,7 +261,7 @@ void inspect(Lexicon *l) { int main(void) { Lexicon lex; - DIR *d; + DIR* d; lex.len = 0; if (!(d = opendir("inc"))) return error("Open", "Missing inc/ folder. ");