The following commit has been merged in the master branch:
commit 51926eebbba1f20c3bf994e7364512a1c63a25f2
Author: Guillem Jover <[email protected]>
Date:   Mon Apr 13 04:57:43 2009 +0200

    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.

diff --git a/TODO b/TODO
index 0b13e06..77760d3 100644
--- a/TODO
+++ b/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.
diff --git a/debian/changelog b/debian/changelog
index bce89c2..72c9902 100644
--- a/debian/changelog
+++ b/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
diff --git a/dselect/Makefile.am b/dselect/Makefile.am
index 40c0b16..dfade7c 100644
--- a/dselect/Makefile.am
+++ b/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; \
diff --git a/lib/test/t-pkginfo.c b/dselect/dselect-curses.h
similarity index 62%
copy from lib/test/t-pkginfo.c
copy to dselect/dselect-curses.h
index 0172d8f..254eb5d 100644
--- a/lib/test/t-pkginfo.c
+++ b/dselect/dselect-curses.h
@@ -1,6 +1,6 @@
-/*
- * libdpkg - Debian packaging suite library routines
- * t-pkginfo.c - test pkginfo handling
+/* -*- c++ -*-
+ * dselect - selection of Debian packages
+ * dselect-curses.h - curses header wrapper
  *
  * Copyright © 2009 Guillem Jover <[email protected]>
  *
@@ -19,26 +19,22 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#include <dpkg-test.h>
-#include <dpkg-db.h>
+#ifndef DSELECT_CURSES_H
+#define DSELECT_CURSES_H
 
-static void
-test_pkginfo_informative(void)
-{
-       struct pkginfo pkg;
+#include <config.h>
 
-       blankpackage(&pkg);
-       pkg.want = want_purge;
-       test_pass(informative(&pkg, &pkg.installed));
+#undef ERR
 
-       /* FIXME: Complete. */
-}
+#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
 
-static void
-test(void)
-{
-       test_pkginfo_informative();
-
-       /* FIXME: Complete. */
-}
+#endif /* DSELECT_CURSES_H */
 
diff --git a/dselect/dselect.h b/dselect/dselect.h
index 3faa1fa..652b8b7 100644
--- a/dselect/dselect.h
+++ b/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;
diff --git a/dselect/main.cc b/dselect/main.cc
index 82ff324..7b05220 100644
--- a/dselect/main.cc
+++ b/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>
diff --git a/m4/libs.m4 b/m4/libs.m4
index 1b3cb24..29f2028 100644
--- a/m4/libs.m4
+++ b/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"],

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to