From 112ea13d4f5730dc0a47f90aea4480f7821377bc Mon Sep 17 00:00:00 2001 From: Christos Zoulas Date: Fri, 13 May 2011 22:15:40 +0000 Subject: [PATCH] make this compile with a c++ compiler again. --- src/file.h | 4 +++- src/softmagic.c | 10 +++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/file.h b/src/file.h index 6b0ad956..fad9efcb 100644 --- a/src/file.h +++ b/src/file.h @@ -27,7 +27,7 @@ */ /* * file.h - definitions for file(1) program - * @(#)$File: file.h,v 1.131 2011/02/03 01:43:33 christos Exp $ + * @(#)$File: file.h,v 1.132 2011/03/20 20:36:52 christos Exp $ */ #ifndef __file_h__ @@ -333,8 +333,10 @@ struct mlist { #ifdef __cplusplus #define CAST(T, b) static_cast(b) +#define RCAST(T, b) reinterpret_cast(b) #else #define CAST(T, b) (T)(b) +#define RCAST(T, b) (T)(b) #endif struct level_info { diff --git a/src/softmagic.c b/src/softmagic.c index 47b15cc8..f25f2e5b 100644 --- a/src/softmagic.c +++ b/src/softmagic.c @@ -32,7 +32,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: softmagic.c,v 1.143 2010/12/22 18:14:06 christos Exp $") +FILE_RCSID("@(#)$File: softmagic.c,v 1.144 2011/01/07 23:22:28 rrt Exp $") #endif /* lint */ #include "magic.h" @@ -912,7 +912,7 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir, if (indir == 0) { switch (type) { case FILE_SEARCH: - ms->search.s = (const char *)s + offset; + ms->search.s = RCAST(const char *, s) + offset; ms->search.s_len = nbytes - offset; ms->search.offset = offset; return 0; @@ -930,8 +930,8 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir, ms->search.s = NULL; return 0; } - buf = (const char *)s + offset; - end = last = (const char *)s + nbytes; + buf = RCAST(const char *, s) + offset; + end = last = RCAST(const char *, s) + nbytes; /* mget() guarantees buf <= last */ for (lines = linecnt, b = buf; lines && b < end && ((b = CAST(const char *, @@ -944,7 +944,7 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir, b++; } if (lines) - last = (const char *)s + nbytes; + last = RCAST(const char *, s) + nbytes; ms->search.s = buf; ms->search.s_len = last - buf; -- 2.40.0