Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

cal 5875707

Name: Anonymous 2008-12-17 19:59

$ cal 5875707
cal: year 5875707 not in range 1..5875706


What is the significance of the year 5875706? Why stop there? This seems like some kind of RMS Michael Shuttleworth ploy to fuck us over in the calendar department.

Name: Anonymous 2008-12-17 20:05

Anonix will fix this.

Name: Anonymous 2008-12-17 20:08

>>1
Who cares, we'll be dead by then

Name: Anonymous 2008-12-17 20:21

$ cal 5875707
cal: year 5875707 not in range 1..9999

Name: Anonymous 2008-12-17 20:30

>>4
Wow, how do you sleep at night?

Name: Anonymous 2008-12-17 20:40

5875706 should be enough for anybody.

Name: Anonymous 2008-12-17 20:50

>>6
If it's good enough for Mark `Rimmis` Shuttleworth, it's good enough for me.

Name: Anonymous 2008-12-17 20:55

5875706 = 2 × 2937853
5875707 = 3 × 1958569

Seems pretty obvious to me.

Name: Anonymous 2008-12-17 21:09

Our god, RMS MS S, has decided that there will be no year 5875707, because 5875706 is when GPL v3 will expire.

Name: Anonymous 2008-12-17 23:26

I just tried this on FreeBSD, OS X, and Linux (with util-linux-ng), and they all restrict the dates to 1-9999. What version of cal are you using?

Name: Anonymous 2008-12-17 23:32

>>10
64 bit man! 64 bit!

Name: Anonymous 2008-12-17 23:39

I tried it on Debian and Ubanto and they both give 5875706

Name: Anonymous 2008-12-17 23:52

Is cal even GUN? It's part of a package called "bsdmainutils" on the Ubanto repositories.

Name: Anonymous 2008-12-17 23:56

HISTORY
     A cal command appeared in Version 6 AT&T UNIX.

Name: Cudder !MhMRSATORI!vzR1SbE7g/KHqrb 2008-12-18 0:07

>>2
$ cal 1 5875707
            Jan 5875707
Sun    Mon    Tue    Wed    Thu    Fri    Sat
 1     2     3     4     5     6     7
 8     9    10    11    12    13    14
15    16    17    18    19    20    21
22    23    24    25    26    27    28
29      30      31
$

Name: Anonymous 2008-12-18 0:07

>>15
Gtfo tripfag

Name: Anonymous 2008-12-18 0:09

>>15
SICP OR GTFO

Name: Anonymous 2008-12-18 1:00

>>15
That certainly lined up correctly and didn't look like complete shit.

Name: Anonymous 2008-12-18 1:02

>>11
Yes, my Linux box is an amd64 running in pure 64-bit mode. (No lib32 bullshit here.)

Name: Anonymous 2008-12-18 1:04

>>19
My Linux box is an amd128 running in pure 128-bit mode. (No lib64 bullshit here.)

Name: Anonymous 2008-12-18 1:13

Debian i686 and x86_64 both give 5875706.
OS X 32/64 bit (cal binary is 32 bit) and CentOS i686 give 9999.

Name: Anonymous 2008-12-18 1:28

/* usage: argv[0] y m d
 m and d are 1-based */

#include <stdio.h>

int yeldtab[] = {0,31,59,90,120,151,181,212,243,273,304,334};
char *daynames[] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" };

int isleap(int yrm1) {
 int dd;
 yrm1++;
 return (yrm1&3)?(dd=yrm1%100)?1:(dd&3)?0:1:0;
}

main(int argc, char **argv) {
 if(argc==4) {
  unsigned int yrm1 = atoi(argv[1])-1;
  unsigned int mnth = atoi(argv[2])-1;
  unsigned int date = atoi(argv[3])-1;
  unsigned int adn = 365*yrm1;
  unsigned int ax = yrm1/100;
  unsigned int dx = yrm1%100;
  adn -= ax;
  ax /=4;
  adn += ax;
  adn += yrm1/4;
  adn += yeldtab[mnth];
  if(mnth>2)
   adn += isleap(yrm1);
  adn += date;
  printf("ADN for %u-%u-%u (%s) is %u\n",yrm1+1,mnth+1,date+1,daynames[(adn+1)%7],adn+1);
 }
}

Name: Anonymous 2008-12-18 1:32

>>22
Your variable names suck. ax? dx? These are good register names, but when we program in higher level languages you can use words that mean something. Try it sometime.

Name: Anonymous 2008-12-18 2:04

>>21
Yes, but which cal are you using? As I said, mine is "util-linux-ng". Obviously, yours is not. Where did it come from? Could you please provide a link to the source or something?

Name: Anonymous 2008-12-18 3:14

>>23
It's half-edited decompiler output. Here's a fixed version (with a bug corrected):

/* usage: argv[0] y m d
 m and d are 1-based */

#include <stdio.h>

int yeldtab[] = {0,31,59,90,120,151,181,212,243,273,304,334};
char *daynames[] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" };

int isleap(int yrm1) {
 yrm1++;
 return (!(yrm1%4) && yrm1%100) || !(yrm1%400);
}

main(int argc, char **argv) {
 if(argc==4) {
  unsigned int yrm1 = atoi(argv[1])-1;
  unsigned int mnth = atoi(argv[2])-1;
  unsigned int date = atoi(argv[3])-1;
  unsigned int adn = 365*yrm1 - yrm1/100 + yrm1/400 + yrm1/4 + yeldtab[mnth];
  if(mnth>2)
   adn += isleap(yrm1);
  adn += date;
  printf("ADN for %u-%u-%u (%s) is %u\n",yrm1+1,mnth+1,date+1,daynames[(adn)%7],adn,adn);
 }
}

Name: Anonymous 2008-12-18 5:58

http://opengroup.org/susv3xcu/cal.html
The cal utility shall write a calendar to standard output using the Julian calendar for dates from January 1, 1 through September 2, 1752 and the Gregorian calendar for dates from September 14, 1752 through December 31, 9999 as though the Gregorian calendar had been adopted on September 14, 1752.
9999 is the STANDARD!!!

/* Copyright (c) 2008 Anonymous
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that you grant this
 * same permission to anyone you distribute it to without any additional
 * restrictions.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#include <inttypes.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(int argc, char **argv){
 uintmax_t year = 0;
 uintmax_t month = 0;
 int_fast8_t month_days = 0, day_of_week = 0;
 const char *month_names[12] = { "January", "February", "March", "April", "May",
  "June", "July", "August", "September", "October", "November", "December" };
 const int_fast8_t months_days[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31,
  30, 31 };
 time_t t = time(NULL);
 struct tm *time_struct = localtime(&t);
 switch(argc){
  case 1:
   year = time_struct->tm_year + 1900;
   month = time_struct->tm_mon + 1;
   break;
  case 2:
   year = strtoumax(argv[1], NULL, 10);
   month = time_struct->tm_mon + 1;
   break;
  default:
   month = strtoumax(argv[1], NULL, 10);
   year = strtoumax(argv[2], NULL, 10);
 }
 if(!year || !month || month > 12){
  fputs("learn to use cal, you idiot: http://opengroup.org/susv3xcu/cal.html",
   stderr);
  abort();
 }
 if(year > 9999){
  fputs("learn to use cal, you idiot: http://opengroup.org/susv3xcu/cal.html",
   stderr);
  abort();
 }
 if(year == 1752 && month == 9){
  puts("September 1752");
  puts("Su Mo Tu We Th Fr Sa");
  puts("       1  2 14 15 16");
  puts("17 18 19 20 21 22 23");
  puts("24 25 26 27 28 29 30");
  return 0;
 }else{
  printf("%s %d\n", month_names[month - 1], year);
  puts("Su Mo Tu We Th Fr Sa");
  month_days = months_days[month - 1];
  if(year > 1752 || (year == 1752 && month > 9)){
   /* Gregorian */
   if(month == 2 && !(year % 4) && year % 100 || !(year % 400))
    month_days = 29;
   time_struct->tm_mon = month - 1;
   time_struct->tm_year = year - 1900;
   time_struct->tm_mday = 1;
   t = mktime(time_struct);
   time_struct = localtime(&t);
   day_of_week = time_struct->tm_wday;
   day_of_week = ((153 * (month + 12 * ((14 - month) / 12) - 3) + 2) / 5 +
    365 * (year + 4800 - ((14 - month) / 12)) + (year + 4800 - ((14 - month) /
    12)) / 4 - (year + 4800 - ((14 - month) / 12)) / 100 + (year + 4800 - ((14 -
    month) / 12)) - 32044) % 7;
  }else{
   /* Julian */
   if(month == 2 && !(year % 4))
    month_days = 29;
   day_of_week = ((153 * (month + 12 * ((14 - month) / 12) - 3) + 2) / 5 +
    365 * (year + 4800 - ((14 - month) / 12)) + (year + 4800 - ((14 - month) /
    12)) / 4 - 32081) % 7;
  }
  for(int i = 0; i < day_of_week; ++i) fputs("   ", stdout);
  for(int i = 1; i <= month_days; ++i){
   printf("% 2u", i);
   ++day_of_week;
   putchar((day_of_week %= 7) ? ' ' : '\n');
  }
 }
 putchar('\n');
 return 0;
}

Name: Anonymous 2008-12-18 6:14

>>26
The following environment variables shall affect the execution of cal:

Your implementation of cal is broken, anon.

Name: Anonymous 2008-12-18 6:42

>>27
1. add this at the top of the file: #include <libintl.h>
2. add this at the beginning of main:
textdomain("cal");
 setlocale(LC_ALL,"");

2. replace "learn to use cal, you idiot: http://opengroup.org/susv3xcu/cal.html" with gettext("learn to use cal, you idiot: http://opengroup.org/susv3xcu/cal.html")
problem solved.

Name: Anonymous 2008-12-18 7:40

>>28
GNU bloat detected.

Name: Anonymous 2008-12-18 7:50

>>1
get a better cal.
$ cal 340282366920938463463374607431768211456
December 340282366920938463463374607431768211456
Su Mo Tu We Th Fr Sa
    1  2  3  4  5  6
 7  8  9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31

Name: Anonymous 2008-12-18 8:25

>>28
I don't want to fix it, I have my own working from gnu.

I just want to point out that the one you wrote broken, and the fixed one won't work for anonix (or the fix will do nothing).

Name: Anonymous 2008-12-18 11:10

Why don't all these small programs just use a bignum library for all of their integers? It's not like it'll affect performance.

Heck, write them in Python. That WILL affect performance though.

Name: Anonymous 2008-12-18 11:17

>>32
Write them in Stackless Python, then.

Name: Anonymous 2008-12-18 11:19

THE FORCED INDENTATION OF THE SMALL PROGRAMS

Name: Anonymous 2008-12-18 12:41

I just want to point out that the one you wrote broken, and the fixed one won't work for anonix (or the fix will do nothing).
according to them it's not broken:
- No internationalization. A large amount of GNU bloat is caused by this, and
with English continuing to dominate, the ANONIX initial planning group decided
against explicitly adding code for this, instead opting to let those  few who
need it translate themselves.


I don't want to fix it, I have my own working from gnu.
your gnu one can't do cal 1 340282366920938463463374607431768211456, while this one can (and supports localization):
/* Copyright (c) 2008 Anonymous
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that you grant this
 * same permission to anyone you distribute it to without any additional
 * restrictions.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#include <inttypes.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#include <gmp.h>
#include <langinfo.h>
#include <libintl.h>

int main(int argc, char **argv){
 mpz_t year, tmp1, tmp2, tmp3, tmp4;
 unsigned long day_of_week;
 uintmax_t month = 0, month_min = 1, month_max = 12;
 int_fast8_t month_days = 0;
 const int_fast8_t months_days[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31,
  30, 31 };
 time_t t = time(NULL);
 char weekday[13] = {0}, weekdays[65] = {0}, month_name[LINE_MAX] = {0},
  cal_head[LINE_MAX] = {0};
 struct tm *time_struct = localtime(&t);
 textdomain("cal");
 setlocale(LC_ALL, "");
 bind_textdomain_codeset("cal", nl_langinfo(CODESET));
 mpz_init(year);
 switch(argc){
  case 1:
   mpz_set_ui(year, time_struct->tm_year + 1900);
   month_min = month_max = time_struct->tm_mon + 1;
   break;
  case 2:
   mpz_set_str(year, argv[1], 10);
   break;
  default:
   month_min = month_max = strtoumax(argv[1], NULL, 10);
   mpz_set_str(year, argv[2], 10);
 }
 if(mpz_sgn(year) < 1 || !month_min || month_min > 12){
  fputs(gettext(
   "learn to use cal, you idiot: http://opengroup.org/susv3xcu/cal.html\n"),
   stderr);
  abort();
 }
 for(int i = 0; i < 7; ++i){
  time_struct->tm_wday = i;
  strftime(weekday, 13, "%a", time_struct);
  strncat(weekdays, weekday, 12);
  strcat(weekdays, " ");
 }
 for(int month = month_min; month <= month_max; ++month){
  time_struct->tm_mon = month - 1;
  strftime(month_name, LINE_MAX, "%B", time_struct);
  for(int i = (27 - snprintf(cal_head, LINE_MAX, "%s %s", month_name,
   mpz_get_str(NULL, 10, year))) / 2; i > 0; --i) putchar(' ');
  puts(cal_head);
  puts(weekdays);
  if(!mpz_cmp_ui(year, 1752) && month == 9){
   puts("          1   2  14  15  16");
   puts(" 17  18  19  20  21  22  23");
   puts(" 24  25  26  27  28  29  30");
  }else{
   month_days = months_days[month - 1];
   mpz_init(tmp1);
   mpz_init(tmp2);
   mpz_init(tmp3);
   mpz_init(tmp4);
   if(mpz_cmp_ui(year, 1752) > 0 || (!mpz_cmp_ui(year, 1752) && month > 9)){
    /* Gregorian */
    if(month == 2 && mpz_divisible_ui_p(year, 4) && !mpz_divisible_ui_p(year,
     100) || mpz_divisible_ui_p(year, 400)) month_days = 29;
    mpz_add_ui(tmp4, year, 4800 - (14 - month) / 12);
    mpz_tdiv_q_ui(tmp1, tmp4, 4);
    mpz_tdiv_q_ui(tmp2, tmp4, 100);
    mpz_tdiv_q_ui(tmp3, tmp4, 400);
    mpz_mul_ui(tmp4, tmp4, 365);
    mpz_add(tmp4, tmp4, tmp1);
    mpz_sub(tmp4, tmp4, tmp2);
    mpz_add(tmp4, tmp4, tmp3);
    mpz_add_ui(tmp4, tmp4, (153 * (month + 12 * ((14 - month) / 12) - 3) + 2) /
     5);
    mpz_sub_ui(tmp4, tmp4, 32043);
    day_of_week = mpz_tdiv_ui(tmp4, 7);
   }else{
    /* Julian */
    if(month == 2 && mpz_divisible_ui_p(year, 4))
     month_days = 29;
    mpz_add_ui(tmp2, year, 4800 - (14 - month) / 12);
    mpz_tdiv_q_ui(tmp1, tmp2, 4);
    mpz_mul_ui(tmp2, tmp2, 365);
    mpz_add(tmp2, tmp2, tmp1);
    mpz_add_ui(tmp2, tmp2, (153 * (month + 12 * ((14 - month) / 12) - 3) + 2) /
     5);
    mpz_sub_ui(tmp2, tmp2, 32081);
    day_of_week = mpz_tdiv_ui(tmp2, 7);
   }
   mpz_clear(tmp1);
   mpz_clear(tmp2);
   mpz_clear(tmp3);
   mpz_clear(tmp4);
   for(int i = 0; i < day_of_week; ++i) fputs("    ", stdout);
   for(int i = 1; i <= month_days; ++i){
    printf("% 3u", i);
    ++day_of_week;
    putchar((day_of_week %= 7) ? ' ' : '\n');
   }
  }
  putchar('\n');
 }
 mpz_clear(year);
 return 0;
}


and here's a localization file for it:
# icelandic localization for cal
# Copyright (C) 2008 anonymous
# This file is distributed under the same license as the cal package.
#
msgid ""
msgstr ""
"Project-Id-Version: cal 1.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2008-12-18 12:28-0000\n"
"PO-Revision-Date: 2008-12-18 10:29-0500\n"
"Last-Translator: anonymous\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language-Team: Icelandic\n"

msgid "learn to use cal, you idiot: http://opengroup.org/susv3xcu/cal.html\n"
msgstr ""
"lærðu að nota cal, þú fábjáni: http://opengroup.org/susv3xcu/cal.html\n"

Name: Anonymous 2008-12-18 12:53

>>35
Here's a bug fix:

# icelandic localization for cal
# Copyright (C) 2008 anonymous
# This file is distributed under the same license as the cal package.
#
msgid ""
msgstr ""
"Project-Id-Version: cal 1.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2008-12-18 12:28-0000\n"
"PO-Revision-Date: 2008-12-18 10:29-0500\n"
"Last-Translator: anonymous\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language-Team: Icelandic\n"

msgid "learn to use cal, you idiot: http://opengroup.org/susv3xcu/cal.html\n"
msgstr ""
"GRUNNUR"

Name: Anonymous 2008-12-18 13:39

"GRUNN"

Name: Anonymous 2008-12-18 13:57

>>35
~ % gcc loldongs2.c -o loldongs2 -pedantic -Wall -std=c99 -lgmp -lintl -I/opt/local/include -L/opt/local/lib
loldongs2.c: In function ‘main’:
loldongs2.c:88: warning: suggest parentheses around && within ||
loldongs2.c:120: warning: ' ' flag used with ‘%u’ printf format
loldongs2.c:32: warning: unused variable ‘month’


Also, your calendar output for full years is ugly.

And good job, guys, you were fooled into writing code for Anonix.

Name: Anonymous 2008-12-18 14:59

>>38
Damned, what have we Done?!

Name: Anonymous 2008-12-18 15:32

loldongs2.c:88: warning: suggest parentheses around && within ||
wow, that's actually a bug! the stuff after the last && should be in parentheses.

loldongs2.c:120: warning: ' ' flag used with ‘%u’ printf format
the ' ' doesn't do anything, but it doesn't hurt anything either.

loldongs2.c:32: warning: unused variable ‘month’
ok, the first one isn't used, but that doesn't hurt anything.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List