void OCatCmd_Cat (void) { CHAR path[128]; INTEGER i; Texts_Text T = NIL; Texts_Reader R; CHAR ch; BOOLEAN tab; CHAR buf[1024]; INTEGER bufpos; struct Cat__1 _s; _s.buf = (void*)buf; _s.bufpos = &bufpos; _s.lnk = Cat__1_s; Cat__1_s = &_s; path[0] = 0x00; __NEW(T, Texts_TextDesc); Args_Get(1, (void*)path, 128); if (__STRCMP(path, "-t") == 0) { tab = 1; i = 2; Args_Get(2, (void*)path, 128); } else { tab = 0; i = 1; } while (path[0] != 0x00) { if (Files_Old(path, 128) != NIL) { Texts_Open(T, path, 128); Texts_OpenReader(&R, Texts_Reader__typ, T, 0); Texts_Read(&R, Texts_Reader__typ, &ch); bufpos = 0; while (!R.eot) { if (ch >= ' ') { ConsoleChar__2(ch); } else if (ch == 0x09) { if (tab) { ConsoleChar__2(ch); } else { ConsoleChar__2(' '); ConsoleChar__2(' '); } } else if (ch == 0x0d) { ConsoleChar__2(0x0a); } Texts_Read(&R, Texts_Reader__typ, &ch); } buf[__X(bufpos, 1024)] = 0x00; Console_String(buf, 1024); } else { Console_String((CHAR*)"OCat: cannot open ", 19); Console_String(path, 128); Console_Ln(); } i += 1; path[0] = 0x00; Args_Get(i, (void*)path, 128); } Cat__1_s = _s.lnk; }
int main() { long x, y; /* get size and alignment of standard types */ printf("CHAR %d %d\n", sizeof(CHAR), (char*)&c.x - (char*)&c); printf("BOOLEAN %d %d\n", sizeof(BOOLEAN), (char*)&b.x - (char*)&b); printf("SHORTINT %d %d\n", sizeof(SHORTINT), (char*)&si.x - (char*)&si); printf("INTEGER %d %d\n", sizeof(INTEGER), (char*)&i.x - (char*)&i); printf("LONGINT %d %d\n", sizeof(LONGINT), (char*)&li.x - (char*)&li); printf("SET %d %d\n", sizeof(SET), (char*)&s.x - (char*)&s); printf("REAL %d %d\n", sizeof(REAL), (char*)&r.x - (char*)&r); printf("LONGREAL %d %d\n", sizeof(LONGREAL), (char*)&lr.x - (char*)&lr); printf("PTR %d %d\n", sizeof p.x, (char*)&p.x - (char*)&p); printf("PROC %d %d\n", sizeof f.x, (char*)&f.x - (char*)&f); printf("RECORD %d %d\n", (sizeof rec2 == 65) == (sizeof rec0 == 1), sizeof rec2 - 64); x = 1; printf("ENDIAN %d %d\n", *(char*)&x, 0); if (sizeof(CHAR)!=1) printf("error: CHAR should have size 1\n"); if (sizeof(BOOLEAN)!=1) printf("error: BOOLEAN should have size 1\n"); if (sizeof(SHORTINT)!=1 && sizeof(SHORTINT)!=2) printf("error: SHORTINT should have size 1 or 2\n"); if (sizeof(LONGINT)!=sizeof p.x) printf("error: LONGINT should have the same size as pointers\n"); if (sizeof(LONGINT)!=sizeof f.x) printf("error: LONGINT should have the same size as function pointers\n"); if (((sizeof rec2 == 65) == (sizeof rec0 == 1)) && ((sizeof rec2 - 64) != sizeof rec0)) printf("error: unsupported record layout sizeof rec0 = %d sizeof rec2 = %d\n", sizeof rec0, sizeof rec2); /* test the __ASHR macro */ if (__ASHR(-1, 1) != -1) printf("error: ASH(-1, -1) # -1\n"); if (__ASHR(-2, 1) != -1) printf("error: ASH(-2, -1) # -1\n"); if (__ASHR(0, 1) != 0) printf("error: ASH(0, 1) # 0\n"); if (__ASHR(1, 1) != 0) printf("error: ASH(1, 1) # 0\n"); if (__ASHR(2, 1) != 1) printf("error: ASH(2, 1) # 1\n"); /* test the __SETRNG macro */ x = 0; y = sizeof(SET)*8 - 1; if (__SETRNG(x, y) != -1) printf("error: SETRNG(0, MAX(SET)) != -1\n"); /* test string comparison for extended ascii */ {char a[10], b[10]; a[0] = (CHAR)128; a[1] = 0; b[0] = 0; if (__STRCMP(a, b) < 0) printf("error: __STRCMP(a, b) with extended ascii charcters; should be unsigned\n"); } return 0; }