add my .clang-format

This commit is contained in:
Iris Lightshard 2021-04-15 14:44:07 -04:00
parent 836e861d99
commit ff4700df5a
Signed by: Iris Lightshard
GPG key ID: 3B7FBC22144E6398
2 changed files with 58 additions and 28 deletions

23
.clang-format Normal file
View file

@ -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

47
main.c
View file

@ -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("<span style='float:right'>", f);
@ -84,7 +84,7 @@ void fpedited(FILE *f, char *path) {
fputs("</span>", 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, "<h2 id='%s'><a href='%s.html'>%s</a></h2>",
scsw(filename, ' ', '_'), filename, s);
fprintf(
f,
"<h2 id='%s'><a href='%s.html'>%s</a></h2>",
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,13 +149,14 @@ 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("<!DOCTYPE html><html lang='en'>", f);
fputs("<head>", f);
fprintf(f,
fprintf(
f,
"<meta charset='utf-8'>"
"<meta name='description' content='%s'/>"
"<meta name='viewport' content='width=device-width,initial-scale=1'>",
@ -161,7 +166,8 @@ FILE *build(FILE *f, Lexicon *l, char *name, char *srcpath) {
} else {
fputs("<link rel='stylesheet' type='text/css' href='" MAINCSS "'>", f);
}
fprintf(f,
fprintf(
f,
"<link rel='shortcut icon' href='/favicon.ico'>"
"<title>" NAME " &mdash; %s</title>",
name);
@ -196,7 +202,8 @@ FILE *build(FILE *f, Lexicon *l, char *name, char *srcpath) {
/* footer */
fputs("<footer>", f);
fpedited(f, srcpath);
fputs("contact: <a href='mailto://drkste@zoho.com'>drkste@zoho.com</a> ",
fputs(
"contact: <a href='mailto://drkste@zoho.com'>drkste@zoho.com</a> ",
f);
fputs("(<a href='keys.html'>keys</a>)", f);
/* fputs("<a href='" LICENSE "' target='_blank'>BY-NC-SA 4.0</a>", 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. ");