Enlightenment CVS committal

Author  : mej
Project : eterm
Module  : libast

Dir     : eterm/libast/src


Modified Files:
        array.c conf.c strings.c 


Log Message:
Fri Jul 16 19:20:48 2004                        Michael Jennings (mej)

Working on cleaning some things up for portability and C99-compliance.
----------------------------------------------------------------------

===================================================================
RCS file: /cvsroot/enlightenment/eterm/libast/src/array.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -3 -r1.17 -r1.18
--- array.c     10 Mar 2004 22:50:21 -0000      1.17
+++ array.c     16 Jul 2004 23:22:18 -0000      1.18
@@ -21,7 +21,7 @@
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
-static const char cvs_ident[] = "$Id: array.c,v 1.17 2004/03/10 22:50:21 mej Exp $";
+static const char cvs_ident[] = "$Id: array.c,v 1.18 2004/07/16 23:22:18 mej Exp $";
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
@@ -292,7 +292,7 @@
 static spif_str_t
 spif_array_show(spif_array_t self, spif_charptr_t name, spif_str_t buff, size_t 
indent)
 {
-    char tmp[4096];
+    spif_char_t tmp[4096];
     spif_listidx_t i;
 
     if (SPIF_LIST_ISNULL(self)) {
@@ -301,19 +301,20 @@
     }
 
     memset(tmp, ' ', indent);
-    snprintf(tmp + indent, sizeof(tmp) - indent, "(spif_array_t) %s:  %10p {\n", 
name, self);
+    snprintf(SPIF_CAST_C(char *) tmp + indent, sizeof(tmp) - indent,
+             "(spif_array_t) %s:  %10p {\n", name, SPIF_CAST(ptr) self);
     if (SPIF_STR_ISNULL(buff)) {
         buff = spif_str_new_from_ptr(tmp);
     } else {
-        spif_str_append_from_ptr(buff, tmp);
+        spif_str_append_from_ptr(buff, SPIF_CAST(charptr) tmp);
     }
 
     if (SPIF_ARRAY_ISNULL(self->items)) {
-        spif_str_append_from_ptr(buff, SPIF_NULLSTR_TYPE_C(spif_obj_t *));
+        spif_str_append_from_ptr(buff, SPIF_CAST(charptr) SPIF_NULLSTR_TYPE_PTR(obj));
     } else {
         for (i = 0; i < self->len; i++) {
             spif_obj_t o = self->items[i];
-            sprintf(tmp, "item %d", i);
+            sprintf(SPIF_CAST_C(char *) tmp, "item %d", i);
             if (SPIF_OBJ_ISNULL(o)) {
                 char tmp2[4096];
 
@@ -325,8 +326,8 @@
     }
 
     memset(tmp, ' ', indent);
-    snprintf(tmp + indent, sizeof(tmp) - indent, "}\n");
-    spif_str_append_from_ptr(buff, tmp);
+    snprintf(SPIF_CAST_C(char *) tmp + indent, sizeof(tmp) - indent, "}\n");
+    spif_str_append_from_ptr(buff, SPIF_CAST(charptr) tmp);
     return buff;
 }
 
@@ -785,7 +786,7 @@
 
     ASSERT_RVAL(!SPIF_ARRAY_ISNULL(self), FALSE);
     for (i = 0, j = self->len - 1; i < j; i++, j--) {
-        BINSWAP(self->items[i], self->items[j]);
+        SWAP(self->items[i], self->items[j]);
     }
     return TRUE;
 }
@@ -877,7 +878,7 @@
 static spif_str_t
 spif_array_iterator_show(spif_array_iterator_t self, spif_charptr_t name, spif_str_t 
buff, size_t indent)
 {
-    char tmp[4096];
+    spif_char_t tmp[4096];
 
     if (SPIF_ITERATOR_ISNULL(self)) {
         SPIF_OBJ_SHOW_NULL(iterator, name, buff, indent, tmp);
@@ -885,21 +886,23 @@
     }
 
     memset(tmp, ' ', indent);
-    snprintf(tmp + indent, sizeof(tmp) - indent, "(spif_array_iterator_t) %s:  %10p 
{\n", name, self);
+    snprintf(SPIF_CAST_C(char *) tmp + indent, sizeof(tmp) - indent,
+             "(spif_array_iterator_t) %s:  %10p {\n", name, SPIF_CAST(ptr) self);
     if (SPIF_STR_ISNULL(buff)) {
         buff = spif_str_new_from_ptr(tmp);
     } else {
         spif_str_append_from_ptr(buff, tmp);
     }
 
-    buff = spif_array_show(self->subject, "subject", buff, indent + 2);
+    buff = spif_array_show(self->subject, SPIF_CAST(charptr) "subject", buff, indent 
+ 2);
 
     memset(tmp, ' ', indent + 2);
-    snprintf(tmp + indent, sizeof(tmp) - indent, "  (spif_listidx_t) current_index:  
%lu\n",
+    snprintf(SPIF_CAST_C(char *) tmp + indent, sizeof(tmp) - indent,
+             "  (spif_listidx_t) current_index:  %lu\n",
              SPIF_CAST_C(unsigned long) self->current_index);
     spif_str_append_from_ptr(buff, tmp);
 
-    snprintf(tmp + indent, sizeof(tmp) - indent, "}\n");
+    snprintf(SPIF_CAST_C(char *) tmp + indent, sizeof(tmp) - indent, "}\n");
     spif_str_append_from_ptr(buff, tmp);
     return buff;
 }
===================================================================
RCS file: /cvsroot/enlightenment/eterm/libast/src/conf.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -3 -r1.21 -r1.22
--- conf.c      29 Jun 2004 21:18:08 -0000      1.21
+++ conf.c      16 Jul 2004 23:22:18 -0000      1.22
@@ -31,7 +31,7 @@
  * @author Michael Jennings <[EMAIL PROTECTED]>
  */
 
-static const char cvs_ident[] = "$Id: conf.c,v 1.21 2004/06/29 21:18:08 mej Exp $";
+static const char cvs_ident[] = "$Id: conf.c,v 1.22 2004/07/16 23:22:18 mej Exp $";
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
@@ -480,19 +480,19 @@
 
 /* spifconf_shell_expand() takes care of shell variable expansion, quote conventions,
    calling of built-in functions, etc.                                -- mej */
-char *
-spifconf_shell_expand(char *s)
+spif_charptr_t
+spifconf_shell_expand(spif_charptr_t s)
 {
-    register char *tmp;
-    register char *pbuff = s, *tmp1;
-    register unsigned long j, k, l = 0;
-    char newbuff[CONFIG_BUFF];
-    unsigned char in_single = 0, in_double = 0;
-    unsigned long cnt1 = 0, cnt2 = 0;
-    const unsigned long max = CONFIG_BUFF - 1;
-    char *Command, *Output, *EnvVar;
+    register spif_charptr_t tmp;
+    register spif_charptr_t pbuff = s, tmp1;
+    register spif_uint32_t j, k, l = 0;
+    spif_char_t newbuff[CONFIG_BUFF];
+    spif_uint8_t in_single = 0, in_double = 0;
+    spif_uint32_t cnt1 = 0, cnt2 = 0;
+    const spif_uint32_t max = CONFIG_BUFF - 1;
+    spif_charptr_t Command, Output, EnvVar;
 
-    ASSERT_RVAL(s != NULL, (char *) NULL);
+    ASSERT_RVAL(s != NULL, SPIF_NULL_TYPE(charptr));
 
 #if 0
     newbuff = (char *) MALLOC(CONFIG_BUFF);
@@ -502,10 +502,10 @@
         switch (*pbuff) {
           case '~':
               D_CONF(("Tilde detected.\n"));
-              EnvVar = getenv("HOME");
+              EnvVar = SPIF_CAST(charptr) getenv("HOME");
               if (!in_single && !in_double && EnvVar && *EnvVar) {
-                  spiftool_safe_strncpy(newbuff + j, getenv("HOME"), max - j);
-                  cnt1 = strlen(EnvVar) - 1;
+                  spiftool_safe_strncpy(newbuff + j, EnvVar, max - j);
+                  cnt1 = strlen(SPIF_CAST_C(char *) EnvVar) - 1;
                   cnt2 = max - j - 1;
                   j += MIN(cnt1, cnt2);
               } else {
@@ -554,7 +554,10 @@
               for (k = 0, pbuff++; builtins[k].name != NULL; k++) {
                   D_PARSE(("Checking for function %%%s, pbuff == \"%s\"\n", 
builtins[k].name, pbuff));
                   l = strlen(builtins[k].name);
-                  if (!strncasecmp(builtins[k].name, pbuff, l) && ((pbuff[l] == '(') 
|| (pbuff[l] == ' ' && pbuff[l + 1] == ')'))) {
+                  if (!strncasecmp(builtins[k].name, SPIF_CAST_C(char *) pbuff, l)
+                      && ((pbuff[l] == '(')
+                          || (pbuff[l] == ' '
+                              && pbuff[l + 1] == ')'))) {
                       break;
                   }
               }
@@ -562,7 +565,7 @@
                   newbuff[j] = *pbuff;
               } else {
                   D_CONF(("Call to built-in function %s detected.\n", 
builtins[k].name));
-                  Command = (char *) MALLOC(CONFIG_BUFF);
+                  Command = SPIF_CAST(charptr) MALLOC(CONFIG_BUFF);
                   pbuff += l;
                   if (*pbuff != '(')
                       pbuff++;
@@ -582,15 +585,15 @@
                   *(--tmp1) = 0;
                   if (l) {
                       libast_print_error("parse error in file %s, line %lu:  
Mismatched parentheses\n", file_peek_path(), file_peek_line());
-                      return ((char *) NULL);
+                      return SPIF_NULL_TYPE(charptr);
                   }
                   Command = spifconf_shell_expand(Command);
-                  Output = (builtins[k].ptr) (Command);
+                  Output = SPIF_CAST(charptr) (builtins[k].ptr) (SPIF_CAST_C(char *) 
Command);
                   FREE(Command);
                   if (Output) {
                       if (*Output) {
                           spiftool_safe_strncpy(newbuff + j, Output, max - j);
-                          l = strlen(Output) - 1;
+                          l = strlen(SPIF_CAST_C(char *) Output) - 1;
                           cnt2 = max - j - 1;
                           j += MIN(l, cnt2);
                       } else {
@@ -607,7 +610,7 @@
 #if ALLOW_BACKQUOTE_EXEC
               D_CONF(("Backquotes detected.  Evaluating expression.\n"));
               if (!in_single) {
-                  Command = (char *) MALLOC(CONFIG_BUFF);
+                  Command = SPIF_CAST(charptr) MALLOC(CONFIG_BUFF);
                   l = 0;
                   for (pbuff++; *pbuff && *pbuff != '`' && l < max; pbuff++, l++) {
                       Command[l] = *pbuff;
@@ -615,12 +618,12 @@
                   ASSERT_RVAL(l < CONFIG_BUFF, NULL);
                   Command[l] = 0;
                   Command = spifconf_shell_expand(Command);
-                  Output = builtin_exec(Command);
+                  Output = SPIF_CAST(charptr) builtin_exec(SPIF_CAST_C(char *) 
Command);
                   FREE(Command);
                   if (Output) {
                       if (*Output) {
                           spiftool_safe_strncpy(newbuff + j, Output, max - j);
-                          l = strlen(Output) - 1;
+                          l = strlen(SPIF_CAST_C(char *) Output) - 1;
                           cnt2 = max - j - 1;
                           j += MIN(l, cnt2);
                       } else {
@@ -641,7 +644,7 @@
           case '$':
               D_CONF(("Environment variable detected.  Evaluating.\n"));
               if (!in_single) {
-                  EnvVar = (char *) MALLOC(128);
+                  EnvVar = SPIF_CAST(charptr) MALLOC(128);
                   switch (*(++pbuff)) {
                     case '{':
                         for (pbuff++, k = 0; *pbuff != '}' && k < 127; k++, pbuff++)
@@ -657,9 +660,10 @@
                         break;
                   }
                   EnvVar[k] = 0;
-                  if ((tmp = getenv(EnvVar)) && *tmp) {
+                  tmp = SPIF_CAST(charptr) getenv(SPIF_CAST_C(char *) EnvVar);
+                  if (tmp && *tmp) {
                       spiftool_safe_strncpy(newbuff, tmp, max - j);
-                      cnt1 = strlen(tmp) - 1;
+                      cnt1 = strlen(SPIF_CAST_C(char *) tmp) - 1;
                       cnt2 = max - j - 1;
                       j += MIN(cnt1, cnt2);
                   }
@@ -698,9 +702,11 @@
     newbuff[j] = 0;
 
     D_PARSE(("spifconf_shell_expand(%s) returning \"%s\"\n", s, newbuff));
-    D_PARSE((" strlen(s) == %lu, strlen(newbuff) == %lu, j == %lu\n", strlen(s), 
strlen(newbuff), j));
+    D_PARSE((" strlen(s) == %lu, strlen(newbuff) == %lu, j == %lu\n",
+             strlen(SPIF_CAST_C(char *) s),
+             strlen(SPIF_CAST_C(char *) newbuff), j));
 
-    strcpy(s, newbuff);
+    strcpy(SPIF_CAST_C(char *) s, SPIF_CAST_C(char *) newbuff);
 #if 0
     FREE(newbuff);
 #endif
@@ -843,7 +849,7 @@
               char *path;
               FILE *fp;
 
-              spifconf_shell_expand(buff);
+              spifconf_shell_expand(SPIF_CAST(charptr) buff);
               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(),
@@ -875,7 +881,7 @@
               if (file_peek_skip()) {
                   SPIFCONF_PARSE_RET();
               }
-              spifconf_shell_expand(buff);
+              spifconf_shell_expand(SPIF_CAST(charptr) buff);
           }
           break;
       case 'b':
@@ -897,7 +903,7 @@
           if (file_peek_skip()) {
               SPIFCONF_PARSE_RET();
           }
-          spifconf_shell_expand(buff);
+          spifconf_shell_expand(SPIF_CAST(charptr) buff);
           ctx_poke_state((*ctx_id_to_func(id)) (buff, ctx_peek_state()));
     }
     SPIFCONF_PARSE_RET();
===================================================================
RCS file: /cvsroot/enlightenment/eterm/libast/src/strings.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -3 -r1.20 -r1.21
--- strings.c   29 Jun 2004 21:26:18 -0000      1.20
+++ strings.c   16 Jul 2004 23:22:18 -0000      1.21
@@ -30,7 +30,7 @@
  * @author Michael Jennings <[EMAIL PROTECTED]>
  */
 
-static const char cvs_ident[] = "$Id: strings.c,v 1.20 2004/06/29 21:26:18 mej Exp $";
+static const char cvs_ident[] = "$Id: strings.c,v 1.21 2004/07/16 23:22:18 mej Exp $";
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
@@ -102,13 +102,13 @@
 char *
 strcasestr(const char *haystack, register const char *needle)
 {
-    register const char *t;
+    register const spif_uchar_t *t;
     register size_t len;
 
     REQUIRE_RVAL(needle != SPIF_NULL_TYPE(ptr), SPIF_NULL_TYPE(ptr));
     REQUIRE_RVAL(haystack != SPIF_NULL_TYPE(ptr), SPIF_NULL_TYPE(ptr));
     len = strlen(needle);
-    for (t = haystack; t && *t; t++) {
+    for (t = SPIF_CAST_PTR(uchar) haystack; t && *t; t++) {
         if (!strncasecmp(t, needle, len)) {
             return ((char *) t);
         }




-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to