linux comp

This commit is contained in:
Alexander Popov 2022-09-30 00:39:09 +03:00
parent 003e7a740c
commit a250dd83d4
Signed by: iiiypuk
GPG Key ID: D8C9B59A9F04A70C
6 changed files with 49 additions and 7 deletions

23
.editorconfig Normal file
View File

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

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
indent

View File

@ -3,4 +3,5 @@
PROG= indent
SRCS= indent.c io.c lexi.c parse.c pr_comment.c args.c
.include <bsd.prog.mk>
$(PROG): $(SRCS)
# .include <bsd.prog.mk>

6
args.c
View File

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

View File

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

3
lexi.c
View File

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