diff options
author | Ron Yorston <rmy@pobox.com> | 2018-10-08 08:31:11 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2018-10-08 08:31:11 +0100 |
commit | eee3722fd32c8c0929cfbacdbe0b6524e1fd645c (patch) | |
tree | c9026160e56f204c42029c705d1d16cecd515244 /libbb | |
parent | 25a1bcec7637e0f0c75d3ae6c09eb78fdb6f0a75 (diff) | |
parent | 349d72c19ced4fae64e8fdd5792b37e78ac2f616 (diff) | |
download | busybox-w32-eee3722fd32c8c0929cfbacdbe0b6524e1fd645c.tar.gz busybox-w32-eee3722fd32c8c0929cfbacdbe0b6524e1fd645c.tar.bz2 busybox-w32-eee3722fd32c8c0929cfbacdbe0b6524e1fd645c.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/lineedit.c | 2 | ||||
-rw-r--r-- | libbb/printable_string.c | 7 | ||||
-rw-r--r-- | libbb/time.c | 14 | ||||
-rw-r--r-- | libbb/unicode.c | 2 |
4 files changed, 22 insertions, 3 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 6ecf01765..19b579782 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
@@ -1139,7 +1139,7 @@ static void showfiles(void) | |||
1139 | ); | 1139 | ); |
1140 | } | 1140 | } |
1141 | if (ENABLE_UNICODE_SUPPORT) | 1141 | if (ENABLE_UNICODE_SUPPORT) |
1142 | puts(printable_string(NULL, matches[n])); | 1142 | puts(printable_string(matches[n])); |
1143 | else | 1143 | else |
1144 | puts(matches[n]); | 1144 | puts(matches[n]); |
1145 | } | 1145 | } |
diff --git a/libbb/printable_string.c b/libbb/printable_string.c index e638a178e..2e8895a4f 100644 --- a/libbb/printable_string.c +++ b/libbb/printable_string.c | |||
@@ -9,7 +9,7 @@ | |||
9 | #include "libbb.h" | 9 | #include "libbb.h" |
10 | #include "unicode.h" | 10 | #include "unicode.h" |
11 | 11 | ||
12 | const char* FAST_FUNC printable_string(uni_stat_t *stats, const char *str) | 12 | const char* FAST_FUNC printable_string2(uni_stat_t *stats, const char *str) |
13 | { | 13 | { |
14 | char *dst; | 14 | char *dst; |
15 | const char *s; | 15 | const char *s; |
@@ -55,3 +55,8 @@ const char* FAST_FUNC printable_string(uni_stat_t *stats, const char *str) | |||
55 | #endif | 55 | #endif |
56 | return auto_string(dst); | 56 | return auto_string(dst); |
57 | } | 57 | } |
58 | |||
59 | const char* FAST_FUNC printable_string(const char *str) | ||
60 | { | ||
61 | return printable_string2(NULL, str); | ||
62 | } | ||
diff --git a/libbb/time.c b/libbb/time.c index 82e6cb172..f9b8da0b3 100644 --- a/libbb/time.c +++ b/libbb/time.c | |||
@@ -184,6 +184,7 @@ void FAST_FUNC parse_datestr(const char *date_str, struct tm *ptm) | |||
184 | ptm->tm_year -= 1900; /* Adjust years */ | 184 | ptm->tm_year -= 1900; /* Adjust years */ |
185 | ptm->tm_mon -= 1; /* Adjust month from 1-12 to 0-11 */ | 185 | ptm->tm_mon -= 1; /* Adjust month from 1-12 to 0-11 */ |
186 | } else { | 186 | } else { |
187 | err: | ||
187 | bb_error_msg_and_die(bb_msg_invalid_date, date_str); | 188 | bb_error_msg_and_die(bb_msg_invalid_date, date_str); |
188 | } | 189 | } |
189 | ptm->tm_sec = 0; /* assume zero if [.SS] is not given */ | 190 | ptm->tm_sec = 0; /* assume zero if [.SS] is not given */ |
@@ -194,6 +195,19 @@ void FAST_FUNC parse_datestr(const char *date_str, struct tm *ptm) | |||
194 | end = '\0'; | 195 | end = '\0'; |
195 | /* else end != NUL and we error out */ | 196 | /* else end != NUL and we error out */ |
196 | } | 197 | } |
198 | /* Users were confused by "date -s 20180923" | ||
199 | * working (not in the way they were expecting). | ||
200 | * It was interpreted as MMDDhhmm, and not bothered by | ||
201 | * "month #20" in the least. Prevent such cases: | ||
202 | */ | ||
203 | if (ptm->tm_sec > 60 /* allow "23:60" leap second */ | ||
204 | || ptm->tm_min > 59 | ||
205 | || ptm->tm_hour > 23 | ||
206 | || ptm->tm_mday > 31 | ||
207 | || ptm->tm_mon > 11 /* month# is 0..11, not 1..12 */ | ||
208 | ) { | ||
209 | goto err; | ||
210 | } | ||
197 | } | 211 | } |
198 | if (end != '\0') { | 212 | if (end != '\0') { |
199 | bb_error_msg_and_die(bb_msg_invalid_date, date_str); | 213 | bb_error_msg_and_die(bb_msg_invalid_date, date_str); |
diff --git a/libbb/unicode.c b/libbb/unicode.c index d378175a4..89d42179b 100644 --- a/libbb/unicode.c +++ b/libbb/unicode.c | |||
@@ -996,7 +996,7 @@ size_t FAST_FUNC unicode_strlen(const char *string) | |||
996 | size_t FAST_FUNC unicode_strwidth(const char *string) | 996 | size_t FAST_FUNC unicode_strwidth(const char *string) |
997 | { | 997 | { |
998 | uni_stat_t uni_stat; | 998 | uni_stat_t uni_stat; |
999 | printable_string(&uni_stat, string); | 999 | printable_string2(&uni_stat, string); |
1000 | return uni_stat.unicode_width; | 1000 | return uni_stat.unicode_width; |
1001 | } | 1001 | } |
1002 | 1002 | ||