changeset 7625:8f18f8a9c3ba

<Kaynato> ` sed -i -e \'s/long/int/g\' daoyu.c
author HackBot
date Fri, 29 Apr 2016 01:28:30 +0000
parents c803b6d4eaee
children 81cc75173638
files daoyu.c
diffstat 1 files changed, 40 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/daoyu.c	Fri Apr 29 01:27:51 2016 +0000
+++ b/daoyu.c	Fri Apr 29 01:28:30 2016 +0000
@@ -10,7 +10,7 @@
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
-*   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*   aint with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 /*
@@ -24,21 +24,21 @@
 #include <string.h>
 
 #define BITS_IN_BYTE	8
-#define BITS_IN_CELL 	(sizeof(unsigned long) * 8)
+#define BITS_IN_CELL 	(sizeof(unsigned int) * 8)
 #define INPUT_DELIMITER '@'
 
 typedef struct PATH
 {
 	struct PATH*	owner;						/* OWNER      PROGRAM */
 	struct PATH*	child;						/* CHILD      PROGRAM */
-	unsigned long*	prg_data;					/*		   DATA	      */
-	unsigned long	prg_allocbits;				/* OPEN	   DATA   BITS*/
-	unsigned long	prg_index;					/* INSTRUCTION POINTER*/
+	unsigned int*	prg_data;					/*		   DATA	      */
+	unsigned int	prg_allocbits;				/* OPEN	   DATA   BITS*/
+	unsigned int	prg_index;					/* INSTRUCTION POINTER*/
 	unsigned char	prg_level;					/* OPERATING   LEVEL  */
-	unsigned long	sel_length;					/* LENGTH OF SELECTION*/
-	unsigned long	sel_index;					/* INDEX  OF SELECTION*/
+	unsigned int	sel_length;					/* LENGTH OF SELECTION*/
+	unsigned int	sel_index;					/* INDEX  OF SELECTION*/
 	unsigned int    prg_floor;					/* FLOOR  OF PATH     */
-	unsigned long   prg_start;					/* START  OF RUNNING  */
+	unsigned int   prg_start;					/* START  OF RUNNING  */
 } Pathstrx;
 
 typedef Pathstrx* Path;
@@ -51,15 +51,15 @@
 char 			getInput();
 char 			algn(Path);
 char 			getChar(unsigned char);
-char*			bin(unsigned long);
+char*			bin(unsigned int);
 char*			str_dup(char *s);
-char*			l_to_str(unsigned long, unsigned char, unsigned char);
+char*			l_to_str(unsigned int, unsigned char, unsigned char);
 static void		skip();
-static void 	write_by_bit_index(Path, unsigned long, unsigned long, unsigned long);
+static void 	write_by_bit_index(Path, unsigned int, unsigned int, unsigned int);
 unsigned char 	getNybble(char);
-unsigned long 	read_by_bit_index(Path, unsigned long, unsigned long);
-unsigned long 	mask(int);
-unsigned long	ptwo_round(unsigned long);
+unsigned int 	read_by_bit_index(Path, unsigned int, unsigned int);
+unsigned int 	mask(int);
+unsigned int	ptwo_round(unsigned int);
 
 static unsigned char command = 0;
 static int doloop = 1;
@@ -117,7 +117,7 @@
 
 void interpret(char* input)
 {
-	unsigned long length = 0;										/* How many bytes in input 							*/
+	unsigned int length = 0;										/* How many bytes in input 							*/
 
 	/* Initialize path */
 	struct PATH newpath = NEW_PATH;
@@ -136,8 +136,8 @@
 	(dao->prg_allocbits) = length * 8;
 
 	/* Prevent zero-sized allocation */
-	if (length % sizeof(unsigned long) != 0)
-		length = sizeof(unsigned long);		
+	if (length % sizeof(unsigned int) != 0)
+		length = sizeof(unsigned int);		
 
 	/* Allocate bytes for data array */
 	if (((dao->prg_data) = calloc(length, 1)) == NULL)
@@ -164,10 +164,10 @@
 
 }
 
-unsigned long ptwo_round(unsigned long x)
+unsigned int ptwo_round(unsigned int x)
 {
-	unsigned long rounded = x;										/* Initialize bytes_alloc with the file_size value. */
-	unsigned long	shift = 0;										/* Shift for first one of file size for rounding    */
+	unsigned int rounded = x;										/* Initialize bytes_alloc with the file_size value. */
+	unsigned int	shift = 0;										/* Shift for first one of file size for rounding    */
 
 	while ((rounded >> 1) != 0)										/* Determine leftmost '1' bit of file size.		 	*/
 	{																/*													*/
@@ -214,7 +214,7 @@
     return d;                            /*Return new memory		*/
 }
 
-char* bin(unsigned long val) { return l_to_str(val, 32, 2); }
+char* bin(unsigned int val) { return l_to_str(val, 32, 2); }
 
 char getChar(unsigned char ch)
 {
@@ -222,7 +222,7 @@
 	return symbols[ch];
 }
 
-char* l_to_str(unsigned long val, unsigned char len, unsigned char radix)
+char* l_to_str(unsigned int val, unsigned char len, unsigned char radix)
 {
 	static char buf[32] = { '0' };
 	int i = 33;
@@ -259,12 +259,12 @@
 static void swaps(Path path)
 {
 	unsigned int i = 0;
-	unsigned long report = 0;
+	unsigned int report = 0;
 	levlim(1)
 	if (P_LEN == 1)	return;
 	if (P_LEN <= BITS_IN_CELL)
 	{
-		unsigned long half_len = P_LEN / 2;
+		unsigned int half_len = P_LEN / 2;
 		write_by_bit_index(path, P_IND, P_LEN, read_by_bit_index(path, P_IND, half_len) | (read_by_bit_index(path, P_IND + half_len, half_len) << half_len));
 		return;
 	}
@@ -303,8 +303,8 @@
 
 static void sifts(Path path)
 {
-	unsigned long write = P_IND;
-	unsigned long read = 0;
+	unsigned int write = P_IND;
+	unsigned int read = 0;
 	levlim(5)
 	while(write<P_ALC)
 	{
@@ -320,7 +320,7 @@
 
 static void execs(Path path, Path caller)
 {
-	unsigned long tempNum1 = 0;																/* Expedite calculation								*/
+	unsigned int tempNum1 = 0;																/* Expedite calculation								*/
 	levlim(8)																				/* Level operation checking							*/
 	P_RUNNING = path;																		/* Set running 										*/
 
@@ -334,7 +334,7 @@
 		memcpy(P_CHILD, &NEW_PATH, sizeof(struct PATH));									/* Copy over initialization data			 		*/
 		path->child->owner = path;															/* Set owner of this new Path 						*/
 		path->child->prg_floor = (path->prg_floor) + 1;										/* Set floor of this new Path 						*/
-		path->child->prg_data = calloc(1, sizeof(unsigned long));							/* Set data  of this new Path 						*/
+		path->child->prg_data = calloc(1, sizeof(unsigned int));							/* Set data  of this new Path 						*/
 	}
 
 	P_WRITTEN = P_CHILD;																	/* Set this as written on 							*/
@@ -403,7 +403,7 @@
 
 static void reads(Path path)
 {
-	long pos = P_IND;
+	int pos = P_IND;
 	levlim(6)
 	if (P_LEN < 8)
 	{
@@ -423,7 +423,7 @@
 		int report = read_by_bit_index(path, 0, 1);
 		if ((P_RUNNING->owner) != NULL)
 		{
-			unsigned long ownind = ((P_RUNNING->owner)->prg_index);
+			unsigned int ownind = ((P_RUNNING->owner)->prg_index);
 			write_by_bit_index(P_RUNNING->owner, (ownind) * 4, 4, report);
 		}
 		free(P_DATA);
@@ -485,8 +485,8 @@
 
 static void doalc(Path path)
 {
-	unsigned long new_cell_count = 0;
-	unsigned long* new_data_pointer = NULL;
+	unsigned int new_cell_count = 0;
+	unsigned int* new_data_pointer = NULL;
 	levlim(1)
 		P_ALC <<= 1;
 
@@ -495,19 +495,19 @@
 	else
 		new_cell_count = P_ALC / BITS_IN_BYTE;
 
-	new_cell_count /= sizeof(unsigned long);
+	new_cell_count /= sizeof(unsigned int);
 
-	if ((new_data_pointer = calloc(new_cell_count, sizeof(unsigned long))) == NULL)
+	if ((new_data_pointer = calloc(new_cell_count, sizeof(unsigned int))) == NULL)
 	{
-		printf("Error allocating %d bytes: ", new_cell_count * sizeof(unsigned long));
+		printf("Error allocating %d bytes: ", new_cell_count * sizeof(unsigned int));
 		perror("");
 		abort();
 	}
 
 	if (new_cell_count > 1)
-		memcpy(new_data_pointer, P_DATA, new_cell_count * sizeof(unsigned long) / 2);
+		memcpy(new_data_pointer, P_DATA, new_cell_count * sizeof(unsigned int) / 2);
 	else
-		memcpy(new_data_pointer, P_DATA, sizeof(unsigned long));
+		memcpy(new_data_pointer, P_DATA, sizeof(unsigned int));
 
 	P_DATA = new_data_pointer;
 
@@ -542,18 +542,18 @@
 	return P_IND % (P_LEN << 1) == 0;
 }
 
-unsigned long mask(int length)
+unsigned int mask(int length)
 {
 	if (length < BITS_IN_CELL)	return ((int)1 << length) - 1;
 	else			 			return 0xFFFFFFFF;
 }
 
-unsigned long read_by_bit_index(Path path, unsigned long i, unsigned long len)
+unsigned int read_by_bit_index(Path path, unsigned int i, unsigned int len)
 {
 	return (P_DATA[i / BITS_IN_CELL] >> (BITS_IN_CELL - (i % BITS_IN_CELL) - len)) & mask(len);
 }
 
-static void write_by_bit_index(Path path, unsigned long i, unsigned long len, unsigned long write)
+static void write_by_bit_index(Path path, unsigned int i, unsigned int len, unsigned int write)
 {
 	int shift = BITS_IN_CELL - (i % BITS_IN_CELL) - len;
 	if (len > BITS_IN_CELL) abort();