Explorar o código

Detect the curses headers to use instead of hardcoding them

Wrap the curses headers to use and select them through the config.h macros
detected at configure time. This way we can also cleanly detect the path
needed by mkcurkeys.pl w/o duplicating the selection logic.
Guillem Jover %!s(int64=17) %!d(string=hai) anos
pai
achega
51926eebbb
Modificáronse 7 ficheiros con 54 adicións e 5 borrados
  1. 0 1
      TODO
  2. 1 0
      debian/changelog
  3. 4 2
      dselect/Makefile.am
  4. 40 0
      dselect/dselect-curses.h
  5. 1 2
      dselect/dselect.h
  6. 6 0
      dselect/main.cc
  7. 2 0
      m4/libs.m4

+ 0 - 1
TODO

@@ -45,7 +45,6 @@ squeeze + 1
    - Refactor src/processarc.c.
    - Make sure all vsnprintf callers are checking the return value, as the
      system version will not ohsite on us.
-   - Fix ncursesw headers.
    - Consider ferror_fclose function.
    - Fix naming consistency of next/prev members.
    - Do more unused header include removal.

+ 1 - 0
debian/changelog

@@ -61,6 +61,7 @@ dpkg (1.15.1) UNRELEASED; urgency=low
     - Remove m68k.
     - Add kfreebsd-i386 and kfreebsd-amd64.
   * Add avr32 to cputable. Closes: #523456
+  * Detect the curses headers to use instead of hardcoding them.
 
   [ Frank Lichtenheld ]
   * Dpkg::Version: Remove unnecessary function next_elem which just

+ 4 - 2
dselect/Makefile.am

@@ -15,6 +15,7 @@ bin_PROGRAMS = dselect
 
 dselect_SOURCES = \
 	dselect.h \
+	dselect-curses.h \
 	basecmds.cc \
 	baselist.cc \
 	basetop.cc \
@@ -47,8 +48,9 @@ CLEANFILES = curkeys.h
 
 curkeys.$(OBJEXT): curkeys.h
 curkeys.h: $(srcdir)/keyoverride $(srcdir)/mkcurkeys.pl
-	cursesfile=`echo '#include <ncursesw/curses.h>' | \
-		$(CPP) - | grep 'curses.h' | head -n 1 | \
+	cursesfile=`echo '#include <dselect-curses.h>' | \
+		$(CPP) -I$(top_srcdir) -I$(srcdir) - | \
+		grep 'curses.h' | head -n 1 | \
 		sed -e 's/^[^"]*"//; s/".*$$//'`; \
 	if [ "$$cursesfile" = "" ]; then \
 		echo "can't find curses file"; exit 1; \

+ 40 - 0
dselect/dselect-curses.h

@@ -0,0 +1,40 @@
+/* -*- c++ -*-
+ * dselect - selection of Debian packages
+ * dselect-curses.h - curses header wrapper
+ *
+ * Copyright © 2009 Guillem Jover <guillem@debian.org>
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2,
+ * or (at your option) any later version.
+ *
+ * This 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 a copy of the GNU General Public
+ * License along with dpkg; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef DSELECT_CURSES_H
+#define DSELECT_CURSES_H
+
+#include <config.h>
+
+#undef ERR
+
+#if defined(HAVE_NCURSESW_NCURSES_H)
+#include <ncursesw/ncurses.h>
+#elif defined(HAVE_NCURSES_NCURSES_H)
+#include <ncurses/ncurses.h>
+#elif defined(HAVE_NCURSES_H)
+#include <ncurses.h>
+#else
+#include <curses.h>
+#endif
+
+#endif /* DSELECT_CURSES_H */
+

+ 1 - 2
dselect/dselect.h

@@ -29,8 +29,7 @@
 #define MAX_DISPLAY_INFO 120
 
 #include <signal.h>
-#undef ERR
-#include <ncursesw/curses.h>
+#include <dselect-curses.h>
 
 struct helpmenuentry {
   char key;

+ 6 - 0
dselect/main.cc

@@ -43,7 +43,13 @@
 #include <locale.h>
 #endif
 
+#if defined(HAVE_NCURSESW_TERM_H)
 #include <ncursesw/term.h>
+#elif defined(HAVE_NCURSES_TERM_H)
+#include <ncurses/term.h>
+#else
+#include <term.h>
+#endif
 
 #include <dpkg.h>
 #include <dpkg-db.h>

+ 2 - 0
m4/libs.m4

@@ -93,6 +93,8 @@ fi
 # Check for curses library.
 AC_DEFUN([DPKG_LIB_CURSES],
 [AC_ARG_VAR([CURSES_LIBS], [linker flags for curses library])dnl
+AC_CHECK_HEADERS([ncursesw/ncurses.h ncurses/ncurses.h ncurses.h curses.h \
+                  ncursesw/term.h ncurses/term.h term.h])
 AC_CHECK_LIB([ncursesw], [initscr], [CURSES_LIBS="${CURSES_LIBS:+$CURSES_LIBS }-lncursesw"],
 	[AC_CHECK_LIB([ncurses], [initscr], [CURSES_LIBS="${CURSES_LIBS:+$CURSES_LIBS }-lncurses"],
 		[AC_CHECK_LIB([curses], [initscr], [CURSES_LIBS="${CURSES_LIBS:+$CURSES_LIBS }-lcurses"],