Mercurial > repo
changeset 7621:49eadf845bb9
<fizzie> ` sed -i -e \'s/long/int/g\' daoyu.c
author | HackBot |
---|---|
date | Fri, 29 Apr 2016 01:17:51 +0000 |
parents | e25bae38b003 |
children | 07e484728e5e |
files | daoyu.c |
diffstat | 1 files changed, 40 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/daoyu.c Fri Apr 29 01:10:49 2016 +0000 +++ b/daoyu.c Fri Apr 29 01:17:51 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/>. */ /* @@ -26,7 +26,7 @@ #define DEFAULT_INTERPRET_CELL_LENGTH 32 #define BITS_IN_BYTE 8 -#define BITS_IN_CELL (sizeof(unsigned long) * 8) +#define BITS_IN_CELL (sizeof(unsigned int) * 8) #define BYTE_MASK 0xff #define INPUT_DELIMITER '@' @@ -34,14 +34,14 @@ { 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; @@ -54,15 +54,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; @@ -120,7 +120,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; @@ -139,8 +139,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) @@ -167,10 +167,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. */ { /* */ @@ -217,7 +217,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) { @@ -225,7 +225,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; @@ -262,12 +262,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; } @@ -304,8 +304,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) { @@ -321,7 +321,7 @@ static void execs(Path path, Path caller) { /***************************************************************EXECUTION LOOP***************************************************************/ - unsigned long tempNum1 = 0; /* Expedite calculation */ + unsigned int tempNum1 = 0; /* Expedite calculation */ levlim(8) /* Level operation checking */ P_RUNNING = path; /* Set running */ @@ -335,7 +335,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 */ @@ -404,7 +404,7 @@ static void reads(Path path) { - long pos = P_IND; + int pos = P_IND; levlim(6) if (P_LEN < 8) { @@ -424,7 +424,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); @@ -486,8 +486,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; @@ -496,19 +496,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; @@ -543,18 +543,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();