Skip to content

Commit

Permalink
Add tparm fallback to use under systems having tparm with fixed numbe…
Browse files Browse the repository at this point in the history
…r of paramters, required with Solaris curses. Updated configure script to check for c99 for compilation with Sun Studio under solaris and updated LDFlAGS for fish_pager etc to include library dependencies from common.c etc.

darcs-hash:20070822075741-cac88-5532b074490bce1d7f37289b1774a4a5e44416d8.gz
  • Loading branch information
Claes Nästén committed Aug 22, 2007
1 parent 2994378 commit 74a270e
Show file tree
Hide file tree
Showing 3 changed files with 158 additions and 52 deletions.
139 changes: 88 additions & 51 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,13 @@ AH_BOTTOM([#if __GNUC__ >= 3
# Set up various programs needed for install
#

AC_PROG_CC
# Here we look for c99 before cc as Sun Studio compiler supports c99
# through the c99 binary.

AC_PROG_CC([gcc c99 cc])
AC_PROG_CPP
AC_PROG_INSTALL


#
# Check for seq command. If missing, make sure fallback shellscript
# implementation is installed.
Expand Down Expand Up @@ -232,33 +234,44 @@ fi
#
# Test if the compiler accepts the -std=c99 flag. If so, using it
# increases the odds of correct compilation, since we want to use the
# *wprintf functions, which where defined in C99.
#

XCFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -std=c99"
XCPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -std=c99"
AC_MSG_CHECKING(if -std=c99 works)

AC_CACHE_VAL(
local_cv_has__std_c99,
[
AC_TRY_RUN(
[
#include <stdlib.h>
#include <stdio.h>
# *wprintf functions, which where defined in C99.
#
# NOTE: Never versions of autoconf has AC_CHECK_PROG_CC_C99
#

if test "$CC" != "c99"; then
XCFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -std=c99"
XCPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -std=c99"
AC_MSG_CHECKING(if -std=c99 works)

AC_CACHE_VAL(
local_cv_has__std_c99,
[
AC_TRY_RUN(
[
#include <stdlib.h>
#include <stdio.h>
int main()
{
return 0;
}
],
local_cv_has__std_c99=yes,
local_cv_has__std_c99=no,
)
]
)

int main()
{
return 0;
}
],
local_cv_has__std_c99=yes,
local_cv_has__std_c99=no,
)
]
)
AC_MSG_RESULT($local_cv_has__std_c99)
case x$local_cv_has__std_c99 in
xno)
CFLAGS="$XCFLAGS"
CPPFLAGS="$XCPPFLAGS" ;;
esac
fi

#
# Try to enable large file support. This will make sure that on systems
Expand All @@ -268,20 +281,12 @@ AC_CACHE_VAL(

CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64"

AC_MSG_RESULT($local_cv_has__std_c99)
case x$local_cv_has__std_c99 in
xno)
CFLAGS="$XCFLAGS"
CPPFLAGS="$XCPPFLAGS" ;;
esac


#
# If we are using gcc, set some flags that increase the odds of the
# compiler producing a working binary...
#

if test "$CC" = gcc; then
if test "$GCC" = yes; then

#
# -fno-optimize-sibling-calls seems to work around a bug where
Expand Down Expand Up @@ -387,6 +392,34 @@ case $target_os in
;;
esac

# Check for Solaris curses tputs having fixed length parameter list.
AC_MSG_CHECKING([if we are using non varargs tparm.])
AC_COMPILE_IFELSE(
[
AC_LANG_PROGRAM(
[
#include <curses.h>
#include <term.h>
],
[
tparm( "" );
]
)
],
[tparm_solaris_kludge=no],
[tparm_solaris_kludge=yes]
)
if test "x$tparm_solaris_kludge" = "xyes"; then
AC_MSG_RESULT(yes)
AC_DEFINE(
[TPARM_SOLARIS_KLUDGE],
[1],
[Define to 1 if tparm accepts a fixed amount of paramters.]
)
else
AC_MSG_RESULT(no)
fi


#
# BSD-specific flags go here
Expand Down Expand Up @@ -466,18 +499,26 @@ AC_DEFINE(
# slower compiles when developing fish.
#

# Check for os dependant libraries for all binaries.
LIBS_COMMON=$LIBS
LIBS=""
AC_SEARCH_LIBS( connect, socket, , [AC_MSG_ERROR([Cannot find the socket library, needed to build this package.] )] )
AC_SEARCH_LIBS( nanosleep, rt, , [AC_MSG_ERROR([Cannot find the rt library, needed to build this package.] )] )
AC_SEARCH_LIBS( setupterm, [ncurses curses], , [AC_MSG_ERROR([Could not find a curses implementation, needed to build fish])] )
LIBS_SHARED=$LIBS
LIBS=$LIBS_COMMON

#
# Check for libraries needed by fish.
#

LIBS_COMMON=$LIBS
LIBS=""
LIBS="$LIBS_SHARED"
if test x$local_gettext != xno; then
AC_SEARCH_LIBS( gettext, intl,,)
fi
AC_SEARCH_LIBS( connect, socket, , [AC_MSG_ERROR([Cannot find the socket library, needed to build this package.] )] )
AC_SEARCH_LIBS( nanosleep, rt, , [AC_MSG_ERROR([Cannot find the rt library, needed to build this package.] )] )
AC_SEARCH_LIBS( setupterm, [ncurses curses], , [AC_MSG_ERROR([Could not find a curses implementation, needed to build fish])] )


AC_SEARCH_LIBS( iconv_open, iconv, , [AC_MSG_ERROR([Could not find an iconv implementation, needed to build fish])] )
LIBS_FISH=$LIBS
LIBS=$LIBS_COMMON
Expand All @@ -487,7 +528,7 @@ LIBS=$LIBS_COMMON
#

LIBS_COMMON=$LIBS
LIBS=""
LIBS="$LIBS_SHARED"
if test x$local_gettext != xno; then
AC_SEARCH_LIBS( gettext, intl,,)
fi
Expand All @@ -499,12 +540,10 @@ LIBS=$LIBS_COMMON
#

LIBS_COMMON=$LIBS
LIBS=""
LIBS="$LIBS_SHARED"
if test x$local_gettext != xno; then
AC_SEARCH_LIBS( gettext, intl,,)
fi
AC_SEARCH_LIBS( connect, socket, , [AC_MSG_ERROR([Cannot find the socket library, needed to build this package.] )] )
AC_SEARCH_LIBS( setupterm, [ncurses curses], , [AC_MSG_ERROR([Could not find a curses implementation, needed to build fish])] )
LIBS_FISH_PAGER=$LIBS
LIBS=$LIBS_COMMON

Expand All @@ -513,11 +552,10 @@ LIBS=$LIBS_COMMON
#

LIBS_COMMON=$LIBS
LIBS=""
LIBS="$LIBS_SHARED"
if test x$local_gettext != xno; then
AC_SEARCH_LIBS( gettext, intl,,)
fi
AC_SEARCH_LIBS( connect, socket, , [AC_MSG_ERROR([Cannot find the socket library, needed to build this package.] )] )
LIBS_FISHD=$LIBS
LIBS=$LIBS_COMMON

Expand All @@ -526,11 +564,11 @@ LIBS=$LIBS_COMMON
#

LIBS_COMMON=$LIBS
LIBS=""
LIBS="$LIBS_SHARED"
if test x$local_gettext != xno; then
AC_SEARCH_LIBS( gettext, intl,,)
fi
LIBS_FISHD=$LIBS
LIBS_MIMEDB=$LIBS
LIBS=$LIBS_COMMON


Expand All @@ -539,11 +577,10 @@ LIBS=$LIBS_COMMON
#

LIBS_COMMON=$LIBS
LIBS=""
LIBS="$LIBS_SHARED"
if test x$local_gettext != xno; then
AC_SEARCH_LIBS( gettext, intl,,)
fi
AC_SEARCH_LIBS( setupterm, [ncurses curses], , [AC_MSG_ERROR([Could not find a curses implementation, needed to build fish])] )
LIBS_SET_COLOR=$LIBS
LIBS=$LIBS_COMMON

Expand Down
58 changes: 58 additions & 0 deletions fallback.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,64 @@ int tputs(const char *str, int affcnt, int (*fish_putc)(tputs_arg_t))

#endif

#ifdef TPARM_SOLARIS_KLUDGE

#undef tparm

/**
Checks for known string values and maps to correct number of parameters.
*/
char *tparm_solaris_kludge( char *str, ... )
{
long int param[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };

va_list ap;
va_start( ap, str );

if( ( set_a_foreground && ! strcmp( str, set_a_foreground ) )
|| ( set_a_background && ! strcmp( str, set_a_background ) )
|| ( set_foreground && ! strcmp( str, set_foreground ) )
|| ( set_background && ! strcmp( str, set_background ) )
|| ( enter_underline_mode && ! strcmp( str, enter_underline_mode ) )
|| ( exit_underline_mode && ! strcmp( str, exit_underline_mode ) )
|| ( enter_standout_mode && ! strcmp( str, enter_standout_mode ) )
|| ( exit_standout_mode && ! strcmp( str, exit_standout_mode ) )
|| ( flash_screen && ! strcmp( str, flash_screen ) )
|| ( enter_subscript_mode && ! strcmp( str, enter_subscript_mode ) )
|| ( exit_subscript_mode && ! strcmp( str, exit_subscript_mode ) )
|| ( enter_superscript_mode && ! strcmp( str, enter_superscript_mode ) )
|| ( exit_superscript_mode && ! strcmp( str, exit_superscript_mode ) )
|| ( enter_blink_mode && ! strcmp( str, enter_blink_mode ) )
|| ( enter_italics_mode && ! strcmp( str, enter_italics_mode ) )
|| ( exit_italics_mode && ! strcmp( str, exit_italics_mode ) )
|| ( enter_reverse_mode && ! strcmp( str, enter_reverse_mode ) )
|| ( enter_shadow_mode && ! strcmp( str, enter_shadow_mode ) )
|| ( exit_shadow_mode && ! strcmp( str, exit_shadow_mode ) )
|| ( enter_standout_mode && ! strcmp( str, enter_standout_mode ) )
|| ( exit_standout_mode && ! strcmp( str, exit_standout_mode ) )
|| ( enter_secure_mode && ! strcmp( str, enter_secure_mode ) )
|| ( enter_bold_mode && ! strcmp ( str, enter_bold_mode ) ) )
{
param[0] = va_arg( ap, long int );
}
else if( cursor_address && ! strcmp( str, cursor_address ) )
{
param[0] = va_arg( ap, long int );
param[1] = va_arg( ap, long int );
}

va_end( ap );


return tparm( str, param[0], param[1], param[2], param[3],
param[4], param[5], param[6], param[7], param[8] );
}

// Re-defining just to make sure nothing breaks further down in this file.
#define tparm tparm_solaris_kludge

#endif


#ifndef HAVE_FWPRINTF
#define INTERNAL_FWPRINTF 1
Expand Down
13 changes: 12 additions & 1 deletion fallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ int tputs(const char *str, int affcnt, int (*fish_putc)(tputs_arg_t));

#endif

#ifdef TPARM_SOLARIS_KLUDGE

/**
Solaris tparm has a set fixed of paramters in it's curses implementation,
work around this here.
*/

#define tparm tparm_solaris_kludge
char *tparm_solaris_kludge( char *str, ... );

#endif

#ifndef HAVE_FWPRINTF

/**
Expand Down Expand Up @@ -424,4 +436,3 @@ int getopt_long(int argc,
#endif

#endif

0 comments on commit 74a270e

Please sign in to comment.