Enlightenment CVS committal

Author  : raster
Project : e17
Module  : libs/etox

Dir     : e17/libs/etox/src


Modified Files:
        etox.c etox_line.c 


Log Message:


1. actually FORMAt correctly on resizes...
2. dont LEAK!

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/etox/src/etox.c,v
retrieving revision 1.101
retrieving revision 1.102
diff -u -3 -r1.101 -r1.102
--- etox.c      2 Nov 2004 16:19:57 -0000       1.101
+++ etox.c      13 Nov 2004 11:17:11 -0000      1.102
@@ -12,7 +12,7 @@
 
 static Evas_List *_etox_break_text(Etox * et, char *text);
 
-Evas_Smart *etox_smart = NULL;
+static Evas_Smart *etox_smart = NULL;
 
 /**
  * etox_new - create a new etox with default settings
@@ -26,12 +26,14 @@
 
        CHECK_PARAM_POINTER_RETURN("evas", evas, NULL);
 
-       if (!etox_smart)
+       if (!etox_smart) {
+               evas_font_path_append(evas, PACKAGE_DATA_DIR "/fonts");
                etox_smart = evas_smart_new("etox_smart", NULL, etox_free,
                                etox_set_layer, NULL, NULL, NULL, NULL,
                                etox_move, etox_resize, etox_show, etox_hide,
                                NULL, etox_set_clip, etox_unset_clip,
                                NULL);
+       }
 
        /*
         * Create the etox and assign it's evas to draw on.
@@ -39,7 +41,6 @@
        et = (Etox *) calloc(1, sizeof(Etox));
 
        et->evas = evas;
-       evas_font_path_append(evas, PACKAGE_DATA_DIR "/fonts");
        et->smart_obj = evas_object_smart_add(evas, etox_smart);
        evas_object_smart_data_set(et->smart_obj, et);
 
@@ -684,7 +685,7 @@
         * etox_get_length() includes the \n's at the end of each line
         * whereas et->length does not.
         */
-       ret = (char *) calloc(et->length, sizeof(char));
+       ret = (char *) calloc(et->length + 1, sizeof(char));
 
        temp = ret;
 
@@ -693,7 +694,7 @@
         */
        for (l = et->lines; l; l = l->next) {
                line = l->data;
-               etox_line_get_text(line, temp, et->length);
+               etox_line_get_text(line, temp, et->length + 1);
 
                /*
                 * FIXME: Currently, in etox_line_get_text(), line->length
@@ -937,7 +938,16 @@
         * Layout lines if appropriate.
         */
        if (et->lines)
-               etox_layout(et);
+         {
+            char *text;
+            
+            text = etox_get_text(obj);
+            if (text)
+              {
+                 etox_set_text(obj, text);
+                 free(text);
+              }
+         }
 
        /*
         * Adjust the clip box to display the contents correctly. We need to
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/etox/src/etox_line.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -3 -r1.45 -r1.46
--- etox_line.c 30 Oct 2004 04:42:23 -0000      1.45
+++ etox_line.c 13 Nov 2004 11:17:13 -0000      1.46
@@ -361,7 +361,7 @@
        char *temp;
        Evas_Object *es;
        Evas_List *l;
-       int sum = 0;
+       int sum = 0, pos = 0;
 
        CHECK_PARAM_POINTER("line", line);
        CHECK_PARAM_POINTER("buf", buf);
@@ -371,8 +371,11 @@
         * of the buffer. Then append a \n to the buffer at the end of the
         * line.
         */
+       if (len < 1) return;
+       buf[0] = 0;
        for (l = line->bits; l; l = l->next) {
                int t;
+               int tlen;
                es = l->data;
 
                sum += etox_style_length(es);
@@ -384,8 +387,15 @@
                        temp = "\t";
                else
                        temp = etox_style_get_text(es);
-               if (snprintf(buf, len, "%s%s", buf, temp) < len)
-                       fprintf(stderr, "WARNING! Etox concatenated a line.");
+               tlen = strlen(temp);
+               if (pos + tlen < len) {
+                       pos += tlen;
+                       strcat(buf, temp);
+               }
+               else {
+                       strncat(buf, temp, (len - pos));
+                       pos = len - 1;
+               }
                free(temp);
        }
        line->length = sum;
@@ -539,6 +549,7 @@
                        if (t == ETOX_BIT_TYPE_WRAP_MARKER) {
                                line->bits = evas_list_remove(line->bits,
                                                              marker);
+                               evas_object_del(marker);
                        }
                }
 




-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE
FREE OODBMS DOWNLOAD - A multidimensional database that combines
robust object and relational technologies, making it a perfect match
for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to