From 38c1141db4abc31da4b5e17853b91d2500538010 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Fri, 23 Aug 2013 13:06:36 -0400 Subject: [PATCH 1/4] added .gitignore --- .gitignore | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ccc7596 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +*~ +*.o +*.dpu +*.exe +dpu +undpu From 37b4824a62065571ecf8dee3015bb97c8b17932d Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Fri, 23 Aug 2013 13:07:31 -0400 Subject: [PATCH 2/4] make sure the factor is valid (also accept non-base 10 numbers) --- dpu.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dpu.c b/dpu.c index aa6fc80..d699d85 100755 --- a/dpu.c +++ b/dpu.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -7,7 +8,13 @@ int main (int argc, char **argv){ FILE *bob,*joe,*moe; int thing, factor, arg; if(argc >= 3){ - factor = atoi (argv[1]); + char *end_char; + factor = strtol(argv[1], &end_char, 0); + if(!*(argv[1]) || *end_char) + { + fputs("I can haz number?\n", stderr); + return EXIT_FAILURE; + } arg = 2; }else{ factor = 9; From 13d83b05544f0f9344ffd4383b4edb540aed4a27 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Fri, 23 Aug 2013 13:12:03 -0400 Subject: [PATCH 3/4] removed unnecessary #include --- dpu.c | 1 - 1 file changed, 1 deletion(-) diff --git a/dpu.c b/dpu.c index d699d85..7248903 100755 --- a/dpu.c +++ b/dpu.c @@ -1,4 +1,3 @@ -#include #include #include #include From d54f47eeb6a326cb67c63580e09bd57a2cf00fbd Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Fri, 23 Aug 2013 13:23:28 -0400 Subject: [PATCH 4/4] convert spaces to tabs --- dpu.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dpu.c b/dpu.c index 7248903..5746339 100755 --- a/dpu.c +++ b/dpu.c @@ -7,13 +7,13 @@ int main (int argc, char **argv){ FILE *bob,*joe,*moe; int thing, factor, arg; if(argc >= 3){ - char *end_char; + char *end_char; factor = strtol(argv[1], &end_char, 0); - if(!*(argv[1]) || *end_char) - { - fputs("I can haz number?\n", stderr); - return EXIT_FAILURE; - } + if(!*(argv[1]) || *end_char) + { + fputs("I can haz number?\n", stderr); + return EXIT_FAILURE; + } arg = 2; }else{ factor = 9;