
Путь: Toys/POSIX, команды версии: Ver.4 Ver.9 cat Комментарии в файле cat.c :
Исходный текст в файле cat.c #define FOR_cat
#define FORCE_FLAGS
#include "toys.h"
static void do_cat(int fd, char *name)
{
int i, len, size=FLAG(u) ? 1 : sizeof(toybuf);
for(;;) {
len = read(fd, toybuf, size);
if (len<0) perror_msg_raw(name);
if (len<1) break;
if (toys.optflags&~FLAG_u) {
for (i = 0; i<len; i++) {
char c = toybuf[i];
if (c>126 && FLAG(v)) {
if (c>127) {
printf("M-");
c -= 128;
}
if (c == 127) {
printf("^?");
continue;
}
}
if (c<32) {
if (c == 10) {
if (FLAG(e)) xputc('$');
} else if (toys.optflags & (c==9 ? FLAG_t : FLAG_v)) {
printf("^%c", c+'@');
continue;
}
}
xputc(c);
}
} else xwrite(1, toybuf, len);
}
}
void cat_main(void)
{
loopfiles(toys.optargs, do_cat);
} |
![]() |