com php-src: first shot for ext/calendar: ext/calendar/cal_un ix.c ext/calendar/calendar.c ext/calendar/dow.c ext /calendar/easter.c
ext/calendar/french.c ext/calendar/g regor.c ext/calendar/jewish.c ext/calendar/julian.c ext/calendar/sdncal.h
| From: | Anatol Belski | Date: | Wed, 27 Nov 2013 12:35:26 +0000 |
| Subject: | com php-src: first shot for ext/calendar: ext/calendar/cal_un ix.c ext/calendar/calendar.c ext/calendar/dow.c ext /calendar/easter.c ext/calendar/french.c ext/calendar/g regor.c ext/calendar/jewish.c ext/calendar/julian.c ext/calendar/sdncal.h |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-74092@lists.php.net to get a copy of this message | ||
Commit: b9c19f5d74acefe1697816c8babef420499f0a14
Author: Anatol Belski <ab@php.net> Wed, 27 Nov 2013 13:35:26 +0100
Parents: 81158446748d3153c5defe479b3083601d366d03
Branches: str_size_and_int64
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b9c19f5d74acefe1697816c8babef420499f0a14
Log:
first shot for ext/calendar
At the first glance the extension could be fixed for bigger timestamps,
but that's not the goal right now. One test fail yet on win 64
Changed paths:
M ext/calendar/cal_unix.c
M ext/calendar/calendar.c
M ext/calendar/dow.c
M ext/calendar/easter.c
M ext/calendar/french.c
M ext/calendar/gregor.c
M ext/calendar/jewish.c
M ext/calendar/julian.c
M ext/calendar/sdncal.h
diff --git a/ext/calendar/cal_unix.c b/ext/calendar/cal_unix.c index c65b046..c02fe03 100644 --- a/ext/calendar/cal_unix.c +++ b/ext/calendar/cal_unix.c @@ -31,7 +31,7 @@ PHP_FUNCTION(unixtojd) time_t ts = 0; struct tm *ta, tmbuf; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &ts) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|i", &ts) == FAILURE) { return; } @@ -53,9 +53,9 @@ PHP_FUNCTION(unixtojd) Convert Julian Day to UNIX timestamp */ PHP_FUNCTION(jdtounix) { - long uday; + php_int_t uday; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &uday) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &uday) == FAILURE) { return; } uday -= 2440588 /* J.D. of 1.1.1970 */; diff --git a/ext/calendar/calendar.c b/ext/calendar/calendar.c index d881494..efdc58e 100644 --- a/ext/calendar/calendar.c +++ b/ext/calendar/calendar.c @@ -178,8 +178,8 @@ enum cal_name_type_t { CAL_NUM_CALS }; -typedef long int (*cal_to_jd_func_t) (int month, int day, int year); -typedef void (*cal_from_jd_func_t) (long int jd, int *year, int *month, int *day); +typedef php_int_t (*cal_to_jd_func_t) (int month, int day, int year); +typedef void (*cal_from_jd_func_t) (php_int_t jd, int *year, int *month, int *day); typedef char *(*cal_as_string_func_t) (int year, int month, int day); struct cal_entry_t { @@ -290,10 +290,10 @@ static void _php_cal_info(int cal, zval **ret) Returns information about a particular calendar */ PHP_FUNCTION(cal_info) { - long cal = -1; + php_int_t cal = -1; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &cal) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|i", &cal) == FAILURE) { RETURN_FALSE; } @@ -326,11 +326,11 @@ PHP_FUNCTION(cal_info) Returns the number of days in a month for a given year and calendar */ PHP_FUNCTION(cal_days_in_month) { - long cal, month, year; + php_int_t cal, month, year; struct cal_entry_t *calendar; - long sdn_start, sdn_next; + php_int_t sdn_start, sdn_next; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &cal, &month, &year) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "iii", &cal, &month, &year) == FAILURE) { RETURN_FALSE; } @@ -370,9 +370,9 @@ PHP_FUNCTION(cal_days_in_month) Converts from a supported calendar to Julian Day Count */ PHP_FUNCTION(cal_to_jd) { - long cal, month, day, year; + php_int_t cal, month, day, year; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll", &cal, &month, &day, &year) != SUCCESS) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "iiii", &cal, &month, &day, &year) != SUCCESS) { RETURN_FALSE; } @@ -389,12 +389,12 @@ PHP_FUNCTION(cal_to_jd) Converts from Julian Day Count to a supported calendar and return extended information */ PHP_FUNCTION(cal_from_jd) { - long jd, cal; + php_int_t jd, cal; int month, day, year, dow; char date[16]; struct cal_entry_t *calendar; - if (zend_parse_parameters(ZEND_NUM_ARGS()TSRMLS_CC, "ll", &jd, &cal) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS()TSRMLS_CC, "ii", &jd, &cal) == FAILURE) { RETURN_FALSE; } @@ -436,11 +436,11 @@ PHP_FUNCTION(cal_from_jd) Converts a julian day count to a gregorian calendar date */ PHP_FUNCTION(jdtogregorian) { - long julday; + php_int_t julday; int year, month, day; char date[16]; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &julday) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &julday) == FAILURE) { RETURN_FALSE; } @@ -455,9 +455,9 @@ PHP_FUNCTION(jdtogregorian) Converts a gregorian calendar date to julian day count */ PHP_FUNCTION(gregoriantojd) { - long year, month, day; + php_int_t year, month, day; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &month, &day, &year) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "iii", &month, &day, &year) == FAILURE) { RETURN_FALSE; } @@ -469,11 +469,11 @@ PHP_FUNCTION(gregoriantojd) Convert a julian day count to a julian calendar date */ PHP_FUNCTION(jdtojulian) { - long julday; + php_int_t julday; int year, month, day; char date[16]; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &julday) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &julday) == FAILURE) { RETURN_FALSE; } @@ -488,9 +488,9 @@ PHP_FUNCTION(jdtojulian) Converts a julian calendar date to julian day count */ PHP_FUNCTION(juliantojd) { - long year, month, day; + php_int_t year, month, day; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &month, &day, &year) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "iii", &month, &day, &year) == FAILURE) { RETURN_FALSE; } @@ -597,13 +597,13 @@ static char *heb_number_to_chars(int n, int fl, char **ret) Converts a julian day count to a jewish calendar date */ PHP_FUNCTION(jdtojewish) { - long julday, fl = 0; + php_int_t julday, fl = 0; zend_bool heb = 0; int year, month, day; char date[16], hebdate[32]; char *dayp, *yearp; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|bl", &julday, &heb, &fl) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i|bi", &julday, &heb, &fl) == FAILURE) { RETURN_FALSE; } @@ -636,9 +636,9 @@ PHP_FUNCTION(jdtojewish) Converts a jewish calendar date to a julian day count */ PHP_FUNCTION(jewishtojd) { - long year, month, day; + php_int_t year, month, day; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &month, &day, &year) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "iii", &month, &day, &year) == FAILURE) { RETURN_FALSE; } @@ -650,11 +650,11 @@ PHP_FUNCTION(jewishtojd) Converts a julian day count to a french republic calendar date */ PHP_FUNCTION(jdtofrench) { - long julday; + php_int_t julday; int year, month, day; char date[16]; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &julday) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &julday) == FAILURE) { RETURN_FALSE; } @@ -669,9 +669,9 @@ PHP_FUNCTION(jdtofrench) Converts a french republic calendar date to julian day count */ PHP_FUNCTION(frenchtojd) { - long year, month, day; + php_int_t year, month, day; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &month, &day, &year) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "iii", &month, &day, &year) == FAILURE) { RETURN_FALSE; } @@ -683,11 +683,11 @@ PHP_FUNCTION(frenchtojd) Returns name or number of day of week from julian day count */ PHP_FUNCTION(jddayofweek) { - long julday, mode = CAL_DOW_DAYNO; + php_int_t julday, mode = CAL_DOW_DAYNO; int day; char *daynamel, *daynames; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &julday, &mode) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i|i", &julday, &mode) == FAILURE) { RETURN_FALSE; } @@ -714,11 +714,11 @@ PHP_FUNCTION(jddayofweek) Returns name of month for julian day count */ PHP_FUNCTION(jdmonthname) { - long julday, mode; + php_int_t julday, mode; char *monthname = NULL; int month, day, year; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &julday, &mode) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ii", &julday, &mode) == FAILURE) { RETURN_FALSE; } diff --git a/ext/calendar/dow.c b/ext/calendar/dow.c index 64ae008..882b9b7 100644 --- a/ext/calendar/dow.c +++ b/ext/calendar/dow.c @@ -12,7 +12,7 @@ * * int * DayOfWeek( - * long int sdn); + * php_int_t sdn); * * Convert a SDN to a day-of-week number (0 to 6). Where 0 stands for * Sunday, 1 for Monday, etc. and 6 stands for Saturday. @@ -32,7 +32,7 @@ #include "sdncal.h" int DayOfWeek( - long int sdn) + php_int_t sdn) { int dow; diff --git a/ext/calendar/easter.c b/ext/calendar/easter.c index 1948ff9..9c1a444 100644 --- a/ext/calendar/easter.c +++ b/ext/calendar/easter.c @@ -24,14 +24,14 @@ #include "sdncal.h" #include <time.h> -static void _cal_easter(INTERNAL_FUNCTION_PARAMETERS, int gm) +static void _cal_easter(INTERNAL_FUNCTION_PARAMETERS, php_int_t gm) { /* based on code by Simon Kershaw, <webmaster@ely.anglican.org> */ struct tm te; - long year, golden, solar, lunar, pfm, dom, tmp, easter; - long method = CAL_EASTER_DEFAULT; + php_int_t year, golden, solar, lunar, pfm, dom, tmp, easter; + php_int_t method = CAL_EASTER_DEFAULT; /* Default to the current year if year parameter is not given */ { @@ -47,7 +47,7 @@ static void _cal_easter(INTERNAL_FUNCTION_PARAMETERS, int gm) } if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, - "|ll", &year, &method) == FAILURE) { + "|ii", &year, &method) == FAILURE) { return; } diff --git a/ext/calendar/french.c b/ext/calendar/french.c index 5b4dd53..11bb753 100644 --- a/ext/calendar/french.c +++ b/ext/calendar/french.c @@ -11,7 +11,7 @@ * * void * SdnToFrench( - * long int sdn, + * php_int_t sdn, * int *pYear, * int *pMonth, * int *pDay); @@ -24,7 +24,7 @@ * 13, the SDN represents one of the holidays at the end of the year and * *pDay will be in the range 1 to 6 inclusive. * - * long int + * php_int_t * FrenchToSdn( * int year, * int month, @@ -93,12 +93,12 @@ #define LAST_VALID 2380952 void SdnToFrench( - long int sdn, + php_int_t sdn, int *pYear, int *pMonth, int *pDay) { - long int temp; + php_int_t temp; int dayOfYear; if (sdn < FIRST_VALID || sdn > LAST_VALID) { @@ -114,7 +114,7 @@ void SdnToFrench( *pDay = dayOfYear % DAYS_PER_MONTH + 1; } -long int FrenchToSdn( +php_int_t FrenchToSdn( int year, int month, int day) diff --git a/ext/calendar/gregor.c b/ext/calendar/gregor.c index ebb743f..3867feb 100644 --- a/ext/calendar/gregor.c +++ b/ext/calendar/gregor.c @@ -11,7 +11,7 @@ * * void * SdnToGregorian( - * long int sdn, + * php_int_t sdn, * int *pYear, * int *pMonth, * int *pDay); @@ -21,7 +21,7 @@ * *pYear will be >= -4714 and != 0; *pMonth will be in the range 1 to 12 * inclusive; *pDay will be in the range 1 to 31 inclusive. * - * long int + * php_int_t * GregorianToSdn( * int inputYear, * int inputMonth, @@ -135,7 +135,7 @@ #define DAYS_PER_400_YEARS 146097 void SdnToGregorian( - long int sdn, + php_int_t sdn, int *pYear, int *pMonth, int *pDay) @@ -144,7 +144,7 @@ void SdnToGregorian( int year; int month; int day; - long int temp; + php_int_t temp; int dayOfYear; if (sdn <= 0 || @@ -190,7 +190,7 @@ fail: *pDay = 0; } -long int GregorianToSdn( +php_int_t GregorianToSdn( int inputYear, int inputMonth, int inputDay) diff --git a/ext/calendar/jewish.c b/ext/calendar/jewish.c index ddc8aaa..bdd827c 100644 --- a/ext/calendar/jewish.c +++ b/ext/calendar/jewish.c @@ -11,7 +11,7 @@ * * void * SdnToJewish( - * long int sdn, + * php_int_t sdn, * int *pYear, * int *pMonth, * int *pDay); @@ -22,7 +22,7 @@ * inclusive; *pDay will be in the range 1 to 30 inclusive. Note that Adar * II is assigned the month number 7 and Elul is always 13. * - * long int + * php_int_t * JewishToSdn( * int year, * int month, @@ -382,12 +382,12 @@ char *JewishMonthHebName[14] = * (called dehiyyot) delays it. These 4 rules can delay the start of the * year by as much as 2 days. */ -static long int Tishri1( +static php_int_t Tishri1( int metonicYear, - long int moladDay, - long int moladHalakim) + php_int_t moladDay, + php_int_t moladHalakim) { - long int tishri1; + php_int_t tishri1; int dow; int leapYear; int lastWasLeapYear; @@ -429,10 +429,10 @@ static long int Tishri1( */ static void MoladOfMetonicCycle( int metonicCycle, - long int *pMoladDay, - long int *pMoladHalakim) + php_int_t *pMoladDay, + php_int_t *pMoladHalakim) { - register unsigned long int r1, r2, d1, d2; + register php_uint_t r1, r2, d1, d2; /* Start with the time of the first molad after creation. */ r1 = NEW_MOON_OF_CREATION; @@ -468,14 +468,14 @@ static void MoladOfMetonicCycle( * us to avoid calculating the length of the year in most cases. */ static void FindTishriMolad( - long int inputDay, + php_int_t inputDay, int *pMetonicCycle, int *pMetonicYear, - long int *pMoladDay, - long int *pMoladHalakim) + php_int_t *pMoladDay, + php_int_t *pMoladHalakim) { - long int moladDay; - long int moladHalakim; + php_int_t moladDay; + php_int_t moladHalakim; int metonicCycle; int metonicYear; @@ -523,8 +523,8 @@ static void FindStartOfYear( int year, int *pMetonicCycle, int *pMetonicYear, - long int *pMoladDay, - long int *pMoladHalakim, + php_int_t *pMoladDay, + php_int_t *pMoladHalakim, int *pTishri1) { *pMetonicCycle = (year - 1) / 19; @@ -546,14 +546,14 @@ static void FindStartOfYear( * range 1 to 13 inclusive; *pDay will be in the range 1 to 30 inclusive. */ void SdnToJewish( - long int sdn, + php_int_t sdn, int *pYear, int *pMonth, int *pDay) { - long int inputDay; - long int day; - long int halakim; + php_int_t inputDay; + php_int_t day; + php_int_t halakim; int metonicCycle; int metonicYear; int tishri1; @@ -684,18 +684,18 @@ void SdnToJewish( * value. To verify that a date is valid, convert it to SDN and then back * and compare with the original. */ -long int JewishToSdn( +php_int_t JewishToSdn( int year, int month, int day) { - long int sdn; + php_int_t sdn; int metonicCycle; int metonicYear; int tishri1; int tishri1After; - long int moladDay; - long int moladHalakim; + php_int_t moladDay; + php_int_t moladHalakim; int yearLength; int lengthOfAdarIAndII; diff --git a/ext/calendar/julian.c b/ext/calendar/julian.c index 17e7bcb..3527627 100644 --- a/ext/calendar/julian.c +++ b/ext/calendar/julian.c @@ -11,7 +11,7 @@ * * void * SdnToJulian( - * long int sdn, + * php_int_t sdn, * int *pYear, * int *pMonth, * int *pDay); @@ -21,7 +21,7 @@ * will be >= -4713 and != 0; *pMonth will be in the range 1 to 12 * inclusive; *pDay will be in the range 1 to 31 inclusive. * - * long int + * php_int_t * JulianToSdn( * int inputYear, * int inputMonth, @@ -153,7 +153,7 @@ #define DAYS_PER_4_YEARS 1461 void SdnToJulian( - long int sdn, + php_int_t sdn, int *pYear, int *pMonth, int *pDay) @@ -161,7 +161,7 @@ void SdnToJulian( int year; int month; int day; - long int temp; + php_int_t temp; int dayOfYear; if (sdn <= 0) { @@ -212,7 +212,7 @@ fail: *pDay = 0; } -long int JulianToSdn( +php_int_t JulianToSdn( int inputYear, int inputMonth, int inputDay) diff --git a/ext/calendar/sdncal.h b/ext/calendar/sdncal.h index c0463c8..488f8c0 100644 --- a/ext/calendar/sdncal.h +++ b/ext/calendar/sdncal.h @@ -32,7 +32,7 @@ * calculating the number of days between two dates. * * When using this software on 16 bit systems, be careful to store SDNs in - * a long int, because it will not fit in the 16 bits that some systems + * a php_int_t, because it will not fit in the 16 bits that some systems * allocate to an int. * * For each calendar, there are two routines provided. One converts dates @@ -53,7 +53,7 @@ * * int y1, m1, d1; * int y2, m2, d2; - * long int sdn; + * php_int_t sdn; * ... * sdn = GregorianToSdn(y1, m1, d1); * if (sdn > 0) { @@ -65,19 +65,21 @@ * **************************************************************************/ +#include "php.h" + /* Gregorian calendar conversions. */ -void SdnToGregorian(long int sdn, int *pYear, int *pMonth, int *pDay); -long int GregorianToSdn(int year, int month, int day); +void SdnToGregorian(php_int_t sdn, int *pYear, int *pMonth, int *pDay); +php_int_t GregorianToSdn(int year, int month, int day); extern char *MonthNameShort[13]; extern char *MonthNameLong[13]; /* Julian calendar conversions. */ -void SdnToJulian(long int sdn, int *pYear, int *pMonth, int *pDay); -long int JulianToSdn(int year, int month, int day); +void SdnToJulian(php_int_t sdn, int *pYear, int *pMonth, int *pDay); +php_int_t JulianToSdn(int year, int month, int day); /* Jewish calendar conversions. */ -void SdnToJewish(long int sdn, int *pYear, int *pMonth, int *pDay); -long int JewishToSdn(int year, int month, int day); +void SdnToJewish(php_int_t sdn, int *pYear, int *pMonth, int *pDay); +php_int_t JewishToSdn(int year, int month, int day); extern char *JewishMonthName[14]; extern char *JewishMonthNameLeap[14]; extern char *JewishMonthHebName[14]; @@ -85,15 +87,15 @@ extern char *JewishMonthHebNameLeap[14]; extern int monthsPerYear[19]; /* French republic calendar conversions. */ -void SdnToFrench(long int sdn, int *pYear, int *pMonth, int *pDay); -long int FrenchToSdn(int inputYear, int inputMonth, int inputDay); +void SdnToFrench(php_int_t sdn, int *pYear, int *pMonth, int *pDay); +php_int_t FrenchToSdn(int inputYear, int inputMonth, int inputDay); extern char *FrenchMonthName[14]; /* Islamic calendar conversions. */ /* Not implemented yet. */ /* Day of week conversion. 0=Sunday, 6=Saturday */ -int DayOfWeek(long int sdn); +int DayOfWeek(php_int_t sdn); extern char *DayNameShort[7]; extern char *DayNameLong[7];
diff --git a/ext/calendar/cal_unix.c b/ext/calendar/cal_unix.c index c65b046..c02fe03 100644 --- a/ext/calendar/cal_unix.c +++ b/ext/calendar/cal_unix.c @@ -31,7 +31,7 @@ PHP_FUNCTION(unixtojd) time_t ts = 0; struct tm *ta, tmbuf; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &ts) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|i", &ts) == FAILURE) { return; } @@ -53,9 +53,9 @@ PHP_FUNCTION(unixtojd) Convert Julian Day to UNIX timestamp */ PHP_FUNCTION(jdtounix) { - long uday; + php_int_t uday; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &uday) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &uday) == FAILURE) { return; } uday -= 2440588 /* J.D. of 1.1.1970 */; diff --git a/ext/calendar/calendar.c b/ext/calendar/calendar.c index d881494..efdc58e 100644 --- a/ext/calendar/calendar.c +++ b/ext/calendar/calendar.c @@ -178,8 +178,8 @@ enum cal_name_type_t { CAL_NUM_CALS }; -typedef long int (*cal_to_jd_func_t) (int month, int day, int year); -typedef void (*cal_from_jd_func_t) (long int jd, int *year, int *month, int *day); +typedef php_int_t (*cal_to_jd_func_t) (int month, int day, int year); +typedef void (*cal_from_jd_func_t) (php_int_t jd, int *year, int *month, int *day); typedef char *(*cal_as_string_func_t) (int year, int month, int day); struct cal_entry_t { @@ -290,10 +290,10 @@ static void _php_cal_info(int cal, zval **ret) Returns information about a particular calendar */ PHP_FUNCTION(cal_info) { - long cal = -1; + php_int_t cal = -1; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &cal) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|i", &cal) == FAILURE) { RETURN_FALSE; } @@ -326,11 +326,11 @@ PHP_FUNCTION(cal_info) Returns the number of days in a month for a given year and calendar */ PHP_FUNCTION(cal_days_in_month) { - long cal, month, year; + php_int_t cal, month, year; struct cal_entry_t *calendar; - long sdn_start, sdn_next; + php_int_t sdn_start, sdn_next; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &cal, &month, &year) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "iii", &cal, &month, &year) == FAILURE) { RETURN_FALSE; } @@ -370,9 +370,9 @@ PHP_FUNCTION(cal_days_in_month) Converts from a supported calendar to Julian Day Count */ PHP_FUNCTION(cal_to_jd) { - long cal, month, day, year; + php_int_t cal, month, day, year; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll", &cal, &month, &day, &year) != SUCCESS) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "iiii", &cal, &month, &day, &year) != SUCCESS) { RETURN_FALSE; } @@ -389,12 +389,12 @@ PHP_FUNCTION(cal_to_jd) Converts from Julian Day Count to a supported calendar and return extended information */ PHP_FUNCTION(cal_from_jd) { - long jd, cal; + php_int_t jd, cal; int month, day, year, dow; char date[16]; struct cal_entry_t *calendar; - if (zend_parse_parameters(ZEND_NUM_ARGS()TSRMLS_CC, "ll", &jd, &cal) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS()TSRMLS_CC, "ii", &jd, &cal) == FAILURE) { RETURN_FALSE; } @@ -436,11 +436,11 @@ PHP_FUNCTION(cal_from_jd) Converts a julian day count to a gregorian calendar date */ PHP_FUNCTION(jdtogregorian) { - long julday; + php_int_t julday; int year, month, day; char date[16]; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &julday) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &julday) == FAILURE) { RETURN_FALSE; } @@ -455,9 +455,9 @@ PHP_FUNCTION(jdtogregorian) Converts a gregorian calendar date to julian day count */ PHP_FUNCTION(gregoriantojd) { - long year, month, day; + php_int_t year, month, day; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &month, &day, &year) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "iii", &month, &day, &year) == FAILURE) { RETURN_FALSE; } @@ -469,11 +469,11 @@ PHP_FUNCTION(gregoriantojd) Convert a julian day count to a julian calendar date */ PHP_FUNCTION(jdtojulian) { - long julday; + php_int_t julday; int year, month, day; char date[16]; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &julday) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &julday) == FAILURE) { RETURN_FALSE; } @@ -488,9 +488,9 @@ PHP_FUNCTION(jdtojulian) Converts a julian calendar date to julian day count */ PHP_FUNCTION(juliantojd) { - long year, month, day; + php_int_t year, month, day; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &month, &day, &year) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "iii", &month, &day, &year) == FAILURE) { RETURN_FALSE; } @@ -597,13 +597,13 @@ static char *heb_number_to_chars(int n, int fl, char **ret) Converts a julian day count to a jewish calendar date */ PHP_FUNCTION(jdtojewish) { - long julday, fl = 0; + php_int_t julday, fl = 0; zend_bool heb = 0; int year, month, day; char date[16], hebdate[32]; char *dayp, *yearp; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|bl", &julday, &heb, &fl) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i|bi", &julday, &heb, &fl) == FAILURE) { RETURN_FALSE; } @@ -636,9 +636,9 @@ PHP_FUNCTION(jdtojewish) Converts a jewish calendar date to a julian day count */ PHP_FUNCTION(jewishtojd) { - long year, month, day; + php_int_t year, month, day; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &month, &day, &year) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "iii", &month, &day, &year) == FAILURE) { RETURN_FALSE; } @@ -650,11 +650,11 @@ PHP_FUNCTION(jewishtojd) Converts a julian day count to a french republic calendar date */ PHP_FUNCTION(jdtofrench) { - long julday; + php_int_t julday; int year, month, day; char date[16]; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &julday) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &julday) == FAILURE) { RETURN_FALSE; } @@ -669,9 +669,9 @@ PHP_FUNCTION(jdtofrench) Converts a french republic calendar date to julian day count */ PHP_FUNCTION(frenchtojd) { - long year, month, day; + php_int_t year, month, day; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &month, &day, &year) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "iii", &month, &day, &year) == FAILURE) { RETURN_FALSE; } @@ -683,11 +683,11 @@ PHP_FUNCTION(frenchtojd) Returns name or number of day of week from julian day count */ PHP_FUNCTION(jddayofweek) { - long julday, mode = CAL_DOW_DAYNO; + php_int_t julday, mode = CAL_DOW_DAYNO; int day; char *daynamel, *daynames; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &julday, &mode) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i|i", &julday, &mode) == FAILURE) { RETURN_FALSE; } @@ -714,11 +714,11 @@ PHP_FUNCTION(jddayofweek) Returns name of month for julian day count */ PHP_FUNCTION(jdmonthname) { - long julday, mode; + php_int_t julday, mode; char *monthname = NULL; int month, day, year; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &julday, &mode) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ii", &julday, &mode) == FAILURE) { RETURN_FALSE; } diff --git a/ext/calendar/dow.c b/ext/calendar/dow.c index 64ae008..882b9b7 100644 --- a/ext/calendar/dow.c +++ b/ext/calendar/dow.c @@ -12,7 +12,7 @@ * * int * DayOfWeek( - * long int sdn); + * php_int_t sdn); * * Convert a SDN to a day-of-week number (0 to 6). Where 0 stands for * Sunday, 1 for Monday, etc. and 6 stands for Saturday. @@ -32,7 +32,7 @@ #include "sdncal.h" int DayOfWeek( - long int sdn) + php_int_t sdn) { int dow; diff --git a/ext/calendar/easter.c b/ext/calendar/easter.c index 1948ff9..9c1a444 100644 --- a/ext/calendar/easter.c +++ b/ext/calendar/easter.c @@ -24,14 +24,14 @@ #include "sdncal.h" #include <time.h> -static void _cal_easter(INTERNAL_FUNCTION_PARAMETERS, int gm) +static void _cal_easter(INTERNAL_FUNCTION_PARAMETERS, php_int_t gm) { /* based on code by Simon Kershaw, <webmaster@ely.anglican.org> */ struct tm te; - long year, golden, solar, lunar, pfm, dom, tmp, easter; - long method = CAL_EASTER_DEFAULT; + php_int_t year, golden, solar, lunar, pfm, dom, tmp, easter; + php_int_t method = CAL_EASTER_DEFAULT; /* Default to the current year if year parameter is not given */ { @@ -47,7 +47,7 @@ static void _cal_easter(INTERNAL_FUNCTION_PARAMETERS, int gm) } if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, - "|ll", &year, &method) == FAILURE) { + "|ii", &year, &method) == FAILURE) { return; } diff --git a/ext/calendar/french.c b/ext/calendar/french.c index 5b4dd53..11bb753 100644 --- a/ext/calendar/french.c +++ b/ext/calendar/french.c @@ -11,7 +11,7 @@ * * void * SdnToFrench( - * long int sdn, + * php_int_t sdn, * int *pYear, * int *pMonth, * int *pDay); @@ -24,7 +24,7 @@ * 13, the SDN represents one of the holidays at the end of the year and * *pDay will be in the range 1 to 6 inclusive. * - * long int + * php_int_t * FrenchToSdn( * int year, * int month, @@ -93,12 +93,12 @@ #define LAST_VALID 2380952 void SdnToFrench( - long int sdn, + php_int_t sdn, int *pYear, int *pMonth, int *pDay) { - long int temp; + php_int_t temp; int dayOfYear; if (sdn < FIRST_VALID || sdn > LAST_VALID) { @@ -114,7 +114,7 @@ void SdnToFrench( *pDay = dayOfYear % DAYS_PER_MONTH + 1; } -long int FrenchToSdn( +php_int_t FrenchToSdn( int year, int month, int day) diff --git a/ext/calendar/gregor.c b/ext/calendar/gregor.c index ebb743f..3867feb 100644 --- a/ext/calendar/gregor.c +++ b/ext/calendar/gregor.c @@ -11,7 +11,7 @@ * * void * SdnToGregorian( - * long int sdn, + * php_int_t sdn, * int *pYear, * int *pMonth, * int *pDay); @@ -21,7 +21,7 @@ * *pYear will be >= -4714 and != 0; *pMonth will be in the range 1 to 12 * inclusive; *pDay will be in the range 1 to 31 inclusive. * - * long int + * php_int_t * GregorianToSdn( * int inputYear, * int inputMonth, @@ -135,7 +135,7 @@ #define DAYS_PER_400_YEARS 146097 void SdnToGregorian( - long int sdn, + php_int_t sdn, int *pYear, int *pMonth, int *pDay) @@ -144,7 +144,7 @@ void SdnToGregorian( int year; int month; int day; - long int temp; + php_int_t temp; int dayOfYear; if (sdn <= 0 || @@ -190,7 +190,7 @@ fail: *pDay = 0; } -long int GregorianToSdn( +php_int_t GregorianToSdn( int inputYear, int inputMonth, int inputDay) diff --git a/ext/calendar/jewish.c b/ext/calendar/jewish.c index ddc8aaa..bdd827c 100644 --- a/ext/calendar/jewish.c +++ b/ext/calendar/jewish.c @@ -11,7 +11,7 @@ * * void * SdnToJewish( - * long int sdn, + * php_int_t sdn, * int *pYear, * int *pMonth, * int *pDay); @@ -22,7 +22,7 @@ * inclusive; *pDay will be in the range 1 to 30 inclusive. Note that Adar * II is assigned the month number 7 and Elul is always 13. * - * long int + * php_int_t * JewishToSdn( * int year, * int month, @@ -382,12 +382,12 @@ char *JewishMonthHebName[14] = * (called dehiyyot) delays it. These 4 rules can delay the start of the * year by as much as 2 days. */ -static long int Tishri1( +static php_int_t Tishri1( int metonicYear, - long int moladDay, - long int moladHalakim) + php_int_t moladDay, + php_int_t moladHalakim) { - long int tishri1; + php_int_t tishri1; int dow; int leapYear; int lastWasLeapYear; @@ -429,10 +429,10 @@ static long int Tishri1( */ static void MoladOfMetonicCycle( int metonicCycle, - long int *pMoladDay, - long int *pMoladHalakim) + php_int_t *pMoladDay, + php_int_t *pMoladHalakim) { - register unsigned long int r1, r2, d1, d2; + register php_uint_t r1, r2, d1, d2; /* Start with the time of the first molad after creation. */ r1 = NEW_MOON_OF_CREATION; @@ -468,14 +468,14 @@ static void MoladOfMetonicCycle( * us to avoid calculating the length of the year in most cases. */ static void FindTishriMolad( - long int inputDay, + php_int_t inputDay, int *pMetonicCycle, int *pMetonicYear, - long int *pMoladDay, - long int *pMoladHalakim) + php_int_t *pMoladDay, + php_int_t *pMoladHalakim) { - long int moladDay; - long int moladHalakim; + php_int_t moladDay; + php_int_t moladHalakim; int metonicCycle; int metonicYear; @@ -523,8 +523,8 @@ static void FindStartOfYear( int year, int *pMetonicCycle, int *pMetonicYear, - long int *pMoladDay, - long int *pMoladHalakim, + php_int_t *pMoladDay, + php_int_t *pMoladHalakim, int *pTishri1) { *pMetonicCycle = (year - 1) / 19; @@ -546,14 +546,14 @@ static void FindStartOfYear( * range 1 to 13 inclusive; *pDay will be in the range 1 to 30 inclusive. */ void SdnToJewish( - long int sdn, + php_int_t sdn, int *pYear, int *pMonth, int *pDay) { - long int inputDay; - long int day; - long int halakim; + php_int_t inputDay; + php_int_t day; + php_int_t halakim; int metonicCycle; int metonicYear; int tishri1; @@ -684,18 +684,18 @@ void SdnToJewish( * value. To verify that a date is valid, convert it to SDN and then back * and compare with the original. */ -long int JewishToSdn( +php_int_t JewishToSdn( int year, int month, int day) { - long int sdn; + php_int_t sdn; int metonicCycle; int metonicYear; int tishri1; int tishri1After; - long int moladDay; - long int moladHalakim; + php_int_t moladDay; + php_int_t moladHalakim; int yearLength; int lengthOfAdarIAndII; diff --git a/ext/calendar/julian.c b/ext/calendar/julian.c index 17e7bcb..3527627 100644 --- a/ext/calendar/julian.c +++ b/ext/calendar/julian.c @@ -11,7 +11,7 @@ * * void * SdnToJulian( - * long int sdn, + * php_int_t sdn, * int *pYear, * int *pMonth, * int *pDay); @@ -21,7 +21,7 @@ * will be >= -4713 and != 0; *pMonth will be in the range 1 to 12 * inclusive; *pDay will be in the range 1 to 31 inclusive. * - * long int + * php_int_t * JulianToSdn( * int inputYear, * int inputMonth, @@ -153,7 +153,7 @@ #define DAYS_PER_4_YEARS 1461 void SdnToJulian( - long int sdn, + php_int_t sdn, int *pYear, int *pMonth, int *pDay) @@ -161,7 +161,7 @@ void SdnToJulian( int year; int month; int day; - long int temp; + php_int_t temp; int dayOfYear; if (sdn <= 0) { @@ -212,7 +212,7 @@ fail: *pDay = 0; } -long int JulianToSdn( +php_int_t JulianToSdn( int inputYear, int inputMonth, int inputDay) diff --git a/ext/calendar/sdncal.h b/ext/calendar/sdncal.h index c0463c8..488f8c0 100644 --- a/ext/calendar/sdncal.h +++ b/ext/calendar/sdncal.h @@ -32,7 +32,7 @@ * calculating the number of days between two dates. * * When using this software on 16 bit systems, be careful to store SDNs in - * a long int, because it will not fit in the 16 bits that some systems + * a php_int_t, because it will not fit in the 16 bits that some systems * allocate to an int. * * For each calendar, there are two routines provided. One converts dates @@ -53,7 +53,7 @@ * * int y1, m1, d1; * int y2, m2, d2; - * long int sdn; + * php_int_t sdn; * ... * sdn = GregorianToSdn(y1, m1, d1); * if (sdn > 0) { @@ -65,19 +65,21 @@ * **************************************************************************/ +#include "php.h" + /* Gregorian calendar conversions. */ -void SdnToGregorian(long int sdn, int *pYear, int *pMonth, int *pDay); -long int GregorianToSdn(int year, int month, int day); +void SdnToGregorian(php_int_t sdn, int *pYear, int *pMonth, int *pDay); +php_int_t GregorianToSdn(int year, int month, int day); extern char *MonthNameShort[13]; extern char *MonthNameLong[13]; /* Julian calendar conversions. */ -void SdnToJulian(long int sdn, int *pYear, int *pMonth, int *pDay); -long int JulianToSdn(int year, int month, int day); +void SdnToJulian(php_int_t sdn, int *pYear, int *pMonth, int *pDay); +php_int_t JulianToSdn(int year, int month, int day); /* Jewish calendar conversions. */ -void SdnToJewish(long int sdn, int *pYear, int *pMonth, int *pDay); -long int JewishToSdn(int year, int month, int day); +void SdnToJewish(php_int_t sdn, int *pYear, int *pMonth, int *pDay); +php_int_t JewishToSdn(int year, int month, int day); extern char *JewishMonthName[14]; extern char *JewishMonthNameLeap[14]; extern char *JewishMonthHebName[14]; @@ -85,15 +87,15 @@ extern char *JewishMonthHebNameLeap[14]; extern int monthsPerYear[19]; /* French republic calendar conversions. */ -void SdnToFrench(long int sdn, int *pYear, int *pMonth, int *pDay); -long int FrenchToSdn(int inputYear, int inputMonth, int inputDay); +void SdnToFrench(php_int_t sdn, int *pYear, int *pMonth, int *pDay); +php_int_t FrenchToSdn(int inputYear, int inputMonth, int inputDay); extern char *FrenchMonthName[14]; /* Islamic calendar conversions. */ /* Not implemented yet. */ /* Day of week conversion. 0=Sunday, 6=Saturday */ -int DayOfWeek(long int sdn); +int DayOfWeek(php_int_t sdn); extern char *DayNameShort[7]; extern char *DayNameLong[7];