Compare commits
2 Commits
98a7ba56c7
...
3afc38f7e7
Author | SHA1 | Date | |
---|---|---|---|
|
3afc38f7e7 | ||
|
c3fc72deb3 |
@ -35,18 +35,10 @@ void Compile(const char *src, const char *output_dir) {
|
|||||||
char *path = MakePath(src, output_dir);
|
char *path = MakePath(src, output_dir);
|
||||||
printf("[CC] Building %s -> %s\n", src, path);
|
printf("[CC] Building %s -> %s\n", src, path);
|
||||||
|
|
||||||
size_t len = strlen(CC) + strlen(CFLAGS) + strlen(src) + strlen(path) + 7;
|
if (fork()) {
|
||||||
char *arg = malloc(len + 1);
|
execlp(CC, CC, CFLAGS, src, "-o", path, NULL);
|
||||||
if (arg == NULL) {
|
|
||||||
free(path);
|
|
||||||
fprintf(stderr, "builder: malloc failed");
|
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(arg, len, "%s %s %s -o %s", CC, CFLAGS, src, path);
|
|
||||||
system(arg);
|
|
||||||
|
|
||||||
free(arg);
|
|
||||||
free(path);
|
free(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,6 @@ const char *libs[] = {
|
|||||||
"readline"
|
"readline"
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CFLAGS "-Wall -Wextra -pedantic -Os -s -I ../libmu"
|
#define CFLAGS "-Wall", "-Wextra", "-pedantic", "-Os", "-s", "-I", "../libmu"
|
||||||
#define CC "cc"
|
#define CC "cc"
|
||||||
#endif
|
#endif
|
||||||
|
@ -14,13 +14,16 @@ void cat(const int fd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(const int argc, const char **argv) {
|
int main(const int argc, const char **argv) {
|
||||||
if (argc == 1 || argv[1][0] == '-')
|
if (argc == 1)
|
||||||
cat(STDIN_FILENO);
|
cat(STDIN_FILENO);
|
||||||
|
|
||||||
else {
|
else {
|
||||||
for (int i = 1; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
if (argv[i][0] == '-')
|
if (argv[i][0] == '-')
|
||||||
break;
|
if (argv[i][1])
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
cat(STDIN_FILENO);
|
||||||
|
|
||||||
int fd = open(argv[i], O_RDONLY);
|
int fd = open(argv[i], O_RDONLY);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
|
@ -8,7 +8,8 @@ int main(const int argc, const char **argv) {
|
|||||||
putchar(' ');
|
putchar(' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// https://pubs.opengroup.org/onlinepubs/009604599/utilities/echo.html
|
||||||
|
// This version does not support -n option and escape-sequences
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user