fixed another bug: ver1.0 rrule is not composed properly 89/51389/3
authorJeesun Kim <iamjs.kim@samsung.com>
Thu, 15 Oct 2015 08:29:23 +0000 (17:29 +0900)
committerjeesun kim <iamjs.kim@samsung.com>
Tue, 10 Nov 2015 04:40:05 +0000 (20:40 -0800)
Change-Id: I4937c2f76bd28b326fa8611a1ddd3cf405a464fd

common/cal_vcalendar_make.c
common/cal_vcalendar_parse.c

index 6c62562..f81cb73 100644 (file)
@@ -510,34 +510,31 @@ static void _cal_vcalendar_make_alarm(cal_make_s *b, calendar_record_h alarm)
 
 int _cal_vcalendar_make_rrule_append_mday(char *buf, int buf_len, char *mday)
 {
-       int i;
-       int num;
-       int length = 0;
-       char **t = NULL;
-       char *p = NULL;
+       int ret = 0;
 
-       RETV_IF(NULL == buf, CALENDAR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == mday, CALENDAR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == buf, 0);
+       RETV_IF(NULL == mday, 0);
 
+       char **t = NULL;
        t = g_strsplit_set(mday, " ,", -1);
        if (!t) {
                ERR("g_strsplit_set() Fail");
                g_strfreev(t);
-               return CALENDAR_ERROR_OUT_OF_MEMORY;
+               return 0;
        }
        int len = strlen(buf);
-       length = g_strv_length(t);
-       for (i = 0; i < length; i++) {
+       int tlen = g_strv_length(t);
+       int i;
+       for (i = 0; i < tlen; i++) {
                if (*t[i] == '\0')
                        continue;
 
-               p = t[i];
-               num = atoi(p);
-               len += snprintf(buf +len, buf_len -len, "%d%s ", num, 0 < num? "": "-");
+               int num = atoi(t[i]);
+               ret = snprintf(buf +len, buf_len -len, "%d%s", num, 0 < num? " ": "- ");
        }
        g_strfreev(t);
 
-       return CALENDAR_ERROR_NONE;
+       return ret;
 }
 
 static void _cal_vcalendar_make_rrule_append_setpos(calendar_record_h record, char *buf, int buf_len)
@@ -991,9 +988,9 @@ static void __make_rrule_ver1(cal_make_s *b, calendar_record_h record)
        switch (freq) {
        case CALENDAR_RECURRENCE_YEARLY:
                if (bymonth && *bymonth) {
-                       DBG("bymonth");
+                       DBG("bymonth[%s]", bymonth);
                        len += snprintf(buf +len, sizeof(buf) -len, "YM%d ", interval);
-                       _cal_vcalendar_make_rrule_append_mday(buf, sizeof(buf), bymonth);
+                       len +=_cal_vcalendar_make_rrule_append_mday(buf, sizeof(buf), bymonth);
 
                        if (byday && *byday) {
                                DBG("byday");
index 22e1ff6..0fa531b 100644 (file)
@@ -1565,7 +1565,9 @@ static void __work_component_property_rrule_ver_1(char *value, calendar_record_h
 
        int i;
        for (i = 0; i < len; i++) {
-               if (NULL == t[i] || '\0' == *t[i]) continue;
+               if (NULL == t[i] || '\0' == *t[i])
+                       continue;
+
                DBG("[%s]", t[i]);
 
                if (true == __is_wday_string(t[i])) {