projects
/
oweals
/
busybox.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix warning
[oweals/busybox.git]
/
date.c
diff --git
a/date.c
b/date.c
index 2e69bde4a96afc80e2311dc597ad9ff422d251c1..4b2f66add384cfc87b32eaf3d3bbb0922547df26 100644
(file)
--- a/
date.c
+++ b/
date.c
@@
-20,18
+20,19
@@
*
*/
*
*/
-#include "busybox.h"
-#define BB_DECLARE_EXTERN
-#define bb_need_invalid_date
-#define bb_need_memory_exhausted
-#include "messages.c"
#include <stdlib.h>
#include <errno.h>
#include <sys/time.h>
#include <unistd.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/time.h>
#include <unistd.h>
#include <time.h>
#include <stdio.h>
+#include <string.h>
#include <getopt.h>
#include <getopt.h>
+#include "busybox.h"
+#define BB_DECLARE_EXTERN
+#define bb_need_invalid_date
+#define bb_need_memory_exhausted
+#include "messages.c"
/* This 'date' command supports only 2 time setting formats,
/* This 'date' command supports only 2 time setting formats,
@@
-45,7
+46,7
@@
/* Default input handling to save suprising some people */
/* Default input handling to save suprising some people */
-struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
+st
atic st
ruct tm *date_conv_time(struct tm *tm_time, const char *t_string)
{
int nr;
{
int nr;
@@
-56,7
+57,7
@@
struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
&(tm_time->tm_min), &(tm_time->tm_year));
if (nr < 4 || nr > 5) {
&(tm_time->tm_min), &(tm_time->tm_year));
if (nr < 4 || nr > 5) {
-
fatalError
(invalid_date, t_string);
+
error_msg_and_die
(invalid_date, t_string);
}
/* correct for century - minor Y2K problem here? */
}
/* correct for century - minor Y2K problem here? */
@@
-72,7
+73,7
@@
struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
/* The new stuff for LRP */
/* The new stuff for LRP */
-struct tm *date_conv_ftime(struct tm *tm_time, const char *t_string)
+st
atic st
ruct tm *date_conv_ftime(struct tm *tm_time, const char *t_string)
{
struct tm t;
{
struct tm t;
@@
-121,7
+122,7
@@
struct tm *date_conv_ftime(struct tm *tm_time, const char *t_string)
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
} else {
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
} else {
-
fatalError
(invalid_date, t_string);
+
error_msg_and_die
(invalid_date, t_string);
}
*tm_time = t;
return (tm_time);
}
*tm_time = t;
return (tm_time);
@@
-150,21
+151,21
@@
int date_main(int argc, char **argv)
case 's':
set_time = 1;
if ((date_str != NULL) || ((date_str = optarg) == NULL)) {
case 's':
set_time = 1;
if ((date_str != NULL) || ((date_str = optarg) == NULL)) {
-
usage(date_usage
);
+
show_usage(
);
}
break;
case 'u':
utc = 1;
if (putenv("TZ=UTC0") != 0)
}
break;
case 'u':
utc = 1;
if (putenv("TZ=UTC0") != 0)
-
fatalError
(memory_exhausted);
+
error_msg_and_die
(memory_exhausted);
break;
case 'd':
use_arg = 1;
if ((date_str != NULL) || ((date_str = optarg) == NULL))
break;
case 'd':
use_arg = 1;
if ((date_str != NULL) || ((date_str = optarg) == NULL))
-
usage(date_usage
);
+
show_usage(
);
break;
default:
break;
default:
-
usage(date_usage
);
+
show_usage(
);
}
}
}
}
@@
-176,8
+177,8
@@
int date_main(int argc, char **argv)
}
#if 0
else {
}
#if 0
else {
- error
M
sg("date_str='%s' date_fmt='%s'\n", date_str, date_fmt);
-
usage(date_usage
);
+ error
_m
sg("date_str='%s' date_fmt='%s'\n", date_str, date_fmt);
+
show_usage(
);
}
#endif
}
#endif
@@
-205,16
+206,16
@@
int date_main(int argc, char **argv)
/* Correct any day of week and day of year etc fields */
tm = mktime(&tm_time);
if (tm < 0)
/* Correct any day of week and day of year etc fields */
tm = mktime(&tm_time);
if (tm < 0)
-
fatalError
(invalid_date, date_str);
+
error_msg_and_die
(invalid_date, date_str);
if ( utc ) {
if (putenv("TZ=UTC0") != 0)
if ( utc ) {
if (putenv("TZ=UTC0") != 0)
-
fatalError
(memory_exhausted);
+
error_msg_and_die
(memory_exhausted);
}
/* if setting time, set it */
if (set_time) {
if (stime(&tm) < 0) {
}
/* if setting time, set it */
if (set_time) {
if (stime(&tm) < 0) {
- perror
M
sg("cannot set date");
+ perror
_m
sg("cannot set date");
}
}
}
}
}
}