From: <enl...@li...> - 2002-04-05 02:13:19
|
Enlightenment CVS committal Author : mej Project : eterm Module : libast Dir : eterm/libast/src Modified Files: conf.c debug.c if.c linked_list.c mem.c msgs.c obj.c snprintf.c str.c strings.c tok.c Log Message: Thu Apr 4 21:13:01 2002 Michael Jennings (mej) Re-indenting code. =================================================================== RCS file: /cvsroot/enlightenment/eterm/libast/src/conf.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- conf.c 5 Apr 2002 01:47:01 -0000 1.2 +++ conf.c 5 Apr 2002 02:13:14 -0000 1.3 @@ -21,7 +21,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -static const char cvs_ident[] = "$Id: conf.c,v 1.2 2002/04/05 01:47:01 mej Exp $"; +static const char cvs_ident[] = "$Id: conf.c,v 1.3 2002/04/05 02:13:14 mej Exp $"; #ifdef HAVE_CONFIG_H # include <config.h> @@ -180,8 +180,7 @@ FREE(context); } -static conf_var_t * -conf_new_var(void) +static conf_var_t *conf_new_var(void) { conf_var_t *v; @@ -191,7 +190,7 @@ } static void -conf_free_var(conf_var_t * v) +conf_free_var(conf_var_t *v) { if (v->var) { FREE(v->var); =================================================================== RCS file: /cvsroot/enlightenment/eterm/libast/src/debug.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- debug.c 21 Jan 2002 23:05:00 -0000 1.1 +++ debug.c 5 Apr 2002 02:13:14 -0000 1.2 @@ -21,7 +21,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -static const char cvs_ident[] = "$Id: debug.c,v 1.1 2002/01/21 23:05:00 mej Exp $"; +static const char cvs_ident[] = "$Id: debug.c,v 1.2 2002/04/05 02:13:14 mej Exp $"; #ifdef HAVE_CONFIG_H # include <config.h> @@ -33,4 +33,3 @@ options parser can handle function pointers. */ unsigned int libast_debug_level = 0; unsigned long libast_debug_flags = 0; - =================================================================== RCS file: /cvsroot/enlightenment/eterm/libast/src/if.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- if.c 3 Mar 2002 06:47:48 -0000 1.1 +++ if.c 5 Apr 2002 02:13:14 -0000 1.2 @@ -21,11 +21,10 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -static const char cvs_ident[] = "$Id: if.c,v 1.1 2002/03/03 06:47:48 mej Exp $"; +static const char cvs_ident[] = "$Id: if.c,v 1.2 2002/04/05 02:13:14 mej Exp $"; #ifdef HAVE_CONFIG_H # include <config.h> #endif #include <libast_internal.h> - =================================================================== RCS file: /cvsroot/enlightenment/eterm/libast/src/linked_list.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- linked_list.c 5 Apr 2002 01:47:01 -0000 1.1 +++ linked_list.c 5 Apr 2002 02:13:14 -0000 1.2 @@ -21,7 +21,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -static const char cvs_ident[] = "$Id: linked_list.c,v 1.1 2002/04/05 01:47:01 mej Exp $"; +static const char cvs_ident[] = "$Id: linked_list.c,v 1.2 2002/04/05 02:13:14 mej Exp $"; #ifdef HAVE_CONFIG_H # include <config.h> @@ -56,30 +56,27 @@ static spif_obj_t spif_linked_list_remove_at(spif_linked_list_t, size_t); SPIF_DECL_IFCLASS(list, linked_list) = { - { - SPIF_DECL_CLASSNAME(linked_list), - (spif_newfunc_t) spif_linked_list_new, - (spif_memberfunc_t) spif_linked_list_init, - (spif_memberfunc_t) spif_linked_list_done, - (spif_memberfunc_t) spif_linked_list_del, - (spif_func_t) spif_linked_list_show, - (spif_func_t) spif_linked_list_comp, - (spif_func_t) spif_linked_list_dup, - (spif_func_t) spif_linked_list_type - }, - (spif_memberfunc_t) spif_linked_list_append, - (spif_memberfunc_t) spif_linked_list_contains, - (spif_memberfunc_t) spif_linked_list_count, - (spif_memberfunc_t) spif_linked_list_get, - (spif_memberfunc_t) spif_linked_list_index, - (spif_memberfunc_t) spif_linked_list_insert, - (spif_memberfunc_t) spif_linked_list_insert_at, - (spif_memberfunc_t) spif_linked_list_iterator, - (spif_memberfunc_t) spif_linked_list_next, - (spif_memberfunc_t) spif_linked_list_prepend, - (spif_memberfunc_t) spif_linked_list_remove, - (spif_memberfunc_t) spif_linked_list_remove_at -}; + { +SPIF_DECL_CLASSNAME(linked_list), + (spif_newfunc_t) spif_linked_list_new, + (spif_memberfunc_t) spif_linked_list_init, + (spif_memberfunc_t) spif_linked_list_done, + (spif_memberfunc_t) spif_linked_list_del, + (spif_func_t) spif_linked_list_show, + (spif_func_t) spif_linked_list_comp, + (spif_func_t) spif_linked_list_dup, + (spif_func_t) spif_linked_list_type}, + (spif_memberfunc_t) spif_linked_list_append, + (spif_memberfunc_t) spif_linked_list_contains, + (spif_memberfunc_t) spif_linked_list_count, + (spif_memberfunc_t) spif_linked_list_get, + (spif_memberfunc_t) spif_linked_list_index, + (spif_memberfunc_t) spif_linked_list_insert, + (spif_memberfunc_t) spif_linked_list_insert_at, + (spif_memberfunc_t) spif_linked_list_iterator, + (spif_memberfunc_t) spif_linked_list_next, + (spif_memberfunc_t) spif_linked_list_prepend, + (spif_memberfunc_t) spif_linked_list_remove, (spif_memberfunc_t) spif_linked_list_remove_at}; static spif_linked_list_item_t spif_linked_list_item_new(void) @@ -104,38 +101,38 @@ static spif_bool_t spif_linked_list_item_done(spif_linked_list_item_t self) { - /* FIXME: Should we destroy the data objects? */ - self->data = SPIF_NULL_TYPE(obj); - self->next = SPIF_NULL_TYPE(linked_list_item); - return TRUE; + /* FIXME: Should we destroy the data objects? */ + self->data = SPIF_NULL_TYPE(obj); + self->next = SPIF_NULL_TYPE(linked_list_item); + return TRUE; } static spif_bool_t spif_linked_list_item_del(spif_linked_list_item_t self) { - spif_linked_list_item_done(self); - SPIF_DEALLOC(self); - return TRUE; + spif_linked_list_item_done(self); + SPIF_DEALLOC(self); + return TRUE; } static spif_bool_t spif_linked_list_item_show(spif_linked_list_item_t self) { - USE_VAR(self); - return TRUE; + USE_VAR(self); + return TRUE; } static spif_obj_t spif_linked_list_item_get_data(spif_linked_list_item_t self) { - return (self->data); + return (self->data); } static spif_bool_t spif_linked_list_item_set_data(spif_linked_list_item_t self, spif_obj_t obj) { - self->data = obj; - return TRUE; + self->data = obj; + return TRUE; } static spif_linked_list_t @@ -161,95 +158,95 @@ static spif_bool_t spif_linked_list_done(spif_linked_list_t self) { - spif_linked_list_item_t current; + spif_linked_list_item_t current; - if (self->len) { - for (current = self->head; current; ) { - spif_linked_list_item_t tmp; - - tmp = current; - current = current->next; - spif_linked_list_item_del(tmp); + if (self->len) { + for (current = self->head; current;) { + spif_linked_list_item_t tmp; + + tmp = current; + current = current->next; + spif_linked_list_item_del(tmp); + } + self->len = 0; + self->head = SPIF_NULL_TYPE(linked_list_item); } - self->len = 0; - self->head = SPIF_NULL_TYPE(linked_list_item); - } - return TRUE; + return TRUE; } static spif_bool_t spif_linked_list_del(spif_linked_list_t self) { - spif_linked_list_done(self); - SPIF_DEALLOC(self); - return TRUE; + spif_linked_list_done(self); + SPIF_DEALLOC(self); + return TRUE; } static spif_bool_t spif_linked_list_show(spif_linked_list_t self) { - USE_VAR(self); - return TRUE; + USE_VAR(self); + return TRUE; } static spif_bool_t spif_linked_list_append(spif_linked_list_t self, spif_obj_t obj) { - spif_linked_list_item_t item, current; + spif_linked_list_item_t item, current; - /* Create list member object "item" */ - item = spif_linked_list_item_new(); - spif_linked_list_item_set_data(item, obj); - - /* Append "item" to the end of the list. */ - if (self->head) { - for (current = self->head; current->next; current = current->next); - current->next = item; - } else { - self->head = item; - } - item->next = SPIF_NULL_TYPE(linked_list_item); - self->len++; - return TRUE; + /* Create list member object "item" */ + item = spif_linked_list_item_new(); + spif_linked_list_item_set_data(item, obj); + + /* Append "item" to the end of the list. */ + if (self->head) { + for (current = self->head; current->next; current = current->next); + current->next = item; + } else { + self->head = item; + } + item->next = SPIF_NULL_TYPE(linked_list_item); + self->len++; + return TRUE; } static spif_bool_t spif_linked_list_contains(spif_linked_list_t self, spif_obj_t obj) { - spif_linked_list_item_t current; + spif_linked_list_item_t current; - for (current = self->head; current; current = current->next) { - if (spif_linked_list_item_get_data(current) == obj) { - return TRUE; + for (current = self->head; current; current = current->next) { + if (spif_linked_list_item_get_data(current) == obj) { + return TRUE; + } } - } - return FALSE; + return FALSE; } static size_t spif_linked_list_count(spif_linked_list_t self) { - return self->len; + return self->len; } static spif_obj_t spif_linked_list_get(spif_linked_list_t self, size_t idx) { - size_t i; - spif_linked_list_item_t current; + size_t i; + spif_linked_list_item_t current; - for (current = self->head, i = 0; current && i < idx; i++, current = current->next); - return (current ? (current->data) : SPIF_NULL_TYPE(obj)); + for (current = self->head, i = 0; current && i < idx; i++, current = current->next); + return (current ? (current->data) : SPIF_NULL_TYPE(obj)); } static size_t spif_linked_list_index(spif_linked_list_t self, spif_obj_t obj) { - size_t i; - spif_linked_list_item_t current; + size_t i; + spif_linked_list_item_t current; - for (current = self->head, i = 0; current && (current->data != obj); i++, current = current->next); - return (current ? i : ((size_t) (-1))); + for (current = self->head, i = 0; current && (current->data != obj); i++, current = current->next); + return (current ? i : ((size_t) (-1))); } static spif_bool_t =================================================================== RCS file: /cvsroot/enlightenment/eterm/libast/src/mem.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- mem.c 5 Apr 2002 01:47:01 -0000 1.2 +++ mem.c 5 Apr 2002 02:13:14 -0000 1.3 @@ -22,7 +22,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -static const char cvs_ident[] = "$Id: mem.c,v 1.2 2002/04/05 01:47:01 mej Exp $"; +static const char cvs_ident[] = "$Id: mem.c,v 1.3 2002/04/05 02:13:14 mej Exp $"; #ifdef HAVE_CONFIG_H # include <config.h> @@ -61,7 +61,7 @@ } static void -memrec_add_var(memrec_t * memrec, const char *filename, unsigned long line, void *ptr, size_t size) +memrec_add_var(memrec_t *memrec, const char *filename, unsigned long line, void *ptr, size_t size) { register ptr_t *p; @@ -80,8 +80,7 @@ p->line = line; } -static ptr_t * -memrec_find_var(memrec_t * memrec, const void *ptr) +static ptr_t *memrec_find_var(memrec_t *memrec, const void *ptr) { register ptr_t *p; register unsigned long i; @@ -99,7 +98,7 @@ } static void -memrec_rem_var(memrec_t * memrec, const char *var, const char *filename, unsigned long line, const void *ptr) +memrec_rem_var(memrec_t *memrec, const char *var, const char *filename, unsigned long line, const void *ptr) { register ptr_t *p; @@ -118,7 +117,7 @@ } static void -memrec_chg_var(memrec_t * memrec, const char *var, const char *filename, unsigned long line, const void *oldp, void *newp, size_t size) +memrec_chg_var(memrec_t *memrec, const char *var, const char *filename, unsigned long line, const void *oldp, void *newp, size_t size) { register ptr_t *p; @@ -137,7 +136,7 @@ } static void -memrec_dump_pointers(memrec_t * memrec) +memrec_dump_pointers(memrec_t *memrec) { register ptr_t *p; unsigned long i, j, k, l, total = 0; @@ -206,7 +205,7 @@ } static void -memrec_dump_resources(memrec_t * memrec) +memrec_dump_resources(memrec_t *memrec) { register ptr_t *p; unsigned long i, total; =================================================================== RCS file: /cvsroot/enlightenment/eterm/libast/src/msgs.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- msgs.c 21 Jan 2002 23:05:00 -0000 1.1 +++ msgs.c 5 Apr 2002 02:13:14 -0000 1.2 @@ -21,7 +21,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -static const char cvs_ident[] = "$Id: msgs.c,v 1.1 2002/01/21 23:05:00 mej Exp $"; +static const char cvs_ident[] = "$Id: msgs.c,v 1.2 2002/04/05 02:13:14 mej Exp $"; #ifdef HAVE_CONFIG_H # include <config.h> @@ -34,68 +34,67 @@ void libast_set_program_name(const char *progname) { - if (libast_program_name && strcmp(libast_program_name, PACKAGE)) { - FREE(libast_program_name); - } - libast_program_name = STRDUP(progname); + if (libast_program_name && strcmp(libast_program_name, PACKAGE)) { + FREE(libast_program_name); + } + libast_program_name = STRDUP(progname); } void libast_set_program_version(const char *progversion) { - if (libast_program_version && strcmp(libast_program_version, VERSION)) { - FREE(libast_program_version); - } - libast_program_version = STRDUP(progversion); + if (libast_program_version && strcmp(libast_program_version, VERSION)) { + FREE(libast_program_version); + } + libast_program_version = STRDUP(progversion); } int libast_dprintf(const char *format, ...) { - va_list args; - int n; + va_list args; + int n; - va_start(args, format); - n = vfprintf(LIBAST_DEBUG_FD, format, args); - va_end(args); - fflush(LIBAST_DEBUG_FD); - return (n); + va_start(args, format); + n = vfprintf(LIBAST_DEBUG_FD, format, args); + va_end(args); + fflush(LIBAST_DEBUG_FD); + return (n); } /* Print a non-terminal error message */ void print_error(const char *fmt, ...) { - va_list arg_ptr; + va_list arg_ptr; - va_start(arg_ptr, fmt); - fprintf(stderr, "%s: Error: ", libast_program_name); - vfprintf(stderr, fmt, arg_ptr); - va_end(arg_ptr); + va_start(arg_ptr, fmt); + fprintf(stderr, "%s: Error: ", libast_program_name); + vfprintf(stderr, fmt, arg_ptr); + va_end(arg_ptr); } /* Print a simple warning */ void print_warning(const char *fmt, ...) { - va_list arg_ptr; + va_list arg_ptr; - va_start(arg_ptr, fmt); - fprintf(stderr, "%s: Warning: ", libast_program_name); - vfprintf(stderr, fmt, arg_ptr); - va_end(arg_ptr); + va_start(arg_ptr, fmt); + fprintf(stderr, "%s: Warning: ", libast_program_name); + vfprintf(stderr, fmt, arg_ptr); + va_end(arg_ptr); } /* Print a fatal error message and terminate */ void fatal_error(const char *fmt, ...) { - va_list arg_ptr; + va_list arg_ptr; - va_start(arg_ptr, fmt); - fprintf(stderr, "%s: FATAL: ", libast_program_name); - vfprintf(stderr, fmt, arg_ptr); - va_end(arg_ptr); - exit(-1); + va_start(arg_ptr, fmt); + fprintf(stderr, "%s: FATAL: ", libast_program_name); + vfprintf(stderr, fmt, arg_ptr); + va_end(arg_ptr); + exit(-1); } - =================================================================== RCS file: /cvsroot/enlightenment/eterm/libast/src/obj.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- obj.c 5 Apr 2002 01:47:01 -0000 1.4 +++ obj.c 5 Apr 2002 02:13:14 -0000 1.5 @@ -21,7 +21,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -static const char cvs_ident[] = "$Id: obj.c,v 1.4 2002/04/05 01:47:01 mej Exp $"; +static const char cvs_ident[] = "$Id: obj.c,v 1.5 2002/04/05 02:13:14 mej Exp $"; #ifdef HAVE_CONFIG_H # include <config.h> @@ -30,16 +30,12 @@ #include <libast_internal.h> spif_const_class_t SPIF_CLASS_VAR(obj) = { - SPIF_DECL_CLASSNAME(obj), - (spif_newfunc_t) spif_obj_new, - (spif_memberfunc_t) spif_obj_init, - (spif_memberfunc_t) spif_obj_done, - (spif_memberfunc_t) spif_obj_del, - (spif_func_t) spif_obj_show, - (spif_func_t) spif_obj_comp, - (spif_func_t) spif_obj_dup, - (spif_func_t) spif_obj_type -}; +SPIF_DECL_CLASSNAME(obj), + (spif_newfunc_t) spif_obj_new, + (spif_memberfunc_t) spif_obj_init, + (spif_memberfunc_t) spif_obj_done, + (spif_memberfunc_t) spif_obj_del, + (spif_func_t) spif_obj_show, (spif_func_t) spif_obj_comp, (spif_func_t) spif_obj_dup, (spif_func_t) spif_obj_type}; spif_nullobj_t @@ -131,21 +127,21 @@ spif_cmp_t spif_obj_comp(spif_obj_t self, spif_obj_t other) { - return (self == other); + return (self == other); } spif_obj_t spif_obj_dup(spif_obj_t self) { - spif_obj_t tmp; + spif_obj_t tmp; - tmp = spif_obj_new(); - memcpy(tmp, self, SPIF_SIZEOF_TYPE(obj)); - return tmp; + tmp = spif_obj_new(); + memcpy(tmp, self, SPIF_SIZEOF_TYPE(obj)); + return tmp; } spif_classname_t spif_obj_type(spif_obj_t self) { - return (SPIF_CAST(classname) (self)); + return (SPIF_CAST(classname) (self)); } =================================================================== RCS file: /cvsroot/enlightenment/eterm/libast/src/snprintf.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- snprintf.c 21 Jan 2002 23:05:00 -0000 1.1 +++ snprintf.c 5 Apr 2002 02:13:14 -0000 1.2 @@ -7,7 +7,7 @@ # include <stdarg.h> #endif -static const char cvs_ident[] = "$Id: snprintf.c,v 1.1 2002/01/21 23:05:00 mej Exp $"; +static const char cvs_ident[] = "$Id: snprintf.c,v 1.2 2002/04/05 02:13:14 mej Exp $"; /* * Shamelessly snarfed from Enlightenment... @@ -23,7 +23,7 @@ #define VA_LOCAL_DECL va_list ap #define VA_START(f) va_start(ap, f) -#define VA_SHIFT(v,t) ; /* no-op for ANSI */ +#define VA_SHIFT(v,t) ; /* no-op for ANSI */ #define VA_END va_end(ap) /* @@ -32,10 +32,8 @@ static void dopr(char *buffer, const char *format, va_list args); static void fmtstr(char *value, int ljust, int len, int zpad, int precision); -static void fmtnum(long value, int base, int dosign, - int ljust, int len, int zpad, int precision); -static void fmtdouble(int fmt, double value, - int ljust, int len, int zpad, int precision); +static void fmtnum(long value, int base, int dosign, int ljust, int len, int zpad, int precision); +static void fmtdouble(int fmt, double value, int ljust, int len, int zpad, int precision); static void dostr(char *); static char *output; static void dopr_outch(int c); @@ -45,188 +43,187 @@ int vsnprintf(char *str, size_t count, const char *fmt, va_list args) { - str[0] = 0; - end = str + count - 1; - dopr(str, fmt, args); - if (count > 0) { - end[0] = 0; - } - return (strlen(str)); + str[0] = 0; + end = str + count - 1; + dopr(str, fmt, args); + if (count > 0) { + end[0] = 0; + } + return (strlen(str)); } #ifdef HAVE_STDARG_H int -snprintf(char *str, size_t count, const char *fmt,...) +snprintf(char *str, size_t count, const char *fmt, ...) #else int snprintf(va_alist) va_dcl - #endif { #ifndef HAVE_STDARG_H - char *str; - size_t count; - char *fmt; + char *str; + size_t count; + char *fmt; #endif - VA_LOCAL_DECL; + VA_LOCAL_DECL; - VA_START(fmt); - VA_SHIFT(str, char *); + VA_START(fmt); + VA_SHIFT(str, char *); - VA_SHIFT(count, size_t); - VA_SHIFT(fmt, char *); + VA_SHIFT(count, size_t); + VA_SHIFT(fmt, char *); - (void) vsnprintf(str, count, fmt, ap); - VA_END; - return (strlen(str)); + (void) vsnprintf(str, count, fmt, ap); + VA_END; + return (strlen(str)); } static void dopr(char *buffer, const char *format, va_list args) { - int ch; - long value; - int longflag = 0; - char *strvalue; - int ljust; - int len; - int zpad; - int precision; - int set_precision; - double dval; - - output = buffer; - while ((ch = *format++)) { - switch (ch) { - case '%': - ljust = len = zpad = 0; - precision = -1; - set_precision = 0; - nextch: - ch = *format++; - switch (ch) { - case 0: - dostr("**end of format**"); - return; - case '-': - ljust = 1; - goto nextch; - case '.': - set_precision = 1; - precision = 0; - goto nextch; - case '*': - len = va_arg(args, int); - - goto nextch; - case '0': /* set zero padding if len not set */ - if (len == 0 && set_precision == 0) - zpad = '0'; - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (set_precision) { - precision = precision * 10 + ch - '0'; - } else { - len = len * 10 + ch - '0'; - } - goto nextch; - case 'l': - longflag = 1; - goto nextch; - case 'u': - case 'U': - /*fmtnum(value,base,dosign,ljust,len, zpad, precision) */ - if (longflag) { - value = va_arg(args, long); - } else { - value = va_arg(args, int); - } - fmtnum(value, 10, 0, ljust, len, zpad, precision); - break; - case 'o': - case 'O': - /*fmtnum(value,base,dosign,ljust,len, zpad, precision) */ - if (longflag) { - value = va_arg(args, long); - } else { - value = va_arg(args, int); - } - fmtnum(value, 8, 0, ljust, len, zpad, precision); - break; - case 'd': - case 'i': - case 'D': - if (longflag) { - value = va_arg(args, long); - } else { - value = va_arg(args, int); - } - fmtnum(value, 10, 1, ljust, len, zpad, precision); - break; - case 'x': - if (longflag) { - value = va_arg(args, long); - } else { - value = va_arg(args, int); - } - fmtnum(value, 16, 0, ljust, len, zpad, precision); - break; - case 'X': - if (longflag) { - value = va_arg(args, long); - } else { - value = va_arg(args, int); - } - fmtnum(value, -16, 0, ljust, len, zpad, precision); - break; - case 's': - strvalue = va_arg(args, char *); - - fmtstr(strvalue, ljust, len, zpad, precision); - break; - case 'c': - ch = va_arg(args, int); - - { - char b[2]; - int vsb = visible_control; - - b[0] = ch; - b[1] = 0; - visible_control = 0; - fmtstr(b, ljust, len, zpad, precision); - visible_control = vsb; - } - break; - case 'f': - case 'g': - dval = va_arg(args, double); - - fmtdouble(ch, dval, ljust, len, zpad, precision); - break; - case '%': - dopr_outch(ch); - continue; - default: - dostr("???????"); - } - longflag = 0; - break; - default: - dopr_outch(ch); - break; + int ch; + long value; + int longflag = 0; + char *strvalue; + int ljust; + int len; + int zpad; + int precision; + int set_precision; + double dval; + + output = buffer; + while ((ch = *format++)) { + switch (ch) { + case '%': + ljust = len = zpad = 0; + precision = -1; + set_precision = 0; + nextch: + ch = *format++; + switch (ch) { + case 0: + dostr("**end of format**"); + return; + case '-': + ljust = 1; + goto nextch; + case '.': + set_precision = 1; + precision = 0; + goto nextch; + case '*': + len = va_arg(args, int); + + goto nextch; + case '0': /* set zero padding if len not set */ + if (len == 0 && set_precision == 0) + zpad = '0'; + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (set_precision) { + precision = precision * 10 + ch - '0'; + } else { + len = len * 10 + ch - '0'; + } + goto nextch; + case 'l': + longflag = 1; + goto nextch; + case 'u': + case 'U': + /*fmtnum(value,base,dosign,ljust,len, zpad, precision) */ + if (longflag) { + value = va_arg(args, long); + } else { + value = va_arg(args, int); + } + fmtnum(value, 10, 0, ljust, len, zpad, precision); + break; + case 'o': + case 'O': + /*fmtnum(value,base,dosign,ljust,len, zpad, precision) */ + if (longflag) { + value = va_arg(args, long); + } else { + value = va_arg(args, int); + } + fmtnum(value, 8, 0, ljust, len, zpad, precision); + break; + case 'd': + case 'i': + case 'D': + if (longflag) { + value = va_arg(args, long); + } else { + value = va_arg(args, int); + } + fmtnum(value, 10, 1, ljust, len, zpad, precision); + break; + case 'x': + if (longflag) { + value = va_arg(args, long); + } else { + value = va_arg(args, int); + } + fmtnum(value, 16, 0, ljust, len, zpad, precision); + break; + case 'X': + if (longflag) { + value = va_arg(args, long); + } else { + value = va_arg(args, int); + } + fmtnum(value, -16, 0, ljust, len, zpad, precision); + break; + case 's': + strvalue = va_arg(args, char *); + + fmtstr(strvalue, ljust, len, zpad, precision); + break; + case 'c': + ch = va_arg(args, int); + + { + char b[2]; + int vsb = visible_control; + + b[0] = ch; + b[1] = 0; + visible_control = 0; + fmtstr(b, ljust, len, zpad, precision); + visible_control = vsb; + } + break; + case 'f': + case 'g': + dval = va_arg(args, double); + + fmtdouble(ch, dval, ljust, len, zpad, precision); + break; + case '%': + dopr_outch(ch); + continue; + default: + dostr("???????"); + } + longflag = 0; + break; + default: + dopr_outch(ch); + break; + } } - } - *output = 0; + *output = 0; } /* @@ -238,157 +235,155 @@ static void fmtstr(char *value, int ljust, int len, int zpad, int precision) { - int padlen, strlen, i, c; /* amount to pad */ + int padlen, strlen, i, c; /* amount to pad */ - zpad = 0; - if (value == 0) { - value = "<NULL>"; - } - if (precision > 0) { - strlen = precision; - } else { - /* cheap strlen so you do not have library call */ - for (strlen = 0; (c = value[strlen]); ++strlen) { - if (visible_control && iscntrl(c) && !isspace(c)) { - ++strlen; - } - } - } - padlen = len - strlen; - if (padlen < 0) - padlen = 0; - if (ljust) - padlen = -padlen; - while (padlen > 0) { - dopr_outch(' '); - --padlen; - } - /* output characters */ - for (i = 0; (c = value[i]); ++i) { - if (visible_control && iscntrl(c) && !isspace(c)) { - dopr_outch('^'); - c = ('@' | (c & 0x1F)); - } - dopr_outch(c); - } - while (padlen < 0) { - dopr_outch(' '); - ++padlen; - } + zpad = 0; + if (value == 0) { + value = "<NULL>"; + } + if (precision > 0) { + strlen = precision; + } else { + /* cheap strlen so you do not have library call */ + for (strlen = 0; (c = value[strlen]); ++strlen) { + if (visible_control && iscntrl(c) && !isspace(c)) { + ++strlen; + } + } + } + padlen = len - strlen; + if (padlen < 0) + padlen = 0; + if (ljust) + padlen = -padlen; + while (padlen > 0) { + dopr_outch(' '); + --padlen; + } + /* output characters */ + for (i = 0; (c = value[i]); ++i) { + if (visible_control && iscntrl(c) && !isspace(c)) { + dopr_outch('^'); + c = ('@' | (c & 0x1F)); + } + dopr_outch(c); + } + while (padlen < 0) { + dopr_outch(' '); + ++padlen; + } } static void -fmtnum(long value, int base, int dosign, int ljust, - int len, int zpad, int precision) +fmtnum(long value, int base, int dosign, int ljust, int len, int zpad, int precision) { - int signvalue = 0; - unsigned long uvalue; - char convert[20]; - int place = 0; - int padlen = 0; /* amount to pad */ - int caps = 0; - - precision = 0; - /* DEBUGP(("value 0x%x, base %d, dosign %d, ljust %d, len %d, zpad %d\n", - * value, base, dosign, ljust, len, zpad )); */ - uvalue = value; - if (dosign) { - if (value < 0) { - signvalue = '-'; - uvalue = -value; - } - } - if (base < 0) { - caps = 1; - base = -base; - } - do { - convert[place++] = - (caps ? "0123456789ABCDEF" : "0123456789abcdef") - [uvalue % (unsigned) base]; - uvalue = (uvalue / (unsigned) base); - } - while (uvalue); - convert[place] = 0; - padlen = len - place; - if (padlen < 0) - padlen = 0; - if (ljust) - padlen = -padlen; - /* DEBUGP(( "str '%s', place %d, sign %c, padlen %d\n", - * convert,place,signvalue,padlen)); */ - if (zpad && padlen > 0) { - if (signvalue) { - dopr_outch(signvalue); - --padlen; - signvalue = 0; + int signvalue = 0; + unsigned long uvalue; + char convert[20]; + int place = 0; + int padlen = 0; /* amount to pad */ + int caps = 0; + + precision = 0; + /* DEBUGP(("value 0x%x, base %d, dosign %d, ljust %d, len %d, zpad %d\n", + * value, base, dosign, ljust, len, zpad )); */ + uvalue = value; + if (dosign) { + if (value < 0) { + signvalue = '-'; + uvalue = -value; + } + } + if (base < 0) { + caps = 1; + base = -base; + } + do { + convert[place++] = (caps ? "0123456789ABCDEF" : "0123456789abcdef") + [uvalue % (unsigned) base]; + uvalue = (uvalue / (unsigned) base); + } + while (uvalue); + convert[place] = 0; + padlen = len - place; + if (padlen < 0) + padlen = 0; + if (ljust) + padlen = -padlen; + /* DEBUGP(( "str '%s', place %d, sign %c, padlen %d\n", + * convert,place,signvalue,padlen)); */ + if (zpad && padlen > 0) { + if (signvalue) { + dopr_outch(signvalue); + --padlen; + signvalue = 0; + } + while (padlen > 0) { + dopr_outch(zpad); + --padlen; + } } while (padlen > 0) { - dopr_outch(zpad); - --padlen; + dopr_outch(' '); + --padlen; + } + if (signvalue) + dopr_outch(signvalue); + while (place > 0) + dopr_outch(convert[--place]); + while (padlen < 0) { + dopr_outch(' '); + ++padlen; } - } - while (padlen > 0) { - dopr_outch(' '); - --padlen; - } - if (signvalue) - dopr_outch(signvalue); - while (place > 0) - dopr_outch(convert[--place]); - while (padlen < 0) { - dopr_outch(' '); - ++padlen; - } } static void fmtdouble(int fmt, double value, int ljust, int len, int zpad, int precision) { - char convert[128]; - char fmtstr[128]; - int l; - - zpad = 0; - if (len == 0) - len = 10; - if (len > (int) sizeof(convert) - 10) { - len = (int) sizeof(convert) - 10; - } - if (precision > (int) sizeof(convert) - 10) { - precision = (int) sizeof(convert) - 10; - } - if (precision > len) - precision = len; - strcpy(fmtstr, "%"); - if (ljust) - strcat(fmtstr, "-"); - if (len) { - sprintf(fmtstr + strlen(fmtstr), "%d", len); - } - if (precision > 0) { - sprintf(fmtstr + strlen(fmtstr), ".%d", precision); - } - l = strlen(fmtstr); - fmtstr[l] = fmt; - fmtstr[l + 1] = 0; - sprintf(convert, fmtstr, value); - dostr(convert); + char convert[128]; + char fmtstr[128]; + int l; + + zpad = 0; + if (len == 0) + len = 10; + if (len > (int) sizeof(convert) - 10) { + len = (int) sizeof(convert) - 10; + } + if (precision > (int) sizeof(convert) - 10) { + precision = (int) sizeof(convert) - 10; + } + if (precision > len) + precision = len; + strcpy(fmtstr, "%"); + if (ljust) + strcat(fmtstr, "-"); + if (len) { + sprintf(fmtstr + strlen(fmtstr), "%d", len); + } + if (precision > 0) { + sprintf(fmtstr + strlen(fmtstr), ".%d", precision); + } + l = strlen(fmtstr); + fmtstr[l] = fmt; + fmtstr[l + 1] = 0; + sprintf(convert, fmtstr, value); + dostr(convert); } static void dostr(char *str) { - while (*str) - dopr_outch(*str++); + while (*str) + dopr_outch(*str++); } static void dopr_outch(int c) { - if (end == 0 || output < end) { - *output++ = c; - } + if (end == 0 || output < end) { + *output++ = c; + } } /************************************************************** =================================================================== RCS file: /cvsroot/enlightenment/eterm/libast/src/str.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- str.c 5 Apr 2002 01:47:01 -0000 1.5 +++ str.c 5 Apr 2002 02:13:14 -0000 1.6 @@ -21,7 +21,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -static const char cvs_ident[] = "$Id: str.c,v 1.5 2002/04/05 01:47:01 mej Exp $"; +static const char cvs_ident[] = "$Id: str.c,v 1.6 2002/04/05 02:13:14 mej Exp $"; #ifdef HAVE_CONFIG_H # include <config.h> @@ -30,16 +30,12 @@ #include <libast_internal.h> spif_const_class_t SPIF_CLASS_VAR(str) = { - SPIF_DECL_CLASSNAME(str), - (spif_newfunc_t) spif_str_new, - (spif_memberfunc_t) spif_str_init, - (spif_memberfunc_t) spif_str_done, - (spif_memberfunc_t) spif_str_del, - (spif_func_t) spif_str_show, - (spif_func_t) spif_str_cmp, - (spif_func_t) spif_str_dup, - (spif_func_t) spif_str_type -}; +SPIF_DECL_CLASSNAME(str), + (spif_newfunc_t) spif_str_new, + (spif_memberfunc_t) spif_str_init, + (spif_memberfunc_t) spif_str_done, + (spif_memberfunc_t) spif_str_del, + (spif_func_t) spif_str_show, (spif_func_t) spif_str_cmp, (spif_func_t) spif_str_dup, (spif_func_t) spif_str_type}; const size_t buff_inc = 4096; @@ -105,7 +101,7 @@ spif_str_init(spif_str_t self) { spif_obj_init(SPIF_OBJ(self)); - spif_obj_set_class(SPIF_OBJ(self), & SPIF_CLASS_VAR(str)); + spif_obj_set_class(SPIF_OBJ(self), &SPIF_CLASS_VAR(str)); self->s = SPIF_NULL_TYPE(charptr); self->len = 0; self->mem = 0; @@ -145,12 +141,9 @@ self->len = 0; self->s = SPIF_CAST(charptr) MALLOC(self->mem); - for (p = self->s; fgets(SPIF_CAST_C(char *) p, buff_inc, fp); p += buff_inc) { - if ((end = - SPIF_CAST(charptr) - strchr( - SPIF_CONST_CAST_C(char *) p, - '\n')) == NULL) { + for (p = self->s; fgets(SPIF_CAST_C(char *)p, buff_inc, fp); p += buff_inc) { + if ((end = SPIF_CAST(charptr) + strchr(SPIF_CONST_CAST_C(char *)p, '\n')) == NULL) { self->mem += buff_inc; self->s = SPIF_CAST(charptr) REALLOC(self->s, self->mem); } else { @@ -160,7 +153,7 @@ } self->len = (size_t) ((end) ? (end - self->s) - : ((int) strlen(SPIF_CONST_CAST_C(char *) self->s))); + : ((int) strlen(SPIF_CONST_CAST_C(char *)self->s))); self->mem = self->len + 1; self->s = SPIF_CAST(charptr) REALLOC(self->s, self->mem); return TRUE; @@ -216,75 +209,75 @@ spif_cmp_t spif_str_cmp(spif_str_t self, spif_str_t other) { - return SPIF_CMP_FROM_INT(strcmp(SPIF_CONST_CAST_C(char *) SPIF_STR_STR(self), SPIF_CONST_CAST_C(char *) SPIF_STR_STR(other))); + return SPIF_CMP_FROM_INT(strcmp(SPIF_CONST_CAST_C(char *) SPIF_STR_STR(self), SPIF_CONST_CAST_C(char *)SPIF_STR_STR(other))); } spif_cmp_t spif_str_cmp_with_ptr(spif_str_t self, spif_charptr_t other) { - return SPIF_CMP_FROM_INT(strcmp(SPIF_CONST_CAST_C(char *) SPIF_STR_STR(self), SPIF_CONST_CAST_C(char *) other)); + return SPIF_CMP_FROM_INT(strcmp(SPIF_CONST_CAST_C(char *) SPIF_STR_STR(self), SPIF_CONST_CAST_C(char *)other)); } spif_cmp_t spif_str_casecmp(spif_str_t self, spif_str_t other) { - return SPIF_CMP_FROM_INT(strcasecmp(SPIF_CONST_CAST_C(char *) SPIF_STR_STR(self), SPIF_CONST_CAST_C(char *) SPIF_STR_STR(other))); + return SPIF_CMP_FROM_INT(strcasecmp(SPIF_CONST_CAST_C(char *) SPIF_STR_STR(self), SPIF_CONST_CAST_C(char *)SPIF_STR_STR(other))); } spif_cmp_t spif_str_casecmp_with_ptr(spif_str_t self, spif_charptr_t other) { - return SPIF_CMP_FROM_INT(strcasecmp(SPIF_CONST_CAST_C(char *) SPIF_STR_STR(self), SPIF_CONST_CAST_C(char *) other)); + return SPIF_CMP_FROM_INT(strcasecmp(SPIF_CONST_CAST_C(char *) SPIF_STR_STR(self), SPIF_CONST_CAST_C(char *)other)); } spif_cmp_t spif_str_ncmp(spif_str_t self, spif_str_t other, size_t cnt) { - return SPIF_CMP_FROM_INT(strncmp(SPIF_CONST_CAST_C(char *) SPIF_STR_STR(self), SPIF_CONST_CAST_C(char *) SPIF_STR_STR(other), cnt)); + return SPIF_CMP_FROM_INT(strncmp(SPIF_CONST_CAST_C(char *) SPIF_STR_STR(self), SPIF_CONST_CAST_C(char *)SPIF_STR_STR(other), cnt)); } spif_cmp_t spif_str_ncmp_with_ptr(spif_str_t self, spif_charptr_t other, size_t cnt) { - return SPIF_CMP_FROM_INT(strncmp(SPIF_CONST_CAST_C(char *) SPIF_STR_STR(self), SPIF_CONST_CAST_C(char *) other, cnt)); + return SPIF_CMP_FROM_INT(strncmp(SPIF_CONST_CAST_C(char *) SPIF_STR_STR(self), SPIF_CONST_CAST_C(char *)other, cnt)); } spif_cmp_t spif_str_ncasecmp(spif_str_t self, spif_str_t other, size_t cnt) { - return SPIF_CMP_FROM_INT(strncasecmp(SPIF_CONST_CAST_C(char *) SPIF_STR_STR(self), SPIF_CONST_CAST_C(char *) SPIF_STR_STR(other), cnt)); + return SPIF_CMP_FROM_INT(strncasecmp(SPIF_CONST_CAST_C(char *) SPIF_STR_STR(self), SPIF_CONST_CAST_C(char *)SPIF_STR_STR(other), cnt)); } spif_cmp_t spif_str_ncasecmp_with_ptr(spif_str_t self, spif_charptr_t other, size_t cnt) { - return SPIF_CMP_FROM_INT(strncasecmp(SPIF_CONST_CAST_C(char *) SPIF_STR_STR(self), SPIF_CONST_CAST_C(char *) other, cnt)); + return SPIF_CMP_FROM_INT(strncasecmp(SPIF_CONST_CAST_C(char *) SPIF_STR_STR(self), SPIF_CONST_CAST_C(char *)other, cnt)); } size_t spif_str_index(spif_str_t self, spif_char_t c) { - return (size_t) ((int) (index(SPIF_CONST_CAST_C(char *) SPIF_STR_STR(self), c)) - (int) (SPIF_STR_STR(self))); + return (size_t) ((int) (index(SPIF_CONST_CAST_C(char *)SPIF_STR_STR(self), c)) - (int) (SPIF_STR_STR(self))); } size_t spif_str_rindex(spif_str_t self, spif_char_t c) { - return (size_t) ((int) (rindex(SPIF_CONST_CAST_C(char *) SPIF_STR_STR(self), c)) - (int) (SPIF_STR_STR(self))); + return (size_t) ((int) (rindex(SPIF_CONST_CAST_C(char *)SPIF_STR_STR(self), c)) - (int) (SPIF_STR_STR(self))); } size_t spif_str_find(spif_str_t self, spif_str_t other) { - return (size_t) ((int) (strstr(SPIF_CONST_CAST_C(char *) SPIF_STR_STR(self), - SPIF_CONST_CAST_C(char *) SPIF_STR_STR(other))) - (int) (SPIF_STR_STR(self))); + return (size_t) ((int) (strstr(SPIF_CONST_CAST_C(char *)SPIF_STR_STR(self), + SPIF_CONST_CAST_C(char *)SPIF_STR_STR(other))) - (int) (SPIF_STR_STR(self))); } size_t spif_str_find_from_ptr(spif_str_t self, spif_charptr_t other) { - return (size_t) ((int) (strstr(SPIF_CONST_CAST_C(char *) SPIF_STR_STR(self), - SPIF_CONST_CAST_C(char *) other)) - (int) (SPIF_STR_STR(self))); + return (size_t) ((int) (strstr(SPIF_CONST_CAST_C(char *)SPIF_STR_STR(self), + SPIF_CONST_CAST_C(char *)other)) - (int) (SPIF_STR_STR(self))); } spif_str_t @@ -313,7 +306,7 @@ double spif_str_to_float(spif_str_t self) { - return (double) (strtod(SPIF_CONST_CAST_C(char *) SPIF_STR_STR(self), (char **) NULL)); + return (double) (strtod(SPIF_CONST_CAST_C(char *)SPIF_STR_STR(self), (char **) NULL)); } spif_bool_t @@ -468,5 +461,5 @@ spif_classname_t spif_str_type(spif_str_t self) { - return (SPIF_CAST(classname) (self)); + return (SPIF_CAST(classname) (self)); } =================================================================== RCS file: /cvsroot/enlightenment/eterm/libast/src/strings.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- strings.c 5 Apr 2002 01:47:01 -0000 1.3 +++ strings.c 5 Apr 2002 02:13:14 -0000 1.4 @@ -21,7 +21,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -static const char cvs_ident[] = "$Id: strings.c,v 1.3 2002/04/05 01:47:01 mej Exp $"; +static const char cvs_ident[] = "$Id: strings.c,v 1.4 2002/04/05 02:13:14 mej Exp $"; #ifdef HAVE_CONFIG_H # include <config.h> @@ -173,7 +173,7 @@ } unsigned char -regexp_match_r(register const char *str, register const char *pattern, register regex_t ** rexp) +regexp_match_r(register const char *str, register const char *pattern, register regex_t **rexp) { register int result; char errbuf[256]; =================================================================== RCS file: /cvsroot/enlightenment/eterm/libast/src/tok.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- tok.c 5 Apr 2002 01:47:01 -0000 1.3 +++ tok.c 5 Apr 2002 02:13:14 -0000 1.4 @@ -21,7 +21,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -static const char cvs_ident[] = "$Id: tok.c,v 1.3 2002/04/05 01:47:01 mej Exp $"; +static const char cvs_ident[] = "$Id: tok.c,v 1.4 2002/04/05 02:13:14 mej Exp $"; #ifdef HAVE_CONFIG_H # include <config.h> @@ -30,16 +30,12 @@ #include <libast_internal.h> spif_const_class_t SPIF_CLASS_VAR(tok) = { - SPIF_DECL_CLASSNAME(tok), - (spif_newfunc_t) spif_tok_new, - (spif_memberfunc_t) spif_tok_init, - (spif_memberfunc_t) spif_tok_done, - (spif_memberfunc_t) spif_tok_del, - (spif_func_t) spif_tok_show, - (spif_func_t) spif_tok_comp, - (spif_func_t) spif_tok_dup, - (spif_func_t) spif_tok_type -}; +SPIF_DECL_CLASSNAME(tok), + (spif_newfunc_t) spif_tok_new, + (spif_memberfunc_t) spif_tok_init, + (spif_memberfunc_t) spif_tok_done, + (spif_memberfunc_t) spif_tok_del, + (spif_func_t) spif_tok_show, (spif_func_t) spif_tok_comp, (spif_func_t) spif_tok_dup, (spif_func_t) spif_tok_type}; spif_tok_t @@ -94,7 +90,7 @@ spif_tok_init(spif_tok_t self) { spif_str_init(SPIF_STR(self)); - spif_obj_set_class(SPIF_OBJ(self), & SPIF_CLASS_VAR(tok)); + spif_obj_set_class(SPIF_OBJ(self), &SPIF_CLASS_VAR(tok)); self->count = 0; self->token = ((spif_str_t *) (NULL)); self->sep = SPIF_NULL_TYPE(str); @@ -105,7 +101,7 @@ spif_tok_init_from_ptr(spif_tok_t self, spif_charptr_t old) { spif_str_init_from_ptr(SPIF_STR(self), old); - spif_obj_set_class(SPIF_OBJ(self), & SPIF_CLASS_VAR(tok)); + spif_obj_set_class(SPIF_OBJ(self), &SPIF_CLASS_VAR(tok)); self->count = 0; self->token = ((spif_str_t *) (NULL)); self->sep = SPIF_NULL_TYPE(str); @@ -116,7 +112,7 @@ spif_tok_init_from_fp(spif_tok_t self, FILE * fp) { spif_str_init_from_fp(SPIF_STR(self), fp); - spif_obj_set_class(SPIF_OBJ(self), & SPIF_CLASS_VAR(tok)); + spif_obj_set_class(SPIF_OBJ(self), &SPIF_CLASS_VAR(tok)); self->count = 0; self->token = ((spif_str_t *) (NULL)); self->sep = SPIF_NULL_TYPE(str); @@ -127,7 +123,7 @@ spif_tok_init_from_fd(spif_tok_t self, int fd) { spif_str_init_from_fd(SPIF_STR(self), fd); - spif_obj_set_class(SPIF_OBJ(self), & SPIF_CLASS_VAR(tok)); + spif_obj_set_class(SPIF_OBJ(self), &SPIF_CLASS_VAR(tok)); self->count = 0; self->token = ((spif_str_t *) (NULL)); self->sep = SPIF_NULL_TYPE(str); @@ -257,31 +253,31 @@ spif_cmp_t spif_tok_comp(spif_tok_t self, spif_tok_t other) { - return spif_obj_comp(SPIF_OBJ(self), SPIF_OBJ(other)); + return spif_obj_comp(SPIF_OBJ(self), SPIF_OBJ(other)); } spif_tok_t spif_tok_dup(spif_tok_t self) { - spif_tok_t tmp; - spif_str_t tmp_str; - size_t i; - - tmp = spif_tok_new(); - tmp_str = spif_str_dup(SPIF_STR(self)); - memcpy(tmp, tmp_str, SPIF_SIZEOF_TYPE(str)); - tmp->count = self->count; - tmp->sep = spif_str_dup(SPIF_STR(self->sep)); - - tmp->token = (spif_str_t *) MALLOC(SPIF_SIZEOF_TYPE(str) * tmp->count); - for (i = 0; i < tmp->count; i++) { - tmp->token[i] = spif_str_dup(SPIF_STR(self->token[i])); - } - return tmp; + spif_tok_t tmp; + spif_str_t tmp_str; + size_t i; + + tmp = spif_tok_new(); + tmp_str = spif_str_dup(SPIF_STR(self)); + memcpy(tmp, tmp_str, SPIF_SIZEOF_TYPE(str)); + tmp->count = self->count; + tmp->sep = spif_str_dup(SPIF_STR(self->sep)); + + tmp->token = (spif_str_t *) MALLOC(SPIF_SIZEOF_TYPE(str) * tmp->count); + for (i = 0; i < tmp->count; i++) { + tmp->token[i] = spif_str_dup(SPIF_STR(self->token[i])); + } + return tmp; } spif_classname_t spif_tok_type(spif_tok_t self) { - return (SPIF_CAST(classname) (self)); + return (SPIF_CAST(classname) (self)); } |