1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339
|
Description: Fix 32/64-bit issues.
Forwarded: no
Author: Drake Wilson <drake@begriffli.ch>
Bug-Debian: http://bugs.debian.org/427360
Bug-Ubuntu: https://launchpad.net/bugs/307897
Index: VCS/defs.h
===================================================================
--- VCS.orig/defs.h 2015-12-29 01:58:36.779203509 +0100
+++ VCS/defs.h 2015-12-29 01:58:36.771203469 +0100
@@ -8,6 +8,7 @@
#define _defs_h_
#include <stdio.h>
+#include <stdint.h>
#include "gen.h"
/*
@@ -34,8 +35,8 @@
/* Pseudorandom number generators.
*/
typedef struct prng {
- unsigned long initial; /* initial seed value */
- unsigned long value; /* latest random value */
+ uint32_t initial; /* initial seed value */
+ uint32_t value; /* latest random value */
char shared; /* FALSE if independent sequence */
} prng;
@@ -65,8 +66,8 @@
*/
typedef struct solutioninfo {
actlist moves; /* the actual moves of the solution */
- unsigned long rndseed; /* the PRNG's initial seed */
- unsigned long flags; /* other flags (currently unused) */
+ uint32_t rndseed; /* the PRNG's initial seed */
+ uint32_t flags; /* other flags (currently unused) */
unsigned char rndslidedir; /* random slide's initial direction */
signed char stepping; /* the timer offset */
} solutioninfo;
@@ -189,7 +190,7 @@
int solutionsize; /* size of the saved solution data */
unsigned char *leveldata; /* the data defining the level */
unsigned char *solutiondata; /* the player's best solution so far */
- unsigned long levelhash; /* the level data's hash value */
+ uint32_t levelhash; /* the level data's hash value */
char const *unsolvable; /* why level is unsolvable, or NULL */
char name[256]; /* name of the level */
char passwd[256]; /* the level's password */
Index: VCS/fileio.c
===================================================================
--- VCS.orig/fileio.c 2015-12-29 01:58:36.779203509 +0100
+++ VCS/fileio.c 2015-12-29 01:58:36.775203489 +0100
@@ -242,7 +242,7 @@
/* Read one byte as an unsigned integer value.
*/
-int filereadint8(fileinfo *file, unsigned char *val8, char const *msg)
+int filereadint8(fileinfo *file, uint8_t *val8, char const *msg)
{
int byte;
@@ -255,7 +255,7 @@
/* Write one byte as an unsigned integer value.
*/
-int filewriteint8(fileinfo *file, unsigned char val8, char const *msg)
+int filewriteint8(fileinfo *file, uint8_t val8, char const *msg)
{
errno = 0;
if (fputc(val8, file->fp) != EOF)
@@ -265,7 +265,7 @@
/* Read two bytes as an unsigned integer value stored in little-endian.
*/
-int filereadint16(fileinfo *file, unsigned short *val16, char const *msg)
+int filereadint16(fileinfo *file, uint16_t *val16, char const *msg)
{
int byte;
@@ -282,7 +282,7 @@
/* Write two bytes as an unsigned integer value in little-endian.
*/
-int filewriteint16(fileinfo *file, unsigned short val16, char const *msg)
+int filewriteint16(fileinfo *file, uint16_t val16, char const *msg)
{
errno = 0;
if (fputc(val16 & 0xFF, file->fp) != EOF
@@ -293,7 +293,7 @@
/* Read four bytes as an unsigned integer value stored in little-endian.
*/
-int filereadint32(fileinfo *file, unsigned long *val32, char const *msg)
+int filereadint32(fileinfo *file, uint32_t *val32, char const *msg)
{
int byte;
@@ -316,7 +316,7 @@
/* Write four bytes as an unsigned integer value in little-endian.
*/
-int filewriteint32(fileinfo *file, unsigned long val32, char const *msg)
+int filewriteint32(fileinfo *file, uint32_t val32, char const *msg)
{
errno = 0;
if (fputc(val32 & 0xFF, file->fp) != EOF
Index: VCS/fileio.h
===================================================================
--- VCS.orig/fileio.h 2015-12-29 01:58:36.779203509 +0100
+++ VCS/fileio.h 2015-12-29 01:58:36.775203489 +0100
@@ -8,6 +8,7 @@
#define _fileio_h_
#include "defs.h"
+#include <stdint.h>
/* Reset a fileinfo structure to indicate no file.
*/
@@ -49,17 +50,17 @@
* from the current position in the given file. For the multi-byte
* values, the value is assumed to be stored in little-endian.
*/
-extern int filereadint8(fileinfo *file, unsigned char *val8,
+extern int filereadint8(fileinfo *file, uint8_t *val8,
char const *msg);
-extern int filewriteint8(fileinfo *file, unsigned char val8,
+extern int filewriteint8(fileinfo *file, uint8_t val8,
char const *msg);
-extern int filereadint16(fileinfo *file, unsigned short *val16,
+extern int filereadint16(fileinfo *file, uint16_t *val16,
char const *msg);
-extern int filewriteint16(fileinfo *file, unsigned short val16,
+extern int filewriteint16(fileinfo *file, uint16_t val16,
char const *msg);
-extern int filereadint32(fileinfo *file, unsigned long *val32,
+extern int filereadint32(fileinfo *file, uint32_t *val32,
char const *msg);
-extern int filewriteint32(fileinfo *file, unsigned long val32,
+extern int filewriteint32(fileinfo *file, uint32_t val32,
char const *msg);
/* Read size bytes from the given file and return the bytes in a
Index: VCS/oshw.h
===================================================================
--- VCS.orig/oshw.h 2015-12-29 01:58:36.779203509 +0100
+++ VCS/oshw.h 2015-12-29 01:58:36.775203489 +0100
@@ -131,7 +131,7 @@
/* The font provides special monospaced digit characters at 144-153.
*/
-enum { CHAR_MZERO = 144 };
+#define CHAR_MZERO ((char)144)
/*
* Video output functions.
Index: VCS/random.c
===================================================================
--- VCS.orig/random.c 2015-12-29 01:58:36.779203509 +0100
+++ VCS/random.c 2015-12-29 01:58:36.775203489 +0100
@@ -24,12 +24,12 @@
/* The most recently generated random number is stashed here, so that
* it can provide the initial seed of the next PRNG.
*/
-static unsigned long lastvalue = 0x80000000UL;
+static uint32_t lastvalue = 0x80000000UL;
/* The standard linear congruential random-number generator needs no
* introduction.
*/
-static unsigned long nextvalue(unsigned long value)
+static uint32_t nextvalue(uint32_t value)
{
return ((value * 1103515245UL) + 12345UL) & 0x7FFFFFFFUL;
}
@@ -67,7 +67,7 @@
/* Reset a PRNG to an independent sequence.
*/
-void restartprng(prng *gen, unsigned long seed)
+void restartprng(prng *gen, uint32_t seed)
{
gen->value = gen->initial = seed & 0x7FFFFFFFUL;
gen->shared = FALSE;
Index: VCS/random.h
===================================================================
--- VCS.orig/random.h 2015-12-29 01:58:36.779203509 +0100
+++ VCS/random.h 2015-12-29 01:58:36.775203489 +0100
@@ -19,7 +19,7 @@
/* Restart an existing PRNG upon a predetermined sequence.
*/
-extern void restartprng(prng *gen, unsigned long initial);
+extern void restartprng(prng *gen, uint32_t initial);
/* Retrieve the original seed value of the current sequence.
*/
Index: VCS/series.c
===================================================================
--- VCS.orig/series.c 2015-12-29 01:58:36.779203509 +0100
+++ VCS/series.c 2015-12-29 01:58:36.775203489 +0100
@@ -58,9 +58,9 @@
/* Calculate a hash value for the given block of data.
*/
-static unsigned long hashvalue(unsigned char const *data, unsigned int size)
+static uint32_t hashvalue(unsigned char const *data, unsigned int size)
{
- static unsigned long remainders[256] = {
+ static uint32_t remainders[256] = {
0x00000000, 0x04C11DB7, 0x09823B6E, 0x0D4326D9, 0x130476DC, 0x17C56B6B,
0x1A864DB2, 0x1E475005, 0x2608EDB8, 0x22C9F00F, 0x2F8AD6D6, 0x2B4BCB61,
0x350C9B64, 0x31CD86D3, 0x3C8EA00A, 0x384FBDBD, 0x4C11DB70, 0x48D0C6C7,
@@ -106,7 +106,7 @@
0xBCB4666D, 0xB8757BDA, 0xB5365D03, 0xB1F740B4
};
- unsigned long accum;
+ uint32_t accum;
unsigned int i, j;
for (j = 0, accum = 0xFFFFFFFFUL ; j < size ; ++j) {
@@ -125,7 +125,7 @@
*/
static int readseriesheader(gameseries *series)
{
- unsigned short val16;
+ uint16_t val16;
int ruleset;
if (!filereadint16(&series->mapfile, &val16, "not a valid data file"))
@@ -161,7 +161,7 @@
{
unsigned char *data;
unsigned char const *dataend;
- unsigned short size;
+ uint16_t size;
int n;
if (!filereadint16(file, &size, NULL))
@@ -469,7 +469,7 @@
fileinfo file;
seriesdata *sdata = (seriesdata*)data;
gameseries *series;
- unsigned long magic;
+ uint32_t magic;
char *datfilename;
int config, f;
Index: VCS/solution.c
===================================================================
--- VCS.orig/solution.c 2015-12-29 01:58:36.779203509 +0100
+++ VCS/solution.c 2015-12-29 01:58:36.775203489 +0100
@@ -8,6 +8,7 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
+#include <stdint.h>
#include "defs.h"
#include "err.h"
#include "fileio.h"
@@ -230,9 +231,9 @@
static int readsolutionheader(fileinfo *file, int ruleset, int *flags,
int *extrasize, unsigned char *extra)
{
- unsigned long sig;
- unsigned short f;
- unsigned char n;
+ uint32_t sig;
+ uint16_t f;
+ uint8_t n;
if (!filereadint32(file, &sig, "not a valid solution file"))
return FALSE;
@@ -489,7 +490,7 @@
*/
static int readsolution(fileinfo *file, gamesetup *game)
{
- unsigned long size;
+ uint32_t size;
game->number = 0;
game->sgflags = 0;
@@ -744,8 +745,8 @@
int loadsolutionsetname(char const *filename, char *buffer)
{
fileinfo file;
- unsigned long dwrd;
- unsigned short word;
+ uint32_t dwrd;
+ uint16_t word;
int size;
clearfileinfo(&file);
Index: VCS/unslist.c
===================================================================
--- VCS.orig/unslist.c 2015-12-29 01:58:36.779203509 +0100
+++ VCS/unslist.c 2015-12-29 01:58:36.775203489 +0100
@@ -22,7 +22,7 @@
int setid; /* the ID of the level set's name */
int levelnum; /* the level's number */
int size; /* the levels data's compressed size */
- unsigned long hashval; /* the levels data's hash value */
+ uint32_t hashval; /* the levels data's hash value */
int note; /* the entry's annotation ID, if any */
} unslistentry;
@@ -112,7 +112,7 @@
/* Add a new entry with the given data to the list.
*/
static int addtounslist(int setid, int levelnum,
- int size, unsigned long hashval, int note)
+ int size, uint32_t hashval, int note)
{
if (listcount == listallocated) {
listallocated = listallocated ? listallocated * 2 : 16;
@@ -152,8 +152,10 @@
{
char buf[256], token[256];
char const *p;
- unsigned long hashval;
- int setid, size;
+ uint32_t hashval;
+ unsigned long hashval_long;
+ int setid;
+ unsigned int size;
int lineno, levelnum, n;
setid = 0;
@@ -169,7 +171,8 @@
continue;
}
n = sscanf(p, "%d: %04X%08lX: %[^\n\r]",
- &levelnum, &size, &hashval, token);
+ &levelnum, &size, &hashval_long, token);
+ hashval = (uint32_t)hashval_long;
if (n > 0 && levelnum > 0 && levelnum < 65536 && setid) {
if (n == 1) {
n = sscanf(p, "%*d: %s", token);
|