Enlightenment CVS committal

Author  : dj2
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/lib


Modified Files:
        ewl_calendar.c ewl_calendar.h ewl_datepicker.c 


Log Message:
- name ewl_calendar_ascii_time_get return the string instead of taking an
  array paramter
- use snprintf instead of strcat

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_calendar.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -3 -r1.12 -r1.13
--- ewl_calendar.c      23 Oct 2005 16:21:12 -0000      1.12
+++ ewl_calendar.c      23 Oct 2005 18:19:25 -0000      1.13
@@ -126,22 +126,20 @@
 
 /**
  * @param cal: The calendar to get the date frm
- * @param str: a pre-initialized char * pointer to insert the date into
  * @return none 
  * @brief Returns an ASCII formatted representation of the selected date
- *
- * Inserts an ASCII formatted string of the currently selected date into the 
char* str pointer
+ * the user must freet this string.
  */
-void
-ewl_calendar_ascii_time_get(Ewl_Calendar *cal, char *str) 
+char *
+ewl_calendar_ascii_time_get(Ewl_Calendar *cal) 
 {
        time_t tm;
        struct tm* month_start;
+       char str[1024];
 
        DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR("cal", cal);
-       DCHECK_PARAM_PTR("str", str);
-       DCHECK_TYPE("cal", cal, "calendar");
+       DCHECK_PARAM_PTR_RET("cal", cal, NULL);
+       DCHECK_TYPE_RET("cal", cal, "calendar", NULL);
 
        tm = time(NULL);
        month_start = localtime(&tm);
@@ -150,9 +148,9 @@
        month_start->tm_year = cal->cur_year - 1900;
        mktime(month_start);
 
-       strcpy(str, asctime(month_start));
+       snprintf(str, sizeof(str), "%s", asctime(month_start));
        
-       DLEAVE_FUNCTION(DLEVEL_STABLE);
+       DRETURN_PTR(strdup(str), DLEVEL_STABLE);
 }
 
 /**
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_calendar.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- ewl_calendar.h      23 Oct 2005 16:05:37 -0000      1.5
+++ ewl_calendar.h      23 Oct 2005 18:19:25 -0000      1.6
@@ -40,7 +40,7 @@
 
 Ewl_Widget     *ewl_calendar_new(void);
 int             ewl_calendar_init(Ewl_Calendar *calendar);
-void            ewl_calendar_ascii_time_get(Ewl_Calendar *cal, char *str);
+char *                  ewl_calendar_ascii_time_get(Ewl_Calendar *cal);
 int             ewl_calendar_day_get(Ewl_Calendar *c);
 int             ewl_calendar_month_get(Ewl_Calendar *c);
 int             ewl_calendar_year_get(Ewl_Calendar *c);
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_datepicker.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- ewl_datepicker.c    23 Oct 2005 18:12:26 -0000      1.6
+++ ewl_datepicker.c    23 Oct 2005 18:19:25 -0000      1.7
@@ -113,7 +113,7 @@
 ewl_datepicker_value_changed_cb(Ewl_Widget *w __UNUSED__, void *ev_data 
__UNUSED__, 
                                                        void *user_data) 
 {
-       static char date[1024];
+       char *date;
        Ewl_Datepicker* dp;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
@@ -122,8 +122,9 @@
        dp = EWL_DATEPICKER(user_data);
        ewl_widget_hide(dp->calendar_window);
 
-       ewl_calendar_ascii_time_get(EWL_CALENDAR(dp->calendar), date);
+       date = ewl_calendar_ascii_time_get(EWL_CALENDAR(dp->calendar));
        ewl_text_text_set(EWL_TEXT(dp), date);
+       FREE(date);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }




-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to