Compare commits

..

2 Commits

Author SHA1 Message Date
DTB
5545846c92
dj(1): fix fprintio signature 2024-07-29 11:10:17 -06:00
DTB
162c6411b3
mm(1): remove terminate macro 2024-07-29 11:08:30 -06:00
2 changed files with 9 additions and 36 deletions

View File

@ -118,7 +118,7 @@ oserr(char *e, int n) {
/* Prints statistics regarding the use of dj, particularly partially and /* Prints statistics regarding the use of dj, particularly partially and
* completely read and written records. */ * completely read and written records. */
static void static int
fprintio(FILE *stream, char *fmt, struct Io io[2]) { fprintio(FILE *stream, char *fmt, struct Io io[2]) {
return fprintf( return fprintf(
stream, stream,

View File

@ -88,25 +88,6 @@ oserr(char *s, char *r) {
return EX_OSERR; return EX_OSERR;
} }
/* Hijacks i and j from main and destructs the files[2] struct used by main by
* closing its files and freeing its files and names arrays, returning retval
* from main. */
#define terminate \
for (i = 0; i < 2; ++i) { \
for (j = 0; j < files[i].s; ++j) { \
if ( \
files[i].files[j] != stdin \
&& files[i].files[j] != stdout \
&& files[i].files[j] != stderr \
) { \
fclose(files[i].files[j]); \
} \
} \
free(files[i].files); \
free(files[i].names); \
} \
return retval
static int static int
usage(char *argv0) { usage(char *argv0) {
(void)fprintf( (void)fprintf(
@ -163,8 +144,7 @@ int main(int argc, char *argv[]) {
break; break;
} }
retval = oserr(program_name, "-e"); return oserr(program_name, "-e");
terminate;
case 'i': case 'i':
if ( if (
(strcmp(optarg, "-") == 0 (strcmp(optarg, "-") == 0