Author: edwin
Date: Tue Mar  9 06:43:35 2010
New Revision: 204908
URL: http://svn.freebsd.org/changeset/base/204908

Log:
  - Fix the highlighting for non-terminals when the last week is not
    7 days long.
  - "-m <N> <YYYY>" now prints only the month, not the whole year.

Modified:
  head/usr.bin/ncal/ncal.1
  head/usr.bin/ncal/ncal.c

Modified: head/usr.bin/ncal/ncal.1
==============================================================================
--- head/usr.bin/ncal/ncal.1    Tue Mar  9 03:30:31 2010        (r204907)
+++ head/usr.bin/ncal/ncal.1    Tue Mar  9 06:43:35 2010        (r204908)
@@ -169,3 +169,6 @@ command and manual were written by
 .Sh BUGS
 The assignment of Julian\(enGregorian switching dates to country
 codes is historically naive for many countries.
+.Pp
+Not all options are compatible and using them in different orders
+will give varying results.

Modified: head/usr.bin/ncal/ncal.c
==============================================================================
--- head/usr.bin/ncal/ncal.c    Tue Mar  9 03:30:31 2010        (r204907)
+++ head/usr.bin/ncal/ncal.c    Tue Mar  9 06:43:35 2010        (r204908)
@@ -60,7 +60,7 @@ struct monthlines {
        wchar_t name[MAX_WIDTH + 1];
        char lines[7][MAX_WIDTH + 1];
        char weeks[MAX_WIDTH + 1];
-       unsigned int linelen[7];
+       unsigned int extralen[7];
 };
 
 struct weekdays {
@@ -290,6 +290,8 @@ main(int argc, char *argv[])
                        break;
                case 'm':
                        flag_month = optarg;
+                       before = 0;
+                       after = 0;
                        break;
                case 'o':
                        if (flag_backward)
@@ -336,14 +338,19 @@ main(int argc, char *argv[])
                if (flag_easter)
                        usage();
                flag_month = *argv++;
+               before = 0;
+               after = 0;
+               m = strtol(flag_month, NULL, 10);
                /* FALLTHROUGH */
        case 1:
                y = atoi(*argv++);
                if (y < 1 || y > 9999)
                        errx(EX_USAGE, "year %d not in range 1..9999", y);
-               before = 0;
-               after = 11;
-               m = 1;
+               if (before == -1 && after == -1) {
+                       before = 0;
+                       after = 11;
+                       m = 1;
+               }
                break;
        case 0:
                {
@@ -470,8 +477,7 @@ printeaster(int y, int julian, int ortho
        printf("%s\n", buf);
 }
 
-#define MW(mw, ms, ml) \
-       strlen(ms) > (ml) ? (mw) + 9 : (mw)
+#define MW(mw, me)             ((mw) + me)
 #define        DECREASEMONTH(m, y)             \
                if (--m == 0) {         \
                        m = 12;         \
@@ -564,7 +570,9 @@ monthrangeb(int y, int jd_flag, int m, i
 
                for (i = 0; i != 6; i++) {
                        for (j = 0; j < count; j++)
-                               printf("%-*s  ", mw, year[j].lines[i]+1);
+                               printf("%-*s  ",
+                                   MW(mw, year[j].extralen[i]),
+                                       year[j].lines[i]+1);
                        printf("\n");
                }
 
@@ -641,8 +649,8 @@ monthranger(int y, int jd_flag, int m, i
                        /* Full months */
                        for (j = 0; j < count; j++)
                                printf("%-*s",
-                                   MW(mw, year[j].lines[i],
-                                       year[j].linelen[i]), year[j].lines[i]);
+                                   MW(mw, year[j].extralen[i]),
+                                       year[j].lines[i]);
                        printf("\n");
                }
 
@@ -733,7 +741,7 @@ mkmonthr(int y, int m, int jd_flag, stru
                                memcpy(mlines->lines[i] + k + l, "    ", dw);
                }
                mlines->lines[i][k + l] = '\0';
-               mlines->linelen[i] = k;
+               mlines->extralen[i] = l;
        }
 
        /* fill the weeknumbers */
@@ -840,6 +848,7 @@ mkmonthb(int y, int m, int jd_flag, stru
                        mlines->lines[i][1] = '\0';
                else
                        mlines->lines[i][k + l] = '\0';
+               mlines->extralen[i] = l;
        }
 }
 
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to