Created
January 4, 2011 02:46
-
-
Save bmnick/764314 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* mdates.c -- find number of days between 2 dates - mutation version | |
| Mark Ardis, Rose-Hulman Institute | |
| 3/19/2006 | |
| */ | |
| #include <stdio.h> | |
| #include <string.h> | |
| #define MAXLINE 1000 // maximum input line size | |
| FILE *fid; // test file | |
| char line[MAXLINE]; // current input line | |
| int len; // length of input line | |
| char testfile[80]; // input test file name | |
| int optVerbose; // option flag | |
| /* Date structure */ | |
| typedef struct | |
| { | |
| int month; | |
| int day; | |
| int year; | |
| } DATE; | |
| DATE firstdate; // beginning date | |
| DATE seconddate; // ending date | |
| /************************************************************************* | |
| getline function from K&R | |
| ************************************************************************/ | |
| int getline(char s[], int lim) | |
| { | |
| int c, i; | |
| for (i=0; i < lim-1 && (c=getc(fid)) != EOF && c != '\n'; ++i) | |
| s[i] = c; | |
| if (c == '\n') | |
| { | |
| s[i] = c; | |
| ++i; | |
| } | |
| s[i] = '\0'; | |
| return i; | |
| } | |
| /************************************************************************* | |
| Check input line for valid syntax, return 0 if okay, 1 if not | |
| ************************************************************************/ | |
| int chkinputsyntax() | |
| { | |
| int i; // digit to check | |
| /* the line should look like: | |
| MM/DD/YYYY,MM/DD/YYYY | |
| 012345678901234567890 | |
| 0 1 2 */ | |
| for (i = 0; i < 21; i++) | |
| { | |
| if ((i==2) || (i==5) || (i==10) || (i==13) || (i==16)) | |
| continue; | |
| if (isdigit(line[i]) == 0) | |
| return 1; | |
| } | |
| // All checks passed | |
| return 0; | |
| } | |
| int m1chkinputsyntax() | |
| { | |
| int i; // digit to check | |
| for (i = 1; i < 21; i++) // BUG1: i = 1 | |
| { | |
| if ((i==2) || (i==5) || (i==10) || (i==13) || (i==16)) | |
| continue; | |
| if (isdigit(line[i]) == 0) | |
| return 1; | |
| } | |
| // All checks passed | |
| return 0; | |
| } | |
| int m2chkinputsyntax() | |
| { | |
| int i; // digit to check | |
| for (i = 0; i < 21; i++) | |
| {// BUG2: i==1 | |
| if ((i==1) || (i==2) || (i==5) || (i==10) || (i==13) || (i==16)) | |
| continue; | |
| if (isdigit(line[i]) == 0) | |
| return 1; | |
| } | |
| // All checks passed | |
| return 0; | |
| } | |
| int m3chkinputsyntax() | |
| { | |
| int i; // digit to check | |
| for (i = 0; i < 21; i++) | |
| {// BUG3: i==3 | |
| if ((i==3) || (i==2) || (i==5) || (i==10) || (i==13) || (i==16)) | |
| continue; | |
| if (isdigit(line[i]) == 0) | |
| return 1; | |
| } | |
| // All checks passed | |
| return 0; | |
| } | |
| int m4chkinputsyntax() | |
| { | |
| int i; // digit to check | |
| for (i = 0; i < 21; i++) | |
| {// BUG4: i==4 | |
| if ((i==4) || (i==2) || (i==5) || (i==10) || (i==13) || (i==16)) | |
| continue; | |
| if (isdigit(line[i]) == 0) | |
| return 1; | |
| } | |
| // All checks passed | |
| return 0; | |
| } | |
| int m5chkinputsyntax() | |
| { | |
| int i; // digit to check | |
| for (i = 0; i < 21; i++) | |
| {// BUG5: i==6 | |
| if ((i==6) || (i==2) || (i==5) || (i==10) || (i==13) || (i==16)) | |
| continue; | |
| if (isdigit(line[i]) == 0) | |
| return 1; | |
| } | |
| // All checks passed | |
| return 0; | |
| } | |
| int m6chkinputsyntax() | |
| { | |
| int i; // digit to check | |
| for (i = 0; i < 21; i++) | |
| {// BUG6: i==7 | |
| if ((i==7) || (i==2) || (i==5) || (i==10) || (i==13) || (i==16)) | |
| continue; | |
| if (isdigit(line[i]) == 0) | |
| return 1; | |
| } | |
| // All checks passed | |
| return 0; | |
| } | |
| int m7chkinputsyntax() | |
| { | |
| int i; // digit to check | |
| for (i = 0; i < 21; i++) | |
| {// BUG7: i==8 | |
| if ((i==8) || (i==2) || (i==5) || (i==10) || (i==13) || (i==16)) | |
| continue; | |
| if (isdigit(line[i]) == 0) | |
| return 1; | |
| } | |
| // All checks passed | |
| return 0; | |
| } | |
| int m8chkinputsyntax() | |
| { | |
| int i; // digit to check | |
| for (i = 0; i < 21; i++) | |
| {// BUG8: i==9 | |
| if ((i==9) || (i==2) || (i==5) || (i==10) || (i==13) || (i==16)) | |
| continue; | |
| if (isdigit(line[i]) == 0) | |
| return 1; | |
| } | |
| // All checks passed | |
| return 0; | |
| } | |
| int m9chkinputsyntax() | |
| { | |
| int i; // digit to check | |
| for (i = 0; i < 21; i++) | |
| {// BUG9: i==11 | |
| if ((i==11) || (i==2) || (i==5) || (i==10) || (i==13) || (i==16)) | |
| continue; | |
| if (isdigit(line[i]) == 0) | |
| return 1; | |
| } | |
| // All checks passed | |
| return 0; | |
| } | |
| int m10chkinputsyntax() | |
| { | |
| int i; // digit to check | |
| for (i = 0; i < 21; i++) | |
| {// BUG10: i==12 | |
| if ((i==12) || (i==2) || (i==5) || (i==10) || (i==13) || (i==16)) | |
| continue; | |
| if (isdigit(line[i]) == 0) | |
| return 1; | |
| } | |
| // All checks passed | |
| return 0; | |
| } | |
| int m11chkinputsyntax() | |
| { | |
| int i; // digit to check | |
| for (i = 0; i < 21; i++) | |
| {// BUG11: i==14 | |
| if ((i==14) || (i==2) || (i==5) || (i==10) || (i==13) || (i==16)) | |
| continue; | |
| if (isdigit(line[i]) == 0) | |
| return 1; | |
| } | |
| // All checks passed | |
| return 0; | |
| } | |
| int m12chkinputsyntax() | |
| { | |
| int i; // digit to check | |
| for (i = 0; i < 21; i++) | |
| {// BUG12: i==15 | |
| if ((i==15) || (i==2) || (i==5) || (i==10) || (i==13) || (i==16)) | |
| continue; | |
| if (isdigit(line[i]) == 0) | |
| return 1; | |
| } | |
| // All checks passed | |
| return 0; | |
| } | |
| int m13chkinputsyntax() | |
| { | |
| int i; // digit to check | |
| for (i = 0; i < 21; i++) | |
| {// BUG13: i==17 | |
| if ((i==17) || (i==2) || (i==5) || (i==10) || (i==13) || (i==16)) | |
| continue; | |
| if (isdigit(line[i]) == 0) | |
| return 1; | |
| } | |
| // All checks passed | |
| return 0; | |
| } | |
| int m14chkinputsyntax() | |
| { | |
| int i; // digit to check | |
| for (i = 0; i < 21; i++) | |
| {// BUG14: i==18 | |
| if ((i==18) || (i==2) || (i==5) || (i==10) || (i==13) || (i==16)) | |
| continue; | |
| if (isdigit(line[i]) == 0) | |
| return 1; | |
| } | |
| // All checks passed | |
| return 0; | |
| } | |
| int m15chkinputsyntax() | |
| { | |
| int i; // digit to check | |
| for (i = 0; i < 21; i++) | |
| {// BUG15: i==19 | |
| if ((i==19) || (i==2) || (i==5) || (i==10) || (i==13) || (i==16)) | |
| continue; | |
| if (isdigit(line[i]) == 0) | |
| return 1; | |
| } | |
| // All checks passed | |
| return 0; | |
| } | |
| int m16chkinputsyntax() | |
| { | |
| int i; // digit to check | |
| for (i = 0; i < 20; i++) // BUG16: i < 20 | |
| { | |
| if ((i==2) || (i==5) || (i==10) || (i==13) || (i==16)) | |
| continue; | |
| if (isdigit(line[i]) == 0) | |
| return 1; | |
| } | |
| // All checks passed | |
| return 0; | |
| } | |
| /************************************************************************* | |
| Convert date from string to int | |
| ************************************************************************/ | |
| int strtoint(int i) | |
| { | |
| int n; | |
| n = line[i] - '0'; | |
| return (10 * n + (line[++i] - '0')); | |
| } | |
| /************************************************************************* | |
| If yr is a leap year return 1, else return 0 | |
| ************************************************************************/ | |
| int leap(yr) | |
| { | |
| if (((yr % 4 == 0) && (yr % 100 != 0)) || (yr % 400 == 0)) | |
| return 1; | |
| else | |
| return 0; | |
| } | |
| int m43leap(yr) | |
| { | |
| if ((yr % 4 == 0) && (yr % 100 != 0)) // BUG43: missing yr%400 | |
| return 1; | |
| else | |
| return 0; | |
| } | |
| int m44leap(yr) | |
| { | |
| if (yr % 4 == 0) // BUG44: missing yr%100, yr%400 | |
| return 1; | |
| else | |
| return 0; | |
| } | |
| int m45leap(yr) | |
| { | |
| // if (((yr % 4 == 0) && (yr % 100 != 0)) || (yr % 400 == 0)) | |
| return 1; // BUG45: missing yr%4, yr%100, yr%400 | |
| // else | |
| // return 0; | |
| } | |
| /************************************************************************* | |
| Check for plausible date, return 1 if not, else return 0 | |
| ************************************************************************/ | |
| int chkdate(DATE d) | |
| { | |
| int daysinmonth[13]; | |
| daysinmonth[1] = 31; | |
| daysinmonth[2] = 29; | |
| daysinmonth[3] = 31; | |
| daysinmonth[4] = 30; | |
| daysinmonth[5] = 31; | |
| daysinmonth[6] = 30; | |
| daysinmonth[7] = 31; | |
| daysinmonth[8] = 31; | |
| daysinmonth[9] = 30; | |
| daysinmonth[10] = 31; | |
| daysinmonth[11] = 30; | |
| daysinmonth[12] = 31; | |
| if (d.month < 1 || d.month > 12) | |
| return 1; | |
| if (d.day < 1 || d.day > 31) | |
| return 2; | |
| if (d.year < 1900) | |
| return 3; | |
| if (d.day > daysinmonth[d.month]) | |
| return 4; | |
| if ((d.month == 2) && !leap(d.year) && (d.day == 29)) | |
| return 5; | |
| // All checks passed | |
| return 0; | |
| } | |
| int m17chkdate(DATE d) | |
| { | |
| int daysinmonth[13]; | |
| daysinmonth[1] = 31; | |
| daysinmonth[2] = 29; | |
| daysinmonth[3] = 31; | |
| daysinmonth[4] = 30; | |
| daysinmonth[5] = 31; | |
| daysinmonth[6] = 30; | |
| daysinmonth[7] = 31; | |
| daysinmonth[8] = 31; | |
| daysinmonth[9] = 30; | |
| daysinmonth[10] = 31; | |
| daysinmonth[11] = 30; | |
| daysinmonth[12] = 31; | |
| if (d.month < 0 || d.month > 12) // BUG17: < 0 | |
| return 1; | |
| if (d.day < 1 || d.day > 31) | |
| return 2; | |
| if (d.year < 1900) | |
| return 3; | |
| if (d.day > daysinmonth[d.month]) | |
| return 4; | |
| if ((d.month == 2) && !leap(d.year) && (d.day == 29)) | |
| return 5; | |
| // All checks passed | |
| return 0; | |
| } | |
| int m18chkdate(DATE d) | |
| { | |
| int daysinmonth[13]; | |
| daysinmonth[1] = 31; | |
| daysinmonth[2] = 29; | |
| daysinmonth[3] = 31; | |
| daysinmonth[4] = 30; | |
| daysinmonth[5] = 31; | |
| daysinmonth[6] = 30; | |
| daysinmonth[7] = 31; | |
| daysinmonth[8] = 31; | |
| daysinmonth[9] = 30; | |
| daysinmonth[10] = 31; | |
| daysinmonth[11] = 30; | |
| daysinmonth[12] = 31; | |
| if (d.month < 2 || d.month > 12) // BUG18: < 2 | |
| return 1; | |
| if (d.day < 1 || d.day > 31) | |
| return 2; | |
| if (d.year < 1900) | |
| return 3; | |
| if (d.day > daysinmonth[d.month]) | |
| return 4; | |
| if ((d.month == 2) && !leap(d.year) && (d.day == 29)) | |
| return 5; | |
| // All checks passed | |
| return 0; | |
| } | |
| int m19chkdate(DATE d) | |
| { | |
| int daysinmonth[13]; | |
| daysinmonth[1] = 31; | |
| daysinmonth[2] = 29; | |
| daysinmonth[3] = 31; | |
| daysinmonth[4] = 30; | |
| daysinmonth[5] = 31; | |
| daysinmonth[6] = 30; | |
| daysinmonth[7] = 31; | |
| daysinmonth[8] = 31; | |
| daysinmonth[9] = 30; | |
| daysinmonth[10] = 31; | |
| daysinmonth[11] = 30; | |
| daysinmonth[12] = 31; | |
| if (d.month < 1 || d.month > 11) // BUG19: > 11 | |
| return 1; | |
| if (d.day < 1 || d.day > 31) | |
| return 2; | |
| if (d.year < 1900) | |
| return 3; | |
| if (d.day > daysinmonth[d.month]) | |
| return 4; | |
| if ((d.month == 2) && !leap(d.year) && (d.day == 29)) | |
| return 5; | |
| // All checks passed | |
| return 0; | |
| } | |
| int m20chkdate(DATE d) | |
| { | |
| int daysinmonth[13]; | |
| daysinmonth[1] = 31; | |
| daysinmonth[2] = 29; | |
| daysinmonth[3] = 31; | |
| daysinmonth[4] = 30; | |
| daysinmonth[5] = 31; | |
| daysinmonth[6] = 30; | |
| daysinmonth[7] = 31; | |
| daysinmonth[8] = 31; | |
| daysinmonth[9] = 30; | |
| daysinmonth[10] = 31; | |
| daysinmonth[11] = 30; | |
| daysinmonth[12] = 31; | |
| if (d.month < 1 || d.month > 13) // BUG20: > 13 | |
| return 1; | |
| if (d.day < 1 || d.day > 31) | |
| return 2; | |
| if (d.year < 1900) | |
| return 3; | |
| if (d.day > daysinmonth[d.month]) | |
| return 4; | |
| if ((d.month == 2) && !leap(d.year) && (d.day == 29)) | |
| return 5; | |
| // All checks passed | |
| return 0; | |
| } | |
| int m21chkdate(DATE d) | |
| { | |
| int daysinmonth[13]; | |
| daysinmonth[1] = 31; | |
| daysinmonth[2] = 29; | |
| daysinmonth[3] = 31; | |
| daysinmonth[4] = 30; | |
| daysinmonth[5] = 31; | |
| daysinmonth[6] = 30; | |
| daysinmonth[7] = 31; | |
| daysinmonth[8] = 31; | |
| daysinmonth[9] = 30; | |
| daysinmonth[10] = 31; | |
| daysinmonth[11] = 30; | |
| daysinmonth[12] = 31; | |
| if (d.month < 1 || d.month > 12) | |
| return 1; | |
| if (d.day < 0 || d.day > 31) // BUG21: < 0 | |
| return 2; | |
| if (d.year < 1900) | |
| return 3; | |
| if (d.day > daysinmonth[d.month]) | |
| return 4; | |
| if ((d.month == 2) && !leap(d.year) && (d.day == 29)) | |
| return 5; | |
| // All checks passed | |
| return 0; | |
| } | |
| int m22chkdate(DATE d) | |
| { | |
| int daysinmonth[13]; | |
| daysinmonth[1] = 31; | |
| daysinmonth[2] = 29; | |
| daysinmonth[3] = 31; | |
| daysinmonth[4] = 30; | |
| daysinmonth[5] = 31; | |
| daysinmonth[6] = 30; | |
| daysinmonth[7] = 31; | |
| daysinmonth[8] = 31; | |
| daysinmonth[9] = 30; | |
| daysinmonth[10] = 31; | |
| daysinmonth[11] = 30; | |
| daysinmonth[12] = 31; | |
| if (d.month < 1 || d.month > 12) | |
| return 1; | |
| if (d.day < 2 || d.day > 31) // BUG22: < 2 | |
| return 2; | |
| if (d.year < 1900) | |
| return 3; | |
| if (d.day > daysinmonth[d.month]) | |
| return 4; | |
| if ((d.month == 2) && !leap(d.year) && (d.day == 29)) | |
| return 5; | |
| // All checks passed | |
| return 0; | |
| } | |
| int m23chkdate(DATE d) | |
| { | |
| int daysinmonth[13]; | |
| daysinmonth[1] = 31; | |
| daysinmonth[2] = 29; | |
| daysinmonth[3] = 31; | |
| daysinmonth[4] = 30; | |
| daysinmonth[5] = 31; | |
| daysinmonth[6] = 30; | |
| daysinmonth[7] = 31; | |
| daysinmonth[8] = 31; | |
| daysinmonth[9] = 30; | |
| daysinmonth[10] = 31; | |
| daysinmonth[11] = 30; | |
| daysinmonth[12] = 31; | |
| if (d.month < 1 || d.month > 12) | |
| return 1; | |
| if (d.day < 1 || d.day > 30) // BUG23: > 30 | |
| return 2; | |
| if (d.year < 1900) | |
| return 3; | |
| if (d.day > daysinmonth[d.month]) | |
| return 4; | |
| if ((d.month == 2) && !leap(d.year) && (d.day == 29)) | |
| return 5; | |
| // All checks passed | |
| return 0; | |
| } | |
| int m24chkdate(DATE d) | |
| { | |
| int daysinmonth[13]; | |
| daysinmonth[1] = 31; | |
| daysinmonth[2] = 29; | |
| daysinmonth[3] = 31; | |
| daysinmonth[4] = 30; | |
| daysinmonth[5] = 31; | |
| daysinmonth[6] = 30; | |
| daysinmonth[7] = 31; | |
| daysinmonth[8] = 31; | |
| daysinmonth[9] = 30; | |
| daysinmonth[10] = 31; | |
| daysinmonth[11] = 30; | |
| daysinmonth[12] = 31; | |
| if (d.month < 1 || d.month > 12) | |
| return 1; | |
| if (d.day < 1 || d.day > 32) // BUG24: > 32 | |
| return 2; | |
| if (d.year < 1900) | |
| return 3; | |
| if (d.day > daysinmonth[d.month]) | |
| return 4; | |
| if ((d.month == 2) && !leap(d.year) && (d.day == 29)) | |
| return 5; | |
| // All checks passed | |
| return 0; | |
| } | |
| int m25chkdate(DATE d) | |
| { | |
| int daysinmonth[13]; | |
| daysinmonth[1] = 31; | |
| daysinmonth[2] = 29; | |
| daysinmonth[3] = 31; | |
| daysinmonth[4] = 30; | |
| daysinmonth[5] = 31; | |
| daysinmonth[6] = 30; | |
| daysinmonth[7] = 31; | |
| daysinmonth[8] = 31; | |
| daysinmonth[9] = 30; | |
| daysinmonth[10] = 31; | |
| daysinmonth[11] = 30; | |
| daysinmonth[12] = 31; | |
| if (d.month < 1 || d.month > 12) | |
| return 1; | |
| if (d.day < 1 || d.day > 31) | |
| return 2; | |
| if (d.year < 1899) // BUG25: < 1899 | |
| return 3; | |
| if (d.day > daysinmonth[d.month]) | |
| return 4; | |
| if ((d.month == 2) && !leap(d.year) && (d.day == 29)) | |
| return 5; | |
| // All checks passed | |
| return 0; | |
| } | |
| int m26chkdate(DATE d) | |
| { | |
| int daysinmonth[13]; | |
| daysinmonth[1] = 31; | |
| daysinmonth[2] = 29; | |
| daysinmonth[3] = 31; | |
| daysinmonth[4] = 30; | |
| daysinmonth[5] = 31; | |
| daysinmonth[6] = 30; | |
| daysinmonth[7] = 31; | |
| daysinmonth[8] = 31; | |
| daysinmonth[9] = 30; | |
| daysinmonth[10] = 31; | |
| daysinmonth[11] = 30; | |
| daysinmonth[12] = 31; | |
| if (d.month < 1 || d.month > 12) | |
| return 1; | |
| if (d.day < 1 || d.day > 31) | |
| return 2; | |
| if (d.year < 1901) // BUG26: 1901 | |
| return 3; | |
| if (d.day > daysinmonth[d.month]) | |
| return 4; | |
| if ((d.month == 2) && !leap(d.year) && (d.day == 29)) | |
| return 5; | |
| // All checks passed | |
| return 0; | |
| } | |
| int m27chkdate(DATE d) | |
| { | |
| int daysinmonth[13]; | |
| daysinmonth[1] = 31; | |
| daysinmonth[2] = 29; | |
| daysinmonth[3] = 31; | |
| daysinmonth[4] = 30; | |
| daysinmonth[5] = 31; | |
| daysinmonth[6] = 30; | |
| daysinmonth[7] = 31; | |
| daysinmonth[8] = 31; | |
| daysinmonth[9] = 30; | |
| daysinmonth[10] = 31; | |
| daysinmonth[11] = 30; | |
| daysinmonth[12] = 31; | |
| if (d.month < 1 || d.month > 12) | |
| return 1; | |
| if (d.day < 1 || d.day > 31) | |
| return 2; | |
| if (d.year < 1900) | |
| return 3; | |
| if (d.day > daysinmonth[d.month]) | |
| return 4; | |
| if ((d.month == 1) && !leap(d.year) && (d.day == 29)) // BUG27: 1 | |
| return 5; | |
| // All checks passed | |
| return 0; | |
| } | |
| int m28chkdate(DATE d) | |
| { | |
| int daysinmonth[13]; | |
| daysinmonth[1] = 31; | |
| daysinmonth[2] = 29; | |
| daysinmonth[3] = 31; | |
| daysinmonth[4] = 30; | |
| daysinmonth[5] = 31; | |
| daysinmonth[6] = 30; | |
| daysinmonth[7] = 31; | |
| daysinmonth[8] = 31; | |
| daysinmonth[9] = 30; | |
| daysinmonth[10] = 31; | |
| daysinmonth[11] = 30; | |
| daysinmonth[12] = 31; | |
| if (d.month < 1 || d.month > 12) | |
| return 1; | |
| if (d.day < 1 || d.day > 31) | |
| return 2; | |
| if (d.year < 1900) | |
| return 3; | |
| if (d.day > daysinmonth[d.month]) | |
| return 4; | |
| if ((d.month == 3) && !leap(d.year) && (d.day == 29)) // BUG28: 3 | |
| return 5; | |
| // All checks passed | |
| return 0; | |
| } | |
| int m29chkdate(DATE d) | |
| { | |
| int daysinmonth[13]; | |
| daysinmonth[1] = 31; | |
| daysinmonth[2] = 29; | |
| daysinmonth[3] = 31; | |
| daysinmonth[4] = 30; | |
| daysinmonth[5] = 31; | |
| daysinmonth[6] = 30; | |
| daysinmonth[7] = 31; | |
| daysinmonth[8] = 31; | |
| daysinmonth[9] = 30; | |
| daysinmonth[10] = 31; | |
| daysinmonth[11] = 30; | |
| daysinmonth[12] = 31; | |
| if (d.month < 1 || d.month > 12) | |
| return 1; | |
| if (d.day < 1 || d.day > 31) | |
| return 2; | |
| if (d.year < 1900) | |
| return 3; | |
| if (d.day > daysinmonth[d.month]) | |
| return 4; | |
| if ((d.month == 2) && !leap(d.year) && (d.day == 28)) // BUG29: 28 | |
| return 5; | |
| // All checks passed | |
| return 0; | |
| } | |
| int m30chkdate(DATE d) | |
| { | |
| int daysinmonth[13]; | |
| daysinmonth[1] = 31; | |
| daysinmonth[2] = 29; | |
| daysinmonth[3] = 31; | |
| daysinmonth[4] = 30; | |
| daysinmonth[5] = 31; | |
| daysinmonth[6] = 30; | |
| daysinmonth[7] = 31; | |
| daysinmonth[8] = 31; | |
| daysinmonth[9] = 30; | |
| daysinmonth[10] = 31; | |
| daysinmonth[11] = 30; | |
| daysinmonth[12] = 31; | |
| if (d.month < 1 || d.month > 12) | |
| return 1; | |
| if (d.day < 1 || d.day > 31) | |
| return 2; | |
| if (d.year < 1900) | |
| return 3; | |
| if (d.day > daysinmonth[d.month]) | |
| return 4; // BUG30: no check for leap day | |
| // if ((d.month == 2) && !leap(d.year) && (d.day == 29)) | |
| // return 5; | |
| // All checks passed | |
| return 0; | |
| } | |
| int m31chkdate(DATE d) | |
| { | |
| int daysinmonth[13]; | |
| daysinmonth[1] = 30; // BUG31: 30 | |
| daysinmonth[2] = 29; | |
| daysinmonth[3] = 31; | |
| daysinmonth[4] = 30; | |
| daysinmonth[5] = 31; | |
| daysinmonth[6] = 30; | |
| daysinmonth[7] = 31; | |
| daysinmonth[8] = 31; | |
| daysinmonth[9] = 30; | |
| daysinmonth[10] = 31; | |
| daysinmonth[11] = 30; | |
| daysinmonth[12] = 31; | |
| if (d.month < 1 || d.month > 12) | |
| return 1; | |
| if (d.day < 1 || d.day > 31) | |
| return 2; | |
| if (d.year < 1900) | |
| return 3; | |
| if (d.day > daysinmonth[d.month]) | |
| return 4; | |
| if ((d.month == 2) && !leap(d.year) && (d.day == 29)) | |
| return 5; | |
| // All checks passed | |
| return 0; | |
| } | |
| int m32chkdate(DATE d) | |
| { | |
| int daysinmonth[13]; | |
| daysinmonth[1] = 31; | |
| daysinmonth[2] = 28; // BUG32: 28 | |
| daysinmonth[3] = 31; | |
| daysinmonth[4] = 30; | |
| daysinmonth[5] = 31; | |
| daysinmonth[6] = 30; | |
| daysinmonth[7] = 31; | |
| daysinmonth[8] = 31; | |
| daysinmonth[9] = 30; | |
| daysinmonth[10] = 31; | |
| daysinmonth[11] = 30; | |
| daysinmonth[12] = 31; | |
| if (d.month < 1 || d.month > 12) | |
| return 1; | |
| if (d.day < 1 || d.day > 31) | |
| return 2; | |
| if (d.year < 1900) | |
| return 3; | |
| if (d.day > daysinmonth[d.month]) | |
| return 4; | |
| if ((d.month == 2) && !leap(d.year) && (d.day == 29)) | |
| return 5; | |
| // All checks passed | |
| return 0; | |
| } | |
| int m33chkdate(DATE d) | |
| { | |
| int daysinmonth[13]; | |
| daysinmonth[1] = 31; | |
| daysinmonth[2] = 29; | |
| daysinmonth[3] = 30; // BUG33: 30 | |
| daysinmonth[4] = 30; | |
| daysinmonth[5] = 31; | |
| daysinmonth[6] = 30; | |
| daysinmonth[7] = 31; | |
| daysinmonth[8] = 31; | |
| daysinmonth[9] = 30; | |
| daysinmonth[10] = 31; | |
| daysinmonth[11] = 30; | |
| daysinmonth[12] = 31; | |
| if (d.month < 1 || d.month > 12) | |
| return 1; | |
| if (d.day < 1 || d.day > 31) | |
| return 2; | |
| if (d.year < 1900) | |
| return 3; | |
| if (d.day > daysinmonth[d.month]) | |
| return 4; | |
| if ((d.month == 2) && !leap(d.year) && (d.day == 29)) | |
| return 5; | |
| // All checks passed | |
| return 0; | |
| } | |
| int m34chkdate(DATE d) | |
| { | |
| int daysinmonth[13]; | |
| daysinmonth[1] = 31; | |
| daysinmonth[2] = 29; | |
| daysinmonth[3] = 31; | |
| daysinmonth[4] = 31; // BUG34: 31 | |
| daysinmonth[5] = 31; | |
| daysinmonth[6] = 30; | |
| daysinmonth[7] = 31; | |
| daysinmonth[8] = 31; | |
| daysinmonth[9] = 30; | |
| daysinmonth[10] = 31; | |
| daysinmonth[11] = 30; | |
| daysinmonth[12] = 31; | |
| if (d.month < 1 || d.month > 12) | |
| return 1; | |
| if (d.day < 1 || d.day > 31) | |
| return 2; | |
| if (d.year < 1900) | |
| return 3; | |
| if (d.day > daysinmonth[d.month]) | |
| return 4; | |
| if ((d.month == 2) && !leap(d.year) && (d.day == 29)) | |
| return 5; | |
| // All checks passed | |
| return 0; | |
| } | |
| int m35chkdate(DATE d) | |
| { | |
| int daysinmonth[13]; | |
| daysinmonth[1] = 31; | |
| daysinmonth[2] = 29; | |
| daysinmonth[3] = 31; | |
| daysinmonth[4] = 30; | |
| daysinmonth[5] = 30; // BUG35: 30 | |
| daysinmonth[6] = 30; | |
| daysinmonth[7] = 31; | |
| daysinmonth[8] = 31; | |
| daysinmonth[9] = 30; | |
| daysinmonth[10] = 31; | |
| daysinmonth[11] = 30; | |
| daysinmonth[12] = 31; | |
| if (d.month < 1 || d.month > 12) | |
| return 1; | |
| if (d.day < 1 || d.day > 31) | |
| return 2; | |
| if (d.year < 1900) | |
| return 3; | |
| if (d.day > daysinmonth[d.month]) | |
| return 4; | |
| if ((d.month == 2) && !leap(d.year) && (d.day == 29)) | |
| return 5; | |
| // All checks passed | |
| return 0; | |
| } | |
| int m36chkdate(DATE d) | |
| { | |
| int daysinmonth[13]; | |
| daysinmonth[1] = 31; | |
| daysinmonth[2] = 29; | |
| daysinmonth[3] = 31; | |
| daysinmonth[4] = 30; | |
| daysinmonth[5] = 31; | |
| daysinmonth[6] = 31; // BUG36: 31 | |
| daysinmonth[7] = 31; | |
| daysinmonth[8] = 31; | |
| daysinmonth[9] = 30; | |
| daysinmonth[10] = 31; | |
| daysinmonth[11] = 30; | |
| daysinmonth[12] = 31; | |
| if (d.month < 1 || d.month > 12) | |
| return 1; | |
| if (d.day < 1 || d.day > 31) | |
| return 2; | |
| if (d.year < 1900) | |
| return 3; | |
| if (d.day > daysinmonth[d.month]) | |
| return 4; | |
| if ((d.month == 2) && !leap(d.year) && (d.day == 29)) | |
| return 5; | |
| // All checks passed | |
| return 0; | |
| } | |
| int m37chkdate(DATE d) | |
| { | |
| int daysinmonth[13]; | |
| daysinmonth[1] = 31; | |
| daysinmonth[2] = 29; | |
| daysinmonth[3] = 31; | |
| daysinmonth[4] = 30; | |
| daysinmonth[5] = 31; | |
| daysinmonth[6] = 30; | |
| daysinmonth[7] = 30; // BUG37: 30 | |
| daysinmonth[8] = 31; | |
| daysinmonth[9] = 30; | |
| daysinmonth[10] = 31; | |
| daysinmonth[11] = 30; | |
| daysinmonth[12] = 31; | |
| if (d.month < 1 || d.month > 12) | |
| return 1; | |
| if (d.day < 1 || d.day > 31) | |
| return 2; | |
| if (d.year < 1900) | |
| return 3; | |
| if (d.day > daysinmonth[d.month]) | |
| return 4; | |
| if ((d.month == 2) && !leap(d.year) && (d.day == 29)) | |
| return 5; | |
| // All checks passed | |
| return 0; | |
| } | |
| int m38chkdate(DATE d) | |
| { | |
| int daysinmonth[13]; | |
| daysinmonth[1] = 31; | |
| daysinmonth[2] = 29; | |
| daysinmonth[3] = 31; | |
| daysinmonth[4] = 30; | |
| daysinmonth[5] = 31; | |
| daysinmonth[6] = 30; | |
| daysinmonth[7] = 31; | |
| daysinmonth[8] = 30; // BUG38: 30 | |
| daysinmonth[9] = 30; | |
| daysinmonth[10] = 31; | |
| daysinmonth[11] = 30; | |
| daysinmonth[12] = 31; | |
| if (d.month < 1 || d.month > 12) | |
| return 1; | |
| if (d.day < 1 || d.day > 31) | |
| return 2; | |
| if (d.year < 1900) | |
| return 3; | |
| if (d.day > daysinmonth[d.month]) | |
| return 4; | |
| if ((d.month == 2) && !leap(d.year) && (d.day == 29)) | |
| return 5; | |
| // All checks passed | |
| return 0; | |
| } | |
| int m39chkdate(DATE d) | |
| { | |
| int daysinmonth[13]; | |
| daysinmonth[1] = 31; | |
| daysinmonth[2] = 29; | |
| daysinmonth[3] = 31; | |
| daysinmonth[4] = 30; | |
| daysinmonth[5] = 31; | |
| daysinmonth[6] = 30; | |
| daysinmonth[7] = 31; | |
| daysinmonth[8] = 31; | |
| daysinmonth[9] = 31; // BUG39: 31 | |
| daysinmonth[10] = 31; | |
| daysinmonth[11] = 30; | |
| daysinmonth[12] = 31; | |
| if (d.month < 1 || d.month > 12) | |
| return 1; | |
| if (d.day < 1 || d.day > 31) | |
| return 2; | |
| if (d.year < 1900) | |
| return 3; | |
| if (d.day > daysinmonth[d.month]) | |
| return 4; | |
| if ((d.month == 2) && !leap(d.year) && (d.day == 29)) | |
| return 5; | |
| // All checks passed | |
| return 0; | |
| } | |
| int m40chkdate(DATE d) | |
| { | |
| int daysinmonth[13]; | |
| daysinmonth[1] = 31; | |
| daysinmonth[2] = 29; | |
| daysinmonth[3] = 31; | |
| daysinmonth[4] = 30; | |
| daysinmonth[5] = 31; | |
| daysinmonth[6] = 30; | |
| daysinmonth[7] = 31; | |
| daysinmonth[8] = 31; | |
| daysinmonth[9] = 30; | |
| daysinmonth[10] = 30; // BUG40: 30 | |
| daysinmonth[11] = 30; | |
| daysinmonth[12] = 31; | |
| if (d.month < 1 || d.month > 12) | |
| return 1; | |
| if (d.day < 1 || d.day > 31) | |
| return 2; | |
| if (d.year < 1900) | |
| return 3; | |
| if (d.day > daysinmonth[d.month]) | |
| return 4; | |
| if ((d.month == 2) && !leap(d.year) && (d.day == 29)) | |
| return 5; | |
| // All checks passed | |
| return 0; | |
| } | |
| int m41chkdate(DATE d) | |
| { | |
| int daysinmonth[13]; | |
| daysinmonth[1] = 31; | |
| daysinmonth[2] = 29; | |
| daysinmonth[3] = 31; | |
| daysinmonth[4] = 30; | |
| daysinmonth[5] = 31; | |
| daysinmonth[6] = 30; | |
| daysinmonth[7] = 31; | |
| daysinmonth[8] = 31; | |
| daysinmonth[9] = 30; | |
| daysinmonth[10] = 31; | |
| daysinmonth[11] = 31; // BUG41: 31 | |
| daysinmonth[12] = 31; | |
| if (d.month < 1 || d.month > 12) | |
| return 1; | |
| if (d.day < 1 || d.day > 31) | |
| return 2; | |
| if (d.year < 1900) | |
| return 3; | |
| if (d.day > daysinmonth[d.month]) | |
| return 4; | |
| if ((d.month == 2) && !leap(d.year) && (d.day == 29)) | |
| return 5; | |
| // All checks passed | |
| return 0; | |
| } | |
| int m42chkdate(DATE d) | |
| { | |
| int daysinmonth[13]; | |
| daysinmonth[1] = 31; | |
| daysinmonth[2] = 29; | |
| daysinmonth[3] = 31; | |
| daysinmonth[4] = 30; | |
| daysinmonth[5] = 31; | |
| daysinmonth[6] = 30; | |
| daysinmonth[7] = 31; | |
| daysinmonth[8] = 31; | |
| daysinmonth[9] = 30; | |
| daysinmonth[10] = 31; | |
| daysinmonth[11] = 30; | |
| daysinmonth[12] = 30; // BUG42: 30 | |
| if (d.month < 1 || d.month > 12) | |
| return 1; | |
| if (d.day < 1 || d.day > 31) | |
| return 2; | |
| if (d.year < 1900) | |
| return 3; | |
| if (d.day > daysinmonth[d.month]) | |
| return 4; | |
| if ((d.month == 2) && !leap(d.year) && (d.day == 29)) | |
| return 5; | |
| // All checks passed | |
| return 0; | |
| } | |
| int m43chkdate(DATE d) | |
| { | |
| int daysinmonth[13]; | |
| daysinmonth[1] = 31; | |
| daysinmonth[2] = 29; | |
| daysinmonth[3] = 31; | |
| daysinmonth[4] = 30; | |
| daysinmonth[5] = 31; | |
| daysinmonth[6] = 30; | |
| daysinmonth[7] = 31; | |
| daysinmonth[8] = 31; | |
| daysinmonth[9] = 30; | |
| daysinmonth[10] = 31; | |
| daysinmonth[11] = 30; | |
| daysinmonth[12] = 31; | |
| if (d.month < 1 || d.month > 12) | |
| return 1; | |
| if (d.day < 1 || d.day > 31) | |
| return 2; | |
| if (d.year < 1900) | |
| return 3; | |
| if (d.day > daysinmonth[d.month]) | |
| return 4; | |
| if ((d.month == 2) && !m43leap(d.year) && (d.day == 29)) | |
| return 5; | |
| // All checks passed | |
| return 0; | |
| } | |
| int m44chkdate(DATE d) | |
| { | |
| int daysinmonth[13]; | |
| daysinmonth[1] = 31; | |
| daysinmonth[2] = 29; | |
| daysinmonth[3] = 31; | |
| daysinmonth[4] = 30; | |
| daysinmonth[5] = 31; | |
| daysinmonth[6] = 30; | |
| daysinmonth[7] = 31; | |
| daysinmonth[8] = 31; | |
| daysinmonth[9] = 30; | |
| daysinmonth[10] = 31; | |
| daysinmonth[11] = 30; | |
| daysinmonth[12] = 31; | |
| if (d.month < 1 || d.month > 12) | |
| return 1; | |
| if (d.day < 1 || d.day > 31) | |
| return 2; | |
| if (d.year < 1900) | |
| return 3; | |
| if (d.day > daysinmonth[d.month]) | |
| return 4; | |
| if ((d.month == 2) && !m44leap(d.year) && (d.day == 29)) | |
| return 5; | |
| // All checks passed | |
| return 0; | |
| } | |
| int m45chkdate(DATE d) | |
| { | |
| int daysinmonth[13]; | |
| daysinmonth[1] = 31; | |
| daysinmonth[2] = 29; | |
| daysinmonth[3] = 31; | |
| daysinmonth[4] = 30; | |
| daysinmonth[5] = 31; | |
| daysinmonth[6] = 30; | |
| daysinmonth[7] = 31; | |
| daysinmonth[8] = 31; | |
| daysinmonth[9] = 30; | |
| daysinmonth[10] = 31; | |
| daysinmonth[11] = 30; | |
| daysinmonth[12] = 31; | |
| if (d.month < 1 || d.month > 12) | |
| return 1; | |
| if (d.day < 1 || d.day > 31) | |
| return 2; | |
| if (d.year < 1900) | |
| return 3; | |
| if (d.day > daysinmonth[d.month]) | |
| return 4; | |
| if ((d.month == 2) && !m45leap(d.year) && (d.day == 29)) | |
| return 5; | |
| // All checks passed | |
| return 0; | |
| } | |
| /************************************************************************* | |
| Convert input line to 2 dates | |
| ************************************************************************/ | |
| int convertline() | |
| { | |
| int retchk; // return code from chkdate | |
| /* the line looks like: | |
| MM/DD/YYYY,MM/DD/YYYY | |
| 012345678901234567890 | |
| 0 1 2 */ | |
| firstdate.month = strtoint(0); | |
| firstdate.day = strtoint(3); | |
| firstdate.year = strtoint(6)*100 + strtoint(8); | |
| // Check for plausible values | |
| if ((retchk = chkdate(firstdate)) != 0) | |
| return (10 + retchk); | |
| seconddate.month = strtoint(11); | |
| seconddate.day = strtoint(14); | |
| seconddate.year = strtoint(17)*100 + strtoint(19); | |
| // Check for plausible values | |
| if ((retchk = chkdate(seconddate)) != 0) | |
| return (20 + retchk); | |
| // All checks passed | |
| return 0; | |
| } | |
| int m17convertline() | |
| { | |
| int retchk; // return code from chkdate | |
| firstdate.month = strtoint(0); | |
| firstdate.day = strtoint(3); | |
| firstdate.year = strtoint(6)*100 + strtoint(8); | |
| // Check for plausible values | |
| if ((retchk = m17chkdate(firstdate)) != 0) | |
| return (10 + retchk); | |
| seconddate.month = strtoint(11); | |
| seconddate.day = strtoint(14); | |
| seconddate.year = strtoint(17)*100 + strtoint(19); | |
| // Check for plausible values | |
| if ((retchk = m17chkdate(seconddate)) != 0) | |
| return (20 + retchk); | |
| // All checks passed | |
| return 0; | |
| } | |
| int m18convertline() | |
| { | |
| int retchk; // return code from chkdate | |
| firstdate.month = strtoint(0); | |
| firstdate.day = strtoint(3); | |
| firstdate.year = strtoint(6)*100 + strtoint(8); | |
| // Check for plausible values | |
| if ((retchk = m18chkdate(firstdate)) != 0) | |
| return (10 + retchk); | |
| seconddate.month = strtoint(11); | |
| seconddate.day = strtoint(14); | |
| seconddate.year = strtoint(17)*100 + strtoint(19); | |
| // Check for plausible values | |
| if ((retchk = m18chkdate(seconddate)) != 0) | |
| return (20 + retchk); | |
| // All checks passed | |
| return 0; | |
| } | |
| int m19convertline() | |
| { | |
| int retchk; // return code from chkdate | |
| firstdate.month = strtoint(0); | |
| firstdate.day = strtoint(3); | |
| firstdate.year = strtoint(6)*100 + strtoint(8); | |
| // Check for plausible values | |
| if ((retchk = m19chkdate(firstdate)) != 0) | |
| return (10 + retchk); | |
| seconddate.month = strtoint(11); | |
| seconddate.day = strtoint(14); | |
| seconddate.year = strtoint(17)*100 + strtoint(19); | |
| // Check for plausible values | |
| if ((retchk = m19chkdate(seconddate)) != 0) | |
| return (20 + retchk); | |
| // All checks passed | |
| return 0; | |
| } | |
| int m20convertline() | |
| { | |
| int retchk; // return code from chkdate | |
| firstdate.month = strtoint(0); | |
| firstdate.day = strtoint(3); | |
| firstdate.year = strtoint(6)*100 + strtoint(8); | |
| // Check for plausible values | |
| if ((retchk = m20chkdate(firstdate)) != 0) | |
| return (10 + retchk); | |
| seconddate.month = strtoint(11); | |
| seconddate.day = strtoint(14); | |
| seconddate.year = strtoint(17)*100 + strtoint(19); | |
| // Check for plausible values | |
| if ((retchk = m20chkdate(seconddate)) != 0) | |
| return (20 + retchk); | |
| // All checks passed | |
| return 0; | |
| } | |
| int m21convertline() | |
| { | |
| int retchk; // return code from chkdate | |
| firstdate.month = strtoint(0); | |
| firstdate.day = strtoint(3); | |
| firstdate.year = strtoint(6)*100 + strtoint(8); | |
| // Check for plausible values | |
| if ((retchk = m21chkdate(firstdate)) != 0) | |
| return (10 + retchk); | |
| seconddate.month = strtoint(11); | |
| seconddate.day = strtoint(14); | |
| seconddate.year = strtoint(17)*100 + strtoint(19); | |
| // Check for plausible values | |
| if ((retchk = m21chkdate(seconddate)) != 0) | |
| return (20 + retchk); | |
| // All checks passed | |
| return 0; | |
| } | |
| int m22convertline() | |
| { | |
| int retchk; // return code from chkdate | |
| firstdate.month = strtoint(0); | |
| firstdate.day = strtoint(3); | |
| firstdate.year = strtoint(6)*100 + strtoint(8); | |
| // Check for plausible values | |
| if ((retchk = m22chkdate(firstdate)) != 0) | |
| return (10 + retchk); | |
| seconddate.month = strtoint(11); | |
| seconddate.day = strtoint(14); | |
| seconddate.year = strtoint(17)*100 + strtoint(19); | |
| // Check for plausible values | |
| if ((retchk = m22chkdate(seconddate)) != 0) | |
| return (20 + retchk); | |
| // All checks passed | |
| return 0; | |
| } | |
| int m23convertline() | |
| { | |
| int retchk; // return code from chkdate | |
| firstdate.month = strtoint(0); | |
| firstdate.day = strtoint(3); | |
| firstdate.year = strtoint(6)*100 + strtoint(8); | |
| // Check for plausible values | |
| if ((retchk = m23chkdate(firstdate)) != 0) | |
| return (10 + retchk); | |
| seconddate.month = strtoint(11); | |
| seconddate.day = strtoint(14); | |
| seconddate.year = strtoint(17)*100 + strtoint(19); | |
| // Check for plausible values | |
| if ((retchk = m23chkdate(seconddate)) != 0) | |
| return (20 + retchk); | |
| // All checks passed | |
| return 0; | |
| } | |
| int m24convertline() | |
| { | |
| int retchk; // return code from chkdate | |
| firstdate.month = strtoint(0); | |
| firstdate.day = strtoint(3); | |
| firstdate.year = strtoint(6)*100 + strtoint(8); | |
| // Check for plausible values | |
| if ((retchk = m24chkdate(firstdate)) != 0) | |
| return (10 + retchk); | |
| seconddate.month = strtoint(11); | |
| seconddate.day = strtoint(14); | |
| seconddate.year = strtoint(17)*100 + strtoint(19); | |
| // Check for plausible values | |
| if ((retchk = m24chkdate(seconddate)) != 0) | |
| return (20 + retchk); | |
| // All checks passed | |
| return 0; | |
| } | |
| int m25convertline() | |
| { | |
| int retchk; // return code from chkdate | |
| firstdate.month = strtoint(0); | |
| firstdate.day = strtoint(3); | |
| firstdate.year = strtoint(6)*100 + strtoint(8); | |
| // Check for plausible values | |
| if ((retchk = m25chkdate(firstdate)) != 0) | |
| return (10 + retchk); | |
| seconddate.month = strtoint(11); | |
| seconddate.day = strtoint(14); | |
| seconddate.year = strtoint(17)*100 + strtoint(19); | |
| // Check for plausible values | |
| if ((retchk = m25chkdate(seconddate)) != 0) | |
| return (20 + retchk); | |
| // All checks passed | |
| return 0; | |
| } | |
| int m26convertline() | |
| { | |
| int retchk; // return code from chkdate | |
| firstdate.month = strtoint(0); | |
| firstdate.day = strtoint(3); | |
| firstdate.year = strtoint(6)*100 + strtoint(8); | |
| // Check for plausible values | |
| if ((retchk = m26chkdate(firstdate)) != 0) | |
| return (10 + retchk); | |
| seconddate.month = strtoint(11); | |
| seconddate.day = strtoint(14); | |
| seconddate.year = strtoint(17)*100 + strtoint(19); | |
| // Check for plausible values | |
| if ((retchk = m26chkdate(seconddate)) != 0) | |
| return (20 + retchk); | |
| // All checks passed | |
| return 0; | |
| } | |
| int m27convertline() | |
| { | |
| int retchk; // return code from chkdate | |
| firstdate.month = strtoint(0); | |
| firstdate.day = strtoint(3); | |
| firstdate.year = strtoint(6)*100 + strtoint(8); | |
| // Check for plausible values | |
| if ((retchk = m27chkdate(firstdate)) != 0) | |
| return (10 + retchk); | |
| seconddate.month = strtoint(11); | |
| seconddate.day = strtoint(14); | |
| seconddate.year = strtoint(17)*100 + strtoint(19); | |
| // Check for plausible values | |
| if ((retchk = m27chkdate(seconddate)) != 0) | |
| return (20 + retchk); | |
| // All checks passed | |
| return 0; | |
| } | |
| int m28convertline() | |
| { | |
| int retchk; // return code from chkdate | |
| firstdate.month = strtoint(0); | |
| firstdate.day = strtoint(3); | |
| firstdate.year = strtoint(6)*100 + strtoint(8); | |
| // Check for plausible values | |
| if ((retchk = m28chkdate(firstdate)) != 0) | |
| return (10 + retchk); | |
| seconddate.month = strtoint(11); | |
| seconddate.day = strtoint(14); | |
| seconddate.year = strtoint(17)*100 + strtoint(19); | |
| // Check for plausible values | |
| if ((retchk = m28chkdate(seconddate)) != 0) | |
| return (20 + retchk); | |
| // All checks passed | |
| return 0; | |
| } | |
| int m29convertline() | |
| { | |
| int retchk; // return code from chkdate | |
| firstdate.month = strtoint(0); | |
| firstdate.day = strtoint(3); | |
| firstdate.year = strtoint(6)*100 + strtoint(8); | |
| // Check for plausible values | |
| if ((retchk = m29chkdate(firstdate)) != 0) | |
| return (10 + retchk); | |
| seconddate.month = strtoint(11); | |
| seconddate.day = strtoint(14); | |
| seconddate.year = strtoint(17)*100 + strtoint(19); | |
| // Check for plausible values | |
| if ((retchk = m29chkdate(seconddate)) != 0) | |
| return (20 + retchk); | |
| // All checks passed | |
| return 0; | |
| } | |
| int m30convertline() | |
| { | |
| int retchk; // return code from chkdate | |
| firstdate.month = strtoint(0); | |
| firstdate.day = strtoint(3); | |
| firstdate.year = strtoint(6)*100 + strtoint(8); | |
| // Check for plausible values | |
| if ((retchk = m30chkdate(firstdate)) != 0) | |
| return (10 + retchk); | |
| seconddate.month = strtoint(11); | |
| seconddate.day = strtoint(14); | |
| seconddate.year = strtoint(17)*100 + strtoint(19); | |
| // Check for plausible values | |
| if ((retchk = m30chkdate(seconddate)) != 0) | |
| return (20 + retchk); | |
| // All checks passed | |
| return 0; | |
| } | |
| int m31convertline() | |
| { | |
| int retchk; // return code from chkdate | |
| firstdate.month = strtoint(0); | |
| firstdate.day = strtoint(3); | |
| firstdate.year = strtoint(6)*100 + strtoint(8); | |
| // Check for plausible values | |
| if ((retchk = m31chkdate(firstdate)) != 0) | |
| return (10 + retchk); | |
| seconddate.month = strtoint(11); | |
| seconddate.day = strtoint(14); | |
| seconddate.year = strtoint(17)*100 + strtoint(19); | |
| // Check for plausible values | |
| if ((retchk = m31chkdate(seconddate)) != 0) | |
| return (20 + retchk); | |
| // All checks passed | |
| return 0; | |
| } | |
| int m32convertline() | |
| { | |
| int retchk; // return code from chkdate | |
| firstdate.month = strtoint(0); | |
| firstdate.day = strtoint(3); | |
| firstdate.year = strtoint(6)*100 + strtoint(8); | |
| // Check for plausible values | |
| if ((retchk = m32chkdate(firstdate)) != 0) | |
| return (10 + retchk); | |
| seconddate.month = strtoint(11); | |
| seconddate.day = strtoint(14); | |
| seconddate.year = strtoint(17)*100 + strtoint(19); | |
| // Check for plausible values | |
| if ((retchk = m32chkdate(seconddate)) != 0) | |
| return (20 + retchk); | |
| // All checks passed | |
| return 0; | |
| } | |
| int m33convertline() | |
| { | |
| int retchk; // return code from chkdate | |
| firstdate.month = strtoint(0); | |
| firstdate.day = strtoint(3); | |
| firstdate.year = strtoint(6)*100 + strtoint(8); | |
| // Check for plausible values | |
| if ((retchk = m33chkdate(firstdate)) != 0) | |
| return (10 + retchk); | |
| seconddate.month = strtoint(11); | |
| seconddate.day = strtoint(14); | |
| seconddate.year = strtoint(17)*100 + strtoint(19); | |
| // Check for plausible values | |
| if ((retchk = m33chkdate(seconddate)) != 0) | |
| return (20 + retchk); | |
| // All checks passed | |
| return 0; | |
| } | |
| int m34convertline() | |
| { | |
| int retchk; // return code from chkdate | |
| firstdate.month = strtoint(0); | |
| firstdate.day = strtoint(3); | |
| firstdate.year = strtoint(6)*100 + strtoint(8); | |
| // Check for plausible values | |
| if ((retchk = m34chkdate(firstdate)) != 0) | |
| return (10 + retchk); | |
| seconddate.month = strtoint(11); | |
| seconddate.day = strtoint(14); | |
| seconddate.year = strtoint(17)*100 + strtoint(19); | |
| // Check for plausible values | |
| if ((retchk = m34chkdate(seconddate)) != 0) | |
| return (20 + retchk); | |
| // All checks passed | |
| return 0; | |
| } | |
| int m35convertline() | |
| { | |
| int retchk; // return code from chkdate | |
| firstdate.month = strtoint(0); | |
| firstdate.day = strtoint(3); | |
| firstdate.year = strtoint(6)*100 + strtoint(8); | |
| // Check for plausible values | |
| if ((retchk = m35chkdate(firstdate)) != 0) | |
| return (10 + retchk); | |
| seconddate.month = strtoint(11); | |
| seconddate.day = strtoint(14); | |
| seconddate.year = strtoint(17)*100 + strtoint(19); | |
| // Check for plausible values | |
| if ((retchk = m35chkdate(seconddate)) != 0) | |
| return (20 + retchk); | |
| // All checks passed | |
| return 0; | |
| } | |
| int m36convertline() | |
| { | |
| int retchk; // return code from chkdate | |
| firstdate.month = strtoint(0); | |
| firstdate.day = strtoint(3); | |
| firstdate.year = strtoint(6)*100 + strtoint(8); | |
| // Check for plausible values | |
| if ((retchk = m36chkdate(firstdate)) != 0) | |
| return (10 + retchk); | |
| seconddate.month = strtoint(11); | |
| seconddate.day = strtoint(14); | |
| seconddate.year = strtoint(17)*100 + strtoint(19); | |
| // Check for plausible values | |
| if ((retchk = m36chkdate(seconddate)) != 0) | |
| return (20 + retchk); | |
| // All checks passed | |
| return 0; | |
| } | |
| int m37convertline() | |
| { | |
| int retchk; // return code from chkdate | |
| firstdate.month = strtoint(0); | |
| firstdate.day = strtoint(3); | |
| firstdate.year = strtoint(6)*100 + strtoint(8); | |
| // Check for plausible values | |
| if ((retchk = m37chkdate(firstdate)) != 0) | |
| return (10 + retchk); | |
| seconddate.month = strtoint(11); | |
| seconddate.day = strtoint(14); | |
| seconddate.year = strtoint(17)*100 + strtoint(19); | |
| // Check for plausible values | |
| if ((retchk = m37chkdate(seconddate)) != 0) | |
| return (20 + retchk); | |
| // All checks passed | |
| return 0; | |
| } | |
| int m38convertline() | |
| { | |
| int retchk; // return code from chkdate | |
| firstdate.month = strtoint(0); | |
| firstdate.day = strtoint(3); | |
| firstdate.year = strtoint(6)*100 + strtoint(8); | |
| // Check for plausible values | |
| if ((retchk = m38chkdate(firstdate)) != 0) | |
| return (10 + retchk); | |
| seconddate.month = strtoint(11); | |
| seconddate.day = strtoint(14); | |
| seconddate.year = strtoint(17)*100 + strtoint(19); | |
| // Check for plausible values | |
| if ((retchk = m38chkdate(seconddate)) != 0) | |
| return (20 + retchk); | |
| // All checks passed | |
| return 0; | |
| } | |
| int m39convertline() | |
| { | |
| int retchk; // return code from chkdate | |
| firstdate.month = strtoint(0); | |
| firstdate.day = strtoint(3); | |
| firstdate.year = strtoint(6)*100 + strtoint(8); | |
| // Check for plausible values | |
| if ((retchk = m39chkdate(firstdate)) != 0) | |
| return (10 + retchk); | |
| seconddate.month = strtoint(11); | |
| seconddate.day = strtoint(14); | |
| seconddate.year = strtoint(17)*100 + strtoint(19); | |
| // Check for plausible values | |
| if ((retchk = m39chkdate(seconddate)) != 0) | |
| return (20 + retchk); | |
| // All checks passed | |
| return 0; | |
| } | |
| int m40convertline() | |
| { | |
| int retchk; // return code from chkdate | |
| firstdate.month = strtoint(0); | |
| firstdate.day = strtoint(3); | |
| firstdate.year = strtoint(6)*100 + strtoint(8); | |
| // Check for plausible values | |
| if ((retchk = m40chkdate(firstdate)) != 0) | |
| return (10 + retchk); | |
| seconddate.month = strtoint(11); | |
| seconddate.day = strtoint(14); | |
| seconddate.year = strtoint(17)*100 + strtoint(19); | |
| // Check for plausible values | |
| if ((retchk = m40chkdate(seconddate)) != 0) | |
| return (20 + retchk); | |
| // All checks passed | |
| return 0; | |
| } | |
| int m41convertline() | |
| { | |
| int retchk; // return code from chkdate | |
| firstdate.month = strtoint(0); | |
| firstdate.day = strtoint(3); | |
| firstdate.year = strtoint(6)*100 + strtoint(8); | |
| // Check for plausible values | |
| if ((retchk = m41chkdate(firstdate)) != 0) | |
| return (10 + retchk); | |
| seconddate.month = strtoint(11); | |
| seconddate.day = strtoint(14); | |
| seconddate.year = strtoint(17)*100 + strtoint(19); | |
| // Check for plausible values | |
| if ((retchk = m41chkdate(seconddate)) != 0) | |
| return (20 + retchk); | |
| // All checks passed | |
| return 0; | |
| } | |
| int m42convertline() | |
| { | |
| int retchk; // return code from chkdate | |
| firstdate.month = strtoint(0); | |
| firstdate.day = strtoint(3); | |
| firstdate.year = strtoint(6)*100 + strtoint(8); | |
| // Check for plausible values | |
| if ((retchk = m42chkdate(firstdate)) != 0) | |
| return (10 + retchk); | |
| seconddate.month = strtoint(11); | |
| seconddate.day = strtoint(14); | |
| seconddate.year = strtoint(17)*100 + strtoint(19); | |
| // Check for plausible values | |
| if ((retchk = m42chkdate(seconddate)) != 0) | |
| return (20 + retchk); | |
| // All checks passed | |
| return 0; | |
| } | |
| int m43convertline() | |
| { | |
| int retchk; // return code from chkdate | |
| firstdate.month = strtoint(0); | |
| firstdate.day = strtoint(3); | |
| firstdate.year = strtoint(6)*100 + strtoint(8); | |
| // Check for plausible values | |
| if ((retchk = m43chkdate(firstdate)) != 0) | |
| return (10 + retchk); | |
| seconddate.month = strtoint(11); | |
| seconddate.day = strtoint(14); | |
| seconddate.year = strtoint(17)*100 + strtoint(19); | |
| // Check for plausible values | |
| if ((retchk = m43chkdate(seconddate)) != 0) | |
| return (20 + retchk); | |
| // All checks passed | |
| return 0; | |
| } | |
| int m44convertline() | |
| { | |
| int retchk; // return code from chkdate | |
| firstdate.month = strtoint(0); | |
| firstdate.day = strtoint(3); | |
| firstdate.year = strtoint(6)*100 + strtoint(8); | |
| // Check for plausible values | |
| if ((retchk = m44chkdate(firstdate)) != 0) | |
| return (10 + retchk); | |
| seconddate.month = strtoint(11); | |
| seconddate.day = strtoint(14); | |
| seconddate.year = strtoint(17)*100 + strtoint(19); | |
| // Check for plausible values | |
| if ((retchk = m44chkdate(seconddate)) != 0) | |
| return (20 + retchk); | |
| // All checks passed | |
| return 0; | |
| } | |
| int m45convertline() | |
| { | |
| int retchk; // return code from chkdate | |
| firstdate.month = strtoint(0); | |
| firstdate.day = strtoint(3); | |
| firstdate.year = strtoint(6)*100 + strtoint(8); | |
| // Check for plausible values | |
| if ((retchk = m45chkdate(firstdate)) != 0) | |
| return (10 + retchk); | |
| seconddate.month = strtoint(11); | |
| seconddate.day = strtoint(14); | |
| seconddate.year = strtoint(17)*100 + strtoint(19); | |
| // Check for plausible values | |
| if ((retchk = m45chkdate(seconddate)) != 0) | |
| return (20 + retchk); | |
| // All checks passed | |
| return 0; | |
| } | |
| /************************************************************************* | |
| Compute number of days between dates | |
| ************************************************************************/ | |
| int daysdiff(DATE first, DATE second) | |
| { | |
| int fjd, sjd; | |
| int mdays[13]; | |
| mdays[1] = 0; | |
| mdays[2] = 31; | |
| mdays[3] = 59; | |
| mdays[4] = 90; | |
| mdays[5] = 120; | |
| mdays[6] = 151; | |
| mdays[7] = 181; | |
| mdays[8] = 212; | |
| mdays[9] = 243; | |
| mdays[10] = 273; | |
| mdays[11] = 304; | |
| mdays[12] = 334; | |
| fjd = first.year*365 + first.year/4 - first.year/100 + first.year/400; | |
| fjd = fjd + mdays[first.month] + first.day; | |
| if ((leap(first.year) == 1) && (first.month < 3)) | |
| fjd--; | |
| sjd = second.year*365 + second.year/4 - second.year/100 + second.year/400; | |
| sjd = sjd + mdays[second.month] + second.day; | |
| if ((leap(second.year) == 1) && (second.month < 3)) | |
| sjd--; | |
| return (sjd - fjd); | |
| } | |
| int m46daysdiff(DATE first, DATE second) | |
| { | |
| int fjd, sjd; | |
| int mdays[13]; | |
| mdays[1] = 0; | |
| mdays[2] = 31; | |
| mdays[3] = 59; | |
| mdays[4] = 90; | |
| mdays[5] = 120; | |
| mdays[6] = 151; | |
| mdays[7] = 181; | |
| mdays[8] = 212; | |
| mdays[9] = 243; | |
| mdays[10] = 273; | |
| mdays[11] = 304; | |
| mdays[12] = 334; | |
| fjd = first.year*365 + first.year/4 - first.year/100; // BUG46: missing 400 | |
| fjd = fjd + mdays[first.month] + first.day; | |
| if ((leap(first.year) == 1) && (first.month < 3)) | |
| fjd--; | |
| sjd = second.year*365 + second.year/4 - second.year/100; // BUG46: missing 400 | |
| sjd = sjd + mdays[second.month] + second.day; | |
| if ((leap(second.year) == 1) && (second.month < 3)) | |
| sjd--; | |
| return (sjd - fjd); | |
| } | |
| int m47daysdiff(DATE first, DATE second) | |
| { | |
| int fjd, sjd; | |
| int mdays[13]; | |
| mdays[1] = 0; | |
| mdays[2] = 31; | |
| mdays[3] = 59; | |
| mdays[4] = 90; | |
| mdays[5] = 120; | |
| mdays[6] = 151; | |
| mdays[7] = 181; | |
| mdays[8] = 212; | |
| mdays[9] = 243; | |
| mdays[10] = 273; | |
| mdays[11] = 304; | |
| mdays[12] = 334; | |
| fjd = first.year*365 + first.year/4; // BUG47: missing 100, 400 | |
| fjd = fjd + mdays[first.month] + first.day; | |
| if ((leap(first.year) == 1) && (first.month < 3)) | |
| fjd--; | |
| sjd = second.year*365 + second.year/4; // BUG47: missing 100, 400 | |
| sjd = sjd + mdays[second.month] + second.day; | |
| if ((leap(second.year) == 1) && (second.month < 3)) | |
| sjd--; | |
| return (sjd - fjd); | |
| } | |
| int m48daysdiff(DATE first, DATE second) | |
| { | |
| int fjd, sjd; | |
| int mdays[13]; | |
| mdays[1] = 0; | |
| mdays[2] = 31; | |
| mdays[3] = 59; | |
| mdays[4] = 90; | |
| mdays[5] = 120; | |
| mdays[6] = 151; | |
| mdays[7] = 181; | |
| mdays[8] = 212; | |
| mdays[9] = 243; | |
| mdays[10] = 273; | |
| mdays[11] = 304; | |
| mdays[12] = 334; | |
| fjd = first.year*365; // BUG48: missing 4, 100, 400 | |
| fjd = fjd + mdays[first.month] + first.day; | |
| if ((leap(first.year) == 1) && (first.month < 3)) | |
| fjd--; | |
| sjd = second.year*365; // BUG48: missing 4, 100, 400 | |
| sjd = sjd + mdays[second.month] + second.day; | |
| if ((leap(second.year) == 1) && (second.month < 3)) | |
| sjd--; | |
| return (sjd - fjd); | |
| } | |
| int m49daysdiff(DATE first, DATE second) | |
| { | |
| int fjd, sjd; | |
| int mdays[13]; | |
| mdays[1] = 0; | |
| mdays[2] = 31; | |
| mdays[3] = 59; | |
| mdays[4] = 90; | |
| mdays[5] = 120; | |
| mdays[6] = 151; | |
| mdays[7] = 181; | |
| mdays[8] = 212; | |
| mdays[9] = 243; | |
| mdays[10] = 273; | |
| mdays[11] = 304; | |
| mdays[12] = 334; | |
| fjd = first.year*365 + first.year/4 - first.year/100 + first.year/400; | |
| fjd = fjd + mdays[first.month] + first.day; | |
| if ((m43leap(first.year) == 1) && (first.month < 3)) // BUG49: m43leap | |
| fjd--; | |
| sjd = second.year*365 + second.year/4 - second.year/100 + second.year/400; | |
| sjd = sjd + mdays[second.month] + second.day; | |
| if ((m43leap(second.year) == 1) && (second.month < 3)) // BUG49: m43leap | |
| sjd--; | |
| return (sjd - fjd); | |
| } | |
| int m50daysdiff(DATE first, DATE second) | |
| { | |
| int fjd, sjd; | |
| int mdays[13]; | |
| mdays[1] = 0; | |
| mdays[2] = 31; | |
| mdays[3] = 59; | |
| mdays[4] = 90; | |
| mdays[5] = 120; | |
| mdays[6] = 151; | |
| mdays[7] = 181; | |
| mdays[8] = 212; | |
| mdays[9] = 243; | |
| mdays[10] = 273; | |
| mdays[11] = 304; | |
| mdays[12] = 334; | |
| fjd = first.year*365 + first.year/4 - first.year/100 + first.year/400; | |
| fjd = fjd + mdays[first.month] + first.day; | |
| if ((m44leap(first.year) == 1) && (first.month < 3)) // BUG50: m44leap | |
| fjd--; | |
| sjd = second.year*365 + second.year/4 - second.year/100 + second.year/400; | |
| sjd = sjd + mdays[second.month] + second.day; | |
| if ((m44leap(second.year) == 1) && (second.month < 3)) // BUG50: m44leap | |
| sjd--; | |
| return (sjd - fjd); | |
| } | |
| int m51daysdiff(DATE first, DATE second) | |
| { | |
| int fjd, sjd; | |
| int mdays[13]; | |
| mdays[1] = 0; | |
| mdays[2] = 31; | |
| mdays[3] = 59; | |
| mdays[4] = 90; | |
| mdays[5] = 120; | |
| mdays[6] = 151; | |
| mdays[7] = 181; | |
| mdays[8] = 212; | |
| mdays[9] = 243; | |
| mdays[10] = 273; | |
| mdays[11] = 304; | |
| mdays[12] = 334; | |
| fjd = first.year*365 + first.year/4 - first.year/100 + first.year/400; | |
| fjd = fjd + mdays[first.month] + first.day; | |
| if ((leap(first.year) == 1) && (first.month < 2)) // BUG51: < 2 | |
| fjd--; | |
| sjd = second.year*365 + second.year/4 - second.year/100 + second.year/400; | |
| sjd = sjd + mdays[second.month] + second.day; | |
| if ((leap(second.year) == 1) && (second.month < 2)) // BUG51: < 2 | |
| sjd--; | |
| return (sjd - fjd); | |
| } | |
| int m52daysdiff(DATE first, DATE second) | |
| { | |
| int fjd, sjd; | |
| int mdays[13]; | |
| mdays[1] = 0; | |
| mdays[2] = 31; | |
| mdays[3] = 59; | |
| mdays[4] = 90; | |
| mdays[5] = 120; | |
| mdays[6] = 151; | |
| mdays[7] = 181; | |
| mdays[8] = 212; | |
| mdays[9] = 243; | |
| mdays[10] = 273; | |
| mdays[11] = 304; | |
| mdays[12] = 334; | |
| fjd = first.year*365 + first.year/4 - first.year/100 + first.year/400; | |
| fjd = fjd + mdays[first.month] + first.day; | |
| if ((leap(first.year) == 1) && (first.month < 4)) // BUG52: < 4 | |
| fjd--; | |
| sjd = second.year*365 + second.year/4 - second.year/100 + second.year/400; | |
| sjd = sjd + mdays[second.month] + second.day; | |
| if ((leap(second.year) == 1) && (second.month < 4)) // BUG52: < 4 | |
| sjd--; | |
| return (sjd - fjd); | |
| } | |
| int m53daysdiff(DATE first, DATE second) | |
| { | |
| int fjd, sjd; | |
| int mdays[13]; | |
| mdays[1] = 0; | |
| mdays[2] = 31; | |
| mdays[3] = 59; | |
| mdays[4] = 90; | |
| mdays[5] = 120; | |
| mdays[6] = 151; | |
| mdays[7] = 181; | |
| mdays[8] = 212; | |
| mdays[9] = 243; | |
| mdays[10] = 273; | |
| mdays[11] = 304; | |
| mdays[12] = 334; | |
| fjd = first.year*365 + first.year/4 - first.year/100 + first.year/400; | |
| fjd = fjd + mdays[first.month] + first.day; // BUG53: no leap check | |
| // if ((leap(first.year) == 1) && (first.month < 3)) | |
| // fjd--; | |
| sjd = second.year*365 + second.year/4 - second.year/100 + second.year/400; | |
| sjd = sjd + mdays[second.month] + second.day; // BUG53: no leap check | |
| // if ((leap(second.year) == 1) && (second.month < 3)) | |
| // sjd--; | |
| return (sjd - fjd); | |
| } | |
| int m54daysdiff(DATE first, DATE second) | |
| { | |
| int fjd, sjd; | |
| int mdays[13]; | |
| mdays[1] = 31; // BUG54: all table entries shifted | |
| mdays[2] = 59; | |
| mdays[3] = 90; | |
| mdays[4] = 120; | |
| mdays[5] = 151; | |
| mdays[6] = 181; | |
| mdays[7] = 212; | |
| mdays[8] = 243; | |
| mdays[9] = 273; | |
| mdays[10] = 304; | |
| mdays[11] = 334; | |
| mdays[12] = 365; | |
| fjd = first.year*365 + first.year/4 - first.year/100 + first.year/400; | |
| fjd = fjd + mdays[first.month] + first.day; | |
| if ((leap(first.year) == 1) && (first.month < 3)) | |
| fjd--; | |
| sjd = second.year*365 + second.year/4 - second.year/100 + second.year/400; | |
| sjd = sjd + mdays[second.month] + second.day; | |
| if ((leap(second.year) == 1) && (second.month < 3)) | |
| sjd--; | |
| return (sjd - fjd); | |
| } | |
| int m55daysdiff(DATE first, DATE second) | |
| { | |
| int fjd, sjd; | |
| int mdays[13]; | |
| mdays[1] = 0; | |
| mdays[2] = 30; // BUG55: 30 | |
| mdays[3] = 59; | |
| mdays[4] = 90; | |
| mdays[5] = 120; | |
| mdays[6] = 151; | |
| mdays[7] = 181; | |
| mdays[8] = 212; | |
| mdays[9] = 243; | |
| mdays[10] = 273; | |
| mdays[11] = 304; | |
| mdays[12] = 334; | |
| fjd = first.year*365 + first.year/4 - first.year/100 + first.year/400; | |
| fjd = fjd + mdays[first.month] + first.day; | |
| if ((leap(first.year) == 1) && (first.month < 3)) | |
| fjd--; | |
| sjd = second.year*365 + second.year/4 - second.year/100 + second.year/400; | |
| sjd = sjd + mdays[second.month] + second.day; | |
| if ((leap(second.year) == 1) && (second.month < 3)) | |
| sjd--; | |
| return (sjd - fjd); | |
| } | |
| int m56daysdiff(DATE first, DATE second) | |
| { | |
| int fjd, sjd; | |
| int mdays[13]; | |
| mdays[1] = 0; | |
| mdays[2] = 31; | |
| mdays[3] = 58; // BUG56: 58 | |
| mdays[4] = 90; | |
| mdays[5] = 120; | |
| mdays[6] = 151; | |
| mdays[7] = 181; | |
| mdays[8] = 212; | |
| mdays[9] = 243; | |
| mdays[10] = 273; | |
| mdays[11] = 304; | |
| mdays[12] = 334; | |
| fjd = first.year*365 + first.year/4 - first.year/100 + first.year/400; | |
| fjd = fjd + mdays[first.month] + first.day; | |
| if ((leap(first.year) == 1) && (first.month < 3)) | |
| fjd--; | |
| sjd = second.year*365 + second.year/4 - second.year/100 + second.year/400; | |
| sjd = sjd + mdays[second.month] + second.day; | |
| if ((leap(second.year) == 1) && (second.month < 3)) | |
| sjd--; | |
| return (sjd - fjd); | |
| } | |
| int m57daysdiff(DATE first, DATE second) | |
| { | |
| int fjd, sjd; | |
| int mdays[13]; | |
| mdays[1] = 0; | |
| mdays[2] = 31; | |
| mdays[3] = 59; | |
| mdays[4] = 89; // BUG57: 89 | |
| mdays[5] = 120; | |
| mdays[6] = 151; | |
| mdays[7] = 181; | |
| mdays[8] = 212; | |
| mdays[9] = 243; | |
| mdays[10] = 273; | |
| mdays[11] = 304; | |
| mdays[12] = 334; | |
| fjd = first.year*365 + first.year/4 - first.year/100 + first.year/400; | |
| fjd = fjd + mdays[first.month] + first.day; | |
| if ((leap(first.year) == 1) && (first.month < 3)) | |
| fjd--; | |
| sjd = second.year*365 + second.year/4 - second.year/100 + second.year/400; | |
| sjd = sjd + mdays[second.month] + second.day; | |
| if ((leap(second.year) == 1) && (second.month < 3)) | |
| sjd--; | |
| return (sjd - fjd); | |
| } | |
| int m58daysdiff(DATE first, DATE second) | |
| { | |
| int fjd, sjd; | |
| int mdays[13]; | |
| mdays[1] = 0; | |
| mdays[2] = 31; | |
| mdays[3] = 59; | |
| mdays[4] = 90; | |
| mdays[5] = 119; // BUG58: 119 | |
| mdays[6] = 151; | |
| mdays[7] = 181; | |
| mdays[8] = 212; | |
| mdays[9] = 243; | |
| mdays[10] = 273; | |
| mdays[11] = 304; | |
| mdays[12] = 334; | |
| fjd = first.year*365 + first.year/4 - first.year/100 + first.year/400; | |
| fjd = fjd + mdays[first.month] + first.day; | |
| if ((leap(first.year) == 1) && (first.month < 3)) | |
| fjd--; | |
| sjd = second.year*365 + second.year/4 - second.year/100 + second.year/400; | |
| sjd = sjd + mdays[second.month] + second.day; | |
| if ((leap(second.year) == 1) && (second.month < 3)) | |
| sjd--; | |
| return (sjd - fjd); | |
| } | |
| int m59daysdiff(DATE first, DATE second) | |
| { | |
| int fjd, sjd; | |
| int mdays[13]; | |
| mdays[1] = 0; | |
| mdays[2] = 31; | |
| mdays[3] = 59; | |
| mdays[4] = 90; | |
| mdays[5] = 120; | |
| mdays[6] = 150; // BUG59: 150 | |
| mdays[7] = 181; | |
| mdays[8] = 212; | |
| mdays[9] = 243; | |
| mdays[10] = 273; | |
| mdays[11] = 304; | |
| mdays[12] = 334; | |
| fjd = first.year*365 + first.year/4 - first.year/100 + first.year/400; | |
| fjd = fjd + mdays[first.month] + first.day; | |
| if ((leap(first.year) == 1) && (first.month < 3)) | |
| fjd--; | |
| sjd = second.year*365 + second.year/4 - second.year/100 + second.year/400; | |
| sjd = sjd + mdays[second.month] + second.day; | |
| if ((leap(second.year) == 1) && (second.month < 3)) | |
| sjd--; | |
| return (sjd - fjd); | |
| } | |
| int m60daysdiff(DATE first, DATE second) | |
| { | |
| int fjd, sjd; | |
| int mdays[13]; | |
| mdays[1] = 0; | |
| mdays[2] = 31; | |
| mdays[3] = 59; | |
| mdays[4] = 90; | |
| mdays[5] = 120; | |
| mdays[6] = 151; | |
| mdays[7] = 180; // BUG60: 180 | |
| mdays[8] = 212; | |
| mdays[9] = 243; | |
| mdays[10] = 273; | |
| mdays[11] = 304; | |
| mdays[12] = 334; | |
| fjd = first.year*365 + first.year/4 - first.year/100 + first.year/400; | |
| fjd = fjd + mdays[first.month] + first.day; | |
| if ((leap(first.year) == 1) && (first.month < 3)) | |
| fjd--; | |
| sjd = second.year*365 + second.year/4 - second.year/100 + second.year/400; | |
| sjd = sjd + mdays[second.month] + second.day; | |
| if ((leap(second.year) == 1) && (second.month < 3)) | |
| sjd--; | |
| return (sjd - fjd); | |
| } | |
| int m61daysdiff(DATE first, DATE second) | |
| { | |
| int fjd, sjd; | |
| int mdays[13]; | |
| mdays[1] = 0; | |
| mdays[2] = 31; | |
| mdays[3] = 59; | |
| mdays[4] = 90; | |
| mdays[5] = 120; | |
| mdays[6] = 151; | |
| mdays[7] = 181; | |
| mdays[8] = 211; // BUG61: 211 | |
| mdays[9] = 243; | |
| mdays[10] = 273; | |
| mdays[11] = 304; | |
| mdays[12] = 334; | |
| fjd = first.year*365 + first.year/4 - first.year/100 + first.year/400; | |
| fjd = fjd + mdays[first.month] + first.day; | |
| if ((leap(first.year) == 1) && (first.month < 3)) | |
| fjd--; | |
| sjd = second.year*365 + second.year/4 - second.year/100 + second.year/400; | |
| sjd = sjd + mdays[second.month] + second.day; | |
| if ((leap(second.year) == 1) && (second.month < 3)) | |
| sjd--; | |
| return (sjd - fjd); | |
| } | |
| int m62daysdiff(DATE first, DATE second) | |
| { | |
| int fjd, sjd; | |
| int mdays[13]; | |
| mdays[1] = 0; | |
| mdays[2] = 31; | |
| mdays[3] = 59; | |
| mdays[4] = 90; | |
| mdays[5] = 120; | |
| mdays[6] = 151; | |
| mdays[7] = 181; | |
| mdays[8] = 212; | |
| mdays[9] = 242; // BUG62: 242 | |
| mdays[10] = 273; | |
| mdays[11] = 304; | |
| mdays[12] = 334; | |
| fjd = first.year*365 + first.year/4 - first.year/100 + first.year/400; | |
| fjd = fjd + mdays[first.month] + first.day; | |
| if ((leap(first.year) == 1) && (first.month < 3)) | |
| fjd--; | |
| sjd = second.year*365 + second.year/4 - second.year/100 + second.year/400; | |
| sjd = sjd + mdays[second.month] + second.day; | |
| if ((leap(second.year) == 1) && (second.month < 3)) | |
| sjd--; | |
| return (sjd - fjd); | |
| } | |
| int m63daysdiff(DATE first, DATE second) | |
| { | |
| int fjd, sjd; | |
| int mdays[13]; | |
| mdays[1] = 0; | |
| mdays[2] = 31; | |
| mdays[3] = 59; | |
| mdays[4] = 90; | |
| mdays[5] = 120; | |
| mdays[6] = 151; | |
| mdays[7] = 181; | |
| mdays[8] = 212; | |
| mdays[9] = 243; | |
| mdays[10] = 272; // BUG63: 272 | |
| mdays[11] = 304; | |
| mdays[12] = 334; | |
| fjd = first.year*365 + first.year/4 - first.year/100 + first.year/400; | |
| fjd = fjd + mdays[first.month] + first.day; | |
| if ((leap(first.year) == 1) && (first.month < 3)) | |
| fjd--; | |
| sjd = second.year*365 + second.year/4 - second.year/100 + second.year/400; | |
| sjd = sjd + mdays[second.month] + second.day; | |
| if ((leap(second.year) == 1) && (second.month < 3)) | |
| sjd--; | |
| return (sjd - fjd); | |
| } | |
| int m64daysdiff(DATE first, DATE second) | |
| { | |
| int fjd, sjd; | |
| int mdays[13]; | |
| mdays[1] = 0; | |
| mdays[2] = 31; | |
| mdays[3] = 59; | |
| mdays[4] = 90; | |
| mdays[5] = 120; | |
| mdays[6] = 151; | |
| mdays[7] = 181; | |
| mdays[8] = 212; | |
| mdays[9] = 243; | |
| mdays[10] = 273; | |
| mdays[11] = 303; // BUG64: 303 | |
| mdays[12] = 334; | |
| fjd = first.year*365 + first.year/4 - first.year/100 + first.year/400; | |
| fjd = fjd + mdays[first.month] + first.day; | |
| if ((leap(first.year) == 1) && (first.month < 3)) | |
| fjd--; | |
| sjd = second.year*365 + second.year/4 - second.year/100 + second.year/400; | |
| sjd = sjd + mdays[second.month] + second.day; | |
| if ((leap(second.year) == 1) && (second.month < 3)) | |
| sjd--; | |
| return (sjd - fjd); | |
| } | |
| int m65daysdiff(DATE first, DATE second) | |
| { | |
| int fjd, sjd; | |
| int mdays[13]; | |
| mdays[1] = 0; | |
| mdays[2] = 31; | |
| mdays[3] = 59; | |
| mdays[4] = 90; | |
| mdays[5] = 120; | |
| mdays[6] = 151; | |
| mdays[7] = 181; | |
| mdays[8] = 212; | |
| mdays[9] = 243; | |
| mdays[10] = 273; | |
| mdays[11] = 304; | |
| mdays[12] = 333; // BUG65: 333 | |
| fjd = first.year*365 + first.year/4 - first.year/100 + first.year/400; | |
| fjd = fjd + mdays[first.month] + first.day; | |
| if ((leap(first.year) == 1) && (first.month < 3)) | |
| fjd--; | |
| sjd = second.year*365 + second.year/4 - second.year/100 + second.year/400; | |
| sjd = sjd + mdays[second.month] + second.day; | |
| if ((leap(second.year) == 1) && (second.month < 3)) | |
| sjd--; | |
| return (sjd - fjd); | |
| } | |
| /************************************************************************* | |
| testline - return num days difference or negative error code | |
| ************************************************************************/ | |
| int testline(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m1(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (m1chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m2(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (m2chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m3(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (m3chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m4(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (m4chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m5(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (m5chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m6(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (m6chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m7(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (m7chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m8(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (m8chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m9(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (m9chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m10(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (m10chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m11(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (m11chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m12(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (m12chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m13(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (m13chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m14(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (m14chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m15(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (m15chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m16(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (m16chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m17(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = m17convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m18(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = m18convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m19(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = m19convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m20(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = m20convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m21(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = m21convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m22(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = m22convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m23(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = m23convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m24(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = m24convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m25(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = m25convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m26(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = m26convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m27(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = m27convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m28(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = m28convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m29(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = m29convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m30(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = m30convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m31(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = m31convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m32(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = m32convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m33(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = m33convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m34(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = m34convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m35(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = m35convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m36(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = m36convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m37(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = m37convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m38(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = m38convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m39(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = m39convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m40(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = m40convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m41(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = m41convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m42(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = m42convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m43(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = m43convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m44(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = m44convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m45(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = m45convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m46(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = m46daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m47(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = m47daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m48(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = m48daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m49(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = m49daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m50(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = m50daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m51(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = m51daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m52(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = m52daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m53(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = m53daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m54(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = m54daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m55(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = m55daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m56(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = m56daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m57(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = m57daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m58(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = m58daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m59(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = m59daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m60(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = m60daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m61(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = m61daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m62(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = m62daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m63(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = m63daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m64(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = m64daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| int m65(int len) | |
| { | |
| int dd; // number of days difference between dates | |
| int cnvrtcode; // result of converting input to dates | |
| if (len < 22) | |
| return -4; | |
| if (chkinputsyntax() != 0) | |
| return -4; | |
| if ((cnvrtcode = convertline()) != 0) | |
| return -cnvrtcode; | |
| dd = m65daysdiff(firstdate, seconddate); | |
| if (dd < 0) | |
| return -3; | |
| return dd; | |
| } | |
| /************************************************************************* | |
| test the perfect program and mutant -- return 0 if equal, 1 otherwise | |
| ************************************************************************/ | |
| int testrun(int (*mtest)(int), int mutant) | |
| { | |
| int perfect; // return from perfect version of testline | |
| int mreturn; // return from mutated version of testline | |
| int i; // index to output line | |
| if ((fid=fopen(testfile, "r")) == NULL) | |
| { | |
| printf("error opening file\n"); | |
| exit(1); | |
| } | |
| while ((len = getline(line, MAXLINE)) > 0) | |
| { | |
| perfect = testline(len); | |
| mreturn = (*mtest)(len); | |
| if (perfect != mreturn) | |
| { | |
| if (optVerbose > 0) | |
| { | |
| printf("Input: "); | |
| for (i=0;i<len;i++) | |
| putchar(line[i]); | |
| printf("%d =?= %d\n", perfect, mreturn); | |
| printf("Killed mutant %d.\n", mutant); | |
| } | |
| fclose(fid); | |
| return 1; | |
| } | |
| } | |
| fclose(fid); | |
| return 0; | |
| } | |
| /************************************************************************* | |
| Print command arguments | |
| ************************************************************************/ | |
| void usage() | |
| { | |
| fprintf(stderr, "Usage: mdates [-uv] -i <test file>\n"); | |
| exit(1); | |
| } | |
| /************************************************************************* | |
| Main program | |
| ************************************************************************/ | |
| int main(int argc, char *argv[]) | |
| { | |
| char ch; // option character | |
| extern char *optarg; // value of option argument | |
| int mcnt; // number of mutants killed | |
| optVerbose = 0; | |
| mcnt = 0; | |
| strcpy(testfile, ""); | |
| while ((ch = getopt(argc, argv, "i:uv")) != -1) | |
| { | |
| switch (ch) { | |
| case 'i': | |
| strcpy(testfile, optarg); | |
| break; | |
| case 'v': | |
| optVerbose = 1; | |
| break; | |
| case 'u': | |
| usage(); | |
| break; | |
| default: | |
| usage(); | |
| break; | |
| } | |
| } | |
| if (strcmp(testfile, "") == 0) | |
| usage(); | |
| mcnt = mcnt + testrun(m1, 1); | |
| mcnt = mcnt + testrun(m2, 2); | |
| mcnt = mcnt + testrun(m3, 3); | |
| mcnt = mcnt + testrun(m4, 4); | |
| mcnt = mcnt + testrun(m5, 5); | |
| mcnt = mcnt + testrun(m6, 6); | |
| mcnt = mcnt + testrun(m7, 7); | |
| mcnt = mcnt + testrun(m8, 8); | |
| mcnt = mcnt + testrun(m9, 9); | |
| mcnt = mcnt + testrun(m10, 10); | |
| mcnt = mcnt + testrun(m11, 11); | |
| mcnt = mcnt + testrun(m12, 12); | |
| mcnt = mcnt + testrun(m13, 13); | |
| mcnt = mcnt + testrun(m14, 14); | |
| mcnt = mcnt + testrun(m15, 15); | |
| mcnt = mcnt + testrun(m16, 16); | |
| mcnt = mcnt + testrun(m17, 17); | |
| mcnt = mcnt + testrun(m18, 18); | |
| mcnt = mcnt + testrun(m19, 19); | |
| mcnt = mcnt + testrun(m20, 20); | |
| mcnt = mcnt + testrun(m21, 21); | |
| mcnt = mcnt + testrun(m22, 22); | |
| mcnt = mcnt + testrun(m23, 23); | |
| mcnt = mcnt + testrun(m24, 24); | |
| mcnt = mcnt + testrun(m25, 25); | |
| mcnt = mcnt + testrun(m26, 26); | |
| mcnt = mcnt + testrun(m27, 27); | |
| mcnt = mcnt + testrun(m28, 28); | |
| mcnt = mcnt + testrun(m29, 29); | |
| mcnt = mcnt + testrun(m30, 30); | |
| mcnt = mcnt + testrun(m31, 31); | |
| mcnt = mcnt + testrun(m32, 32); | |
| mcnt = mcnt + testrun(m33, 33); | |
| mcnt = mcnt + testrun(m34, 34); | |
| mcnt = mcnt + testrun(m35, 35); | |
| mcnt = mcnt + testrun(m36, 36); | |
| mcnt = mcnt + testrun(m37, 37); | |
| mcnt = mcnt + testrun(m38, 38); | |
| mcnt = mcnt + testrun(m39, 39); | |
| mcnt = mcnt + testrun(m40, 40); | |
| mcnt = mcnt + testrun(m41, 41); | |
| mcnt = mcnt + testrun(m42, 42); | |
| mcnt = mcnt + testrun(m43, 43); | |
| mcnt = mcnt + testrun(m44, 44); | |
| mcnt = mcnt + testrun(m45, 45); | |
| mcnt = mcnt + testrun(m46, 46); | |
| mcnt = mcnt + testrun(m47, 47); | |
| mcnt = mcnt + testrun(m48, 48); | |
| mcnt = mcnt + testrun(m49, 49); | |
| mcnt = mcnt + testrun(m50, 50); | |
| mcnt = mcnt + testrun(m51, 51); | |
| mcnt = mcnt + testrun(m52, 52); | |
| mcnt = mcnt + testrun(m53, 53); | |
| mcnt = mcnt + testrun(m54, 54); | |
| mcnt = mcnt + testrun(m55, 55); | |
| mcnt = mcnt + testrun(m56, 56); | |
| mcnt = mcnt + testrun(m57, 57); | |
| mcnt = mcnt + testrun(m58, 58); | |
| mcnt = mcnt + testrun(m59, 59); | |
| mcnt = mcnt + testrun(m60, 60); | |
| mcnt = mcnt + testrun(m61, 61); | |
| mcnt = mcnt + testrun(m62, 62); | |
| mcnt = mcnt + testrun(m63, 63); | |
| mcnt = mcnt + testrun(m64, 64); | |
| mcnt = mcnt + testrun(m65, 65); | |
| printf("%d/65 mutants killed. (%.0f", mcnt, 100*mcnt/65.0); | |
| putchar('%'); | |
| printf(")\n"); | |
| exit(0); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment