--- ray/src/cal/lam.c 2005/09/25 20:36:02 1.7 +++ ray/src/cal/lam.c 2010/06/18 01:12:57 1.10 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: lam.c,v 1.7 2005/09/25 20:36:02 greg Exp $"; +static const char RCSid[] = "$Id: lam.c,v 1.10 2010/06/18 01:12:57 greg Exp $"; #endif /* * lam.c - simple program to laminate files. @@ -53,9 +53,15 @@ char *argv[]; case 'd': curbytes = sizeof(double); break; - case 'w': + case 'i': curbytes = sizeof(int); break; + case 'w': + curbytes = 2; + break; + case 'b': + curbytes = 1; + break; case 'a': curbytes = argv[i][3] ? 1 : 0; break; @@ -69,6 +75,8 @@ char *argv[]; fputs(": illegal input size\n", stderr); exit(1); } + if (curbytes) + curtab = ""; break; case '\0': tabc[nfiles] = curtab; @@ -84,19 +92,25 @@ char *argv[]; } else if (argv[i][0] == '!') { tabc[nfiles] = curtab; bytsiz[nfiles] = curbytes; - if ((input[nfiles++] = popen(argv[i]+1, "r")) == NULL) { + if ((input[nfiles] = popen(argv[i]+1, "r")) == NULL) { fputs(argv[i], stderr); fputs(": cannot start command\n", stderr); exit(1); } + if (bytsiz[nfiles]) + SET_FILE_BINARY(input[nfiles]); + ++nfiles; } else { tabc[nfiles] = curtab; bytsiz[nfiles] = curbytes; - if ((input[nfiles++] = fopen(argv[i], "r")) == NULL) { + if ((input[nfiles] = fopen(argv[i], "r")) == NULL) { fputs(argv[i], stderr); fputs(": cannot open file\n", stderr); exit(1); } + if (bytsiz[nfiles]) + SET_FILE_BINARY(input[nfiles]); + ++nfiles; } if (nfiles >= MAXFILE) { fputs(argv[0], stderr);