From 144527b190869c81bd5537e4153af7fba2eb78b9 Mon Sep 17 00:00:00 2001 From: Pierre Joye Date: Mon, 20 Oct 2008 14:45:59 +0000 Subject: [PATCH] - support for VC6 and some other platforms (before some other cleanup) --- ext/fileinfo/config.w32 | 4 ++++ ext/fileinfo/libmagic/apprentice.c | 6 ++++++ ext/fileinfo/libmagic/softmagic.c | 34 +++++++++++++++--------------- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/ext/fileinfo/config.w32 b/ext/fileinfo/config.w32 index f94929c81f..085f9b2c3e 100644 --- a/ext/fileinfo/config.w32 +++ b/ext/fileinfo/config.w32 @@ -13,6 +13,10 @@ if (PHP_FILEINFO != 'no') { magic.c print.c \ readelf.c softmagic.c"; + if (VCVERS <1500) { + ADD_FLAG('CFLAGS', '/Zm1000'); + } + EXTENSION('fileinfo', 'fileinfo.c', true, "/I" + configure_module_dirname + "/libmagic /I" + configure_module_dirname); ADD_SOURCES(configure_module_dirname + '\\libmagic', LIBMAGIC_SOURCES, "fileinfo"); } else { diff --git a/ext/fileinfo/libmagic/apprentice.c b/ext/fileinfo/libmagic/apprentice.c index d06875bfbe..d4e0e889d5 100644 --- a/ext/fileinfo/libmagic/apprentice.c +++ b/ext/fileinfo/libmagic/apprentice.c @@ -38,11 +38,17 @@ #ifdef PHP_WIN32 #include "win32/unistd.h" +#if _MSC_VER <= 1300 +#include "win32/php_strtoi64.h" +#endif #define strtoull _strtoui64 #else #include #endif + + + #include #include #include diff --git a/ext/fileinfo/libmagic/softmagic.c b/ext/fileinfo/libmagic/softmagic.c index ad64d97f1d..3afc0c6d1f 100644 --- a/ext/fileinfo/libmagic/softmagic.c +++ b/ext/fileinfo/libmagic/softmagic.c @@ -582,16 +582,16 @@ cvt_64(union VALUETYPE *p, const struct magic *m) if (m->num_mask) \ switch (m->mask_op & FILE_OPS_MASK) { \ case FILE_OPADD: \ - p->fld += cast m->num_mask; \ + p->fld += cast (int64_t)m->num_mask; \ break; \ case FILE_OPMINUS: \ - p->fld -= cast m->num_mask; \ + p->fld -= cast (int64_t)m->num_mask; \ break; \ case FILE_OPMULTIPLY: \ - p->fld *= cast m->num_mask; \ + p->fld *= cast (int64_t)m->num_mask; \ break; \ case FILE_OPDIVIDE: \ - p->fld /= cast m->num_mask; \ + p->fld /= cast (int64_t)m->num_mask; \ break; \ } \ @@ -1860,7 +1860,7 @@ magiccheck(struct magic_set *ms, struct magic *m) case 'x': if ((ms->flags & MAGIC_DEBUG) != 0) (void) fprintf(stderr, "%llu == *any* = 1\n", - (unsigned long long)v); + (uint64_t)v); matched = 1; break; @@ -1868,7 +1868,7 @@ magiccheck(struct magic_set *ms, struct magic *m) matched = v != l; if ((ms->flags & MAGIC_DEBUG) != 0) (void) fprintf(stderr, "%llu != %llu = %d\n", - (unsigned long long)v, (unsigned long long)l, + (uint64_t)v, (uint64_t)l, matched); break; @@ -1876,7 +1876,7 @@ magiccheck(struct magic_set *ms, struct magic *m) matched = v == l; if ((ms->flags & MAGIC_DEBUG) != 0) (void) fprintf(stderr, "%llu == %llu = %d\n", - (unsigned long long)v, (unsigned long long)l, + (uint64_t)v, (uint64_t)l, matched); break; @@ -1885,14 +1885,14 @@ magiccheck(struct magic_set *ms, struct magic *m) matched = v > l; if ((ms->flags & MAGIC_DEBUG) != 0) (void) fprintf(stderr, "%llu > %llu = %d\n", - (unsigned long long)v, - (unsigned long long)l, matched); + (uint64_t)v, + (uint64_t)l, matched); } else { matched = (int64_t) v > (int64_t) l; if ((ms->flags & MAGIC_DEBUG) != 0) (void) fprintf(stderr, "%lld > %lld = %d\n", - (long long)v, (long long)l, matched); + (uint64_t)v, (uint64_t)l, matched); } break; @@ -1901,14 +1901,14 @@ magiccheck(struct magic_set *ms, struct magic *m) matched = v < l; if ((ms->flags & MAGIC_DEBUG) != 0) (void) fprintf(stderr, "%llu < %llu = %d\n", - (unsigned long long)v, - (unsigned long long)l, matched); + (uint64_t)v, + (uint64_t)l, matched); } else { matched = (int64_t) v < (int64_t) l; if ((ms->flags & MAGIC_DEBUG) != 0) (void) fprintf(stderr, "%lld < %lld = %d\n", - (long long)v, (long long)l, matched); + (int64_t)v, (int64_t)l, matched); } break; @@ -1916,16 +1916,16 @@ magiccheck(struct magic_set *ms, struct magic *m) matched = (v & l) == l; if ((ms->flags & MAGIC_DEBUG) != 0) (void) fprintf(stderr, "((%llx & %llx) == %llx) = %d\n", - (unsigned long long)v, (unsigned long long)l, - (unsigned long long)l, matched); + (uint64_t)v, (uint64_t)l, + (uint64_t)l, matched); break; case '^': matched = (v & l) != l; if ((ms->flags & MAGIC_DEBUG) != 0) (void) fprintf(stderr, "((%llx & %llx) != %llx) = %d\n", - (unsigned long long)v, (unsigned long long)l, - (unsigned long long)l, matched); + (uint64_t)v, (uint64_t)l, + (uint64_t)l, matched); break; default: -- 2.40.0