#include #include #include #include int main(int argc, char **argv) { size_t i, j, len; char *msg = argc <= 1 ? "yes" : argv[1]; #if defined(_PAGE_ALIGN) size_t size = sysconf(_SC_PAGESIZE); char *mem; posix_memalign((void**) &mem, size, size); #elif defined(_PAGE_SIZE) size_t size = sysconf(_SC_PAGESIZE); char *mem = malloc(size); #elif defined(_BUFSIZ) size_t size = BUFSIZ; char mem[BUFSIZ]; #else size_t size = strlen(msg) + 1; char *mem[size + 1]; #endif len = strlen(msg); size = (size / len) * len; for (i = 0, j = 0; i < size; i++) { if (j == len) { mem[i] = '\n'; j = 0; } else { mem[i] = msg[j++ % len]; } } #if defined(_NO_BUFFER) setvbuf(stdout, NULL, _IONBF, size); #elif defined(_LINE_BUFFER) setvbuf(stdout, NULL, _IOLBF, size); #elif defined(_BLOCK_BUFFER) setvbuf(stdout, NULL, _IOFBF, size); #endif for (;;) { #if defined(_USE_WRITE) write(STDOUT_FILENO, mem, size); #else fwrite(mem, 1, size, stdout); #endif } }