aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAiden Woodruff <aiden.woodruff@gmail.com>2018-07-30 00:01:26 -0500
committerAiden Woodruff <aiden.woodruff@gmail.com>2018-07-30 00:01:26 -0500
commit63a4dcc4cdd885ed9df84644b592fcf4738d9358 (patch)
tree15fc16198aca9c3820c99db043a251d36880ad44
parentbbfad59ce340ccdca9771c1b35a95e19485478e2 (diff)
downloadlife-63a4dcc4cdd885ed9df84644b592fcf4738d9358.tar.gz
life-63a4dcc4cdd885ed9df84644b592fcf4738d9358.tar.bz2
life-63a4dcc4cdd885ed9df84644b592fcf4738d9358.zip
Fixed major issue with updatinglife-1.5.2
Related to 1.5.1 change to use 'has' with updatemap - Caused by missing "not" keyword Add B{0..9}/S{0..9} in rule selection for ease Moved macro definitions to life-macros.h Tarballed and signed life-1.5.2 Signed-off-by: Aiden Woodruff <aiden.woodruff@gmail.com>
-rw-r--r--Makefile.am2
-rw-r--r--Makefile.in2
-rwxr-xr-xconfigure20
-rw-r--r--configure.ac2
-rw-r--r--life-1.5.1.tar.gzbin117118 -> 0 bytes
-rw-r--r--life-1.5.2.tar.gzbin0 -> 117036 bytes
-rw-r--r--life-1.5.2.tar.gz.sigbin0 -> 310 bytes
-rw-r--r--life-macros.h10
-rw-r--r--life.c15
-rw-r--r--life.h1
-rw-r--r--menus.c12
-rw-r--r--menus.h2
-rw-r--r--updatemap.c18
-rw-r--r--updatemap.h2
14 files changed, 42 insertions, 44 deletions
diff --git a/Makefile.am b/Makefile.am
index e9bb78a..1d77ffd 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
1AM_OPTIONS = gnu 1AM_OPTIONS = gnu
2bin_PROGRAMS = life 2bin_PROGRAMS = life
3life_SOURCES = life.c cmdline-life.c updatemap.c menus.c 3life_SOURCES = life.c cmdline-life.c updatemap.c menus.c
4life_CFLAGS = -I$(srcdir) 4life_CFLAGS = -I$(srcdir) -Wall -pedantic
5include_HEADERS = life.h updatemap.h menus.h cmdline-life.h 5include_HEADERS = life.h updatemap.h menus.h cmdline-life.h
6man_MANS = life.6 6man_MANS = life.6
7EXTRA_DIST = $(man_MANS) 7EXTRA_DIST = $(man_MANS)
diff --git a/Makefile.in b/Makefile.in
index 20279d8..7b20984 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -312,7 +312,7 @@ top_builddir = @top_builddir@
312top_srcdir = @top_srcdir@ 312top_srcdir = @top_srcdir@
313AM_OPTIONS = gnu 313AM_OPTIONS = gnu
314life_SOURCES = life.c cmdline-life.c updatemap.c menus.c 314life_SOURCES = life.c cmdline-life.c updatemap.c menus.c
315life_CFLAGS = -I$(srcdir) 315life_CFLAGS = -I$(srcdir) -Wall -pedantic
316include_HEADERS = life.h updatemap.h menus.h cmdline-life.h 316include_HEADERS = life.h updatemap.h menus.h cmdline-life.h
317man_MANS = life.6 317man_MANS = life.6
318EXTRA_DIST = $(man_MANS) 318EXTRA_DIST = $(man_MANS)
diff --git a/configure b/configure
index 20a362a..cb1f77e 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
1#! /bin/sh 1#! /bin/sh
2# Guess values for system-dependent variables and create Makefiles. 2# Guess values for system-dependent variables and create Makefiles.
3# Generated by GNU Autoconf 2.69 for life 1.5.1. 3# Generated by GNU Autoconf 2.69 for life 1.5.2.
4# 4#
5# Report bugs to <aiden.woodruff@gmail.com>. 5# Report bugs to <aiden.woodruff@gmail.com>.
6# 6#
@@ -580,8 +580,8 @@ MAKEFLAGS=
580# Identity of this package. 580# Identity of this package.
581PACKAGE_NAME='life' 581PACKAGE_NAME='life'
582PACKAGE_TARNAME='life' 582PACKAGE_TARNAME='life'
583PACKAGE_VERSION='1.5.1' 583PACKAGE_VERSION='1.5.2'
584PACKAGE_STRING='life 1.5.1' 584PACKAGE_STRING='life 1.5.2'
585PACKAGE_BUGREPORT='aiden.woodruff@gmail.com' 585PACKAGE_BUGREPORT='aiden.woodruff@gmail.com'
586PACKAGE_URL='' 586PACKAGE_URL=''
587 587
@@ -1277,7 +1277,7 @@ if test "$ac_init_help" = "long"; then
1277 # Omit some internal or obsolete options to make the list less imposing. 1277 # Omit some internal or obsolete options to make the list less imposing.
1278 # This message is too long to be a string in the A/UX 3.1 sh. 1278 # This message is too long to be a string in the A/UX 3.1 sh.
1279 cat <<_ACEOF 1279 cat <<_ACEOF
1280\`configure' configures life 1.5.1 to adapt to many kinds of systems. 1280\`configure' configures life 1.5.2 to adapt to many kinds of systems.
1281 1281
1282Usage: $0 [OPTION]... [VAR=VALUE]... 1282Usage: $0 [OPTION]... [VAR=VALUE]...
1283 1283
@@ -1344,7 +1344,7 @@ fi
1344 1344
1345if test -n "$ac_init_help"; then 1345if test -n "$ac_init_help"; then
1346 case $ac_init_help in 1346 case $ac_init_help in
1347 short | recursive ) echo "Configuration of life 1.5.1:";; 1347 short | recursive ) echo "Configuration of life 1.5.2:";;
1348 esac 1348 esac
1349 cat <<\_ACEOF 1349 cat <<\_ACEOF
1350 1350
@@ -1435,7 +1435,7 @@ fi
1435test -n "$ac_init_help" && exit $ac_status 1435test -n "$ac_init_help" && exit $ac_status
1436if $ac_init_version; then 1436if $ac_init_version; then
1437 cat <<\_ACEOF 1437 cat <<\_ACEOF
1438life configure 1.5.1 1438life configure 1.5.2
1439generated by GNU Autoconf 2.69 1439generated by GNU Autoconf 2.69
1440 1440
1441Copyright (C) 2012 Free Software Foundation, Inc. 1441Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1804,7 +1804,7 @@ cat >config.log <<_ACEOF
1804This file contains any messages produced by compilers while 1804This file contains any messages produced by compilers while
1805running configure, to aid debugging if configure makes a mistake. 1805running configure, to aid debugging if configure makes a mistake.
1806 1806
1807It was created by life $as_me 1.5.1, which was 1807It was created by life $as_me 1.5.2, which was
1808generated by GNU Autoconf 2.69. Invocation command line was 1808generated by GNU Autoconf 2.69. Invocation command line was
1809 1809
1810 $ $0 $@ 1810 $ $0 $@
@@ -4306,7 +4306,7 @@ fi
4306 4306
4307# Define the identity of the package. 4307# Define the identity of the package.
4308 PACKAGE='life' 4308 PACKAGE='life'
4309 VERSION='1.5.1' 4309 VERSION='1.5.2'
4310 4310
4311 4311
4312cat >>confdefs.h <<_ACEOF 4312cat >>confdefs.h <<_ACEOF
@@ -5057,7 +5057,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
5057# report actual input values of CONFIG_FILES etc. instead of their 5057# report actual input values of CONFIG_FILES etc. instead of their
5058# values after options handling. 5058# values after options handling.
5059ac_log=" 5059ac_log="
5060This file was extended by life $as_me 1.5.1, which was 5060This file was extended by life $as_me 1.5.2, which was
5061generated by GNU Autoconf 2.69. Invocation command line was 5061generated by GNU Autoconf 2.69. Invocation command line was
5062 5062
5063 CONFIG_FILES = $CONFIG_FILES 5063 CONFIG_FILES = $CONFIG_FILES
@@ -5123,7 +5123,7 @@ _ACEOF
5123cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 5123cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
5124ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" 5124ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
5125ac_cs_version="\\ 5125ac_cs_version="\\
5126life config.status 1.5.1 5126life config.status 1.5.2
5127configured by $0, generated by GNU Autoconf 2.69, 5127configured by $0, generated by GNU Autoconf 2.69,
5128 with options \\"\$ac_cs_config\\" 5128 with options \\"\$ac_cs_config\\"
5129 5129
diff --git a/configure.ac b/configure.ac
index 14d78b8..3174aa1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@
2# Process this file with autoconf to produce a configure script. 2# Process this file with autoconf to produce a configure script.
3 3
4AC_PREREQ([2.69]) 4AC_PREREQ([2.69])
5AC_INIT([life], [1.5.1], [aiden.woodruff@gmail.com]) 5AC_INIT([life], [1.5.2], [aiden.woodruff@gmail.com])
6AC_CONFIG_SRCDIR([life.c]) 6AC_CONFIG_SRCDIR([life.c])
7AC_CONFIG_HEADERS([config.h]) 7AC_CONFIG_HEADERS([config.h])
8 8
diff --git a/life-1.5.1.tar.gz b/life-1.5.1.tar.gz
deleted file mode 100644
index 5a4222e..0000000
--- a/life-1.5.1.tar.gz
+++ /dev/null
Binary files differ
diff --git a/life-1.5.2.tar.gz b/life-1.5.2.tar.gz
new file mode 100644
index 0000000..d631ed3
--- /dev/null
+++ b/life-1.5.2.tar.gz
Binary files differ
diff --git a/life-1.5.2.tar.gz.sig b/life-1.5.2.tar.gz.sig
new file mode 100644
index 0000000..f9b8200
--- /dev/null
+++ b/life-1.5.2.tar.gz.sig
Binary files differ
diff --git a/life-macros.h b/life-macros.h
new file mode 100644
index 0000000..32eb3f0
--- /dev/null
+++ b/life-macros.h
@@ -0,0 +1,10 @@
1#ifndef has
2#define has(var, bit) (((var) & (bit)) == (bit))
3#endif
4
5#ifndef foreach
6#define foreach(func, count, first,...) \
7 {typeof(first) things[] = {__VA_ARGS__}; \
8 func(first); \
9 for (int _i = 0; _i < count - 1; _i++) func(things[_i]);}
10#endif
diff --git a/life.c b/life.c
index 4c698b2..dafb8af 100644
--- a/life.c
+++ b/life.c
@@ -21,22 +21,11 @@
21 21
22#ifndef stat_bar_print 22#ifndef stat_bar_print
23// Print text to status bar in the nice way, without erasing or refreshing 23// Print text to status bar in the nice way, without erasing or refreshing
24#define stat_bar_print(win, fmt,...) \ 24#define stat_bar_print(win,...) \
25 wprintw(win, fmt, ##__VA_ARGS__); \ 25 wprintw(win, __VA_ARGS__); \
26 for (int _i = getcurx(win); _i < COLS; _i++) waddch(win, ' '); 26 for (int _i = getcurx(win); _i < COLS; _i++) waddch(win, ' ');
27#endif 27#endif
28 28
29#ifndef foreach
30#define foreach(func, count, first,...) \
31 {typeof(first) things[] = {__VA_ARGS__}; \
32 func(first); \
33 for (int _i = 0; _i < count - 1; _i++) func(things[_i]);}
34#endif
35
36#ifndef has
37#define has(var, bit) ((var & bit) == bit)
38#endif
39
40int main (int argc, char * argv[]) { 29int main (int argc, char * argv[]) {
41 unsigned int RULE = 0; 30 unsigned int RULE = 0;
42 struct gengetopt_args_info args_info; 31 struct gengetopt_args_info args_info;
diff --git a/life.h b/life.h
index ecde3aa..bad4815 100644
--- a/life.h
+++ b/life.h
@@ -29,6 +29,7 @@
29#include <ncurses.h> 29#include <ncurses.h>
30 30
31// Project Libraries 31// Project Libraries
32#include "life-macros.h"
32#include "cmdline-life.h" 33#include "cmdline-life.h"
33#include "updatemap.h" 34#include "updatemap.h"
34#include "menus.h" 35#include "menus.h"
diff --git a/menus.c b/menus.c
index 1c1414a..7c2abd8 100644
--- a/menus.c
+++ b/menus.c
@@ -19,10 +19,6 @@
19 */ 19 */
20#include "menus.h" 20#include "menus.h"
21 21
22#ifndef has
23#define has(var, bit) ((var & bit) == bit)
24#endif
25
26int print_copying_warranty (WINDOW * win) { 22int print_copying_warranty (WINDOW * win) {
27 const char * WARRANTY = " THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.\n EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.\n THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.\n SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION."; 23 const char * WARRANTY = " THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.\n EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.\n THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.\n SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.";
28 return waddstr(win, WARRANTY); 24 return waddstr(win, WARRANTY);
@@ -75,6 +71,7 @@ int fancy_rules (WINDOW * win, int ruleint, int speed) {
75 werase(win); 71 werase(win);
76 waddstr(win, "Press space to toggle buttons\n"); 72 waddstr(win, "Press space to toggle buttons\n");
77 wprintw(win, "Rule int: %d\n", ruleint); 73 wprintw(win, "Rule int: %d\n", ruleint);
74 waddstr(win, "B012345678/S012345678\n");
78 waddch(win, 'B'); 75 waddch(win, 'B');
79 for (int i = 0; i < 9; i++) { 76 for (int i = 0; i < 9; i++) {
80 if (cursor == i) { 77 if (cursor == i) {
@@ -157,13 +154,14 @@ int fancy_rules (WINDOW * win, int ruleint, int speed) {
157 } else if (ch == ' ' || ch == '\n') { 154 } else if (ch == ' ' || ch == '\n') {
158 switch (cursor) { 155 switch (cursor) {
159 case 18: 156 case 18:
160 return -1; 157 ruleint = -1;
158 done = TRUE;
161 break; 159 break;
162 case 19: 160 case 19:
163 ruleint = 6152; 161 ruleint = 6152;
164 break; 162 break;
165 case 20: 163 case 20:
166 return ruleint; 164 done = TRUE;
167 break; 165 break;
168 default: 166 default:
169 ruleint ^= 1 << cursor; 167 ruleint ^= 1 << cursor;
@@ -174,5 +172,5 @@ int fancy_rules (WINDOW * win, int ruleint, int speed) {
174 ch = wgetch(win); 172 ch = wgetch(win);
175 } 173 }
176 } 174 }
177 ch = 0; 175 return ruleint;
178} 176}
diff --git a/menus.h b/menus.h
index ad385e2..26da8f5 100644
--- a/menus.h
+++ b/menus.h
@@ -23,6 +23,8 @@
23 23
24#include <ncurses.h> 24#include <ncurses.h>
25 25
26#include "life-macros.h"
27
26#ifndef LIFE_MENUS_H_ 28#ifndef LIFE_MENUS_H_
27#define LIFE_MENUS_H_ 29#define LIFE_MENUS_H_
28 30
diff --git a/updatemap.c b/updatemap.c
index d965a53..539def8 100644
--- a/updatemap.c
+++ b/updatemap.c
@@ -19,10 +19,6 @@
19 */ 19 */
20#include "updatemap.h" 20#include "updatemap.h"
21 21
22#ifndef has
23#define has(var, bit) ((var & bit) == bit)
24#endif
25
26char * update_map (char * base_map, const int width, const int height, char livecell, char deadcell, const unsigned int ruleint) { 22char * update_map (char * base_map, const int width, const int height, char livecell, char deadcell, const unsigned int ruleint) {
27 char * intermap = (char*) strndup(base_map, width * height); 23 char * intermap = (char*) strndup(base_map, width * height);
28 for (int i = 0, x = 0, y = 0, surround = 0; i < width*height; i++, surround = 0) { 24 for (int i = 0, x = 0, y = 0, surround = 0; i < width*height; i++, surround = 0) {
@@ -39,19 +35,19 @@ char * update_map (char * base_map, const int width, const int height, char live
39 if (x > 0) { 35 if (x > 0) {
40 if (base_map[i-1] == livecell) surround++; // B1 36 if (base_map[i-1] == livecell) surround++; // B1
41 if (y > 0) { 37 if (y > 0) {
42 if (base_map[i-width-1] == livecell) surround++; // A1 38 if (base_map[i-width-1] == livecell) surround++; // A1
43 } 39 }
44 if (y < height - 1) { 40 if (y < height - 1) {
45 if (base_map[i-1+width] == livecell) surround++; // C1 41 if (base_map[i-1+width] == livecell) surround++; // C1
46 } 42 }
47 } 43 }
48 if (x < width - 1) { 44 if (x < width - 1) {
49 if (base_map[i+1] == livecell) surround++; // B3 45 if (base_map[i+1] == livecell) surround++; // B3
50 if (y > 0) { 46 if (y > 0) {
51 if (base_map[i+1-width] == livecell) surround++; // A3 47 if (base_map[i+1-width] == livecell) surround++; // A3
52 } 48 }
53 if (y < height - 1) { 49 if (y < height - 1) {
54 if (base_map[i + 1 + width] == livecell) surround++; // C3 50 if (base_map[i + 1 + width] == livecell) surround++; // C3
55 } 51 }
56 } 52 }
57 if (y > 0) { 53 if (y > 0) {
@@ -62,11 +58,11 @@ char * update_map (char * base_map, const int width, const int height, char live
62 } 58 }
63 if (base_map[i] == deadcell) { 59 if (base_map[i] == deadcell) {
64 if (has(ruleint, 1 << surround)) { 60 if (has(ruleint, 1 << surround)) {
65 intermap[i] = livecell; 61 intermap[i] = livecell;
66 } 62 }
67 } else if (base_map[i] == livecell) { 63 } else if (base_map[i] == livecell) {
68 if (has(ruleint, 1 << surround + 9)) { 64 if (!has(ruleint, 1 << (surround + 9))) {
69 intermap[i] = deadcell; 65 intermap[i] = deadcell;
70 } 66 }
71 } 67 }
72 } 68 }
diff --git a/updatemap.h b/updatemap.h
index 32331b0..6773998 100644
--- a/updatemap.h
+++ b/updatemap.h
@@ -20,6 +20,8 @@
20#include <stdlib.h> 20#include <stdlib.h>
21#include <string.h> 21#include <string.h>
22 22
23#include "life-macros.h"
24
23#ifndef LIFE_UPDATEMAP_H_ 25#ifndef LIFE_UPDATEMAP_H_
24#define LIFE_UPDATEMAP_H_ 26#define LIFE_UPDATEMAP_H_
25 27