commit dfd6afb7409fac345a26d5b16d967d3f4c5f7fa1
Author: Enrico Forestieri <[email protected]>
Date: Wed Jul 4 09:42:04 2018 +0200
Fix compilation on case insensitive filesystems
In such filesystems, including either Magic.h or magic.h does not
make any difference and the one or other file is included depending
on the search order. In this case, Magic.h was trying to include
itself instead of including magic.h.
---
src/Format.cpp | 2 +-
src/support/Magic.h | 77 -----------------------------------------------
src/support/Makefile.am | 2 +-
src/support/lyxmagic.h | 77 +++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 79 insertions(+), 79 deletions(-)
diff --git a/src/Format.cpp b/src/Format.cpp
index feefd1e..a4882f6 100644
--- a/src/Format.cpp
+++ b/src/Format.cpp
@@ -23,7 +23,7 @@
#include "support/filetools.h"
#include "support/gettext.h"
#include "support/lstrings.h"
-#include "support/Magic.h"
+#include "support/lyxmagic.h"
#include "support/mutex.h"
#include "support/os.h"
#include "support/PathChanger.h"
diff --git a/src/support/Magic.h b/src/support/Magic.h
deleted file mode 100644
index 69ea3a6..0000000
--- a/src/support/Magic.h
+++ /dev/null
@@ -1,77 +0,0 @@
-// -*- C++ -*-
-/**
- * \file Magic.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Jean-Marc Lasgouttes
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef LYX_MAGIC_H
-#define LYX_MAGIC_H
-
-namespace lyx {
-
-#ifdef HAVE_MAGIC_H
-
-#include "support/debug.h"
-
-#include <magic.h>
-
-class Magic {
-public:
- Magic() : ok_(false) {
- cookie_ = magic_open(MAGIC_MIME);
- if (cookie_) {
- if (magic_load(cookie_, NULL) != 0)
- LYXERR(Debug::GRAPHICS, "Magic: couldn't load
magic database - "
- << magic_error(cookie_));
- else
- ok_ = true;
- }
- }
-
- ~Magic() {
- if(cookie_)
- magic_close(cookie_);
- }
-
- // returns a string of the form "mime-type;encoding", or an empty
string on error.
- std::string file(std::string const & name) const {
- if (!ok_)
- return std::string();
-
- char const * result = magic_file(cookie_, name.c_str());
- if (result)
- return result;
- else
- LYXERR(Debug::GRAPHICS, "Magic: couldn't query magic
database - "
- << magic_error(cookie_));
-
- return std::string();
- }
-
-private:
- magic_t cookie_;
- bool ok_;
-};
-
-#else // !HAVE_MAGIC_T
-
-// A dummy Magic class that always returns an empty result
-class Magic {
-public:
- Magic() {
- LYXERR(Debug::GRAPHICS, "Magic: libmagic support not
configured");
- }
-
- std::string file(std::string const & ) const { return empty_string(); }
-};
-
-#endif // HAVE_MAGIC_T
-
-}
-
-#endif // LYX_MAGIC_H
diff --git a/src/support/Makefile.am b/src/support/Makefile.am
index c86cd48..3a4576c 100644
--- a/src/support/Makefile.am
+++ b/src/support/Makefile.am
@@ -74,9 +74,9 @@ liblyxsupport_a_SOURCES = \
lstrings.h \
lyxalgo.h \
lyxlib.h \
+ lyxmagic.h \
lyxtime.cpp \
lyxtime.h \
- Magic.h \
mutex.h \
mutex.cpp \
Messages.cpp \
diff --git a/src/support/lyxmagic.h b/src/support/lyxmagic.h
new file mode 100644
index 0000000..9a40d6f
--- /dev/null
+++ b/src/support/lyxmagic.h
@@ -0,0 +1,77 @@
+// -*- C++ -*-
+/**
+ * \file lyxmagic.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Jean-Marc Lasgouttes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef LYX_MAGIC_H
+#define LYX_MAGIC_H
+
+namespace lyx {
+
+#ifdef HAVE_MAGIC_H
+
+#include "support/debug.h"
+
+#include <magic.h>
+
+class Magic {
+public:
+ Magic() : ok_(false) {
+ cookie_ = magic_open(MAGIC_MIME);
+ if (cookie_) {
+ if (magic_load(cookie_, NULL) != 0)
+ LYXERR(Debug::GRAPHICS, "Magic: couldn't load
magic database - "
+ << magic_error(cookie_));
+ else
+ ok_ = true;
+ }
+ }
+
+ ~Magic() {
+ if(cookie_)
+ magic_close(cookie_);
+ }
+
+ // returns a string of the form "mime-type;encoding", or an empty
string on error.
+ std::string file(std::string const & name) const {
+ if (!ok_)
+ return std::string();
+
+ char const * result = magic_file(cookie_, name.c_str());
+ if (result)
+ return result;
+ else
+ LYXERR(Debug::GRAPHICS, "Magic: couldn't query magic
database - "
+ << magic_error(cookie_));
+
+ return std::string();
+ }
+
+private:
+ magic_t cookie_;
+ bool ok_;
+};
+
+#else // !HAVE_MAGIC_T
+
+// A dummy Magic class that always returns an empty result
+class Magic {
+public:
+ Magic() {
+ LYXERR(Debug::GRAPHICS, "Magic: libmagic support not
configured");
+ }
+
+ std::string file(std::string const & ) const { return empty_string(); }
+};
+
+#endif // HAVE_MAGIC_T
+
+}
+
+#endif // LYX_MAGIC_H