update changelog和日期模块增加g_free
This commit is contained in:
parent
2ec424b02a
commit
b26ae85de1
|
@ -1,3 +1,12 @@
|
|||
libkysdk-system (2.4.0.0-0k1.1) nile; urgency=medium
|
||||
|
||||
* BUG:无
|
||||
* 需求号:26155 提供活跃用户的sdk接口
|
||||
* 其他改动说明:解决日期模块崩溃问题
|
||||
* 其他改动影响域:无
|
||||
|
||||
-- szm-min <shaozhimin@kylinos.cn> Tue, 05 Mar 2024 15:38:23 +0800
|
||||
|
||||
libkysdk-system (2.3.0.0-0k5.2) nile; urgency=medium
|
||||
|
||||
* BUG:无
|
||||
|
|
|
@ -55,7 +55,7 @@ uint verify_file(char *pFileName)
|
|||
|
||||
char *en_long_mon(int mon)
|
||||
{
|
||||
char *en_mon = (char *)malloc(15 * sizeof(char));
|
||||
char *en_mon = (char *)malloc(32 * sizeof(char));
|
||||
switch (mon)
|
||||
{
|
||||
case 1:
|
||||
|
@ -102,7 +102,7 @@ char *en_long_mon(int mon)
|
|||
|
||||
char *en_short_mon(int mon)
|
||||
{
|
||||
char *en_mon = (char *)malloc(15 * sizeof(char));
|
||||
char *en_mon = (char *)malloc(32 * sizeof(char));
|
||||
switch (mon)
|
||||
{
|
||||
case 1:
|
||||
|
@ -279,6 +279,7 @@ char** kdk_system_get_dateformat()
|
|||
index++;
|
||||
res[index] = NULL;
|
||||
fclose(fp);
|
||||
g_free(tmpval);
|
||||
return res;
|
||||
out:
|
||||
while(index)
|
||||
|
@ -287,6 +288,7 @@ out:
|
|||
}
|
||||
free(res);
|
||||
fclose(fp);
|
||||
g_free(tmpval);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -327,7 +329,7 @@ int strtok_short_date(char *tmp, char *str)
|
|||
int kdk_system_set_dateformat(char *date)
|
||||
{
|
||||
int i = 0;
|
||||
char tmp[64];
|
||||
char tmp[64] = {0};
|
||||
char *homeDir = NULL;
|
||||
strcpy(tmp, date);
|
||||
GKeyFile *config = g_key_file_new();
|
||||
|
@ -372,7 +374,7 @@ int kdk_system_set_dateformat(char *date)
|
|||
memset(path, 0, sizeof(path));
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", filename);
|
||||
|
||||
char tpath[100] = {0};
|
||||
char tpath[512] = {0};
|
||||
|
||||
char *home = getlogin();
|
||||
|
||||
|
@ -425,7 +427,7 @@ int kdk_system_set_dateformat(char *date)
|
|||
}
|
||||
else if(strstr(tmp, ","))
|
||||
{
|
||||
char *buf[3], *p = NULL;
|
||||
char *buf[16], *p = NULL;
|
||||
p = strtok(tmp, ",");
|
||||
while(p)
|
||||
{
|
||||
|
@ -504,7 +506,7 @@ int kdk_system_set_24_timeformat()
|
|||
|
||||
GKeyFile *config = g_key_file_new();
|
||||
GError *gerr = NULL;
|
||||
char tpath[100] = {0};
|
||||
char tpath[512] = {0};
|
||||
|
||||
char *home = getlogin();
|
||||
|
||||
|
@ -550,7 +552,7 @@ int kdk_system_set_12_timeformat()
|
|||
memset(path, 0, sizeof(path));
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", filename);
|
||||
GKeyFile *config = g_key_file_new();
|
||||
char tpath[100] = {0};
|
||||
char tpath[512] = {0};
|
||||
|
||||
char *home = getlogin();
|
||||
|
||||
|
@ -633,6 +635,7 @@ char* kdk_system_get_now_dateformat()
|
|||
}
|
||||
}
|
||||
fclose(fp);
|
||||
g_free(value);
|
||||
}
|
||||
g_key_file_free(config);
|
||||
return tvalue;
|
||||
|
@ -644,7 +647,7 @@ char* kdk_system_get_now_timeformat()
|
|||
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
|
||||
textdomain (GETTEXT_PACKAGE);
|
||||
char *homeDir = NULL;
|
||||
char value[64] = "\0";
|
||||
char value[128] = "\0";
|
||||
char *tvalue = malloc(sizeof(char) * 128);
|
||||
char canonical_filename[PATH_MAX_H] = "\0";
|
||||
char filename[PATH_MAX_H] = "\0";
|
||||
|
@ -712,6 +715,7 @@ char* kdk_system_get_now_timeformat()
|
|||
}
|
||||
}
|
||||
fclose(fp);
|
||||
g_free(gkey);
|
||||
g_key_file_free(config);
|
||||
}
|
||||
|
||||
|
@ -724,8 +728,8 @@ kdk_dateinfo *kdk_system_tran_dateformat(struct tm *ptr)
|
|||
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
|
||||
textdomain (GETTEXT_PACKAGE);
|
||||
char *homeDir = NULL;
|
||||
char *value = (char *)malloc(sizeof(char) * 64);
|
||||
char *tvalue = (char *)malloc(sizeof(char) * 64);
|
||||
char *value = (char *)malloc(sizeof(char) * 128);
|
||||
char *tvalue = (char *)malloc(sizeof(char) * 128);
|
||||
char tmp[128] = "\0";
|
||||
char tmpe[128] = "\0";
|
||||
char stmp[128] = "\0";
|
||||
|
@ -781,6 +785,7 @@ kdk_dateinfo *kdk_system_tran_dateformat(struct tm *ptr)
|
|||
strcpy(value, gkey);
|
||||
}
|
||||
fclose(fp);
|
||||
g_free(gkey);
|
||||
}
|
||||
if(strstr(value, "*-*-*"))
|
||||
{
|
||||
|
@ -874,6 +879,7 @@ kdk_dateinfo *kdk_system_tran_dateformat(struct tm *ptr)
|
|||
else{
|
||||
strcpy(tvalue, gkey);
|
||||
}
|
||||
g_free(gkey);
|
||||
|
||||
if(strstr(tvalue, "12小时制"))
|
||||
{
|
||||
|
@ -942,7 +948,7 @@ char* kdk_system_nowtime()
|
|||
time_t current;
|
||||
time(¤t);
|
||||
now = localtime(¤t);
|
||||
char *tvalue = (char*)malloc(sizeof(char) * 64);
|
||||
char *tvalue = (char*)malloc(sizeof(char) * 128);
|
||||
char *value = (char*)malloc(sizeof(char) * 128);
|
||||
GKeyFile *config = g_key_file_new();
|
||||
char canonical_filename[PATH_MAX_H] = "\0";
|
||||
|
@ -984,6 +990,7 @@ char* kdk_system_nowtime()
|
|||
strcpy(tvalue, gkey);
|
||||
}
|
||||
fclose(fp);
|
||||
g_free(gkey);
|
||||
}
|
||||
if(strstr(tvalue, "24小时制"))
|
||||
{
|
||||
|
@ -1040,7 +1047,7 @@ char* kdk_system_nowdate()
|
|||
time_t current;
|
||||
time(¤t);
|
||||
p = localtime(¤t);
|
||||
char *tvalue = malloc(sizeof(char) * 64);
|
||||
char *tvalue = malloc(sizeof(char) * 128);
|
||||
char *value = malloc(sizeof(char) * 128);
|
||||
GKeyFile *config = g_key_file_new();
|
||||
char canonical_filename[PATH_MAX_H] = "\0";
|
||||
|
@ -1087,6 +1094,7 @@ char* kdk_system_nowdate()
|
|||
strcpy(tvalue, gkey);
|
||||
}
|
||||
fclose(fp);
|
||||
g_free(gkey);
|
||||
}
|
||||
if (strstr(tvalue, "**/**/**"))
|
||||
{
|
||||
|
@ -1397,7 +1405,7 @@ char* kdk_system_second()
|
|||
time_t current;
|
||||
time(¤t);
|
||||
now = localtime(¤t);
|
||||
char *tvalue = (char *)malloc(sizeof(char) * 64);
|
||||
char *tvalue = (char *)malloc(sizeof(char) * 128);
|
||||
char *value = (char *)malloc(sizeof(char) * 128);
|
||||
GKeyFile *config = g_key_file_new();
|
||||
char canonical_filename[PATH_MAX_H] = "\0";
|
||||
|
@ -1439,6 +1447,7 @@ char* kdk_system_second()
|
|||
strcpy(tvalue, gkey);
|
||||
}
|
||||
fclose(fp);
|
||||
g_free(gkey);
|
||||
}
|
||||
if(strstr(tvalue, "24小时制"))
|
||||
{
|
||||
|
@ -1632,10 +1641,10 @@ char* kdk_system_gjx_time(char *date)
|
|||
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
|
||||
textdomain (GETTEXT_PACKAGE);
|
||||
char tmp[128] = "\0";
|
||||
char dtmp[64];
|
||||
char dtmp[128] = "\0";
|
||||
strcpy(dtmp, date);
|
||||
char *homeDir = NULL;
|
||||
char *tvalue = (char *)malloc(sizeof(char) * 64);
|
||||
char *tvalue = (char *)malloc(sizeof(char) * 128);
|
||||
char *value = (char*)malloc(sizeof(char) * 128);
|
||||
GKeyFile *config = g_key_file_new();
|
||||
char canonical_filename[PATH_MAX_H] = "\0";
|
||||
|
@ -1667,7 +1676,7 @@ char* kdk_system_gjx_time(char *date)
|
|||
}
|
||||
|
||||
int i = 0;
|
||||
char *buf[3], *p = NULL;
|
||||
char *buf[16], *p = NULL;
|
||||
p = strtok(dtmp, "/");
|
||||
while(p)
|
||||
{
|
||||
|
@ -1678,9 +1687,9 @@ char* kdk_system_gjx_time(char *date)
|
|||
int year = atoi(buf[2]);
|
||||
int mon = atoi(buf[0]);
|
||||
int day = atoi(buf[1]);
|
||||
char *years = (char*)malloc(sizeof(char) * 5);;
|
||||
char *mons = (char*)malloc(sizeof(char) * 5);;
|
||||
char *days = (char*)malloc(sizeof(char) * 5);;
|
||||
char *years = (char*)malloc(sizeof(char) * 32);
|
||||
char *mons = (char*)malloc(sizeof(char) * 32);
|
||||
char *days = (char*)malloc(sizeof(char) * 32);
|
||||
strcpy(years, buf[2]);
|
||||
strcpy(mons, buf[0]);
|
||||
strcpy(days, buf[1]);
|
||||
|
@ -1700,6 +1709,7 @@ char* kdk_system_gjx_time(char *date)
|
|||
strcpy(tvalue, gkey);
|
||||
}
|
||||
fclose(fp);
|
||||
g_free(gkey);
|
||||
}
|
||||
struct tm ptr;
|
||||
ptr.tm_year = year;
|
||||
|
@ -1708,7 +1718,7 @@ char* kdk_system_gjx_time(char *date)
|
|||
time_t timep;
|
||||
timep = mktime(&ptr);
|
||||
strcpy(dtmp, ctime(&timep));
|
||||
char *buff[3], *q = NULL;
|
||||
char *buff[16], *q = NULL;
|
||||
q = strtok(dtmp, " ");
|
||||
while(q)
|
||||
{
|
||||
|
@ -1829,7 +1839,7 @@ void kdk_free_logn_dateinfo(kdk_logn_dateinfo *date)
|
|||
int kdk_system_set_long_dateformat(char *format)
|
||||
{
|
||||
int i = 0;
|
||||
char tmp[64];
|
||||
char tmp[64] = {0};
|
||||
char *homeDir = NULL;
|
||||
strcpy(tmp, format);
|
||||
GKeyFile *config = g_key_file_new();
|
||||
|
@ -1860,7 +1870,7 @@ int kdk_system_set_long_dateformat(char *format)
|
|||
memset(path, 0, sizeof(path));
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", filename);
|
||||
|
||||
char tpath[100] = {0};
|
||||
char tpath[128] = {0};
|
||||
|
||||
char *home = getlogin();
|
||||
|
||||
|
@ -1930,7 +1940,7 @@ err:
|
|||
|
||||
int kdk_system_set_short_dateformat(char *format)
|
||||
{
|
||||
char tmp[64];
|
||||
char tmp[64] = {0};
|
||||
char *homeDir = NULL;
|
||||
strcpy(tmp, format);
|
||||
GKeyFile *config = g_key_file_new();
|
||||
|
@ -2114,6 +2124,7 @@ char* kdk_system_get_longformat_date()
|
|||
strcpy(tvalue, gkey);
|
||||
}
|
||||
fclose(fp);
|
||||
g_free(gkey);
|
||||
}
|
||||
|
||||
if (strstr(tvalue, "yyyy MM dd"))
|
||||
|
@ -2217,6 +2228,7 @@ char* kdk_system_get_shortformat_date()
|
|||
strcpy(tvalue, gkey);
|
||||
}
|
||||
fclose(fp);
|
||||
g_free(gkey);
|
||||
}
|
||||
|
||||
if (strstr(tvalue, "yyyy/MM/dd"))
|
||||
|
@ -2325,6 +2337,7 @@ char* kdk_system_get_longformat()
|
|||
strcpy(tvalue, value);
|
||||
}
|
||||
fclose(fp);
|
||||
g_free(value);
|
||||
}
|
||||
g_key_file_free(config);
|
||||
return tvalue;
|
||||
|
@ -2395,6 +2408,7 @@ char* kdk_system_get_shortformat()
|
|||
strcpy(tvalue, value);
|
||||
}
|
||||
fclose(fp);
|
||||
g_free(value);
|
||||
}
|
||||
g_key_file_free(config);
|
||||
return tvalue;
|
||||
|
@ -2457,6 +2471,7 @@ char* kdk_system_longformat_transform(struct tm *ptr)
|
|||
strcpy(value, gkey);
|
||||
}
|
||||
fclose(fp);
|
||||
g_free(gkey);
|
||||
}
|
||||
|
||||
if(strstr(value, "yy M d"))
|
||||
|
@ -2497,7 +2512,7 @@ char* kdk_system_shortformat_transform(struct tm *ptr)
|
|||
char *homeDir = NULL;
|
||||
char value[32] = "\0";
|
||||
char *tvalue = (char *)malloc(sizeof(char) * 64);
|
||||
char tmp[64];
|
||||
char tmp[64] = {0};
|
||||
char canonical_filename[PATH_MAX_H] = "\0";
|
||||
char filename[PATH_MAX_H] = "\0";
|
||||
struct tm stPrt;
|
||||
|
@ -2559,6 +2574,7 @@ char* kdk_system_shortformat_transform(struct tm *ptr)
|
|||
strcpy(value, gkey);
|
||||
}
|
||||
fclose(fp);
|
||||
g_free(gkey);
|
||||
}
|
||||
|
||||
if(strstr(value, "yy-M-d"))
|
||||
|
@ -2806,6 +2822,7 @@ kdk_timeinfo *kdk_system_timeformat_transform(struct tm *ptr)
|
|||
strcpy(tvalue, gkey);
|
||||
}
|
||||
fclose(fp);
|
||||
g_free(gkey);
|
||||
}
|
||||
res->time = malloc(sizeof(struct tm) + 1);
|
||||
|
||||
|
@ -2872,12 +2889,13 @@ char* kdk_system_tran_absolute_date(struct tm *ptr)
|
|||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
|
||||
textdomain (GETTEXT_PACKAGE);
|
||||
char *absDate = (char *)malloc(sizeof(char) * 128);
|
||||
char *absDate = calloc(1,64);
|
||||
if(!absDate)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
memset(absDate, 0, 64);
|
||||
char *trans = NULL;
|
||||
char *lang = getenv("LANG");
|
||||
time_t timep;
|
||||
time(&timep);
|
||||
|
@ -2892,7 +2910,9 @@ char* kdk_system_tran_absolute_date(struct tm *ptr)
|
|||
asbPtr.tm_mday = absDay;
|
||||
if(ySpace != 0 || mSpace != 0 || dSpace > 1)
|
||||
{
|
||||
absDate = kdk_system_shortformat_transform(&asbPtr);
|
||||
trans = kdk_system_shortformat_transform(&asbPtr);
|
||||
strcpy(absDate, trans);
|
||||
free(trans);
|
||||
}
|
||||
else if(ySpace == 0 && mSpace == 0 && dSpace == 1)
|
||||
{
|
||||
|
@ -2901,8 +2921,11 @@ char* kdk_system_tran_absolute_date(struct tm *ptr)
|
|||
strcpy(absDate, gettext("Yesterday"));
|
||||
}
|
||||
else
|
||||
absDate = kdk_system_shortformat_transform(&asbPtr);
|
||||
|
||||
{
|
||||
trans = kdk_system_shortformat_transform(&asbPtr);
|
||||
strcpy(absDate, trans);
|
||||
free(trans);
|
||||
}
|
||||
}
|
||||
else if(ySpace == 0 && mSpace == 0 && dSpace == 0)
|
||||
{
|
||||
|
@ -2911,7 +2934,11 @@ char* kdk_system_tran_absolute_date(struct tm *ptr)
|
|||
strcpy(absDate, gettext("Today"));
|
||||
}
|
||||
else
|
||||
absDate = kdk_system_shortformat_transform(&asbPtr);
|
||||
{
|
||||
trans = kdk_system_shortformat_transform(&asbPtr);
|
||||
strcpy(absDate, trans);
|
||||
free(trans);
|
||||
}
|
||||
}
|
||||
|
||||
return absDate;
|
||||
|
|
Loading…
Reference in New Issue