Compare commits

..

No commits in common. 'a1184bd3fbf657bfc1b05a1eddcdd47fd465ceda' and '5b4ff0d8002cbd382d70690cb47666825fc93e1c' have entirely different histories.

  1. 31
      dpu.c

31
dpu.c

@ -2,38 +2,27 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <getopt.h>
int main (int argc, char **argv){ int main (int argc, char **argv){
char name[FILENAME_MAX]; char name[FILENAME_MAX];
FILE *bob,*joe,*moe; FILE *bob,*joe,*moe;
int thing, factor, arg; int thing, factor, arg;
int modifier; if(argc >= 3){
factor=0; char *end_char;
while((modifier=getopt(argc,argv,"0123456789"))+1){ factor = strtol(argv[1], &end_char, 0);
switch(modifier){ if(!*(argv[1]) || *end_char)
case '0': case '1': case '2': case '3': case '4': {
case '5': case '6': case '7': case '8': case '9': fputs("I can haz number?\n", stderr);
factor=factor*10+modifier-'0';
break;
default:
fputs("You're going to have to be clearer about what you want.\n",stderr);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
} arg = 2;
if(factor==0){ }else{
factor = 9; factor = 9;
arg = 1;
} }
argc-=optind; if(argc<2){
argv+=optind;
arg=0;
if(argc<1){
fputs("I pity the fool who don't have an input file!\n",stderr); fputs("I pity the fool who don't have an input file!\n",stderr);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if(argc>1){
fputs("Be patient, one thing at a time!\n",stderr);
}
if(strlen(argv[arg]) >= FILENAME_MAX - 4) if(strlen(argv[arg]) >= FILENAME_MAX - 4)
{ {
fputs("It's a filename, not a novel.\n", stderr); fputs("It's a filename, not a novel.\n", stderr);

Loading…
Cancel
Save