提交 ce366525 编写于 作者: B bernard.xiong

use strlcpy instead of rt_strlcpy.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@498 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 c9ee5a06
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
*/ */
#include "rtc_calendar.h" #include "rtc_calendar.h"
#include <string.h>
extern void rt_hw_console_putc(char c); extern void rt_hw_console_putc(char c);
extern rt_uint8_t rt_hw_serial_getc(void); extern rt_uint8_t rt_hw_serial_getc(void);
...@@ -145,18 +146,18 @@ void rt_rtc_year_month_day_seperate(rt_uint32_t year) ...@@ -145,18 +146,18 @@ void rt_rtc_year_month_day_seperate(rt_uint32_t year)
rt_kprintf("\nPlease input year and month, if not, system default is loaded!\n"); rt_kprintf("\nPlease input year and month, if not, system default is loaded!\n");
year = DEFAULT_YEAR; year = DEFAULT_YEAR;
} }
if (year / 100 < 30 && year / 100 > 18) if (year / 100 < 30 && year / 100 > 18)
{ {
year_seprt = year; year_seprt = year;
month_seprt = 0; month_seprt = 0;
day_seprt = 0; day_seprt = 0;
} else if (year / 100 < 300 && year / 100 > 196) } else if (year / 100 < 300 && year / 100 > 196)
{ {
year_seprt = year / 10; year_seprt = year / 10;
month_seprt = year % 10; month_seprt = year % 10;
day_seprt = 0; day_seprt = 0;
} else if (year / 100 < 3000 && year / 100 > 1960) } else if (year / 100 < 3000 && year / 100 > 1960)
{ {
year_seprt = year / 100; year_seprt = year / 100;
month_seprt = year % 100; month_seprt = year % 100;
if (month_seprt > 12) { if (month_seprt > 12) {
...@@ -166,11 +167,11 @@ void rt_rtc_year_month_day_seperate(rt_uint32_t year) ...@@ -166,11 +167,11 @@ void rt_rtc_year_month_day_seperate(rt_uint32_t year)
} else if (month_seprt < 10) } else if (month_seprt < 10)
day_seprt = 0; day_seprt = 0;
} else if (year / 100 < 30000 && year / 100 > 19600) } else if (year / 100 < 30000 && year / 100 > 19600)
{ {
year_seprt = year / 1000; year_seprt = year / 1000;
month_seprt = (year % 1000) / 100; month_seprt = (year % 1000) / 100;
if (month_seprt == 0) if (month_seprt == 0)
{ {
month_seprt = (year % 100) / 10; month_seprt = (year % 100) / 10;
day_seprt = year % 10; day_seprt = year % 10;
...@@ -210,7 +211,7 @@ void rt_rtc_weekdate_calculate(void) ...@@ -210,7 +211,7 @@ void rt_rtc_weekdate_calculate(void)
} }
extern char *rt_strlcpy(char *dest, const char *src, rt_ubase_t n); extern size_t strlcpy(char *dest, const char *src, size_t siz);
rt_uint8_t *list_month[12]={"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; rt_uint8_t *list_month[12]={"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
void rt_calendar(void) void rt_calendar(void)
{ {
...@@ -219,10 +220,10 @@ void rt_calendar(void) ...@@ -219,10 +220,10 @@ void rt_calendar(void)
rt_uint8_t i = 0; rt_uint8_t i = 0;
rt_int32_t result, num_month, num_year; rt_int32_t result, num_month, num_year;
rt_uint8_t date_year[7], date_month[3], *date = __DATE__; rt_uint8_t date_year[7], date_month[3], *date = __DATE__;
rt_strlcpy((char *)date_month, (const char *)date, 3); strlcpy((char *)date_month, (const char *)date, 3);
date += 7; date += 7;
rt_strlcpy((char *)date_year, (const char *)date, 4); strlcpy((char *)date_year, (const char *)date, 4);
date = RT_NULL; date = RT_NULL;
num_year = atoi(date_year); num_year = atoi(date_year);
do{ do{
...@@ -231,7 +232,7 @@ void rt_calendar(void) ...@@ -231,7 +232,7 @@ void rt_calendar(void)
result = 1; result = 1;
else else
num_month = i; num_month = i;
}while(result); }while(result);
i = 0; i = 0;
result = 1; result = 1;
year = num_year*100 + num_month; year = num_year*100 + num_month;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册