]> granicus.if.org Git - php/commitdiff
- Fixed size calculation.
authorDerick Rethans <derick@php.net>
Fri, 25 Jul 2008 08:16:03 +0000 (08:16 +0000)
committerDerick Rethans <derick@php.net>
Fri, 25 Jul 2008 08:16:03 +0000 (08:16 +0000)
- Reverted cosmetic fixes that makes upgrading harder.

ext/fileinfo/libmagic/apprentice.c
ext/fileinfo/libmagic/funcs.c

index 7939102ef04063c08a83c405cce7999576294225..1d525f37c8767e635f9716eb0f865a1a27fcb262 100644 (file)
@@ -582,7 +582,6 @@ set_test_type(struct magic *mstart, struct magic *m)
                /* invalid search type, but no need to complain here */
                break;
        }
-       return 1;
 }
 
 /*
@@ -664,7 +663,7 @@ apprentice_load(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp,
        if (stat(fn, &st) == 0 && S_ISDIR(st.st_mode)) {
                dir = opendir(fn);
                if (dir) {
-                       while ((d = readdir(dir))) {
+                       while (d = readdir(dir)) {
                                snprintf(subfn, sizeof(subfn), "%s/%s",
                                    fn, d->d_name);
                                if (stat(subfn, &st) == 0 && S_ISREG(st.st_mode)) {
@@ -1976,11 +1975,14 @@ internal_loaded:
                    VERSIONNO, dbname, version);
                goto error1;
        }
-#ifndef PHP_BUNDLE
-       *nmagicp = (st.st_size / sizeof(struct magic));
+#ifdef PHP_BUNDLE
+       if (fn == NULL)
+               *nmagicp = (sizeof(php_magic_database) / sizeof(struct magic));
+       else // the statement after the #endif is used
+#endif
+       *nmagicp = (uint32_t)(st.st_size / sizeof(struct magic));
        if (*nmagicp > 0)
                (*nmagicp)--;
-#endif
        (*magicp)++;
        if (needsbyteswap)
                byteswap(*magicp, *nmagicp);
index ef3d3e7daca828e8ac3828369cb5b6802467684e..d9e84fa6dabb8dc60da03fdacc867ddef1a66581 100644 (file)
@@ -48,6 +48,7 @@ protected int
 file_printf(struct magic_set *ms, const char *fmt, ...)
 {
        va_list ap;
+       size_t size;
        int len;
        char *buf, *newstr;