Enlightenment CVS committal

Author  : mej
Project : eterm
Module  : libast

Dir     : eterm/libast/src


Modified Files:
        conf.c mem.c options.c str.c strings.c 


Log Message:
Fri Dec 12 22:01:42 2003                        Michael Jennings (mej)

Finished up namespace cleanups.

===================================================================
RCS file: /cvsroot/enlightenment/eterm/libast/src/conf.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -3 -r1.14 -r1.15
--- conf.c      27 Nov 2003 05:24:41 -0000      1.14
+++ conf.c      13 Dec 2003 03:02:19 -0000      1.15
@@ -31,7 +31,7 @@
  * @author Michael Jennings <[EMAIL PROTECTED]>
  */
 
-static const char cvs_ident[] = "$Id: conf.c,v 1.14 2003/11/27 05:24:41 mej Exp $";
+static const char cvs_ident[] = "$Id: conf.c,v 1.15 2003/12/13 03:02:19 mej Exp $";
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
@@ -292,11 +292,11 @@
         rseed = (unsigned int) (getpid() * time(NULL) % ((unsigned int) -1));
         srand(rseed);
     }
-    n = num_words(param);
+    n = spiftool_num_words(param);
     index = (int) (n * ((float) rand()) / (RAND_MAX + 1.0)) + 1;
     D_PARSE(("random index == %lu\n", index));
 
-    return (get_word(index, param));
+    return (spiftool_get_word(index, param));
 }
 
 static char *
@@ -335,7 +335,7 @@
             Output[fsize] = 0;
             fclose(fp);
             remove(OutFile);
-            Output = condense_whitespace(Output);
+            Output = spiftool_condense_whitespace(Output);
         } else {
             libast_print_warning("Command at line %lu of file %s returned no 
output.\n", file_peek_line(), file_peek_path());
         }
@@ -353,16 +353,16 @@
     char *s, *f, *v;
     unsigned short n;
 
-    if (!param || ((n = num_words(param)) > 2)) {
+    if (!param || ((n = spiftool_num_words(param)) > 2)) {
         libast_print_error("Parse error in file %s, line %lu:  Invalid syntax for 
%get().  Syntax is:  %get(variable)\n", file_peek_path(),
                     file_peek_line());
         return NULL;
     }
 
     D_PARSE(("builtin_get(%s) called\n", param));
-    s = get_word(1, param);
+    s = spiftool_get_word(1, param);
     if (n == 2) {
-        f = get_word(2, param);
+        f = spiftool_get_word(2, param);
     } else {
         f = NULL;
     }
@@ -385,15 +385,15 @@
 {
     char *var, *val;
 
-    if (!param || (num_words(param) != 2)) {
+    if (!param || (spiftool_num_words(param) != 2)) {
         libast_print_error("Parse error in file %s, line %lu:  Invalid syntax for 
%put().  Syntax is:  %put(variable value)\n", file_peek_path(),
                     file_peek_line());
         return NULL;
     }
 
     D_PARSE(("builtin_put(%s) called\n", param));
-    var = get_word(1, param);
-    val = get_word(2, param);
+    var = spiftool_get_word(1, param);
+    val = spiftool_get_word(2, param);
     spifconf_put_var(var, val);
     return NULL;
 }
@@ -408,13 +408,13 @@
     struct stat filestat;
     char *dir, *buff;
 
-    if (!param || (num_words(param) != 1)) {
+    if (!param || (spiftool_num_words(param) != 1)) {
         libast_print_error("Parse error in file %s, line %lu:  Invalid syntax for 
%dirscan().  Syntax is:  %dirscan(directory)\n",
                     file_peek_path(), file_peek_line());
         return NULL;
     }
     D_PARSE(("builtin_dirscan(%s)\n", param));
-    dir = get_word(1, param);
+    dir = spiftool_get_word(1, param);
     dirp = opendir(dir);
     if (!dirp) {
         return NULL;
@@ -784,7 +784,7 @@
         fgets(buff, 256, fp);
         if (strncasecmp(buff, test, strlen(test))) {
             libast_print_warning("%s exists but does not contain the proper magic 
string (<%s-%s>)\n", name, libast_program_name,
-                          libast_program_version);
+                                 libast_program_version);
             fclose(fp);
             fp = NULL;
         } else {
@@ -792,7 +792,7 @@
             if ((end_ptr = strchr(buff, '>')) != NULL) {
                 *end_ptr = 0;
             }
-            ver = version_compare(begin_ptr, libast_program_version);
+            ver = spiftool_version_compare(begin_ptr, libast_program_version);
             if (SPIF_CMP_IS_GREATER(ver)) {
                 libast_print_warning("Config file is designed for a newer version of 
%s\n", libast_program_name);
             }
@@ -817,32 +817,32 @@
     if (fp == NULL) {
         file_push(NULL, "<argv>", NULL, 0, 0);
         ctx_begin(1);
-        buff = get_pword(2, buff);
+        buff = spiftool_get_pword(2, buff);
         if (!buff) {
             SPIFCONF_PARSE_RET();
         }
     }
     id = ctx_peek_id();
-    chomp(buff);
+    spiftool_chomp(buff);
     D_CONF(("Parsing line #%lu of file %s\n", file_peek_line(), file_peek_path()));
     switch (*buff) {
       case '#':
       case '\0':
           SPIFCONF_PARSE_RET();
       case '%':
-          if (!BEG_STRCASECMP(get_pword(1, buff + 1), "include ")) {
+          if (!BEG_STRCASECMP(spiftool_get_pword(1, buff + 1), "include ")) {
               char *path;
               FILE *fp;
 
               spifconf_shell_expand(buff);
-              path = get_word(2, buff + 1);
+              path = spiftool_get_word(2, buff + 1);
               if ((fp = spifconf_open_file(path)) == NULL) {
                   libast_print_error("Parsing file %s, line %lu:  Unable to locate 
%%included config file %s (%s), continuing\n", file_peek_path(),
                               file_peek_line(), path, strerror(errno));
               } else {
                   file_push(fp, path, NULL, 1, 0);
               }
-          } else if (!BEG_STRCASECMP(get_pword(1, buff + 1), "preproc ")) {
+          } else if (!BEG_STRCASECMP(spiftool_get_pword(1, buff + 1), "preproc ")) {
               char cmd[PATH_MAX], fname[PATH_MAX], *outfile;
               int fd;
               FILE *fp;
@@ -853,7 +853,7 @@
               strcpy(fname, "Eterm-preproc-");
               fd = spiftool_temp_file(fname, PATH_MAX);
               outfile = STRDUP(fname);
-              snprintf(cmd, PATH_MAX, "%s < %s > %s", get_pword(2, buff), 
file_peek_path(), fname);
+              snprintf(cmd, PATH_MAX, "%s < %s > %s", spiftool_get_pword(2, buff), 
file_peek_path(), fname);
               system(cmd);
               fp = fdopen(fd, "rt");
               if (fp != NULL) {
===================================================================
RCS file: /cvsroot/enlightenment/eterm/libast/src/mem.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -3 -r1.15 -r1.16
--- mem.c       27 Nov 2003 05:24:41 -0000      1.15
+++ mem.c       13 Dec 2003 03:02:19 -0000      1.16
@@ -28,11 +28,11 @@
  * This file contains the memory management subsystem.
  *
  * @author Michael Jennings <[EMAIL PROTECTED]>
- * $Revision: 1.15 $
- * $Date: 2003/11/27 05:24:41 $
+ * $Revision: 1.16 $
+ * $Date: 2003/12/13 03:02:19 $
  */
 
-static const char cvs_ident[] = "$Id: mem.c,v 1.15 2003/11/27 05:24:41 mej Exp $";
+static const char cvs_ident[] = "$Id: mem.c,v 1.16 2003/12/13 03:02:19 mej Exp $";
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
@@ -216,10 +216,13 @@
     register ptr_t *p;
 
     ASSERT(memrec != NULL);
+    USE_VAR(var);
+    USE_VAR(filename);
+    USE_VAR(line);
 
     if ((p = memrec_find_var(memrec, ptr)) == NULL) {
-        D_MEM(("ERROR:  File %s, line %d attempted to free variable %s (%010p) which 
was not allocated with MALLOC/REALLOC\n", filename, line,
-               var, ptr));
+        D_MEM(("ERROR:  File %s, line %d attempted to free variable %s (%010p) which 
was not allocated with MALLOC/REALLOC\n",
+               filename, line, var, ptr));
         return;
     }
     D_MEM(("Removing variable %s (%010p) of size %lu\n", var, ptr, p->size));
@@ -254,6 +257,7 @@
     register ptr_t *p;
 
     ASSERT(memrec != NULL);
+    USE_VAR(var);
 
     if ((p = memrec_find_var(memrec, oldp)) == NULL) {
         D_MEM(("ERROR:  File %s, line %d attempted to realloc variable %s (%010p) 
which was not allocated with MALLOC/REALLOC\n", filename,
@@ -315,7 +319,7 @@
             fprintf(LIBAST_DEBUG_FD, "   ");
         }
         /* Finally, print the printable ASCII string for those l bytes */
-        fprintf(LIBAST_DEBUG_FD, "| %-8s\n", safe_str((char *) buff, l));
+        fprintf(LIBAST_DEBUG_FD, "| %-8s\n", spiftool_safe_str((char *) buff, l));
         /* Flush after every line in case we crash */
         fflush(LIBAST_DEBUG_FD);
     }
@@ -340,7 +344,7 @@
                 fprintf(LIBAST_DEBUG_FD, "   ");
             }
             /* Finally, print the printable ASCII string for those l bytes */
-            fprintf(LIBAST_DEBUG_FD, "| %-8s\n", safe_str((char *) buff, l));
+            fprintf(LIBAST_DEBUG_FD, "| %-8s\n", spiftool_safe_str((char *) buff, l));
             /* Flush after every line in case we crash */
             fflush(LIBAST_DEBUG_FD);
         }
@@ -574,6 +578,7 @@
     register char *newstr;
     register size_t len;
 
+    USE_VAR(var);
     D_MEM(("Variable %s (%010p) at %s:%lu\n", var, str, filename, line));
 
     len = strlen(str) + 1;      /* Copy NUL byte also */
@@ -690,6 +695,7 @@
 void
 spifmem_imlib_register_pixmap(const char *var, const char *filename, unsigned long 
line, Pixmap p)
 {
+    USE_VAR(var);
     D_MEM(("Registering pixmap %s (0x%08x) created by Imlib2 at %s:%lu\n", var, p, 
filename, line));
     if (p) {
         if (DEBUG_LEVEL >= DEBUG_MEM) {
===================================================================
RCS file: /cvsroot/enlightenment/eterm/libast/src/options.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -3 -r1.11 -r1.12
--- options.c   27 Nov 2003 05:24:41 -0000      1.11
+++ options.c   13 Dec 2003 03:02:19 -0000      1.12
@@ -29,11 +29,11 @@
  * option parser.
  *
  * @author Michael Jennings <[EMAIL PROTECTED]>
- * $Revision: 1.11 $
- * $Date: 2003/11/27 05:24:41 $
+ * $Revision: 1.12 $
+ * $Date: 2003/12/13 03:02:19 $
  */
 
-static const char cvs_ident[] = "$Id: options.c,v 1.11 2003/11/27 05:24:41 mej Exp $";
+static const char cvs_ident[] = "$Id: options.c,v 1.12 2003/12/13 03:02:19 mej Exp $";
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
@@ -479,11 +479,11 @@
     D_OPTIONS(("Argument list option detected\n"));
     if (hasequal) {
         /* There's an equals sign, so just parse the rest of this option into words. 
*/
-        tmp = (char **) MALLOC(sizeof(char *) * (num_words(val_ptr) + 1));
+        tmp = (char **) MALLOC(sizeof(char *) * (spiftool_num_words(val_ptr) + 1));
 
         for (k = 0; val_ptr; k++) {
-            tmp[k] = get_word(1, val_ptr);
-            val_ptr = get_pword(2, val_ptr);
+            tmp[k] = spiftool_get_word(1, val_ptr);
+            val_ptr = spiftool_get_pword(2, val_ptr);
             D_OPTIONS(("tmp[%d] == %s\n", k, tmp[k]));
         }
         tmp[k] = (char *) NULL;
===================================================================
RCS file: /cvsroot/enlightenment/eterm/libast/src/str.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -3 -r1.24 -r1.25
--- str.c       27 Nov 2003 05:24:41 -0000      1.24
+++ str.c       13 Dec 2003 03:02:19 -0000      1.25
@@ -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.24 2003/11/27 05:24:41 mej Exp $";
+static const char cvs_ident[] = "$Id: str.c,v 1.25 2003/12/13 03:02:19 mej Exp $";
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
@@ -392,19 +392,42 @@
 spif_str_t
 spif_str_substr(spif_str_t self, spif_int32_t idx, spif_int32_t cnt)
 {
+    spif_int32_t start_pos, char_count;
+
     ASSERT_RVAL(!SPIF_STR_ISNULL(self), SPIF_NULL_TYPE(str));
-    return spif_str_new_from_buff(SPIF_STR_STR(self) + ((idx < 0) ? (self->len) : 
(0)) + idx, cnt);
+    if (idx < 0) {
+        start_pos = self->len + idx;
+    } else {
+        start_pos = idx;
+    }
+    if (cnt <= 0) {
+        char_count = self->len - start_pos + cnt;
+    } else {
+        char_count = cnt;
+    }
+    return spif_str_new_from_buff(SPIF_STR_STR(self) + start_pos, char_count);
 }
 
 spif_charptr_t
 spif_str_substr_to_ptr(spif_str_t self, spif_int32_t idx, spif_int32_t cnt)
 {
     spif_charptr_t newstr;
+    spif_int32_t start_pos, char_count;
 
     ASSERT_RVAL(!SPIF_STR_ISNULL(self), SPIF_NULL_TYPE(charptr));
-    newstr = SPIF_CAST(charptr) MALLOC(cnt + 1);
-    memcpy(newstr, SPIF_STR_STR(self) + ((idx < 0) ? (self->len) : (0)) + idx, cnt);
-    newstr[cnt] = 0;
+    if (idx < 0) {
+        start_pos = self->len + idx;
+    } else {
+        start_pos = idx;
+    }
+    if (cnt <= 0) {
+        char_count = self->len - start_pos + cnt;
+    } else {
+        char_count = cnt;
+    }
+    newstr = SPIF_CAST(charptr) MALLOC(char_count + 1);
+    memcpy(newstr, SPIF_STR_STR(self) + start_pos, char_count);
+    newstr[char_count] = 0;
     return newstr;
 }
 
===================================================================
RCS file: /cvsroot/enlightenment/eterm/libast/src/strings.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -3 -r1.13 -r1.14
--- strings.c   27 Nov 2003 05:24:41 -0000      1.13
+++ strings.c   13 Dec 2003 03:02:19 -0000      1.14
@@ -30,7 +30,7 @@
  * @author Michael Jennings <[EMAIL PROTECTED]>
  */
 
-static const char cvs_ident[] = "$Id: strings.c,v 1.13 2003/11/27 05:24:41 mej Exp $";
+static const char cvs_ident[] = "$Id: strings.c,v 1.14 2003/12/13 03:02:19 mej Exp $";
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
@@ -94,78 +94,151 @@
 #endif
 ************************/
 
-/* Return the leftmost cnt characters of str */
+#if !(HAVE_STRCASESTR)
 char *
-left_str(const char *str, unsigned long cnt)
+strcasestr(const char *haystack, register const char *needle)
 {
-    char *tmpstr;
+    register const char *t;
+    register size_t len = strlen(needle);
+
+    for (t = haystack; t && *t; t++) {
+        if (!strncasecmp(t, needle, len)) {
+            return ((char *) t);
+        }
+    }
+    return (NULL);
+}
+#endif
 
-    REQUIRE_RVAL(str != NULL, NULL);
-    REQUIRE_RVAL(cnt <= strlen(str), NULL);
-    REQUIRE_RVAL(cnt > 0, NULL);
+#if !(HAVE_STRCASECHR)
+char *
+strcasechr(const char *haystack, register const char needle)
+{
+    register const char *t;
 
-    tmpstr = (char *) MALLOC(cnt + 1);
-    strncpy(tmpstr, str, cnt);
-    tmpstr[cnt] = 0;
-    return (tmpstr);
+    for (t = haystack; t && *t; t++) {
+        if (tolower(*t) == tolower(needle)) {
+            return ((char *) t);
+        }
+    }
+    return (NULL);
 }
+#endif
 
-/* Return cnt characters from str, starting at position index (from 0) */
+#if !(HAVE_STRCASEPBRK)
 char *
-mid_str(const char *str, unsigned long index, unsigned long cnt)
+strcasepbrk(const char *haystack, register const char *needle)
 {
-    char *tmpstr;
-    const char *pstr = str;
-    size_t len;
+    register const char *t;
 
-    REQUIRE_RVAL(str != NULL, NULL);
-    len = strlen(str);
-    REQUIRE_RVAL(index < len, NULL);
-    REQUIRE_RVAL(cnt <= len, NULL);
-    REQUIRE_RVAL(cnt > 0, NULL);
+    for (t = haystack; t && *t; t++) {
+        if (strcasechr(needle, *t)) {
+            return ((char *) t);
+        }
+    }
+    return (NULL);
+}
+#endif
+
+#if !(HAVE_STRREV)
+char *
+strrev(register char *str)
+{
+    register int i, j;
+
+    i = strlen(str);
+    for (j = 0, i--; i > j; i--, j++) {
+        (void) SWAP(str[j], str[i]);
+    }
+    return (str);
 
-    tmpstr = (char *) MALLOC(cnt + 1);
-    pstr += index;
-    strncpy(tmpstr, pstr, cnt);
-    tmpstr[cnt] = 0;
-    return (tmpstr);
 }
+#endif
 
-/* Return the rightmost characters of str */
+#if !(HAVE_STRSEP)
 char *
-right_str(const char *str, unsigned long cnt)
+strsep(char **str, register char *sep)
 {
-    char *tmpstr;
-    const char *pstr = str;
 
-    REQUIRE_RVAL(str != NULL, NULL);
-    REQUIRE_RVAL(cnt <= strlen(str), NULL);
-    REQUIRE_RVAL(cnt > 0, NULL);
+    register char *s = *str;
+    char *sptr;
+
+    D_STRINGS(("strsep(%s, %s) called.\n", *str, sep));
+    sptr = s;
+    for (; *s && !strchr(sep, *s); s++);
+    if (!*s) {
+        if (s != sptr) {
+            *str = s;
+            D_STRINGS(("Reached end of string with token \"%s\" in buffer\n", sptr));
+            return (sptr);
+        } else {
+            D_STRINGS(("Reached end of string\n"));
+            return ((char *) NULL);
+        }
+    }
+    *s = 0;
+    *str = s + 1;
+    D_STRINGS(("Got token \"%s\", *str == \"%s\"\n", sptr, *str));
+    return (sptr);
+}
+#endif
+
+/**
+ * Returns a portion of a larger string.
+ */
+spif_charptr_t
+spiftool_substr(spif_charptr_t str, spif_int32_t idx, spif_int32_t cnt)
+{
+    spif_charptr_t newstr;
+    spif_uint32_t start_pos, char_count;
+    spif_uint32_t len;
+
+    REQUIRE_RVAL(str != SPIF_NULL_TYPE(charptr), SPIF_NULL_TYPE(charptr));
 
-    tmpstr = (char *) MALLOC(cnt + 1);
-    pstr += strlen(str);
-    pstr -= cnt;
-    strcpy(tmpstr, pstr);
-    return (tmpstr);
+    len = SPIF_CAST(uint32) strlen(str);
+
+    if (idx < 0) {
+        start_pos = len + idx;
+    } else {
+        start_pos = idx;
+    }
+    REQUIRE_RVAL(start_pos < len, SPIF_NULL_TYPE(charptr));
+
+    if (cnt <= 0) {
+        char_count = len - start_pos + cnt;
+    } else {
+        char_count = cnt;
+    }
+    UPPER_BOUND(char_count, len - start_pos);
+
+    newstr = SPIF_CAST(charptr) MALLOC(char_count + 1);
+    memcpy(newstr, str + start_pos, char_count);
+    newstr[char_count] = 0;
+    return newstr;
 }
 
-/* Returns TRUE if str matches regular expression pattern, FALSE otherwise */
 #if HAVE_REGEX_H
+/**
+ * Compare a string to a regular expression.
+ */
 spif_bool_t
-regexp_match(register const char *str, register const char *pattern)
+spiftool_regexp_match(const spif_charptr_t str, const spif_charptr_t pattern)
 {
     static regex_t *rexp = NULL;
     register int result;
     char errbuf[256];
 
     if (!str) {
+        /* If we're passed a NULL str, we want to free our static storage. */
         FREE(rexp);
         return FALSE;
     } else if (!rexp) {
+        /* If we don't have static storage yet, make some. */
         rexp = (regex_t *) MALLOC(sizeof(regex_t));
     }
 
     if (pattern) {
+        /* We have a pattern, so we need to compile it. */
         if ((result = regcomp(rexp, pattern, REG_EXTENDED)) != 0) {
             regerror(result, rexp, errbuf, 256);
             libast_print_error("Unable to compile regexp %s -- %s.\n", pattern, 
errbuf);
@@ -173,6 +246,7 @@
         }
     }
 
+    /* Compare the string to the compiled pattern. */
     if (((result = regexec(rexp, str, (size_t) 0, (regmatch_t *) NULL, 0)) != 0)
         && (result != REG_NOMATCH)) {
         regerror(result, rexp, errbuf, 256);
@@ -182,8 +256,11 @@
     return ((result == REG_NOMATCH) ? (FALSE) : (TRUE));
 }
 
+/**
+ * Thread-safe way to compare a string to a regular expression.
+ */
 spif_bool_t
-regexp_match_r(register const char *str, register const char *pattern, register 
regex_t **rexp)
+spiftool_regexp_match_r(register const char *str, register const char *pattern, 
register regex_t **rexp)
 {
     register int result;
     char errbuf[256];
@@ -216,7 +293,7 @@
 #define IS_QUOTE(c)  (quote && quote == (c))
 
 char **
-split(const char *delim, const char *str)
+spiftool_split(const char *delim, const char *str)
 {
     char **slist;
     register const char *pstr;
@@ -299,7 +376,7 @@
 }
 
 char **
-split_regexp(const char *regexp, const char *str)
+spiftool_split_regexp(const char *regexp, const char *str)
 {
     USE_VAR(regexp);
     USE_VAR(str);
@@ -307,7 +384,7 @@
 }
 
 char *
-join(const char *sep, char **slist)
+spiftool_join(const char *sep, char **slist)
 {
     register unsigned long i;
     size_t len, slen;
@@ -337,7 +414,7 @@
 #define IS_DELIM(c)  (delim ? ((c) == delim) : isspace(c))
 
 char *
-get_word(unsigned long index, const char *str)
+spiftool_get_word(unsigned long index, const char *str)
 {
     char *tmpstr;
     char delim = 0;
@@ -393,7 +470,7 @@
 
 /* Return pointer into str to index-th word in str.  "..." counts as 1 word. */
 char *
-get_pword(unsigned long index, const char *str)
+spiftool_get_pword(unsigned long index, const char *str)
 {
     register const char *tmpstr = str;
     register unsigned long j;
@@ -420,7 +497,7 @@
 
 /* Returns the number of words in str, for use with get_word() and get_pword().  
"..." counts as 1 word. */
 unsigned long
-num_words(const char *str)
+spiftool_num_words(const char *str)
 {
     register unsigned long cnt = 0;
     char delim = 0;
@@ -456,7 +533,7 @@
 
 /* chomp() removes leading and trailing whitespace from a string */
 char *
-chomp(char *s)
+spiftool_chomp(char *s)
 {
 
     register char *front, *back;
@@ -473,7 +550,7 @@
 }
 
 char *
-strip_whitespace(register char *str)
+spiftool_strip_whitespace(register char *str)
 {
     register unsigned long i, j;
 
@@ -489,7 +566,7 @@
 }
 
 char *
-downcase_str(char *str)
+spiftool_downcase_str(char *str)
 {
     register char *tmp;
 
@@ -501,7 +578,7 @@
 }
 
 char *
-upcase_str(char *str)
+spiftool_upcase_str(char *str)
 {
     register char *tmp;
 
@@ -512,186 +589,8 @@
     return (str);
 }
 
-#if !(HAVE_STRCASESTR)
-char *
-strcasestr(const char *haystack, register const char *needle)
-{
-    register const char *t;
-    register size_t len = strlen(needle);
-
-    for (t = haystack; t && *t; t++) {
-        if (!strncasecmp(t, needle, len)) {
-            return ((char *) t);
-        }
-    }
-    return (NULL);
-}
-#endif
-
-#if !(HAVE_STRCASECHR)
-char *
-strcasechr(const char *haystack, register const char needle)
-{
-    register const char *t;
-
-    for (t = haystack; t && *t; t++) {
-        if (tolower(*t) == tolower(needle)) {
-            return ((char *) t);
-        }
-    }
-    return (NULL);
-}
-#endif
-
-#if !(HAVE_STRCASEPBRK)
-char *
-strcasepbrk(const char *haystack, register const char *needle)
-{
-    register const char *t;
-
-    for (t = haystack; t && *t; t++) {
-        if (strcasechr(needle, *t)) {
-            return ((char *) t);
-        }
-    }
-    return (NULL);
-}
-#endif
-
-#if !(HAVE_STRREV)
-char *
-strrev(register char *str)
-{
-    register int i, j;
-
-    i = strlen(str);
-    for (j = 0, i--; i > j; i--, j++) {
-        (void) SWAP(str[j], str[i]);
-    }
-    return (str);
-
-}
-#endif
-
-#if !(HAVE_STRSEP)
-char *
-strsep(char **str, register char *sep)
-{
-
-    register char *s = *str;
-    char *sptr;
-
-    D_STRINGS(("strsep(%s, %s) called.\n", *str, sep));
-    sptr = s;
-    for (; *s && !strchr(sep, *s); s++);
-    if (!*s) {
-        if (s != sptr) {
-            *str = s;
-            D_STRINGS(("Reached end of string with token \"%s\" in buffer\n", sptr));
-            return (sptr);
-        } else {
-            D_STRINGS(("Reached end of string\n"));
-            return ((char *) NULL);
-        }
-    }
-    *s = 0;
-    *str = s + 1;
-    D_STRINGS(("Got token \"%s\", *str == \"%s\"\n", sptr, *str));
-    return (sptr);
-}
-#endif
-
-char *
-garbage_collect(char *buff, size_t len)
-{
-
-    register char *tbuff = buff, *pbuff = buff;
-    register unsigned long i, j;
-
-    D_STRINGS(("Garbage collecting on %lu bytes at %10.8p\n", len, buff));
-    for (i = 0, j = 0; j < len; j++)
-        if (pbuff[j])
-            tbuff[i++] = pbuff[j];
-    tbuff[i++] = '\0';
-    D_STRINGS(("Garbage collecting gives: \n%s\n", buff));
-    return ((char *) REALLOC(buff, sizeof(char) * i));
-}
-
-char *
-file_garbage_collect(char *buff, size_t len)
-{
-
-    register char *tbuff = buff, *pbuff = buff;
-    char *tmp1, *tmp2;
-    register unsigned long j;
-
-    D_STRINGS(("File garbage collecting on %lu bytes at %10.8p\n", len, buff));
-    for (j = 0; j < len;) {
-        switch (pbuff[j]) {
-          case '#':
-              for (; !strchr("\r\n", pbuff[j]) && j < len; j++)
-                  pbuff[j] = '\0';     /* First null out the line up to the CR and/or 
LF */
-              for (; strchr("\r\n", pbuff[j]) && j < len; j++)
-                  pbuff[j] = '\0';     /* Then null out the CR and/or LF */
-              break;
-          case '\r':
-          case '\n':
-          case '\f':
-          case ' ':
-          case '\t':
-          case '\v':
-              for (; isspace(pbuff[j]) && j < len; j++)
-                  pbuff[j] = '\0';     /* Null out the whitespace */
-              break;
-          default:
-              /* Find the end of this line and the occurence of the
-                 next mid-line comment. */
-              tmp1 = strpbrk(pbuff + j, "\r\n");
-              tmp2 = strstr(pbuff + j, " #");
-
-              /* If either is null, take the non-null one.  Otherwise,
-                 take the lesser of the two. */
-              if (!tmp1 || !tmp2) {
-                  tbuff = ((tmp1) ? (tmp1) : (tmp2));
-              } else {
-                  tbuff = ((tmp1 < tmp2) ? (tmp1) : (tmp2));
-              }
-
-              /* Now let j catch up so that pbuff+j = tbuff; i.e., let
-                 pbuff[j] refer to the same character that tbuff does */
-              j += tbuff - (pbuff + j);
-
-              /* Finally, change whatever is at pbuff[j] to a newline.
-                 This will accomplish several things at once:
-                 o It will change a \r to a \n if that's what's there
-                 o If it's a \n, it'll stay the same.  No biggie.
-                 o If it's a space, it will end the line there and the
-                 next line will begin with a comment, which is handled
-                 above. */
-              if (j < len)
-                  pbuff[j++] = '\n';
-
-        }
-    }
-
-    /* Change all occurances of a backslash followed by a newline to nulls
-       and null out all whitespace up to the next non-whitespace character.
-       This handles support for breaking a string across multiple lines. */
-    for (j = 0; j < len; j++) {
-        if (pbuff[j] == '\\' && pbuff[j + 1] == '\n') {
-            pbuff[j++] = '\0';
-            for (; isspace(pbuff[j]) && j < len; j++)
-                pbuff[j] = '\0';       /* Null out the whitespace */
-        }
-    }
-
-    /* And the final step, garbage collect the buffer to condense all
-       those nulls we just put in. */
-    return (garbage_collect(buff, len));
-}
-
 char *
-condense_whitespace(char *s)
+spiftool_condense_whitespace(char *s)
 {
 
     register unsigned char gotspc = 0;
@@ -719,7 +618,7 @@
 }
 
 char *
-safe_str(register char *str, unsigned short len)
+spiftool_safe_str(register char *str, unsigned short len)
 {
     register unsigned short i;
 
@@ -733,7 +632,7 @@
 }
 
 void
-hex_dump(void *buff, register size_t count)
+spiftool_hex_dump(void *buff, register size_t count)
 {
 
     register unsigned long j, k, l;
@@ -753,7 +652,7 @@
         for (; k < 8; k++) {
             fprintf(stderr, "   ");
         }
-        fprintf(stderr, "| %-8s\n", safe_str((char *) buffr, l));
+        fprintf(stderr, "| %-8s\n", spiftool_safe_str((char *) buffr, l));
     }
 }
 
@@ -761,7 +660,7 @@
                                      || (isdigit(a) && isdigit(b)) \
                                      || (!isalnum(a) && !isalnum(b)))
 spif_cmp_t
-version_compare(const char *v1, const char *v2)
+spiftool_version_compare(const char *v1, const char *v2)
 {
     char buff1[128], buff2[128];
 
@@ -776,8 +675,8 @@
             *p1 = *p2 = 0;
 
             /* Change the buffered strings to lowercase for easier comparison. */
-            downcase_str(buff1);
-            downcase_str(buff2);
+            spiftool_downcase_str(buff1);
+            spiftool_downcase_str(buff2);
 
             /* Some strings require special handling. */
             if (!strcmp(buff1, "snap")) {




-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to