projects
/
oweals
/
busybox.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sulogin: use bb_error_msg instead of bb_info_msg; better message
[oweals/busybox.git]
/
coreutils
/
cal.c
diff --git
a/coreutils/cal.c
b/coreutils/cal.c
index 5ecb9131ddd2f319f1f321f7eb03d8beaac32b8e..12c46b14ffa6a5f359f7bcbbc789811a63fd511b 100644
(file)
--- a/
coreutils/cal.c
+++ b/
coreutils/cal.c
@@
-4,7
+4,7
@@
*
* See original copyright at the end of this file
*
*
* See original copyright at the end of this file
*
- * Licensed under GPLv2 or later, see file LICENSE in this
tarball for details
.
+ * Licensed under GPLv2 or later, see file LICENSE in this
source tree
.
*/
/* BB_AUDIT SUSv3 compliant with -j and -y extensions (from util-linux). */
*/
/* BB_AUDIT SUSv3 compliant with -j and -y extensions (from util-linux). */
@@
-16,6
+16,14
@@
*
* Major size reduction... over 50% (>1.5k) on i386.
*/
*
* Major size reduction... over 50% (>1.5k) on i386.
*/
+
+//usage:#define cal_trivial_usage
+//usage: "[-jy] [[MONTH] YEAR]"
+//usage:#define cal_full_usage "\n\n"
+//usage: "Display a calendar\n"
+//usage: "\n -j Use julian dates"
+//usage: "\n -y Display the entire year"
+
#include "libbb.h"
#include "unicode.h"
#include "libbb.h"
#include "unicode.h"
@@
-35,7
+43,7
@@
static const unsigned char days_in_month[] ALIGN1 = {
};
static const unsigned char sep1752[] ALIGN1 = {
};
static const unsigned char sep1752[] ALIGN1 = {
-
1,
2, 14, 15, 16,
+
1,
2, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30
};
17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30
};
@@
-87,8
+95,8
@@
int cal_main(int argc UNUSED_PARAM, char **argv)
/* "Su Mo Tu We Th Fr Sa" */
/* -j heading: */
/* " Su Mo Tu We Th Fr Sa" */
/* "Su Mo Tu We Th Fr Sa" */
/* -j heading: */
/* " Su Mo Tu We Th Fr Sa" */
- char day_headings[ENABLE_
FEATURE_ASSUME_UNICODE
? 28 * 6 : 28];
- IF_
FEATURE_ASSUME_UNICODE
(char *hp = day_headings;)
+ char day_headings[ENABLE_
UNICODE_SUPPORT
? 28 * 6 : 28];
+ IF_
UNICODE_SUPPORT
(char *hp = day_headings;)
char buf[40];
init_unicode();
char buf[40];
init_unicode();
@@
-113,7
+121,10
@@
int cal_main(int argc UNUSED_PARAM, char **argv)
if (argv[2]) {
bb_show_usage();
}
if (argv[2]) {
bb_show_usage();
}
- month = xatou_range(*argv++, 1, 12);
+ if (!(flags & 2)) { /* no -y */
+ month = xatou_range(*argv, 1, 12);
+ }
+ argv++;
}
year = xatou_range(*argv, 1, 9999);
}
}
year = xatou_range(*argv, 1, 9999);
}
@@
-131,11
+142,11
@@
int cal_main(int argc UNUSED_PARAM, char **argv)
zero_tm.tm_wday = i;
/* abbreviated weekday name according to locale */
strftime(buf, sizeof(buf), "%a", &zero_tm);
zero_tm.tm_wday = i;
/* abbreviated weekday name according to locale */
strftime(buf, sizeof(buf), "%a", &zero_tm);
-#if ENABLE_
FEATURE_ASSUME_UNICODE
+#if ENABLE_
UNICODE_SUPPORT
if (julian)
*hp++ = ' ';
{
if (julian)
*hp++ = ' ';
{
- char *two_wchars = unicode_c
ut_nchars(2, buf
);
+ char *two_wchars = unicode_c
onv_to_printable_fixedwidth(/*NULL,*/ buf, 2
);
strcpy(hp, two_wchars);
free(two_wchars);
}
strcpy(hp, two_wchars);
free(two_wchars);
}
@@
-146,7
+157,7
@@
int cal_main(int argc UNUSED_PARAM, char **argv)
#endif
}
} while (++i < 12);
#endif
}
} while (++i < 12);
- IF_
FEATURE_ASSUME_UNICODE
(hp[-1] = '\0';)
+ IF_
UNICODE_SUPPORT
(hp[-1] = '\0';)
if (month) {
unsigned row, len, days[MAXDAYS];
if (month) {
unsigned row, len, days[MAXDAYS];
@@
-154,10
+165,10
@@
int cal_main(int argc UNUSED_PARAM, char **argv)
char lineout[30];
day_array(month, year, dp);
char lineout[30];
day_array(month, year, dp);
- len = sprintf(lineout, "%s %
d
", month_names[month - 1], year);
+ len = sprintf(lineout, "%s %
u
", month_names[month - 1], year);
printf("%*s%s\n%s\n",
printf("%*s%s\n%s\n",
- ((7*julian + WEEK_LEN) - len) / 2, "",
- lineout, day_headings);
+
((7*julian + WEEK_LEN) - len) / 2, "",
+
lineout, day_headings);
for (row = 0; row < 6; row++) {
build_row(lineout, dp)[0] = '\0';
dp += 7;
for (row = 0; row < 6; row++) {
build_row(lineout, dp)[0] = '\0';
dp += 7;
@@
-170,10
+181,11
@@
int cal_main(int argc UNUSED_PARAM, char **argv)
sprintf(lineout, "%u", year);
center(lineout,
sprintf(lineout, "%u", year);
center(lineout,
- (WEEK_LEN * 3 + HEAD_SEP * 2)
- + julian * (J_WEEK_LEN * 2 + HEAD_SEP
- - (WEEK_LEN * 3 + HEAD_SEP * 2)),
- 0);
+ (WEEK_LEN * 3 + HEAD_SEP * 2)
+ + julian * (J_WEEK_LEN * 2 + HEAD_SEP
+ - (WEEK_LEN * 3 + HEAD_SEP * 2)),
+ 0
+ );
puts("\n"); /* two \n's */
for (i = 0; i < 12; i++) {
day_array(i + 1, year, days[i]);
puts("\n"); /* two \n's */
for (i = 0; i < 12; i++) {
day_array(i + 1, year, days[i]);