summaryrefslogtreecommitdiff
path: root/ext/calendar
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2014-08-19 10:42:01 +0200
committerAnatol Belski <ab@php.net>2014-08-19 10:42:01 +0200
commitfd279836cf84b1bee95f166f576812190ad9d24f (patch)
tree5e24adb5c703bbecd982a51c69e132d0c0e95212 /ext/calendar
parent29dc15b0bb0bc6e3ab8266a1dc37ae8221edc16f (diff)
downloadphp-git-fd279836cf84b1bee95f166f576812190ad9d24f.tar.gz
ported ext/calendar
Diffstat (limited to 'ext/calendar')
-rw-r--r--ext/calendar/calendar.c68
-rw-r--r--ext/calendar/dow.c2
-rw-r--r--ext/calendar/easter.c8
-rw-r--r--ext/calendar/french.c6
-rw-r--r--ext/calendar/gregor.c6
-rw-r--r--ext/calendar/jewish.c44
-rw-r--r--ext/calendar/julian.c10
-rw-r--r--ext/calendar/sdncal.h22
8 files changed, 84 insertions, 82 deletions
diff --git a/ext/calendar/calendar.c b/ext/calendar/calendar.c
index bea7669284..35652a9ce6 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 {
@@ -289,10 +289,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;
}
@@ -324,16 +324,16 @@ 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;
}
if (cal < 0 || cal >= CAL_NUM_CALS) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid calendar ID %ld.", cal);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid calendar ID %pd.", cal);
RETURN_FALSE;
}
@@ -368,14 +368,14 @@ 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;
}
if (cal < 0 || cal >= CAL_NUM_CALS) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid calendar ID %ld.", cal);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid calendar ID %pd.", cal);
RETURN_FALSE;
}
@@ -387,17 +387,17 @@ 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;
}
if (cal < 0 || cal >= CAL_NUM_CALS) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid calendar ID %ld", cal);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid calendar ID %pd", cal);
RETURN_FALSE;
}
calendar = &cal_conversion_table[cal];
@@ -434,11 +434,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;
}
@@ -453,9 +453,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;
}
@@ -467,11 +467,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;
}
@@ -486,9 +486,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;
}
@@ -595,13 +595,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;
}
@@ -634,9 +634,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;
}
@@ -648,11 +648,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;
}
@@ -667,9 +667,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;
}
@@ -681,11 +681,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;
}
@@ -712,11 +712,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 64ae008f77..1e9b99694c 100644
--- a/ext/calendar/dow.c
+++ b/ext/calendar/dow.c
@@ -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 f0e7d276c5..a61a970461 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, result;
- long method = CAL_EASTER_DEFAULT;
+ php_int_t year, golden, solar, lunar, pfm, dom, tmp, easter, result;
+ 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 5b4dd53750..c6584695e9 100644
--- a/ext/calendar/french.c
+++ b/ext/calendar/french.c
@@ -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 ebb743fddc..b67de5fcc8 100644
--- a/ext/calendar/gregor.c
+++ b/ext/calendar/gregor.c
@@ -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 ddc8aaaf86..83efb9949f 100644
--- a/ext/calendar/jewish.c
+++ b/ext/calendar/jewish.c
@@ -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 17e7bcb597..3527627c2f 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 c0463c80d4..47d7748c4c 100644
--- a/ext/calendar/sdncal.h
+++ b/ext/calendar/sdncal.h
@@ -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];