Cleanup some warnings and a really obvious bug.
[oweals/busybox.git] / date.c
diff --git a/date.c b/date.c
index 73fc705119b34af1e8400daaa2e27f5a3fa8d735..6db3e2838731b0f0b0dd0e26ad021b7a245199d2 100644 (file)
--- a/date.c
+++ b/date.c
  *
 */
 
-#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 <string.h>
 #include <getopt.h>
+#include "busybox.h"
 
 
 /* This 'date' command supports only 2 time setting formats, 
@@ -45,7 +42,7 @@
 
 /* Default input handling to save suprising some people */
 
-struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
+static struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
 {
        int nr;
 
@@ -72,7 +69,7 @@ struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
 
 /* The new stuff for LRP */
 
-struct tm *date_conv_ftime(struct tm *tm_time, const char *t_string)
+static struct tm *date_conv_ftime(struct tm *tm_time, const char *t_string)
 {
        struct tm t;
 
@@ -150,7 +147,7 @@ int date_main(int argc, char **argv)
                        case 's':
                                set_time = 1;
                                if ((date_str != NULL) || ((date_str = optarg) == NULL)) {
-                                       usage(date_usage);
+                                       show_usage();
                                }
                                break;
                        case 'u':
@@ -161,10 +158,10 @@ int date_main(int argc, char **argv)
                        case 'd':
                                use_arg = 1;
                                if ((date_str != NULL) || ((date_str = optarg) == NULL))
-                                       usage(date_usage);
+                                       show_usage();
                                break;
                        default:
-                               usage(date_usage);
+                               show_usage();
                }
        }
 
@@ -177,7 +174,7 @@ int date_main(int argc, char **argv)
 #if 0
        else {
                error_msg("date_str='%s'  date_fmt='%s'\n", date_str, date_fmt);
-               usage(date_usage);
+               show_usage();
        }
 #endif
 
@@ -202,7 +199,7 @@ int date_main(int argc, char **argv)
                        date_conv_time(&tm_time, date_str);
                }
 
-               /* Correct any day of week and day of year etc fields */
+               /* Correct any day of week and day of year etc. fields */
                tm = mktime(&tm_time);
                if (tm < 0)
                        error_msg_and_die(invalid_date, date_str); 
@@ -244,7 +241,7 @@ int date_main(int argc, char **argv)
        /* Print OUTPUT (after ALL that!) */
        t_buff = xmalloc(201);
        strftime(t_buff, 200, date_fmt, &tm_time);
-       printf("%s\n", t_buff);
+       puts(t_buff);
 
        return EXIT_SUCCESS;
 }