1 // $XConsortium: TextRun.cc /main/3 1996/06/11 17:41:52 cde-hal $
2 /* Copyright (c) 1995 FUJITSU LIMITED */
3 /* All Rights Reserved */
11 main(int argc, char** argv)
14 fprintf(stderr, "Usage: %s offset length\n", argv[0]);
18 int offset = atoi(argv[1]);
19 int length = atoi(argv[2]);
22 fprintf(stderr, "(ERROR) offset must be non-negative\n");
26 fprintf(stderr, "(ERROR) length must be positive\n");
33 while (cin.get(ch)) text << ch;
35 char* buf = text.str();
36 *(buf + text.pcount()) = '\0';
39 if (buf == NULL || *buf == '\0') {
40 fprintf(stderr, "(ERROR) empty input stream\n");
45 for (; offset > 0; p += n, offset -= n) {
46 n = mblen(p, MB_CUR_MAX);
49 assert( offset == 0 );
51 fprintf(stdout, "\"%.*s\"\n", length, p);