[Ecls-list] bug in string-trim of an empty string

Ralph Campbell ralphcampbell at sbcglobal.net
Mon Feb 20 13:44:03 UTC 2006


This fixes a minor bug in the string-trim functions when the string
is a null string.  Also, with GCC 4.0, fix warnings about pointer
sign changes.

--- string.d.old        2006-02-20 12:18:32.000000000 -0800
+++ string.d    2006-02-20 13:25:52.000000000 -0800
@@ -51,7 +51,7 @@
        x->string.adjustable = FALSE;
        x->string.displaced = Cnil;
        x->string.dim = (x->string.fillp = l);
-       x->string.self = (char *)cl_alloc_atomic(l+1);
+       x->string.self = (unsigned char *)cl_alloc_atomic(l+1);
        x->string.self[l] = x->string.self[0] = 0;
        return(x);
 }
@@ -85,7 +85,7 @@
        x->string.adjustable = FALSE;
        x->string.displaced = Cnil;
        x->string.dim = (x->string.fillp = l);
-       x->string.self = s;
+       x->string.self = (unsigned char *)s;

        return(x);
 }
@@ -274,8 +274,8 @@
        j = y->string.fillp;
        if (i != j)
                return(FALSE);
-       p = x->string.self;
-       q = y->string.self;
+       p = (char *)x->string.self;
+       q = (char *)y->string.self;
        for (i = 0;  i < j;  i++)
                if (toupper(p[i]) != toupper(q[i]))
                        return(FALSE);
@@ -502,6 +502,8 @@
        cl_index i, j, k;

        strng = cl_string(strng);
+       if (strng->string.fillp == 0)
+               @(return strng)
        i = 0;
        j = strng->string.fillp - 1;
        if (left_trim)
@@ -660,7 +662,7 @@
 @(defun si::string_concatenate (&rest args)
        cl_index l;
        int i;
-       char *vself;
+       unsigned char *vself;
 #ifdef __GNUC__
        cl_object v, strings[narg];
 #else






More information about the ecl-devel mailing list