diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d181cbb --- /dev/null +++ b/.editorconfig @@ -0,0 +1,23 @@ +root = true + +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[{*.c,*.h}] +indent_style = space +indent_size = 4 + +[README] +trim_trailing_whitespace = false + +[Makefile] +indent_style = tab +indent_size = 4 + +[indent.1] +indent_size = unset diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..be1a6c9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +indent diff --git a/Makefile b/Makefile index 08952c2..dc9ab39 100644 --- a/Makefile +++ b/Makefile @@ -3,4 +3,5 @@ PROG= indent SRCS= indent.c io.c lexi.c parse.c pr_comment.c args.c -.include +$(PROG): $(SRCS) +# .include diff --git a/args.c b/args.c index 61ca43e..1d75b52 100644 --- a/args.c +++ b/args.c @@ -168,7 +168,11 @@ set_profile(void) home = getenv("HOME"); if (home != NULL && *home != '\0') { if (snprintf(fname, sizeof fname, "%s/%s", home, prof) >= sizeof fname) { - warnc(ENAMETOOLONG, "%s/%s", home, prof); + #if defined(__linux__) + printf("%s/%s", home, prof); // FIXIT + #else + warnc(ENAMETOOLONG, "%s/%s", home, prof); + #endif return; } if ((f = fopen(option_source = fname, "r")) != NULL) { diff --git a/indent.c b/indent.c index adb77a3..d5f278a 100644 --- a/indent.c +++ b/indent.c @@ -202,8 +202,12 @@ main(int argc, char **argv) int last_else = 0; /* true iff last keyword was an else */ - if (pledge("stdio rpath wpath cpath", NULL) == -1) - err(1, "pledge"); + #if defined(__linux__) + // + #else + if (pledge("stdio rpath wpath cpath", NULL) == -1) + err(1, "pledge"); + #endif /*-----------------------------------------------*\ | INITIALIZATION | @@ -1305,7 +1309,11 @@ bakcopy(void) if (*p == '/') p++; if (snprintf(bakfile, PATH_MAX, "%s.BAK", p) >= PATH_MAX) - errc(1, ENAMETOOLONG, "%s.BAK", p); + #if defined(__linux__) + printf("%s.BAK", p); // FIXIT + #else + errc(1, ENAMETOOLONG, "%s.BAK", p); + #endif /* copy in_name to backup file */ bakchn = open(bakfile, O_CREAT | O_TRUNC | O_WRONLY, 0600); @@ -1328,6 +1336,10 @@ bakcopy(void) if (output == NULL) { int saved_errno = errno; unlink(bakfile); - errc(1, saved_errno, "%s", in_name); + #if defined(__linux__) + printf("%s", in_name); // FIXIT + #else + errc(1, saved_errno, "%s", in_name); + #endif } } diff --git a/lexi.c b/lexi.c index 31cf53a..d868fce 100644 --- a/lexi.c +++ b/lexi.c @@ -297,7 +297,8 @@ lexi(void) while (tp < buf_end) if (*tp++ == ')' && (*tp == ';' || *tp == ',')) goto not_proc; - strlcpy(ps.procname, token, sizeof ps.procname); + strncpy(ps.procname, token, sizeof ps.procname); + // strlcpy(ps.procname, token, sizeof ps.procname); ps.in_parameter_declaration = 1; rparen_count = 1; not_proc:;