Enlightenment CVS committal

Author  : dj2
Project : e17
Module  : libs/etox

Dir     : e17/libs/etox/src


Modified Files:
        etox.c 


Log Message:
- just do a strlen in etox_set_text as we want the full length
- only pass in the remaining size of the buffer in etox_get_text
- et->length contains the full length including \n's so remove the
  incorrect comment
- this makes valgrind happier and my segvs with etox_test seem to have gone
  away

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/etox/src/etox.c,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -3 -r1.104 -r1.105
--- etox.c      29 Nov 2004 16:21:54 -0000      1.104
+++ etox.c      29 Nov 2004 19:51:14 -0000      1.105
@@ -345,15 +345,16 @@
                text = strdup("");
        }
 
-       et->lines = _etox_break_text(et, text);
-       FREE(text);
-
        /*
         * Sum up the length and height of the text in the etox.
         */
        et->h = 0;
-       et->length = 0;
+       et->length = strlen(text);
        et->tw = 0;
+
+       et->lines = _etox_break_text(et, text);
+       FREE(text);
+
        for (l = et->lines; l; l = l->next) {
                line = l->data;
                /*
@@ -363,7 +364,6 @@
                        et->tw = line->w;
 
                et->h += line->h;
-               et->length += line->length;
        }
 
        etox_layout(et);
@@ -385,6 +385,7 @@
        char *ret, *temp;
        Etox_Line *line;
        Evas_List *l;
+       int len;
 
        CHECK_PARAM_POINTER_RETURN("obj", obj, NULL);
 
@@ -396,20 +397,16 @@
        if (!et->lines)
                return NULL;
 
-       /*
-        * etox_get_length() includes the \n's at the end of each line
-        * whereas et->length does not.
-        */
        ret = (char *) calloc(et->length + 1, sizeof(char));
-
        temp = ret;
 
        /*
         * Concatenate the text into the newly allocated buffer.
         */
+       len = et->length;
        for (l = et->lines; l; l = l->next) {
                line = l->data;
-               etox_line_get_text(line, temp, et->length + 1);
+               etox_line_get_text(line, temp, len);
 
                /*
                 * FIXME: Currently, in etox_line_get_text(), line->length
@@ -424,11 +421,14 @@
                        if (!(nline->flags & ETOX_LINE_WRAPPED)) {
                                strcat(temp, "\n");
                                temp++;
+                               len--;
                        }
                }
                temp += line->length;
-       }
+               len -= line->length;
 
+               if (len < 1) break;
+       }
        return ret;
 }
 




-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to