LESS THAN 250 LINES
This commit is contained in:
parent
88a9425ad7
commit
cebb888918
22
mm/mm.c
22
mm/mm.c
@ -21,7 +21,7 @@
|
|||||||
#include <stdio.h> /* fclose(3), fopen(3), fprintf(3), getc(3), putc(3),
|
#include <stdio.h> /* fclose(3), fopen(3), fprintf(3), getc(3), putc(3),
|
||||||
* setvbuf(3), size_t, _IONBF, NULL */
|
* setvbuf(3), size_t, _IONBF, NULL */
|
||||||
#include <stdlib.h> /* free(3), realloc(3) */
|
#include <stdlib.h> /* free(3), realloc(3) */
|
||||||
#include <string.h> /* strerror(3) */
|
#include <string.h> /* strcmp(3), strerror(3) */
|
||||||
#include <unistd.h> /* getopt(3) */
|
#include <unistd.h> /* getopt(3) */
|
||||||
#if !defined EX_OSERR || !defined EX_USAGE
|
#if !defined EX_OSERR || !defined EX_USAGE
|
||||||
# include <sysexits.h>
|
# include <sysexits.h>
|
||||||
@ -161,24 +161,18 @@ int main(int argc, char *argv[]){
|
|||||||
terminate(files);
|
terminate(files);
|
||||||
return oserr(argv[0], "-e");
|
return oserr(argv[0], "-e");
|
||||||
case 'i':
|
case 'i':
|
||||||
if(optarg[0] == '-' && optarg[1] == '\0'){ /* "-" */
|
if((strcmp(optarg, "-") == 0 && Files_append(&files[0],
|
||||||
if(Files_append(&files[0], stdin, stdin_name)
|
stdin, stdin_name) != NULL)
|
||||||
|
|| Files_open(&files[0], optarg)
|
||||||
!= NULL)
|
!= NULL)
|
||||||
break;
|
|
||||||
else
|
|
||||||
optarg = stdin_name;
|
|
||||||
}else if(Files_open(&files[0], optarg) != NULL)
|
|
||||||
break;
|
break;
|
||||||
terminate(files);
|
terminate(files);
|
||||||
return oserr(argv[0], optarg);
|
return oserr(argv[0], optarg);
|
||||||
case 'o':
|
case 'o':
|
||||||
if(optarg[0] == '-' && optarg[1] == '\0'){
|
if((strcmp(optarg, "-") == 0 && Files_append(&files[1],
|
||||||
/* "-" */
|
stdout, stdout_name) != NULL)
|
||||||
if(Files_append(&files[1], stdout,
|
|| Files_open(&files[1], optarg)
|
||||||
stdout_name) != NULL)
|
!= NULL)
|
||||||
break;
|
|
||||||
optarg = stdout_name;
|
|
||||||
}else if(Files_open(&files[1], optarg) != NULL)
|
|
||||||
break;
|
break;
|
||||||
/* does not exist, so try to create it */
|
/* does not exist, so try to create it */
|
||||||
if(errno == ENOENT){
|
if(errno == ENOENT){
|
||||||
|
Loading…
Reference in New Issue
Block a user