From a86946850d08ae3271ee64ffcb35cfbbe40faf3b Mon Sep 17 00:00:00 2001 From: doursse Date: Fri, 11 Apr 2008 19:06:18 +0000 Subject: [PATCH] remove trailing spaces and add indent doc for vi SVN revision: 34246 --- legacy/embryo/src/bin/embryo_cc_prefix.c | 31 ++-- legacy/embryo/src/bin/embryo_cc_sc.h | 1 + legacy/embryo/src/bin/embryo_cc_sc1.c | 4 + legacy/embryo/src/bin/embryo_cc_sc2.c | 8 +- legacy/embryo/src/bin/embryo_cc_sc3.c | 6 +- legacy/embryo/src/bin/embryo_cc_sc4.c | 4 + legacy/embryo/src/bin/embryo_cc_sc5.c | 10 +- legacy/embryo/src/bin/embryo_cc_sc6.c | 4 + legacy/embryo/src/bin/embryo_cc_sc7.c | 4 + legacy/embryo/src/bin/embryo_cc_scexpand.c | 9 +- legacy/embryo/src/bin/embryo_cc_sclist.c | 4 + legacy/embryo/src/bin/embryo_cc_scvars.c | 6 +- legacy/embryo/src/lib/embryo_amx.c | 165 +++++++++++---------- legacy/embryo/src/lib/embryo_args.c | 13 +- legacy/embryo/src/lib/embryo_float.c | 27 ++-- legacy/embryo/src/lib/embryo_main.c | 14 +- legacy/embryo/src/lib/embryo_private.h | 12 +- legacy/embryo/src/lib/embryo_rand.c | 6 +- legacy/embryo/src/lib/embryo_str.c | 48 +++--- legacy/embryo/src/lib/embryo_time.c | 9 +- 20 files changed, 225 insertions(+), 160 deletions(-) diff --git a/legacy/embryo/src/bin/embryo_cc_prefix.c b/legacy/embryo/src/bin/embryo_cc_prefix.c index cd89baa033..dad6e3cdfd 100644 --- a/legacy/embryo/src/bin/embryo_cc_prefix.c +++ b/legacy/embryo/src/bin/embryo_cc_prefix.c @@ -1,8 +1,9 @@ /* * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 */ + #ifdef HAVE_CONFIG_H -# include "config.h" +# include #endif #include @@ -22,7 +23,7 @@ #include #include /* dlopen,dlclose,etc */ #ifdef HAVE_EVIL -# include /* for realpath */ +# include /* for realpath */ #else # include # include @@ -76,7 +77,7 @@ e_prefix_determine(char *argv0) else snprintf(buf, sizeof(buf), "%s/lib", _prefix_path); _prefix_path_lib = strdup(buf); - + if (getenv("E_DATA_DIR")) snprintf(buf, sizeof(buf), "%s/"SHARE_D, getenv("E_DATA_DIR")); else @@ -121,7 +122,7 @@ e_prefix_determine(char *argv0) _prefix_path_bin = strdup(buf); snprintf(buf, sizeof(buf), "%s/lib", _prefix_path); _prefix_path_lib = strdup(buf); - + /* check if AUTHORS file is there - then our guess is right */ snprintf(buf, sizeof(buf), "%s/"MAGIC_DAT, _prefix_path); if (stat(buf, &st) == 0) @@ -166,7 +167,7 @@ e_prefix_shutdown(void) E_FREE(_prefix_path_data); E_FREE(_prefix_path_lib); } - + void e_prefix_fallback(void) { @@ -207,18 +208,18 @@ _e_prefix_share_hunt(void) /* sometimes this isnt the case - so we need to do a more exhaustive search * through more parent and subdirs. hre is an example i have seen: - * + * * /blah/whatever/exec/bin/exe * -> * /blah/whatever/exec/bin * /blah/whatever/common/share/enlightenment * /blah/whatever/exec/lib */ - + /* this is pure black magic to try and find data shares */ /* 2. cache file doesn't exist or is invalid - we need to search - this is * where the real black magic begins */ - + /* BLACK MAGIC 1: * /blah/whatever/dir1/bin * /blah/whatever/dir2/share/enlightenment @@ -227,7 +228,7 @@ _e_prefix_share_hunt(void) { DIR *dirp; struct dirent *dp; - + snprintf(buf, sizeof(buf), "%s", _prefix_path); p = strrchr(buf, '/'); if (p) *p = 0; @@ -235,7 +236,7 @@ _e_prefix_share_hunt(void) if (dirp) { char *file; - + while ((dp = readdir(dirp))) { if ((strcmp(dp->d_name, ".")) && (strcmp(dp->d_name, ".."))) @@ -253,7 +254,7 @@ _e_prefix_share_hunt(void) closedir(dirp); } } - + /* BLACK MAGIC 2: * /blah/whatever/dir1/bin * /blah/whatever/share/enlightenment @@ -270,13 +271,13 @@ _e_prefix_share_hunt(void) _prefix_path_data = strdup(buf2); } } - + /* add more black magic as required as we discover weridnesss - remember * this is to save users having to set environment variables to tell * e where it lives, so e auto-adapts. so these code snippets are just * logic to figure that out for the user */ - + /* done. we found it - write cache file */ if (_prefix_path_data) { @@ -328,7 +329,7 @@ _e_prefix_try_proc(void) int len; char *p, mode[5] = ""; unsigned long ptr1 = 0, ptr2 = 0; - + len = strlen(buf); if (buf[len - 1] == '\n') { @@ -369,7 +370,7 @@ _e_prefix_try_argv(char *argv0) char *path, *p, *cp, *s; int len, lenexe; char buf[4096], buf2[4096], buf3[4096]; - + /* 1. is argv0 abs path? */ if (argv0[0] == '/') { diff --git a/legacy/embryo/src/bin/embryo_cc_sc.h b/legacy/embryo/src/bin/embryo_cc_sc.h index 491a48f349..53a4992ac0 100644 --- a/legacy/embryo/src/bin/embryo_cc_sc.h +++ b/legacy/embryo/src/bin/embryo_cc_sc.h @@ -27,6 +27,7 @@ * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. */ + #ifndef EMBRYO_CC_SC_H #define EMBRYO_CC_SC_H diff --git a/legacy/embryo/src/bin/embryo_cc_sc1.c b/legacy/embryo/src/bin/embryo_cc_sc1.c index 18fe267e97..d54d9d119c 100644 --- a/legacy/embryo/src/bin/embryo_cc_sc1.c +++ b/legacy/embryo/src/bin/embryo_cc_sc1.c @@ -24,6 +24,10 @@ * Version: $Id$ */ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ + #ifdef HAVE_CONFIG_H # include #endif diff --git a/legacy/embryo/src/bin/embryo_cc_sc2.c b/legacy/embryo/src/bin/embryo_cc_sc2.c index 60b2e47002..269b31ee8e 100644 --- a/legacy/embryo/src/bin/embryo_cc_sc2.c +++ b/legacy/embryo/src/bin/embryo_cc_sc2.c @@ -24,6 +24,10 @@ * Version: $Id$ */ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ + #ifdef HAVE_CONFIG_H # include #endif @@ -649,7 +653,7 @@ ftoi(cell * val, char *curptr) if (c1 != 0x00000000L) { - fprintf(stderr, + fprintf(stderr, "embryo_cc: WARNING! you compiler does not SEEM to interpret IEEE floating\n" "point math as embryo expects. this could be bad.\n" "\n" @@ -661,7 +665,7 @@ ftoi(cell * val, char *curptr) } else if (c2 != 0x42480000L) { - fprintf(stderr, + fprintf(stderr, "embryo_cc: WARNING! you compiler does not SEEM to interpret IEEE floating\n" "point math as embryo expects. This could be bad.\n" "\n" diff --git a/legacy/embryo/src/bin/embryo_cc_sc3.c b/legacy/embryo/src/bin/embryo_cc_sc3.c index 39499b0888..f10bb35487 100644 --- a/legacy/embryo/src/bin/embryo_cc_sc3.c +++ b/legacy/embryo/src/bin/embryo_cc_sc3.c @@ -21,6 +21,10 @@ * Version: $Id$ */ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ + #ifdef HAVE_CONFIG_H # include #endif @@ -2014,7 +2018,7 @@ callfunction(symbol * sym) /* * Dont need this warning - its varargs. there is no way of knowing the * required tag/type... - * + * if (!checktag(arg[argidx].tags,arg[argidx].numtags,lval.tag)) error(213); */ diff --git a/legacy/embryo/src/bin/embryo_cc_sc4.c b/legacy/embryo/src/bin/embryo_cc_sc4.c index 1f0dca6813..600112f2f3 100644 --- a/legacy/embryo/src/bin/embryo_cc_sc4.c +++ b/legacy/embryo/src/bin/embryo_cc_sc4.c @@ -21,6 +21,10 @@ * Version: $Id$ */ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ + #ifdef HAVE_CONFIG_H # include #endif diff --git a/legacy/embryo/src/bin/embryo_cc_sc5.c b/legacy/embryo/src/bin/embryo_cc_sc5.c index 367604be82..cc5fd4f0af 100644 --- a/legacy/embryo/src/bin/embryo_cc_sc5.c +++ b/legacy/embryo/src/bin/embryo_cc_sc5.c @@ -25,6 +25,10 @@ * Version: $Id$ */ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ + #ifdef HAVE_CONFIG_H # include #endif @@ -67,10 +71,10 @@ error(int number, ...) * the error reporting is enabled only in the second pass (and only when * actually producing output). Fatal errors may never be ignored. */ - if (((errflag) || (sc_status != statWRITE)) && + if (((errflag) || (sc_status != statWRITE)) && ((number < 100) || (number >= 200))) return 0; - + if (number < 100) { msg = errmsg[number - 1]; @@ -121,7 +125,7 @@ error(int number, ...) } /* if */ /* check whether we are seeing many errors on the same line */ - if (((errstart < 0) && (lastline != fline)) || + if (((errstart < 0) && (lastline != fline)) || (lastline < errstart) || (lastline > fline) || (fcurrent != lastfile)) errorcount = 0; lastline = fline; diff --git a/legacy/embryo/src/bin/embryo_cc_sc6.c b/legacy/embryo/src/bin/embryo_cc_sc6.c index ad3c5551d9..3c2fca2af0 100644 --- a/legacy/embryo/src/bin/embryo_cc_sc6.c +++ b/legacy/embryo/src/bin/embryo_cc_sc6.c @@ -21,6 +21,10 @@ * Version: $Id$ */ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ + #ifdef HAVE_CONFIG_H # include #endif diff --git a/legacy/embryo/src/bin/embryo_cc_sc7.c b/legacy/embryo/src/bin/embryo_cc_sc7.c index 67a7f1c2ae..7eecabbf7f 100644 --- a/legacy/embryo/src/bin/embryo_cc_sc7.c +++ b/legacy/embryo/src/bin/embryo_cc_sc7.c @@ -38,6 +38,10 @@ * Version: $Id$ */ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ + #ifdef HAVE_CONFIG_H # include #endif diff --git a/legacy/embryo/src/bin/embryo_cc_scexpand.c b/legacy/embryo/src/bin/embryo_cc_scexpand.c index cf07159d49..d72476522b 100644 --- a/legacy/embryo/src/bin/embryo_cc_scexpand.c +++ b/legacy/embryo/src/bin/embryo_cc_scexpand.c @@ -10,8 +10,11 @@ * Riemersma) to accept a string as input, instead of a * complete file. */ -#include -#include + +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ + #include "embryo_cc_sc.h" #define STACKSIZE 16 @@ -31,7 +34,7 @@ strexpand(char *dest, unsigned char *source, int maxlen, unsigned char pairtable c = stack[--top]; else if ((c = *(unsigned char *)source++) == '\0') break; - + /* Push pair on stack or output byte to the output string */ if (c > 127) { diff --git a/legacy/embryo/src/bin/embryo_cc_sclist.c b/legacy/embryo/src/bin/embryo_cc_sclist.c index ecefc7f7f2..957fc194bd 100644 --- a/legacy/embryo/src/bin/embryo_cc_sclist.c +++ b/legacy/embryo/src/bin/embryo_cc_sclist.c @@ -24,6 +24,10 @@ * Version: $Id$ */ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ + #ifdef HAVE_CONFIG_H # include #endif diff --git a/legacy/embryo/src/bin/embryo_cc_scvars.c b/legacy/embryo/src/bin/embryo_cc_scvars.c index 147f64713c..0fa802aee1 100644 --- a/legacy/embryo/src/bin/embryo_cc_scvars.c +++ b/legacy/embryo/src/bin/embryo_cc_scvars.c @@ -22,7 +22,11 @@ * * Version: $Id$ */ -#include + +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ + #include /* for _MAX_PATH */ #include "embryo_cc_sc.h" diff --git a/legacy/embryo/src/lib/embryo_amx.c b/legacy/embryo/src/lib/embryo_amx.c index d69908db22..8b4325ca42 100644 --- a/legacy/embryo/src/lib/embryo_amx.c +++ b/legacy/embryo/src/lib/embryo_amx.c @@ -19,6 +19,11 @@ * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. */ + +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ + #include "embryo_private.h" #define JUMPABS(base, ip) ((Embryo_Cell *)(code + (*ip))) @@ -37,7 +42,7 @@ static void _embryo_byte_swap_16(unsigned short *v) { unsigned char *s, t; - + s = (unsigned char *)v; t = s[0]; s[0] = s[1]; s[1] = t; } @@ -46,7 +51,7 @@ static void _embryo_byte_swap_32(unsigned int *v) { unsigned char *s, t; - + s = (unsigned char *)v; t = s[0]; s[0] = s[3]; s[3] = t; t = s[1]; s[1] = s[2]; s[2] = t; @@ -62,7 +67,7 @@ _embryo_native_call(Embryo_Program *ep, Embryo_Cell index, Embryo_Cell *result, hdr = (Embryo_Header *)ep->base; func_entry = GETENTRY(hdr, natives, index); - if ((func_entry->address <= 0) || + if ((func_entry->address <= 0) || (func_entry->address > ep->native_calls_size)) { ep->error = EMBRYO_ERROR_CALLBACK; @@ -84,11 +89,11 @@ _embryo_func_get(Embryo_Program *ep, int index, char *funcname) { Embryo_Header *hdr; Embryo_Func_Stub *func; - + hdr = (Embryo_Header *)ep->code; if (index >= (Embryo_Cell)NUMENTRIES(hdr, publics, natives)) return EMBRYO_ERROR_INDEX; - + func = GETENTRY(hdr, publics, index); strcpy(funcname, GETENTRYNAME(hdr, func)); return EMBRYO_ERROR_NONE; @@ -115,7 +120,7 @@ static int _embryo_program_init(Embryo_Program *ep, void *code) { Embryo_Header *hdr; - + if ((ep->flags & EMBRYO_FLAG_RELOC)) return 1; ep->code = (unsigned char *)code; hdr = (Embryo_Header *)ep->code; @@ -136,30 +141,30 @@ _embryo_program_init(Embryo_Program *ep, void *code) embryo_swap_32((unsigned int *)&hdr->tags); embryo_swap_32((unsigned int *)&hdr->nametable); #endif - + if (hdr->magic != EMBRYO_MAGIC) return 0; if ((hdr->file_version < MIN_FILE_VERSION) || (hdr->ep_version > CUR_FILE_VERSION)) return 0; - if ((hdr->defsize != sizeof(Embryo_Func_Stub)) && + if ((hdr->defsize != sizeof(Embryo_Func_Stub)) && (hdr->defsize != (2 * sizeof(unsigned int)))) return 0; if (hdr->defsize == (2 * sizeof(unsigned int))) { unsigned short *len; - + len = (unsigned short*)((unsigned char*)ep->code + hdr->nametable); #ifdef WORDS_BIGENDIAN embryo_swap_16((unsigned short *)len); -#endif +#endif if (*len > sNAMEMAX) return 0; } if (hdr->stp <= 0) return 0; if ((hdr->flags & EMBRYO_FLAG_COMPACT)) return 0; - + #ifdef WORDS_BIGENDIAN { Embryo_Func_Stub *fs; int i, num; - + /* also align all addresses in the public function, public variable and */ /* public tag tables */ fs = GETENTRY(hdr, publics, 0); @@ -169,7 +174,7 @@ _embryo_program_init(Embryo_Program *ep, void *code) embryo_swap_32(&(fs->address)); fs = (Embryo_Func_Stub *)((unsigned char *)fs + hdr->defsize); } - + fs = GETENTRY(hdr, pubvars, 0); num = NUMENTRIES(hdr, pubvars, tags); for (i = 0; i < num; i++) @@ -177,7 +182,7 @@ _embryo_program_init(Embryo_Program *ep, void *code) embryo_swap_32(&(fs->address)); fs = (Embryo_Func_Stub *)((unsigned char *)fs + hdr->defsize); } - + fs = GETENTRY(hdr, tags, 0); num = NUMENTRIES(hdr, tags, nametable); for (i = 0; i < num; i++) @@ -186,13 +191,13 @@ _embryo_program_init(Embryo_Program *ep, void *code) fs = (Embryo_Func_Stub *)((unsigned char *)fs + hdr->defsize); } } -#endif +#endif ep->flags = EMBRYO_FLAG_RELOC; { Embryo_Cell cip, code_size; Embryo_Cell *code; - + code_size = hdr->dat - hdr->cod; code = (Embryo_Cell *)((unsigned char *)ep->code + (int)hdr->cod); for (cip = 0; cip < (code_size / sizeof(Embryo_Cell)); cip++) @@ -203,7 +208,7 @@ _embryo_program_init(Embryo_Program *ep, void *code) #ifdef WORDS_BIGENDIAN embryo_swap_32(&(code[cip])); #endif - + } } /* init native api for handling floating point - default in embryo */ @@ -235,12 +240,12 @@ embryo_program_new(void *data, int size) { Embryo_Program *ep; void *code_data; - + if (size < (int)sizeof(Embryo_Header)) return NULL; - + ep = calloc(1, sizeof(Embryo_Program)); if (!ep) return NULL; - + code_data = malloc(size); if (!code_data) { @@ -255,7 +260,7 @@ embryo_program_new(void *data, int size) } /** - * Creates a new Embryo program, with bytecode data that cannot be + * Creates a new Embryo program, with bytecode data that cannot be * freed. * @param data Pointer to the bytecode of the program. * @param size Number of bytes of bytecode. @@ -266,12 +271,12 @@ EAPI Embryo_Program * embryo_program_const_new(void *data, int size) { Embryo_Program *ep; - + if (size < (int)sizeof(Embryo_Header)) return NULL; - + ep = calloc(1, sizeof(Embryo_Program)); if (!ep) return NULL; - + if (_embryo_program_init(ep, data)) { ep->dont_free_code = 1; @@ -296,7 +301,7 @@ embryo_program_load(char *file) FILE *f; void *program = NULL; int program_size = 0; - + f = fopen(file, "rb"); if (!f) return NULL; fseek(f, 0, SEEK_END); @@ -315,7 +320,7 @@ embryo_program_load(char *file) rewind(f); #ifdef WORDS_BIGENDIAN embryo_swap_32((unsigned int *)(&hdr.size)); -#endif +#endif if ((int)hdr.size < program_size) program_size = hdr.size; program = malloc(program_size); if (!program) @@ -344,7 +349,7 @@ EAPI void embryo_program_free(Embryo_Program *ep) { int i; - + if (ep->base) free(ep->base); if ((!ep->dont_free_code) && (ep->code)) free(ep->code); if (ep->native_calls) free(ep->native_calls); @@ -379,7 +384,7 @@ embryo_program_native_call_add(Embryo_Program *ep, const char *name, Embryo_Cell if ((ep == NULL ) || (name == NULL) || (func == NULL)) return; if (strlen(name) > sNAMEMAX) return; - + hdr = (Embryo_Header *)ep->code; if (hdr->defsize < 1) return; num = NUMENTRIES(hdr, natives, libraries); @@ -389,9 +394,9 @@ embryo_program_native_call_add(Embryo_Program *ep, const char *name, Embryo_Cell if (ep->native_calls_size > ep->native_calls_alloc) { Embryo_Native *calls; - + ep->native_calls_alloc += 16; - calls = realloc(ep->native_calls, + calls = realloc(ep->native_calls, ep->native_calls_alloc * sizeof(Embryo_Native)); if (!calls) { @@ -402,14 +407,14 @@ embryo_program_native_call_add(Embryo_Program *ep, const char *name, Embryo_Cell ep->native_calls = calls; } ep->native_calls[ep->native_calls_size - 1] = func; - + func_entry = GETENTRY(hdr, natives, 0); for (i = 0; i < num; i++) { if (func_entry->address == 0) { char *entry_name; - + entry_name = GETENTRYNAME(hdr, func_entry); if ((entry_name) && (!strcmp(entry_name, name))) { @@ -420,7 +425,7 @@ embryo_program_native_call_add(Embryo_Program *ep, const char *name, Embryo_Cell /* return; */ } } - func_entry = + func_entry = (Embryo_Func_Stub *)((unsigned char *)func_entry + hdr->defsize); } } @@ -453,12 +458,12 @@ EAPI void embryo_program_vm_reset(Embryo_Program *ep) { Embryo_Header *hdr; - + if ((!ep) || (!ep->base)) return; hdr = (Embryo_Header *)ep->code; memcpy(ep->base, hdr, hdr->size); *(Embryo_Cell *)(ep->base + (int)hdr->stp - sizeof(Embryo_Cell)) = 0; - + ep->hlw = hdr->hea - hdr->dat; /* stack and heap relative to data segment */ ep->stp = hdr->stp - hdr->dat - sizeof(Embryo_Cell); ep->hea = ep->hlw; @@ -549,7 +554,7 @@ embryo_swap_32(unsigned int *v) { #ifdef WORDS_BIGENDIAN _embryo_byte_swap_32(v); -#endif +#endif } /** @@ -642,14 +647,14 @@ EAPI int embryo_program_variable_count_get(Embryo_Program *ep) { Embryo_Header *hdr; - + if (!ep) return 0; if (!ep->base) return 0; hdr = (Embryo_Header *)ep->base; return NUMENTRIES(hdr, pubvars, tags); } -/** +/** * Retrieves the location of the public variable in the given program * with the given identifier. * @param ep The given program. @@ -664,7 +669,7 @@ embryo_program_variable_get(Embryo_Program *ep, int num) Embryo_Header *hdr; Embryo_Cell paddr; char pname[sNAMEMAX + 1]; - + if (!ep) return EMBRYO_CELL_NONE; if (!ep->base) return EMBRYO_CELL_NONE; hdr = (Embryo_Header *)ep->base; @@ -708,7 +713,7 @@ embryo_program_error_get(Embryo_Program *ep) /** * @defgroup Embryo_Program_Data_Group Program Data Functions * - * Functions that set and retrieve data associated with the given + * Functions that set and retrieve data associated with the given * program. */ @@ -799,7 +804,7 @@ embryo_data_string_length_get(Embryo_Program *ep, Embryo_Cell *str_cell) { int len; Embryo_Header *hdr; - + if ((!ep) || (!ep->base)) return 0; hdr = (Embryo_Header *)ep->base; if ((!str_cell) || @@ -822,7 +827,7 @@ embryo_data_string_get(Embryo_Program *ep, Embryo_Cell *str_cell, char *dst) { int i; Embryo_Header *hdr; - + if (!dst) return; if ((!ep) || (!ep->base)) { @@ -842,14 +847,14 @@ embryo_data_string_get(Embryo_Program *ep, Embryo_Cell *str_cell, char *dst) #ifdef WORDS_BIGENDIAN { Embryo_Cell tmp; - + tmp = str_cell[i]; _embryo_byte_swap_32(&tmp); dst[i] = tmp; } #else dst[i] = str_cell[i]; -#endif +#endif } dst[i] = 0; } @@ -867,7 +872,7 @@ embryo_data_string_set(Embryo_Program *ep, const char *src, Embryo_Cell *str_cel { int i; Embryo_Header *hdr; - + if (!ep) return; if (!ep->base) return; hdr = (Embryo_Header *)ep->base; @@ -891,14 +896,14 @@ embryo_data_string_set(Embryo_Program *ep, const char *src, Embryo_Cell *str_cel #ifdef WORDS_BIGENDIAN { Embryo_Cell tmp; - + tmp = src[i]; _embryo_byte_swap_32(&tmp); str_cell[i] = tmp; } #else str_cell[i] = src[i]; -#endif +#endif } str_cell[i] = 0; } @@ -916,7 +921,7 @@ embryo_data_address_get(Embryo_Program *ep, Embryo_Cell addr) { Embryo_Header *hdr; unsigned char *data; - + if ((!ep) || (!ep->base)) return NULL; hdr = (Embryo_Header *)ep->base; data = ep->base + (int)hdr->dat; @@ -1012,7 +1017,7 @@ embryo_program_recursion_get(Embryo_Program *ep) #endif /** - * Runs the given function of the given Embryo program in the current + * Runs the given function of the given Embryo program in the current * virtual machine. The parameter @p fn can be found using * @ref embryo_program_function_find. * @@ -1216,7 +1221,7 @@ embryo_program_run(Embryo_Program *ep, Embryo_Function fn) &&SWITCHTABLE_EMBRYO_OP_NONE, &&SWITCHTABLE_EMBRYO_OP_NONE, &&SWITCHTABLE_EMBRYO_OP_NONE, &&SWITCHTABLE_EMBRYO_OP_NONE, &&SWITCHTABLE_EMBRYO_OP_NONE, &&SWITCHTABLE_EMBRYO_OP_NONE, &&SWITCHTABLE_EMBRYO_OP_NONE, &&SWITCHTABLE_EMBRYO_OP_NONE, &&SWITCHTABLE_EMBRYO_OP_NONE }; -#endif +#endif if (!ep) return EMBRYO_PROGRAM_FAIL; if (!(ep->flags & EMBRYO_FLAG_RELOC)) { @@ -1234,7 +1239,7 @@ embryo_program_run(Embryo_Program *ep, Embryo_Function fn) /* FIXME: test C->vm->C->vm recursion more fully */ /* it seems to work... just fine!!! - strange! */ } - + /* set up the registers */ hdr = (Embryo_Header *)ep->base; codesize = (Embryo_UCell)(hdr->dat - hdr->cod); @@ -1290,17 +1295,17 @@ embryo_program_run(Embryo_Program *ep, Embryo_Function fn) if (fn != EMBRYO_FUNCTION_CONT) { int i; - + for (i = ep->params_size - 1; i >= 0; i--) { Embryo_Param *pr; - + pr = &(ep->params[i]); if (pr->string) { int len; Embryo_Cell ep_addr, *addr; - + len = strlen(pr->string); ep_addr = embryo_data_heap_push(ep, len + 1); if (ep_addr == EMBRYO_CELL_NONE) @@ -1323,7 +1328,7 @@ embryo_program_run(Embryo_Program *ep, Embryo_Function fn) { int len; Embryo_Cell ep_addr, *addr; - + len = pr->cell_array_size; ep_addr = embryo_data_heap_push(ep, len + 1); if (ep_addr == EMBRYO_CELL_NONE) @@ -1333,7 +1338,7 @@ embryo_program_run(Embryo_Program *ep, Embryo_Function fn) } addr = embryo_data_address_get(ep, ep_addr); if (addr) - memcpy(addr, pr->cell_array, + memcpy(addr, pr->cell_array, pr->cell_array_size * sizeof(Embryo_Cell)); else { @@ -1532,14 +1537,14 @@ embryo_program_run(Embryo_Program *ep, Embryo_Function fn) #ifdef WORDS_BIGENDIAN if ((size_t)offs < sizeof(Embryo_Cell)) pri ^= sizeof(Embryo_Cell) - offs; -#endif +#endif BREAK; CASE(EMBRYO_OP_ALIGN_ALT); GETPARAM(offs); #ifdef WORDS_BIGENDIAN if ((size_t)offs < sizeof(Embryo_Cell)) alt ^= sizeof(Embryo_Cell) - offs; -#endif +#endif BREAK; CASE(EMBRYO_OP_LCTRL); GETPARAM(offs); @@ -1968,8 +1973,8 @@ embryo_program_run(Embryo_Program *ep, Embryo_Function fn) GETPARAM(offs); CHKMEM(alt); CHKMEM(alt + offs); - for (i = (int)alt; - (size_t)offs >= sizeof(Embryo_Cell); + for (i = (int)alt; + (size_t)offs >= sizeof(Embryo_Cell); i += sizeof(Embryo_Cell), offs -= sizeof(Embryo_Cell)) *(Embryo_Cell *)(data + i) = pri; BREAK; @@ -2040,14 +2045,14 @@ embryo_program_run(Embryo_Program *ep, Embryo_Function fn) Embryo_Header *hdr; int i, num; Embryo_Func_Stub *func_entry; - + hdr = (Embryo_Header *)ep->code; num = NUMENTRIES(hdr, natives, libraries); func_entry = GETENTRY(hdr, natives, 0); for (i = 0; i < num; i++) { char *entry_name; - + entry_name = GETENTRYNAME(hdr, func_entry); if (i == offs) printf("EMBRYO: CALL [%i] %s() non-existant!\n", i, entry_name); @@ -2086,15 +2091,15 @@ embryo_program_run(Embryo_Program *ep, Embryo_Function fn) CASE(EMBRYO_OP_SWITCH); { Embryo_Cell *cptr; - + /* +1, to skip the "casetbl" opcode */ cptr = (Embryo_Cell *)(code + (*cip)) + 1; /* number of records in the case table */ num = (int)(*cptr); /* preset to "none-matched" case */ cip = (Embryo_Cell *)(code + *(cptr + 1)); - for (cptr += 2; - (num > 0) && (*cptr != pri); + for (cptr += 2; + (num > 0) && (*cptr != pri); num--, cptr += 2); /* case found */ if (num > 0) @@ -2128,7 +2133,7 @@ embryo_program_run(Embryo_Program *ep, Embryo_Function fn) #ifndef EMBRYO_EXEC_JUMPTABLE default: ABORT(ep, EMBRYO_ERROR_INVINSTR); -#endif +#endif SWITCHEND; } ep->max_run_cycles = max_run_cycles; @@ -2155,26 +2160,26 @@ embryo_program_return_value_get(Embryo_Program *ep) /** * Sets the maximum number of abstract machine cycles any given program run * can execute before being put to sleep and returning. - * + * * @param ep The given program. * @param max The number of machine cycles as a limit. - * + * * This sets the maximum number of abstract machine (virtual machine) * instructions that a single run of an embryo function (even if its main) * can use before embryo embryo_program_run() reutrns with the value * EMBRYO_PROGRAM_TOOLONG. If the function fully executes within this number - * of cycles, embryo_program_run() will return as normal with either + * of cycles, embryo_program_run() will return as normal with either * EMBRYO_PROGRAM_OK, EMBRYO_PROGRAM_FAIL or EMBRYO_PROGRAM_SLEEP. If the * run exceeds this instruction count, then EMBRYO_PROGRAM_TOOLONG will be * returned indicating the program exceeded its run count. If the app wishes * to continue running this anyway - it is free to process its own events or - * whatever it wants and continue the function by calling + * whatever it wants and continue the function by calling * embryo_program_run(program, EMBRYO_FUNCTION_CONT); which will start the * run again until the instruction count is reached. This can keep being done * to allow the calling program to still be able to control things outside the * embryo function being called. If the maximum run cycle count is 0 then the * program is allowed to run forever only returning when it is done. - * + * * It is important to note that abstract machine cycles are NOT the same as * the host machine cpu cycles. They are not fixed in runtime per cycle, so * this is more of a helper tool than a way to HARD-FORCE a script to only @@ -2188,16 +2193,16 @@ embryo_program_return_value_get(Embryo_Program *ep) * on how loaded the system is. Making the max cycle run too low will * impact performance requiring the abstract machine to do setup and teardown * cycles too often comapred to cycles actually executed. - * + * * Also note it does NOT include nested abstract machines. IF this abstract * machine run calls embryo script that calls a native function that in turn * calls more embryo script, then the 2nd (and so on) levels are not included * in this run count. They can set their own max instruction count values * separately. - * + * * The default max cycle run value is 0 in any program until set with this * function. - * + * * @ingroup Embryo_Run_Group */ EAPI void @@ -2212,12 +2217,12 @@ embryo_program_max_cycle_run_set(Embryo_Program *ep, int max) * Retreives the maximum number of abstract machine cycles a program is allowed * to run. * @param ep The given program. - * @return The number of cycles a run cycle is allowed to run for this + * @return The number of cycles a run cycle is allowed to run for this * program. - * + * * This returns the value set by embryo_program_max_cycle_run_set(). See * embryo_program_max_cycle_run_set() for more information. - * + * * @ingroup Embryo_Run_Group */ EAPI int @@ -2245,7 +2250,7 @@ EAPI int embryo_parameter_cell_push(Embryo_Program *ep, Embryo_Cell cell) { Embryo_Param *pr; - + ep->params_size++; if (ep->params_size > ep->params_alloc) { @@ -2276,7 +2281,7 @@ embryo_parameter_string_push(Embryo_Program *ep, const char *str) { Embryo_Param *pr; char *str_dup; - + if (!str) return embryo_parameter_string_push(ep, ""); str_dup = strdup(str); @@ -2316,7 +2321,7 @@ embryo_parameter_cell_array_push(Embryo_Program *ep, Embryo_Cell *cells, int num { Embryo_Param *pr; Embryo_Cell *cell_array; - + cell_array = malloc(num * sizeof(Embryo_Cell)); if ((!cells) || (num <= 0)) return embryo_parameter_cell_push(ep, 0); diff --git a/legacy/embryo/src/lib/embryo_args.c b/legacy/embryo/src/lib/embryo_args.c index cd0de560e8..b7456f4cce 100644 --- a/legacy/embryo/src/lib/embryo_args.c +++ b/legacy/embryo/src/lib/embryo_args.c @@ -1,6 +1,7 @@ /* * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 */ + #include "embryo_private.h" #define STRSET(ep, par, str) { \ @@ -17,10 +18,10 @@ _embryo_args_numargs(Embryo_Program *ep, Embryo_Cell *params __UNUSED__) Embryo_Header *hdr; unsigned char *data; Embryo_Cell bytes; - + hdr = (Embryo_Header *)ep->base; data = ep->base + (int)hdr->dat; - bytes = *(Embryo_Cell *)(data + (int)ep->frm + + bytes = *(Embryo_Cell *)(data + (int)ep->frm + (2 * sizeof(Embryo_Cell))); return bytes / sizeof(Embryo_Cell); } @@ -31,11 +32,11 @@ _embryo_args_getarg(Embryo_Program *ep, Embryo_Cell *params) Embryo_Header *hdr; unsigned char *data; Embryo_Cell val; - + if (params[0] != (2 * sizeof(Embryo_Cell))) return 0; hdr = (Embryo_Header *)ep->base; data = ep->base + (int)hdr->dat; - val = *(Embryo_Cell *)(data + (int)ep->frm + + val = *(Embryo_Cell *)(data + (int)ep->frm + (((int)params[1] + 3) * sizeof(Embryo_Cell))); val += params[2] * sizeof(Embryo_Cell); val = *(Embryo_Cell *)(data + (int)val); @@ -48,11 +49,11 @@ _embryo_args_setarg(Embryo_Program *ep, Embryo_Cell *params) Embryo_Header *hdr; unsigned char *data; Embryo_Cell val; - + if (params[0] != (3 * sizeof(Embryo_Cell))) return 0; hdr = (Embryo_Header *)ep->base; data = ep->base + (int)hdr->dat; - val = *(Embryo_Cell *)(data + (int)ep->frm + + val = *(Embryo_Cell *)(data + (int)ep->frm + (((int)params[1] + 3) * sizeof(Embryo_Cell))); val += params[2] * sizeof(Embryo_Cell); if ((val < 0) || ((val >= ep->hea) && (val < ep->stk))) return 0; diff --git a/legacy/embryo/src/lib/embryo_float.c b/legacy/embryo/src/lib/embryo_float.c index 12f0353c30..af241b6523 100644 --- a/legacy/embryo/src/lib/embryo_float.c +++ b/legacy/embryo/src/lib/embryo_float.c @@ -35,6 +35,11 @@ * E coding style. Added extra parameter checks. * Carsten Haitzler, */ + +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ + #include #include "embryo_private.h" @@ -64,7 +69,7 @@ _embryo_fp(Embryo_Program *ep __UNUSED__, Embryo_Cell *params) { /* params[1] = long value to convert to a float */ float f; - + if (params[0] != (1 * sizeof(Embryo_Cell))) return 0; f = (float)params[1]; return EMBRYO_FLOAT_TO_CELL(f); @@ -78,7 +83,7 @@ _embryo_fp_str(Embryo_Program *ep, Embryo_Cell *params) Embryo_Cell *str; float f; int len; - + if (params[0] != (1 * sizeof(Embryo_Cell))) return 0; str = embryo_data_address_get(ep, params[1]); len = embryo_data_string_length_get(ep, str); @@ -94,7 +99,7 @@ _embryo_fp_mul(Embryo_Program *ep __UNUSED__, Embryo_Cell *params) /* params[1] = float operand 1 */ /* params[2] = float operand 2 */ float f; - + if (params[0] != (2 * sizeof(Embryo_Cell))) return 0; f = EMBRYO_CELL_TO_FLOAT(params[1]) * EMBRYO_CELL_TO_FLOAT(params[2]); return EMBRYO_FLOAT_TO_CELL(f); @@ -106,7 +111,7 @@ _embryo_fp_div(Embryo_Program *ep __UNUSED__, Embryo_Cell *params) /* params[1] = float dividend (top) */ /* params[2] = float divisor (bottom) */ float f; - + if (params[0] != (2 * sizeof(Embryo_Cell))) return 0; f = EMBRYO_CELL_TO_FLOAT(params[1]) / EMBRYO_CELL_TO_FLOAT(params[2]); return EMBRYO_FLOAT_TO_CELL(f); @@ -118,7 +123,7 @@ _embryo_fp_add(Embryo_Program *ep __UNUSED__, Embryo_Cell *params) /* params[1] = float operand 1 */ /* params[2] = float operand 2 */ float f; - + if (params[0] != (2 * sizeof(Embryo_Cell))) return 0; f = EMBRYO_CELL_TO_FLOAT(params[1]) + EMBRYO_CELL_TO_FLOAT(params[2]); return EMBRYO_FLOAT_TO_CELL(f); @@ -130,7 +135,7 @@ _embryo_fp_sub(Embryo_Program *ep __UNUSED__, Embryo_Cell *params) /* params[1] = float operand 1 */ /* params[2] = float operand 2 */ float f; - + if (params[0] != (2 * sizeof(Embryo_Cell))) return 0; f = EMBRYO_CELL_TO_FLOAT(params[1]) - EMBRYO_CELL_TO_FLOAT(params[2]); return EMBRYO_FLOAT_TO_CELL(f); @@ -142,7 +147,7 @@ _embryo_fp_fract(Embryo_Program *ep __UNUSED__, Embryo_Cell *params) { /* params[1] = float operand */ float f; - + if (params[0] != (1 * sizeof(Embryo_Cell))) return 0; f = EMBRYO_CELL_TO_FLOAT(params[1]); f -= (float)(floor((double)f)); @@ -156,7 +161,7 @@ _embryo_fp_round(Embryo_Program *ep __UNUSED__, Embryo_Cell *params) /* params[1] = float operand */ /* params[2] = Type of rounding (cell) */ float f; - + if (params[0] != (2 * sizeof(Embryo_Cell))) return 0; f = EMBRYO_CELL_TO_FLOAT(params[1]); switch (params[2]) @@ -198,7 +203,7 @@ _embryo_fp_sqroot(Embryo_Program *ep, Embryo_Cell *params) { /* params[1] = float operand */ float f; - + if (params[0] != (1 * sizeof(Embryo_Cell))) return 0; f = EMBRYO_CELL_TO_FLOAT(params[1]); f = (float)sqrt(f); @@ -278,7 +283,7 @@ _embryo_fp_tan(Embryo_Program *ep __UNUSED__, Embryo_Cell *params) /* params[1] = float operand 1 (angle) */ /* params[2] = float operand 2 (radix) */ float f; - + if (params[0] != (2 * sizeof(Embryo_Cell))) return 0; f = EMBRYO_CELL_TO_FLOAT(params[1]); f = _embryo_fp_degrees_to_radians(f, params[2]); @@ -291,7 +296,7 @@ _embryo_fp_abs(Embryo_Program *ep __UNUSED__, Embryo_Cell *params) { /* params[1] = float operand */ float f; - + if (params[0] != (1 * sizeof(Embryo_Cell))) return 0; f = EMBRYO_CELL_TO_FLOAT(params[1]); f = (f >= 0) ? f : -f; diff --git a/legacy/embryo/src/lib/embryo_main.c b/legacy/embryo/src/lib/embryo_main.c index 1c0ee95413..48f5ba862e 100644 --- a/legacy/embryo/src/lib/embryo_main.c +++ b/legacy/embryo/src/lib/embryo_main.c @@ -1,3 +1,7 @@ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ + #include "embryo_private.h" #include @@ -11,20 +15,20 @@ static int _embryo_init_count = 0; * Functions that start up and shutdown the Embryo library. */ -/** +/** * Initialises the Embryo library. * @return The number of times the library has been initialised without being * shut down. * @ingroup Embryo_Library_Group - */ + */ EAPI int embryo_init(void) { _embryo_init_count++; if (_embryo_init_count > 1) return _embryo_init_count; - + srand(time(NULL)); - + return _embryo_init_count; } @@ -39,6 +43,6 @@ embryo_shutdown(void) { _embryo_init_count--; if (_embryo_init_count > 0) return _embryo_init_count; - + return _embryo_init_count; } diff --git a/legacy/embryo/src/lib/embryo_private.h b/legacy/embryo/src/lib/embryo_private.h index 6569ebabb0..4aa2413f51 100644 --- a/legacy/embryo/src/lib/embryo_private.h +++ b/legacy/embryo/src/lib/embryo_private.h @@ -269,19 +269,19 @@ struct _Embryo_Program Embryo_Native *native_calls; int native_calls_size; int native_calls_alloc; - + unsigned char *code; unsigned char dont_free_code : 1; Embryo_Cell retval; - + Embryo_Param *params; int params_size; int params_alloc; - + int run_count; - + int max_run_cycles; - + void *data; }; @@ -317,5 +317,5 @@ void _embryo_fp_init(Embryo_Program *ep); void _embryo_rand_init(Embryo_Program *ep); void _embryo_str_init(Embryo_Program *ep); void _embryo_time_init(Embryo_Program *ep); - + #endif diff --git a/legacy/embryo/src/lib/embryo_rand.c b/legacy/embryo/src/lib/embryo_rand.c index e04a5aef61..16025b73bf 100644 --- a/legacy/embryo/src/lib/embryo_rand.c +++ b/legacy/embryo/src/lib/embryo_rand.c @@ -1,3 +1,7 @@ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ + #include "embryo_private.h" /* exported random number api */ @@ -13,7 +17,7 @@ _embryo_rand_randf(Embryo_Program *ep __UNUSED__, Embryo_Cell *params __UNUSED__ { double r; float f; - + r = (double)(rand() & 0xffff) / 65535.0; f = (float)r; return EMBRYO_FLOAT_TO_CELL(f); diff --git a/legacy/embryo/src/lib/embryo_str.c b/legacy/embryo/src/lib/embryo_str.c index d98adefe12..fb31271284 100644 --- a/legacy/embryo/src/lib/embryo_str.c +++ b/legacy/embryo/src/lib/embryo_str.c @@ -1,3 +1,7 @@ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ + #include "embryo_private.h" #include @@ -22,7 +26,7 @@ static Embryo_Cell _embryo_str_atoi(Embryo_Program *ep, Embryo_Cell *params) { char *s1; - + /* params[1] = str */ if (params[0] != (1 * sizeof(Embryo_Cell))) return 0; STRGET(ep, s1, params[1]); @@ -34,7 +38,7 @@ static Embryo_Cell _embryo_str_fnmatch(Embryo_Program *ep, Embryo_Cell *params) { char *s1, *s2; - + /* params[1] = glob */ /* params[2] = str */ if (params[0] != (2 * sizeof(Embryo_Cell))) return 0; @@ -48,7 +52,7 @@ static Embryo_Cell _embryo_str_strcmp(Embryo_Program *ep, Embryo_Cell *params) { char *s1, *s2; - + /* params[1] = str1 */ /* params[2] = str2 */ if (params[0] != (2 * sizeof(Embryo_Cell))) return -1; @@ -62,7 +66,7 @@ static Embryo_Cell _embryo_str_strncmp(Embryo_Program *ep, Embryo_Cell *params) { char *s1, *s2; - + /* params[1] = str1 */ /* params[2] = str2 */ /* params[3] = n */ @@ -78,7 +82,7 @@ static Embryo_Cell _embryo_str_strcpy(Embryo_Program *ep, Embryo_Cell *params) { char *s1; - + /* params[1] = dst */ /* params[2] = str */ if (params[0] != (2 * sizeof(Embryo_Cell))) return 0; @@ -93,7 +97,7 @@ _embryo_str_strncpy(Embryo_Program *ep, Embryo_Cell *params) { char *s1; int l; - + /* params[1] = dst */ /* params[2] = str */ /* params[3] = n */ @@ -111,7 +115,7 @@ static Embryo_Cell _embryo_str_strlen(Embryo_Program *ep, Embryo_Cell *params) { char *s1; - + /* params[1] = str */ if (params[0] != (1 * sizeof(Embryo_Cell))) return 0; STRGET(ep, s1, params[1]); @@ -123,7 +127,7 @@ static Embryo_Cell _embryo_str_strcat(Embryo_Program *ep, Embryo_Cell *params) { char *s1, *s2, *s3; - + /* params[1] = dsr */ /* params[2] = str */ if (params[0] != (2 * sizeof(Embryo_Cell))) return 0; @@ -143,7 +147,7 @@ _embryo_str_strncat(Embryo_Program *ep, Embryo_Cell *params) { char *s1, *s2, *s3; int l1, l2; - + /* params[1] = dst */ /* params[2] = str */ /* params[3] = n */ @@ -167,7 +171,7 @@ static Embryo_Cell _embryo_str_strprep(Embryo_Program *ep, Embryo_Cell *params) { char *s1, *s2, *s3; - + /* params[1] = dst */ /* params[2] = str */ if (params[0] != (2 * sizeof(Embryo_Cell))) return 0; @@ -187,7 +191,7 @@ _embryo_str_strnprep(Embryo_Program *ep, Embryo_Cell *params) { char *s1, *s2, *s3; int l1, l2; - + /* params[1] = dst */ /* params[2] = str */ /* params[3] = n */ @@ -212,7 +216,7 @@ _embryo_str_strcut(Embryo_Program *ep, Embryo_Cell *params) { char *s1, *s2; int l1; - + /* params[1] = dst */ /* params[2] = str */ /* params[3] = n */ @@ -227,7 +231,7 @@ _embryo_str_strcut(Embryo_Program *ep, Embryo_Cell *params) if (params[4] >= l1) params[4] = l1; if (params[4] == params[3]) { - STRSET(ep, params[1], ""); + STRSET(ep, params[1], ""); return 0; } s2 = alloca(params[4] - params[3] + 1); @@ -245,7 +249,7 @@ _embryo_str_snprintf(Embryo_Program *ep, Embryo_Cell *params) int inesc = 0; int insub = 0; int p, pnum; - + /* params[1] = buf */ /* params[2] = bufsize */ /* params[3] = format_string */ @@ -273,7 +277,7 @@ _embryo_str_snprintf(Embryo_Program *ep, Embryo_Cell *params) else { Embryo_Cell *cptr; - + if (inesc) { switch (s1[i]) @@ -315,7 +319,7 @@ _embryo_str_snprintf(Embryo_Program *ep, Embryo_Cell *params) char fmt[10] = ""; char tmp[256] = ""; int l; - + if (s1[i] == 'i') strcpy(fmt, "%i"); else if (s1[i] == 'd') strcpy(fmt, "%d"); else if (s1[i] == 'x') strcpy(fmt, "%x"); @@ -338,7 +342,7 @@ _embryo_str_snprintf(Embryo_Program *ep, Embryo_Cell *params) { char tmp[256] = ""; int l; - + cptr = embryo_data_address_get(ep, params[4 + p]); if (cptr) snprintf(tmp, sizeof(tmp), "%f", (double)EMBRYO_CELL_TO_FLOAT(*cptr)); l = strlen(tmp); @@ -357,7 +361,7 @@ _embryo_str_snprintf(Embryo_Program *ep, Embryo_Cell *params) { char *tmp; int l; - + STRGET(ep, tmp, params[4 + p]); l = strlen(tmp); if ((o + l) > (params[2] - 1)) @@ -381,7 +385,7 @@ _embryo_str_snprintf(Embryo_Program *ep, Embryo_Cell *params) } } s2[o] = 0; - + STRSET(ep, params[1], s2); return o; } @@ -390,7 +394,7 @@ static Embryo_Cell _embryo_str_strstr(Embryo_Program *ep, Embryo_Cell *params) { char *s1, *s2, *p; - + /* params[1] = str */ /* params[2] = ndl */ if (params[0] != (2 * sizeof(Embryo_Cell))) return 0; @@ -406,7 +410,7 @@ static Embryo_Cell _embryo_str_strchr(Embryo_Program *ep, Embryo_Cell *params) { char *s1, *s2, *p; - + /* params[1] = str */ /* params[2] = ch */ if (params[0] != (2 * sizeof(Embryo_Cell))) return 0; @@ -421,7 +425,7 @@ static Embryo_Cell _embryo_str_strrchr(Embryo_Program *ep, Embryo_Cell *params) { char *s1, *s2, *p; - + /* params[1] = str */ /* params[2] = ch */ if (params[0] != (2 * sizeof(Embryo_Cell))) return 0; diff --git a/legacy/embryo/src/lib/embryo_time.c b/legacy/embryo/src/lib/embryo_time.c index beaa9b3a19..e0794c3bb8 100644 --- a/legacy/embryo/src/lib/embryo_time.c +++ b/legacy/embryo/src/lib/embryo_time.c @@ -1,6 +1,7 @@ /* * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 */ + #include "embryo_private.h" #include #include @@ -17,7 +18,7 @@ _embryo_time_seconds(Embryo_Program *ep __UNUSED__, Embryo_Cell *params __UNUSED struct timeval timev; double t; float f; - + gettimeofday(&timev, NULL); t = (double)(timev.tv_sec - ((timev.tv_sec / (60 * 60 * 24)) * (60 * 60 * 24))) + (((double)timev.tv_usec) / 1000000); @@ -31,7 +32,7 @@ _embryo_time_date(Embryo_Program *ep, Embryo_Cell *params) struct timeval timev; struct tm *tm; time_t tt; - + if (params[0] != (8 * sizeof(Embryo_Cell))) return 0; gettimeofday(&timev, NULL); tt = (time_t)(timev.tv_sec); @@ -41,7 +42,7 @@ _embryo_time_date(Embryo_Program *ep, Embryo_Cell *params) Embryo_Cell *cptr; double t; float f; - + cptr = embryo_data_address_get(ep, params[1]); if (cptr) *cptr = tm->tm_year + 1900; cptr = embryo_data_address_get(ep, params[2]); @@ -60,7 +61,7 @@ _embryo_time_date(Embryo_Program *ep, Embryo_Cell *params) t = (double)tm->tm_sec + (((double)timev.tv_usec) / 1000000); f = (float)t; if (cptr) *cptr = EMBRYO_FLOAT_TO_CELL(f); - + } return 0; }