From 36ff87c130ff7d8d875ba7339dfb197969f8fd21 Mon Sep 17 00:00:00 2001 From: Dale Weiler Date: Thu, 19 Apr 2012 18:03:30 -0400 Subject: [PATCH] Indentation --- assembler.c | 16 ++++++++-------- code.c | 46 +++++++++++++++++++++++----------------------- util.c | 29 ++++++++++++++--------------- 3 files changed, 45 insertions(+), 46 deletions(-) diff --git a/assembler.c b/assembler.c index c3cde36..e64fb9c 100644 --- a/assembler.c +++ b/assembler.c @@ -156,10 +156,10 @@ typedef struct { VECTOR_MAKE(globals, assembly_constants); void asm_clear() { - size_t i = 0; - for (; i < assembly_constants_elements; i++) - mem_d(assembly_constants_data[i].name); - mem_d(assembly_constants_data); + size_t i = 0; + for (; i < assembly_constants_elements; i++) + mem_d(assembly_constants_data[i].name); + mem_d(assembly_constants_data); } void asm_parse(FILE *fp) { @@ -210,7 +210,7 @@ void asm_parse(FILE *fp) { /* FLOAT */ DECLTYPE(asm_keys[0], { - //util_debug("ASM", "Constant FLOAT\n"); + //util_debug("ASM", "Constant FLOAT\n"); code_defs_add((prog_section_def){ .type = TYPE_FLOAT, .offset = offset_globals, /* global table */ @@ -222,7 +222,7 @@ void asm_parse(FILE *fp) { }); /* VECTOR */ DECLTYPE(asm_keys[1], { - //util_debug("ASM", "Constant VECTOR\n"); + //util_debug("ASM", "Constant VECTOR\n"); code_defs_add((prog_section_def){ .type = TYPE_FLOAT, .offset = offset_globals, /* global table */ @@ -239,7 +239,7 @@ void asm_parse(FILE *fp) { /* FIELD */ DECLTYPE(asm_keys[3], {util_debug("ASM", "Constant FIELD\n");}); /* STRING */ DECLTYPE(asm_keys[4], { - //util_debug("ASM", "Constant STRING\n"); + //util_debug("ASM", "Constant STRING\n"); code_defs_add((prog_section_def){ .type = TYPE_STRING, .offset = offset_globals, /* offset to offset in string table (for data)*/ @@ -249,7 +249,7 @@ void asm_parse(FILE *fp) { }); /* FUNCTION */ DECLTYPE(asm_keys[5], { - //util_debug("ASM", "Constant FUNCTION\n"); + //util_debug("ASM", "Constant FUNCTION\n"); /* TODO: parse */ if (state != ASM_NULL) { printf("%li: Error unfinished function block, expected DONE or RETURN\n", line); diff --git a/code.c b/code.c index ea4833f..4abd99b 100644 --- a/code.c +++ b/code.c @@ -81,12 +81,12 @@ VECTOR_MAKE(int, code_globals ); VECTOR_MAKE(char, code_chars ); int code_strings_add(const char *src) { - size_t size = strlen(src); - size_t iter = 0; - while (iter < size) - code_chars_add(src[iter++]); - code_chars_add('\0'); - return code_chars_elements; + size_t size = strlen(src); + size_t iter = 0; + while (iter < size) + code_chars_add(src[iter++]); + code_chars_add('\0'); + return code_chars_elements; } void code_init() { @@ -179,24 +179,24 @@ void code_write() { util_debug("GEN", "functions:\n"); size_t i = 0; for (; i < code_functions_elements; i++) { - util_debug("GEN", " {.entry =% 5d, .firstlocal =% 5d, .locals =% 5d, .profile =% 5d, .name =% 5d, .file =% 5d, .nargs =% 5d, .argsize =%0X }\n", - code_functions_data[i].entry, - code_functions_data[i].firstlocal, - code_functions_data[i].locals, - code_functions_data[i].profile, - code_functions_data[i].name, - code_functions_data[i].file, - code_functions_data[i].nargs, - *((int32_t*)&code_functions_data[i].argsize) - ); + util_debug("GEN", " {.entry =% 5d, .firstlocal =% 5d, .locals =% 5d, .profile =% 5d, .name =% 5d, .file =% 5d, .nargs =% 5d, .argsize =%0X }\n", + code_functions_data[i].entry, + code_functions_data[i].firstlocal, + code_functions_data[i].locals, + code_functions_data[i].profile, + code_functions_data[i].name, + code_functions_data[i].file, + code_functions_data[i].nargs, + *((int32_t*)&code_functions_data[i].argsize) + ); } - - mem_d(code_statements_data); - mem_d(code_defs_data); - mem_d(code_fields_data); - mem_d(code_functions_data); - mem_d(code_globals_data); - mem_d(code_chars_data); + + mem_d(code_statements_data); + mem_d(code_defs_data); + mem_d(code_fields_data); + mem_d(code_functions_data); + mem_d(code_globals_data); + mem_d(code_chars_data); fclose(fp); } diff --git a/util.c b/util.c index 8505697..d461720 100644 --- a/util.c +++ b/util.c @@ -150,24 +150,23 @@ void util_debug(const char *area, const char *ms, ...) { * certian-sized types like short or int. */ void util_endianswap(void *m, int s, int l) { - size_t w = 0; - size_t i = 0; - - /* ignore if we're already LE */ + size_t w = 0; + size_t i = 0; + + /* ignore if we're already LE */ if(*((char *)&s)) - return; - + return; + for(; w < l; w++) { - for(; i < s << 1; i++) { - unsigned char *p = (unsigned char *)m+w*s; - unsigned char t = p[i]; - p[i] = p[s-i-1]; - p[s-i-1] = t; - } - } + for(; i < s << 1; i++) { + unsigned char *p = (unsigned char *)m+w*s; + unsigned char t = p[i]; + p[i] = p[s-i-1]; + p[s-i-1] = t; + } + } } - /* * Implements libc getline for systems that don't have it, which is * assmed all. This works the same as getline(). @@ -198,7 +197,7 @@ int util_getline(char **lineptr, size_t *n, FILE *stream) { chr = *n + *lineptr - pos; strcpy(tmp,*lineptr); if (!(*lineptr = tmp)) { - mem_d (tmp); + mem_d (tmp); return -1; } pos = *n - chr + *lineptr; -- 2.39.2