diff options
Diffstat (limited to 'ext/fileinfo/libmagic/apprentice.c')
-rw-r--r-- | ext/fileinfo/libmagic/apprentice.c | 88 |
1 files changed, 44 insertions, 44 deletions
diff --git a/ext/fileinfo/libmagic/apprentice.c b/ext/fileinfo/libmagic/apprentice.c index 0bdbbc90bb..3740c7fd51 100644 --- a/ext/fileinfo/libmagic/apprentice.c +++ b/ext/fileinfo/libmagic/apprentice.c @@ -2,7 +2,7 @@ * Copyright (c) Ian F. Darwin 1986-1995. * Software written by Ian F. Darwin and others; * maintained 1995-present by Christos Zoulas and others. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -12,7 +12,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -89,7 +89,7 @@ FILE_RCSID("@(#)$File: apprentice.c,v 1.196 2013/11/19 21:01:12 christos Exp $") #define ALLOC_INCR (size_t)200 struct magic_entry { - struct magic *mp; + struct magic *mp; uint32_t cont_count; uint32_t max_count; }; @@ -123,7 +123,7 @@ private int apprentice_1(struct magic_set *, const char *, int); private size_t apprentice_magic_strength(const struct magic *); private int apprentice_sort(const void *, const void *); private void apprentice_list(struct mlist *, int ); -private struct magic_map *apprentice_load(struct magic_set *, +private struct magic_map *apprentice_load(struct magic_set *, const char *, int); private struct mlist *mlist_alloc(void); private void mlist_free(struct mlist *); @@ -436,7 +436,7 @@ apprentice_1(struct magic_set *ms, const char *fn, int action) apprentice_list(ms->mlist[i], TEXTTEST); } } - + return 0; } @@ -787,7 +787,7 @@ apprentice_magic_strength(const struct magic *m) return val; } -/* +/* * Sort callback for sorting entries by "strength" (basically length) */ private int @@ -805,7 +805,7 @@ apprentice_sort(const void *a, const void *b) return 1; } -/* +/* * Shows sorted patterns list in the order which is used for the matching */ private void @@ -899,7 +899,7 @@ set_test_type(struct magic *mstart, struct magic *m) mstart->flag |= BINTEST; if (mstart->str_flags & STRING_TEXTTEST) mstart->flag |= TEXTTEST; - + if (mstart->flag & (TEXTTEST|BINTEST)) break; @@ -1095,7 +1095,7 @@ set_last_default(struct magic_set *ms, struct magic_entry *me, uint32_t nme) file_magwarn(ms, "level 0 \"default\" did not sort last"); } - return; + return; } } } @@ -1149,7 +1149,7 @@ apprentice_load(struct magic_set *ms, const char *fn, int action) struct magic_entry_set mset[MAGIC_SETS]; php_stream *dir; php_stream_dirent d; - + memset(mset, 0, sizeof(mset)); ms->flags |= MAGIC_CHECK; /* Enable checks for parsed files */ @@ -1511,7 +1511,7 @@ parse(struct magic_set *ms, struct magic_entry *me, const char *line, */ while (*l == '>') { ++l; /* step over */ - cont_level++; + cont_level++; } #ifdef ENABLE_CONDITIONALS if (cont_level == 0 || cont_level > last_cont_level) @@ -1671,7 +1671,7 @@ parse(struct magic_set *ms, struct magic_entry *me, const char *line, "in_offset `%s' invalid", l); l = t; } - if (*l++ != ')' || + if (*l++ != ')' || ((m->in_op & FILE_OPINDIRECT) && *l++ != ')')) if (ms->flags & MAGIC_CHECK) file_magwarn(ms, @@ -1694,7 +1694,7 @@ parse(struct magic_set *ms, struct magic_entry *me, const char *line, /* * Try it as a keyword type prefixed by "u"; match what * follows the "u". If that fails, try it as an SUS - * integer type. + * integer type. */ m->type = get_type(type_tbl, l + 1, &l); if (m->type == FILE_INVALID) { @@ -1734,7 +1734,7 @@ parse(struct magic_set *ms, struct magic_entry *me, const char *line, /* Not found - try it as a special keyword. */ m->type = get_type(special_tbl, l, &l); } - + if (m->type == FILE_INVALID) { if (ms->flags & MAGIC_CHECK) file_magwarn(ms, "type `%s' invalid", l); @@ -1871,7 +1871,7 @@ parse(struct magic_set *ms, struct magic_entry *me, const char *line, * anything if mask = 0 (unless you have a better idea) */ EATAB; - + switch (*l) { case '>': case '<': @@ -1903,7 +1903,7 @@ parse(struct magic_set *ms, struct magic_entry *me, const char *line, break; default: m->reln = '='; /* the default relation */ - if (*l == 'x' && ((isascii((unsigned char)l[1]) && + if (*l == 'x' && ((isascii((unsigned char)l[1]) && isspace((unsigned char)l[1])) || !l[1])) { m->reln = *l; ++l; @@ -1918,7 +1918,7 @@ parse(struct magic_set *ms, struct magic_entry *me, const char *line, /* * TODO finish this macro and start using it! - * #define offsetcheck {if (offset > HOWMANY-1) + * #define offsetcheck {if (offset > HOWMANY-1) * magwarn("offset too big"); } */ @@ -2028,7 +2028,7 @@ parse_apple(struct magic_set *ms, struct magic_entry *me, const char *line) file_magwarn(ms, "Current entry already has a APPLE type " "`%.8s', new type `%s'", m->mimetype, l); return -1; - } + } EATAB; for (i = 0; *l && ((isascii((unsigned char)*l) && @@ -2063,7 +2063,7 @@ parse_mime(struct magic_set *ms, struct magic_entry *me, const char *line) file_magwarn(ms, "Current entry already has a MIME type `%s'," " new type `%s'", m->mimetype, l); return -1; - } + } EATAB; for (i = 0; *l && ((isascii((unsigned char)*l) && @@ -2112,7 +2112,7 @@ check_format_type(const char *ptr, int type) if (*ptr++ != 'l') return -1; } - + switch (*ptr++) { case 'l': switch (*ptr++) { @@ -2126,7 +2126,7 @@ check_format_type(const char *ptr, int type) default: return -1; } - + case 'h': switch (*ptr++) { case 'h': @@ -2155,11 +2155,11 @@ check_format_type(const char *ptr, int type) case 'x': case 'X': return 0; - + default: return -1; } - + case FILE_FMT_FLOAT: case FILE_FMT_DOUBLE: if (*ptr == '-') @@ -2170,7 +2170,7 @@ check_format_type(const char *ptr, int type) if (*ptr == '.') ptr++; while (isdigit((unsigned char)*ptr)) ptr++; - + switch (*ptr++) { case 'e': case 'E': @@ -2179,11 +2179,11 @@ check_format_type(const char *ptr, int type) case 'g': case 'G': return 0; - + default: return -1; } - + case FILE_FMT_STR: if (*ptr == '-') @@ -2195,14 +2195,14 @@ check_format_type(const char *ptr, int type) while (isdigit((unsigned char )*ptr)) ptr++; } - + switch (*ptr++) { case 's': return 0; default: return -1; } - + default: /* internal error */ abort(); @@ -2210,7 +2210,7 @@ check_format_type(const char *ptr, int type) /*NOTREACHED*/ return -1; } - + /* * Check that the optional printf format in description matches * the type of the magic. @@ -2232,7 +2232,7 @@ check_format(struct magic_set *ms, struct magic *m) if (m->type >= file_nformats) { file_magwarn(ms, "Internal error inconsistency between " - "m->type and format strings"); + "m->type and format strings"); return -1; } if (file_formats[m->type] == FILE_FMT_NONE) { @@ -2252,7 +2252,7 @@ check_format(struct magic_set *ms, struct magic *m) file_names[m->type], m->desc); return -1; } - + for (; *ptr; ptr++) { if (*ptr == '%') { file_magwarn(ms, @@ -2265,9 +2265,9 @@ check_format(struct magic_set *ms, struct magic *m) return 0; } -/* - * Read a numeric value from a pointer, into the value union of a magic - * pointer, according to the magic type. Update the string pointer to point +/* + * Read a numeric value from a pointer, into the value union of a magic + * pointer, according to the magic type. Update the string pointer to point * just after the number read. Return 0 for success, non-zero for failure. */ private int @@ -2366,7 +2366,7 @@ getstr(struct magic_set *ms, struct magic *m, const char *s, int warn) default: if (warn) { if (isprint((unsigned char)c)) { - /* Allow escaping of + /* Allow escaping of * ``relations'' */ if (strchr("<>&^=!", c) == NULL && (m->type != FILE_REGEX || @@ -2570,7 +2570,7 @@ eatsize(const char **p) { const char *l = *p; - if (LOWCASE(*l) == 'u') + if (LOWCASE(*l) == 'u') l++; switch (LOWCASE(*l)) { @@ -2760,7 +2760,7 @@ apprentice_compile(struct magic_set *ms, struct magic_map *map, const char *fn) dbname = mkdbname(ms, fn, 0); - if (dbname == NULL) + if (dbname == NULL) goto out; /* wb+ == O_WRONLY|O_CREAT|O_TRUNC|O_BINARY */ @@ -2873,8 +2873,8 @@ private uint16_t swap2(uint16_t sv) { uint16_t rv; - uint8_t *s = (uint8_t *)(void *)&sv; - uint8_t *d = (uint8_t *)(void *)&rv; + uint8_t *s = (uint8_t *)(void *)&sv; + uint8_t *d = (uint8_t *)(void *)&rv; d[0] = s[1]; d[1] = s[0]; return rv; @@ -2887,8 +2887,8 @@ private uint32_t swap4(uint32_t sv) { uint32_t rv; - uint8_t *s = (uint8_t *)(void *)&sv; - uint8_t *d = (uint8_t *)(void *)&rv; + uint8_t *s = (uint8_t *)(void *)&sv; + uint8_t *d = (uint8_t *)(void *)&rv; d[0] = s[3]; d[1] = s[2]; d[2] = s[1]; @@ -2903,8 +2903,8 @@ private uint64_t swap8(uint64_t sv) { uint64_t rv; - uint8_t *s = (uint8_t *)(void *)&sv; - uint8_t *d = (uint8_t *)(void *)&rv; + uint8_t *s = (uint8_t *)(void *)&sv; + uint8_t *d = (uint8_t *)(void *)&rv; #if 0 d[0] = s[3]; d[1] = s[2]; @@ -2947,7 +2947,7 @@ bs1(struct magic *m) } } -protected size_t +protected size_t file_pstring_length_size(const struct magic *m) { switch (m->str_flags & PSTRING_LEN) { |