fixed segfault
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>
Sun, 2 Nov 2014 18:32:12 +0000 (19:32 +0100)
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>
Sun, 2 Nov 2014 18:32:12 +0000 (19:32 +0100)
2048.c
debian/changelog
debian/control
debian/copyright
debian/files

diff --git a/2048.c b/2048.c
index 11692eb..820edbe 100644 (file)
--- a/2048.c
+++ b/2048.c
 
 #define REL_SCOREFILE "/.2048_highscore"
 #define REL_CONFFILE "/.2048_config"
+char * HOME;
+char * SCOREFILE;
+char * CONFFILE;
 uint32_t score=0;
 int highscore=0;
 int oldhighscore=0;
-char SCOREFILE[80];
-char CONFFILE[80];
 uint8_t blackwhite[] = {232,7,234,7,236,7,238,7,240,7,242,7,244,7,246,0,248,0,249,0,250,0,251,0,252,0,253,0,254,0,7,0};
 uint8_t original[] = {8,7,1,7,2,7,3,0,4,7,5,7,6,7,7,0,9,0,10,0,11,0,12,0,13,0,14,0,7,0,7,0};
 uint8_t bluered[] = {235,7,63,7,57,7,93,7,129,7,165,7,201,7,200,7,199,7,198,7,197,7,196,7,196,7,196,7,196,7,196,7};
@@ -66,7 +67,7 @@ void getColor(uint16_t value, char *color, size_t length) {
        foreground+=2;
       }
     }
-  snprintf(color,length,"\033[38;5;%d;48;5;%dm",*foreground,*background);
+  snprintf(color,length,"\e[31m\033[38;5;%d;48;5;%dm",*foreground,*background);
 }
 
 void drawBoard(uint16_t board[SIZE][SIZE]) {
@@ -388,18 +389,26 @@ int set_high_score(int score, int oldhighscore) {
 }
 
 int main(int argc, char *argv[]) {
+
+    
+
   uint16_t board[SIZE][SIZE];
   char c;
   char l = 0;
   size_t dashcount = 0;
   bool success;
   FILE *f = NULL;
-  scheme = original;
-  strcpy(SCOREFILE,"");  
-  strcat(SCOREFILE, getenv("HOME"));
-  strcpy(CONFFILE, SCOREFILE);
+  HOME = (char*)malloc(strlen(getenv("HOME")+1));
+  HOME=getenv("HOME");
+  SCOREFILE= (char*)malloc(strlen(HOME)+strlen(REL_SCOREFILE)+1);
+  CONFFILE= (char*)malloc(strlen(HOME)+strlen(REL_CONFFILE)+1);
+  strcpy(SCOREFILE, HOME);
+  strcpy(CONFFILE, HOME);
   strcat(SCOREFILE, REL_SCOREFILE);
   strcat(CONFFILE, REL_CONFFILE);
+
+  scheme = original;
+  
   f = fopen(CONFFILE, "r");
   if (!(NULL == f)) {
     fscanf(f, "%c", &l);
index b26bc0d..d2c3b76 100644 (file)
@@ -1,5 +1,5 @@
-2048 (1.0-1) UNRELEASED; urgency=low
+2048 (1.0-3) sid; urgency=low
 
-  * Initial release.
+  * Initial release. (Closes: #767414)
 
- -- Gabriel Perez-Cerezo <gpcf@gpcf.eu>  Thu, 30 Oct 2014 13:49:38 +0100
+ -- Gabriel Perez-Cerezo <gabriel@gpcf.eu>  Thu, 30 Oct 2014 13:49:38 +0100
index 7ba8db0..cb3433e 100644 (file)
@@ -1,5 +1,5 @@
 Source: 2048
-Maintainer: Gabriel Perez-Cerezo <gpcf@gpcf.eu>
+Maintainer: Gabriel Perez-Cerezo <gabriel@gpcf.eu>
 Section: games
 Priority: optional
 Homepage: http://en.gpcf.eu/2048
index 31490fa..22e470c 100644 (file)
@@ -1,9 +1,9 @@
 Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/  
 Upstream-Name: 2048
 
-Files: 2048.c
-Copyright: 2014 Maurits van der Schee
-License: MIT
+Files: *  
+Copyright: 2014 Gabriel Pérez-Cerezo <gabriel@gpcf.eu>  
+License: Expat
   Permission is hereby granted, free of charge, to any person obtaining a copy
   of this software and associated documentation files (the "Software"), to deal
   in the Software without restriction, including without limitation the rights
@@ -23,9 +23,9 @@ License: MIT
   SOFTWARE.
 
 
-Files: *  
-Copyright: 2014 Gabriel Pérez-Cerezo <gabriel@gpcf.eu>  
-License: MIT
+Files: 2048.c
+Copyright: 2014 Maurits van der Schee
+License: Expat
   Permission is hereby granted, free of charge, to any person obtaining a copy
   of this software and associated documentation files (the "Software"), to deal
   in the Software without restriction, including without limitation the rights
@@ -43,3 +43,4 @@ License: MIT
   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
   SOFTWARE.
+
index 50b171a..cc78b63 100644 (file)
@@ -1 +1 @@
-2048_1.0-1_i386.deb games optional
+2048_1.0-3_i386.deb games optional