Project

General

Profile

Bug #149

dfc does not build on FreeBSD 7.x

Added by Robin Hahling over 4 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
-
Start date:
09/29/2012
Due date:
% Done:

0%


Description

As the FreeBSD team reported:

We at FreeBSD.org noted that dfc doesn't build on FreeBSD 7.x

  src/util.c: In function 'getttywidth':
  src/util.c:99: error: 'struct ttysize' has no member named 'ws_col'
  *** Error code 1

This is because dfc makes a false assumption about TIOCGSIZE that since
it's there then this is an old system and dfc should use only this:
struct ttysize, TIOCGSIZE and TIOCSSIZE and friends. But this is not so.
FreeBSD supports both older TIOC[GS]SIZE and TIOC[SG]WINSZ. Up to
FreeBSD 7.x TIOCGSIZE presents purely for SunOS 3.2 compatibility.
TIOC[SG]WINSZ is what actually used there. FYI, in the newer FreeBSD
versions (since 8.0) a compatibility for struct ttysize, TIOCGSIZE and
TIOCSSIZE is removed.

This is a first draft to fix the problem.

--- src/util.c.orig     2012-05-31 02:25:46.000000000 +0400
+++ src/util.c  2012-07-24 15:27:31.000000000 +0400
@@ -48,6 +48,10 @@
 #include <libintl.h>
 #endif

+#ifdef TIOCGSIZE
+#undef TIOCGSIZE
+#endif
+
 /*
  * Return the longest of the two parameters
  * @a: first element to compare

But this way is not very clever.
Another way to solve the problem is to use win.ts_cols in struct ttysize
instead of win.ws_col as currently coded in dfc for otherBSD:

--- src/util.c.orig     2012-07-24 15:20:00.000000000 +0400
+++ src/util.c  2012-07-24 15:19:52.000000000 +0400
@@ -179,18 +179,18 @@

 #ifdef TIOCGSIZE
        if (ioctl(STDOUT_FILENO, TIOCGSIZE, &win) == 0)
-#if defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__)
|| defined(__DragonFly__)
+#if defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__)
|| defined(__DragonFly__) || defined(__FreeBSD__)
                width = win.ts_cols;
 #else
                width = win.ws_col;
 #endif /* __APPLE__ || __NetBSD__ || __OpenBSD__ || __DragonFly__ */
 #elif defined(TIOCGWINSZ)
        if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) == 0)
-#if defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__)
|| defined(__DragonFly__)
+#if defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__)
|| defined(__DragonFly__) || defined(__FreeBSD__)
                width = win.ts_cols;
 #else
                width = win.ws_col;
-#endif /* __APPLE__ || __NetBSD__ || __OpenBSD__ || __DragonFly__ */
+#endif /* __APPLE__ || __NetBSD__ || __OpenBSD__ || __DragonFly__ ||
defined(__FreeBSD__) */
 #endif /* TIOCGSIZE */
        return width == 0 ? 80 : width;
        /* NOTREACHED */

Personal comment: first fix is not desirable and the second one causes dfc not to build on FreeBSD 9.x (at least).

History

#1 Updated by Robin Hahling over 3 years ago

  • Status changed from New to Closed

Closing since FreeBSD 7 is no longer maintained.

Also available in: Atom PDF