Skip to content

Commit e430814

Browse files
committed
Revert "Merge pull request #241"
This reverts commit f5edbe2, reversing changes made to 6aaa45d.
1 parent f5edbe2 commit e430814

File tree

3 files changed

+18
-48
lines changed

3 files changed

+18
-48
lines changed

src/BSON/UTCDateTime.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ PHP_METHOD(UTCDateTime, __construct)
5555
long milliseconds;
5656
#if SIZEOF_LONG == 4
5757
char *s_milliseconds;
58-
int s_milliseconds_len;
58+
int s_milliseconds_len;
5959
#endif
6060

6161

src/bson.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,22 @@
4141
#include "php_phongo.h"
4242
#include "php_bson.h"
4343

44+
45+
#define BSON_APPEND_INT32(b,key,val) \
46+
bson_append_int32 (b, key, (int) strlen (key), val)
47+
48+
#if SIZEOF_LONG == 8
49+
# define BSON_APPEND_INT(b, key, keylen, val) \
50+
if (val > INT_MAX || val < INT_MIN) { \
51+
bson_append_int64(b, key, keylen, val); \
52+
} else { \
53+
bson_append_int32(b, key, keylen, val); \
54+
}
55+
#elif SIZEOF_LONG == 4
56+
# define BSON_APPEND_INT(b, key, keylen, val) \
57+
bson_append_int32(b, key, keylen, val);
58+
#endif
59+
4460
#undef MONGOC_LOG_DOMAIN
4561
#define MONGOC_LOG_DOMAIN "PHONGO-BSON"
4662

@@ -989,17 +1005,7 @@ static void phongo_bson_append(bson_t *bson, php_phongo_bson_flags_t flags, cons
9891005
#endif
9901006

9911007
case IS_LONG:
992-
#if SIZEOF_LONG == 8 || (PHP_VERSION_ID >= 70000 && SIZEOF_ZEND_LONG == 8)
993-
if (val > INT_MAX || val < INT_MIN) {
994-
bson_append_int64(bson, key, keylen, Z_LVAL_P(entry));
995-
} else {
996-
bson_append_int32(bson, key, keylen, Z_LVAL_P(entry));
997-
}
998-
#elif SIZEOF_LONG == 4 || (PHP_VERSION_ID >= 70000 && SIZEOF_ZEND_LONG == 4)
999-
bson_append_int32(bson, key, keylen, Z_LVAL_P(entry));
1000-
#else
1001-
#error Need fix for this architecture
1002-
#endif
1008+
BSON_APPEND_INT(bson, key, key_len, Z_LVAL_P(entry));
10031009
break;
10041010

10051011
case IS_DOUBLE:

tests/standalone/bug0544.phpt

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)