This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Move color handling into a separate header


We only need it in nm.c and objdump.c, but it pulls in argp as
dependency. By dropping it from libeu.h, the libraries can be
compiled without argp.

Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
---
 lib/ChangeLog   |  7 +++++++
 lib/Makefile.am |  2 +-
 lib/color.c     |  2 +-
 lib/color.h     | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/libeu.h     | 32 -----------------------------
 src/ChangeLog   |  5 +++++
 src/nm.c        |  1 +
 src/objdump.c   |  1 +
 8 files changed, 79 insertions(+), 34 deletions(-)
 create mode 100644 lib/color.h

diff --git a/lib/ChangeLog b/lib/ChangeLog
index fcf5b10..5ccf4d6 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,10 @@
+2017-02-14  Ulf Hermann  <ulf.hermann@qt.io>
+
+	* color.h: New file.
+	* color.c: Include color.h.
+	* libeu.h: Remove color handling.
+	* Makefile.am (noinst_HEADERS): Add color.h.
+
 2016-12-29  Luiz Angelo Daros de Luca  <luizluca@gmail.com>
* crc32_file.c: Include system.h.
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 1ad9ce8..3e0c601 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -38,7 +38,7 @@ libeu_a_SOURCES = xstrdup.c xstrndup.c xmalloc.c next_prime.c \
 		  color.c version.c
noinst_HEADERS = fixedsizehash.h libeu.h system.h dynamicsizehash.h list.h \
-		 md5.h sha1.h eu-config.h
+		 md5.h sha1.h eu-config.h color.h
 EXTRA_DIST = dynamicsizehash.c
if !GPROF
diff --git a/lib/color.c b/lib/color.c
index fde2d9d..f62389d 100644
--- a/lib/color.c
+++ b/lib/color.c
@@ -38,7 +38,7 @@
 #include <string.h>
 #include <unistd.h>
 #include "libeu.h"
-
+#include "color.h"
/* Prototype for option handler. */
 static error_t parse_opt (int key, char *arg, struct argp_state *state);
diff --git a/lib/color.h b/lib/color.h
new file mode 100644
index 0000000..3872eb0
--- /dev/null
+++ b/lib/color.h
@@ -0,0 +1,63 @@
+/* Handling of color output.
+   Copyright (C) 2017 The Qt Company
+   This file is part of elfutils.
+   Written by Ulrich Drepper <drepper@redhat.com>, 2011.
+
+   This file is free software; you can redistribute it and/or modify
+   it under the terms of either
+
+     * the GNU Lesser General Public License as published by the Free
+       Software Foundation; either version 3 of the License, or (at
+       your option) any later version
+
+   or
+
+     * the GNU General Public License as published by the Free
+       Software Foundation; either version 2 of the License, or (at
+       your option) any later version
+
+   or both in parallel, as here.
+
+   elfutils is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received copies of the GNU General Public License and
+   the GNU Lesser General Public License along with this program.  If
+   not, see <http://www.gnu.org/licenses/>.  */
+
+
+#ifndef COLOR_H
+#define COLOR_H 1
+
+/* Command line parser.  */
+extern const struct argp color_argp;
+
+/* Coloring mode.  */
+enum color_enum
+  {
+    color_never = 0,
+    color_always,
+    color_auto
+  } __attribute__ ((packed));
+extern enum color_enum color_mode;
+
+/* Colors to use for the various components.  */
+extern char *color_address;
+extern char *color_bytes;
+extern char *color_mnemonic;
+extern char *color_operand1;
+extern char *color_operand2;
+extern char *color_operand3;
+extern char *color_label;
+extern char *color_undef;
+extern char *color_undef_tls;
+extern char *color_undef_weak;
+extern char *color_symbol;
+extern char *color_tls;
+extern char *color_weak;
+
+extern const char color_off[];
+
+#endif /* color.h */
diff --git a/lib/libeu.h b/lib/libeu.h
index 69fe3d7..ecb4d01 100644
--- a/lib/libeu.h
+++ b/lib/libeu.h
@@ -43,36 +43,4 @@ extern char *xstrndup (const char *, size_t) __attribute__ ((__malloc__));
 extern uint32_t crc32 (uint32_t crc, unsigned char *buf, size_t len);
 extern int crc32_file (int fd, uint32_t *resp);
-
-/* Color handling.  */
-
-/* Command line parser.  */
-extern const struct argp color_argp;
-
-/* Coloring mode.  */
-enum color_enum
-  {
-    color_never = 0,
-    color_always,
-    color_auto
-  } __attribute__ ((packed));
-extern enum color_enum color_mode;
-
-/* Colors to use for the various components.  */
-extern char *color_address;
-extern char *color_bytes;
-extern char *color_mnemonic;
-extern char *color_operand1;
-extern char *color_operand2;
-extern char *color_operand3;
-extern char *color_label;
-extern char *color_undef;
-extern char *color_undef_tls;
-extern char *color_undef_weak;
-extern char *color_symbol;
-extern char *color_tls;
-extern char *color_weak;
-
-extern const char color_off[];
-
 #endif
diff --git a/src/ChangeLog b/src/ChangeLog
index 2a6d93e..19c7dbb 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2017-02-14  Ulf Hermann  <ulf.hermann@qt.io>
+
+	* nm.c: Include color.h.
+	* objdump.c: Likewise.
+
 2016-12-24  Mark Wielaard  <mark@klomp.org>
* Makefile.am (findtextrel_LDADD): Add $(libeu).
diff --git a/src/nm.c b/src/nm.c
index c54e96f..47a9e3b 100644
--- a/src/nm.c
+++ b/src/nm.c
@@ -44,6 +44,7 @@
#include <libeu.h>
 #include <system.h>
+#include <color.h>
 #include "../libebl/libeblP.h"
 #include "../libdwfl/libdwflP.h"
diff --git a/src/objdump.c b/src/objdump.c
index fff4b81..030274b 100644
--- a/src/objdump.c
+++ b/src/objdump.c
@@ -35,6 +35,7 @@
#include <libeu.h>
 #include <system.h>
+#include <color.h>
 #include "../libebl/libeblP.h"
--
2.1.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]