[comp.os.minix] Calendar program, Information on Bugs, Lets try this again

TEMARI%ECAMV1.dnet.ge.com@vm1.nodak.edu (10/08/90)

This message didn't seem to get out.  So here goes again.........

I have just received minix 1.5 from PH and have just started getting
the minix list.  I have found some bugs:
* /dev/port not on boot diskettes
  file on an empty file gives a core dump
  invalid parameter given to term locks the shell (I've posted this fix)
* client3 of amoeba has paren in wrong place
* permission error for root to search d--------- directory
           ...etc...

The ones with * i've read from messages and tried them
Also, I have read some comments in the programs I have gotten from the
archive sites about working around problems with minix.  Lets fix them!

    So here is what I would like to know
Is there anywhere out there a bug report and patch fixes for the bugs in minix.
If anyone could let me know I would really appreciate it.

Also, to start myself off on a good foot on the net below I submit a calendar
program which will either tell you the day of the week a date fell on or print
out a calendar for the month.  This was in my archives, which was orginally
written in fortran.  I take no credit for it, all I did was convert it to
C some five years ago.

Soon to come a two player nuclear war game!!!!!!

-------------------------------------------------------------------------
/* calendar.c */

#include <stdio.h>

#define	ULC	0xda	/* upper left hand corner */
#define	HL	0xc4	/* horizontal line */
#define	URC	0xbf	/* upper right hand corner */
#define	VL	0xb3	/* vertical line */
#define DT	0xc2	/* T down */
#define	UT	0xc1	/* T up */
#define	RT	0xc3	/* T right */
#define	LT	0xb4	/* T left */
#define	LRC	0xd9	/* lower right hand corner */
#define	LLC	0xc0	/* lower left hand corner */
#define CRO	0xc5	/* cross */

char	*week[7]={ "SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY",
		   "THURSDAY", "FRIDAY", "SATURDAY" };
char	*months[12]={ "JANUARY", "FEBRUARY", "MARCH", "APRIL",
		      "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER",
		      "OCTOBER", "NOVEMBER", "DECEMBER" };
char	*days[42] = { "  ", "  ", "  ", "  ", "  ", "  ", "  ",
		      "  ", "  ", "  ", "  ", "  ", "  ", "  ",
		      "  ", "  ", "  ", "  ", "  ", "  ", "  ",
		      "  ", "  ", "  ", "  ", "  ", "  ", "  ",
		      "  ", "  ", "  ", "  ", "  ", "  ", "  ",
		      "  ", "  ", "  ", "  ", "  ", "  ", "  " };
int	year[12]={ 31,28,31,30,31,30,31,31,30,31,30,31 };

int	inyear,inmonth,frstdy,leap,mntlst,mnthdy,i,j,i1,weeks,lstmnt;

int	gregor(inyear,inmonth,inday)
int	inyear,inmonth,inday;
{
int	iyear,icent,itemp,iday,imnth;
	iyear=inyear;
	if(inmonth<=2)iyear=iyear-1;
	icent=iyear/100;
	iyear=iyear%100;
	imnth=inmonth-2;
	if(imnth<=0) imnth+=12;
	itemp=(175*icent)/100;
	if((175*icent)%100) itemp++;
	iday=inday+((26*imnth-2)/10)-itemp+iyear+iyear/4;
	if(iday<0) iday+=700;
	return(1+(iday%7));
}
void	do_line(a,b,c,d)
	char	a,b,c,d;
{
	int	i;
	printf("%c",a);
	for(i=0;i<7;i++) {
		for(j=0;j<10;j++)
			printf("%c",b);
		if(i==6)
			printf("%c",d);
		else
			printf("%c",c);
	}
	printf("\n");
}

main(argc,argv)
int	argc;
char	*argv[];
{
	char	a,b;

	if(argc<2||argc>4) {
	   printf("usage is %s year month [day]\n",argv[0]);
	   exit(1);
	}
	inyear=atoi(argv[1]);
	inmonth=atoi(argv[2]);
	if(argc==4)
	   frstdy=atoi(argv[3]);
	else
	   frstdy=1;
	if(inyear<100) inyear+=1900;
	if(inmonth<1||inmonth>12) {
	   printf("Invalid month!\n");
	   exit(1);
	}
	if(inyear<1752||inyear>20000) {
	   printf("Invalid year!  Range is 1752-20000\n");
	   exit(1);
	}

	leap=0;
	if((inyear%4)==0) leap=1;
	if((inyear%100)==0) leap=0;
	if((inyear%400)==0) leap=1;
	if((inyear%2000)==0) leap=0;
	mntlst=year[inmonth-1];
	if(inmonth==2) mntlst+=leap;
	if(argc==4)
	   if(frstdy>mntlst) {
	      printf("Invalid day for the month of %s\n",months[inmonth-1]);
	      exit(1);
	   }
	mnthdy=gregor(inyear,inmonth,frstdy);

	if(argc==4)
	   printf("%d %s %d is %s\n",frstdy,
				     months[inmonth-1],
				     inyear,week[mnthdy-1]);
	if(argc==4)
	   return(0);

	do_line(ULC,HL,HL,URC);
	printf("%c  %-10s",VL,months[inmonth-1]);
	for(i=0;i<59;i++) printf(" ");
	printf("%4d %c\n",inyear,VL);
	printf("3  SUNDAY     MONDAY    TUESDAY   WEDNESDAY   THURSDAY    ");
	printf("FRIDAY    SATURDAY 3\n");
	do_line(RT,HL,DT,LT);
	i1=mnthdy+mntlst-1;
	for(i=mnthdy;i<=i1;i++)
	    sprintf(days[i-1],"%02d",i+1-mnthdy);
	weeks=i1/7;
	if(i1%7) weeks++;
	lstmnt=weeks*7;
	for(i=1;i<=lstmnt;i+=7) {
	    for(j=1;j<=7;j++)
		printf("%c%s        ",VL,days[i+j-2]);
	    printf("%c\n",VL);
	    for(j=1;j<=7;j++)
		printf("%c          ",VL);
	    printf("%c\n",VL);
	    if(i!=(lstmnt-6))
		do_line(RT,HL,CRO,LT);
	    else
		do_line(LLC,HL,UT,LRC);
	}
	return(0);
}

rnews@qut.edu.au (10/09/90)

In article <32751@nigel.ee.udel.edu>, TEMARI%ECAMV1.dnet.ge.com@vm1.nodak.edu writes:
> This message didn't seem to get out.  So here goes again.........
> 
> I have just received minix 1.5 from PH and have just started getting
> the minix list.  I have found some bugs:
> * /dev/port not on boot diskettes
>   file on an empty file gives a core dump
>   invalid parameter given to term locks the shell (I've posted this fix)
> * client3 of amoeba has paren in wrong place
> * permission error for root to search d--------- directory
>            ...etc...
> 
> The ones with * i've read from messages and tried them
> Also, I have read some comments in the programs I have gotten from the
> archive sites about working around problems with minix.  Lets fix them!
> 
>     So here is what I would like to know
> Is there anywhere out there a bug report and patch fixes for the bugs in minix.
> If anyone could let me know I would really appreciate it.
> 
> Also, to start myself off on a good foot on the net below I submit a calendar
> program which will either tell you the day of the week a date fell on or print
> out a calendar for the month.  This was in my archives, which was orginally
> written in fortran.  I take no credit for it, all I did was convert it to
> C some five years ago.
> 
> Soon to come a two player nuclear war game!!!!!!
> 
> -------------------------------------------------------------------------
> /* calendar.c */
> 
> #include <stdio.h>
> 
> #define	ULC	0xda	/* upper left hand corner */
> #define	HL	0xc4	/* horizontal line */
> #define	URC	0xbf	/* upper right hand corner */
> #define	VL	0xb3	/* vertical line */
> #define DT	0xc2	/* T down */
> #define	UT	0xc1	/* T up */
> #define	RT	0xc3	/* T right */
> #define	LT	0xb4	/* T left */
> #define	LRC	0xd9	/* lower right hand corner */
> #define	LLC	0xc0	/* lower left hand corner */
> #define CRO	0xc5	/* cross */



arrrgh PC specific code ..... Ill now proceed to faint "-/

Hey do we all have IBM font sets ???