Rename

Harry decides the time has come to create a proper Makefile. And also to gratuitously rename lottery.c.

lottery harry$ git pull
remote: Counting objects: 12, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 7 (delta 2), reused 0 (delta 0)
Unpacking objects: 100% (7/7), done.
From http://server.futilisoft.com:8000/lottery
   0171af4..0e74df9  master     -> origin/master
Updating 0171af4..0e74df9
Fast-forward
 src/lottery.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

lottery harry$ git add Makefile

lottery harry$ git mv src/lottery.c src/pb.c

lottery harry$ git status -s
A  Makefile
R  src/lottery.c -> src/pb.c
?? a.out

lottery harry$ git commit -a -m "Makefile. and lottery.c was too long to type."
[master 8e9cb1b] Makefile. and lottery.c was too long to type.
 2 files changed, 4 insertions(+), 0 deletions(-)
 create mode 100644 Makefile
 rename src/{lottery.c => pb.c} (100%)

lottery harry$ git push
Counting objects: 6, done.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 399 bytes, done.
Total 4 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (4/4), done.
To http://server.futilisoft.com:8000/lottery
   0e74df9..8e9cb1b  master -> master

Sally maintains her momentum with #define and adds names for the ball ranges.

lottery sally$ git diff
diff --git a/src/lottery.c b/src/lottery.c
index 706851c..9f3ce49 100644
--- a/src/lottery.c
+++ b/src/lottery.c
@@ -3,6 +3,8 @@
 #include <stdlib.h>
 
 #define LUCKY_NUMBER 7
+#define MAX_WHITE_BALL 59
+#define MAX_POWER_BALL 39
 
 int calculate_result(int white_balls[5], int power_ball)
 {
@@ -10,7 +12,7 @@
     {
         if (
              (white_balls[i] < 1)
-             || (white_balls[i] > 59)
+             || (white_balls[i] > MAX_WHITE_BALL)
            )
         {
             return -1;
@@ -19,7 +21,7 @@
 
     if (
          (power_ball < 1)
-         || (power_ball > 39)
+         || (power_ball > MAX_POWER_BALL)
        )
     {
         return -1;

And commits her changes.

lottery sally$ git commit -a -m "more #defines"
[master 933ffc3] more #defines
 1 files changed, 4 insertions(+), 2 deletions(-)

lottery sally$ git push
To http://server.futilisoft.com:8000/lottery
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'http://server.futilisoft.com:8000/lottery'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.

Grrr. That Harry. The brain in his head must be like a BB in a boxcar.

lottery sally$ git pull
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 4 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (4/4), done.
From http://server.futilisoft.com:8000/lottery
   0e74df9..8e9cb1b  master     -> origin/master
Merge made by recursive.
 Makefile                |    4 ++++
 src/{lottery.c => pb.c} |    0
 2 files changed, 4 insertions(+), 0 deletions(-)
 create mode 100644 Makefile
 rename src/{lottery.c => pb.c} (100%)

lottery sally$ make
gcc -std=c99 -Wall -Wextra -Werror src/pb.c -o pb

lottery sally$ git push
Counting objects: 12, done.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (7/7), 696 bytes, done.
Total 7 (delta 1), reused 0 (delta 0)
Unpacking objects: 100% (7/7), done.
To http://server.futilisoft.com:8000/lottery
   8e9cb1b..00b1b4f  master -> master