Merge branch 'master' of ssh://dio.dreamhost.com/~/repos.nelsonferreira.com/git/sxema...
authorNelson Ferreira <nelson.ferreira@ieee.org>
Tue, 6 Mar 2012 07:18:25 +0000 (02:18 -0500)
committerNelson Ferreira <nelson.ferreira@ieee.org>
Tue, 6 Mar 2012 07:18:25 +0000 (02:18 -0500)
36 files changed:
autogen.sh
configure.ac
contrib/README
contrib/git-for-steve.sh [new file with mode: 0755]
lib-src/etags.c
lib-src/fakemail.c
lib-src/gnuclient.c
lib-src/gnuserv.c
lib-src/make-dump-id.c
lib-src/movemail.c
lib-src/ootags.c
lib-src/pop.c
lib-src/yow.c
lisp/ffi.el
m4/sxe-aux.m4
m4/sxe-linker.m4
m4/sxe-summary.m4
src/buffer.c
src/database/postgresql.c
src/dumper.c
src/editfns.c
src/effi.c
src/emacs.c
src/emodules-ng.c
src/eval.c
src/extents.c
src/fileio.c
src/media/media.c
src/media/sound-oss.c
src/search.c
src/sxe-utils.h
src/sysdep.c
src/sysdep.h
src/sysfile.h
src/ui/redisplay.c
src/ui/window.c

index 4b2ee13..03fb91a 100755 (executable)
@@ -52,14 +52,21 @@ emacs_is_beta=t
 if test -n "$GIT" -a -n "$($GIT symbolic-ref HEAD 2>/dev/null)"; then
        TREE_VERSION="$($GIT tag|tail -n1|tr -d v)"
        GIT_VERSION="$($GIT describe | head -n1)"
+       GIT_BRANCH="$(git branch --no-color | awk '/^\*/ { print $2 }')"
        IN_GIT="1"
 fi
 if test -z "$TREE_VERSION"; then
        TREE_VERSION="$EXPECTED_TREE_VERSION"
        if test -n "$IN_GIT"; then
-           echo "If you cloned this branch into your own you should issue:"
+           echo "If you cloned this branch into your own you could issue:"
            echo "\tgit tag -s v${TREE_VERSION}.<your branch_name>"
-           echo "\tgit push --tag"
+           echo ""
+           echo "Be careful about pushing the tags as they probably will be "
+           echo "more of a nuisance..."
+           echo ""
+           TREE_VERSION="$EXPECTED_TREE_VERSION.$GIT_BRANCH"
+           echo "For now I am assuming the tre version will be $TREE_VERSION"
+           echo ""
        fi
 fi
 if test -z "$GIT_VERSION"; then
index b60d62b..a6d48ef 100644 (file)
@@ -31,7 +31,7 @@ AC_COPYRIGHT(
 #### Copyright (C) 2005 Malcolm Purvis.
 #### Copyright (C) 2005, 2006, 2007 Steve Youngs.
 #### Copyright (C) 2006, 2007, 2008 Sebastian Freundt.
-#### Copyright (C) 2007, 2010, 2011 Nelson Ferreira
+#### Copyright (C) 2007, 2010, 2011, 2012 Nelson Ferreira
 
 ### Don't edit this script!
 ### This script was automatically generated by the `autoconf' program
@@ -346,9 +346,6 @@ OG_MULTIARG_WITH([static-modules], [dnl
        OG_MULTIARG_ITEM([cl], [cl], [fast Common Lisp implementation])
 ])
 
-dnl _OG_MULTIARG_ITEM([ent], [int], [int], [native integer arithmetics])
-dnl _OG_MULTIARG_ITEM([ent], [fpfloat], [fpfloat], [native fixed precision floats])
-dnl _OG_MULTIARG_ITEM([ent], [indef], [indef], [abstract indefinites])
 OG_MULTIARG_WITH([ent], [dnl
        AS_HELP_STRING([--with-ent], [
                Compile in support for enhanced number types,
@@ -551,6 +548,27 @@ OG_ARG_WITH([ncurses],
                [Use the ncurses library for tty support.]),
        [auto], [Autodetect])
 
+OG_ARG_WITH([curses],
+       AS_HELP_STRING([--with-curses],
+               [Use the curses library for tty support.]),
+       [auto], [Autodetect])
+
+OG_ARG_WITH([terminfo],
+       AS_HELP_STRING([--with-terminfo],
+               [Use the terminfo library for tty support.]),
+       [auto], [Autodetect])
+
+OG_ARG_WITH([termlib],
+       AS_HELP_STRING([--with-termlib],
+               [Use the termlib library for tty support.]),
+       [auto], [Autodetect])
+
+OG_ARG_WITH([termcap],
+       AS_HELP_STRING([--with-termcap],
+               [Use the termcap library for tty support.]),
+       [auto], [Autodetect])
+
+
 OG_ARG_WITH([gpm],
        AS_HELP_STRING([--with-gpm],
                [Compile in GPM mouse support for ttys.]),
@@ -740,9 +758,8 @@ dnl
 ## -------------------------------------------------------------------------
 ## Check for users who regularly forget about running autoconf
 ## -------------------------------------------------------------------------
-if test -f $0.ac -a $0.ac -nt $0; then
-       AC_MSG_ERROR([What are you doing? RUN autoreconf NOW!!!])
-fi
+AS_IF([test -f "$0.ac" -a "$0.ac" -nt "$0"],
+   AC_MSG_ERROR([What are you doing? RUN autoreconf NOW!!!]))
 
 #
 # Turn off core generation. We are already verifying the program fails, no need
@@ -787,6 +804,7 @@ dnl -------------------------------------------------------------------------
 SXE_CHECK_COMMAND_LINE
 
 AM_INIT_AUTOMAKE([foreign -Wall])
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
 SXE_CHECK_BUILDCHAIN
 AC_SUBST(EGREP)
 
@@ -810,22 +828,16 @@ AC_CHECK_PROG([have_git], [git], [yes], [no])
 AC_MSG_CHECKING([for SXEmacs version])
 AC_MSG_RESULT([SXEmacs SXEM4CS_VERSION])
 dnl Must do the following first to determine verbosity for AC_DEFINE
-if test -n "[]SXEM4CS_BETA_P[]"; then
-       beta=yes
-else
-       beta=no
-fi
+AS_IF([test -n "[]SXEM4CS_BETA_P[]"],beta=yes,beta=no)
 : "${extra_verbose=$beta}"
 
 AC_MSG_CHECKING([for SXEmacs patchlevel])
 CURDIR=$(pwd)
 cd "$sxe_srcdir"
-if test "$have_git" = "yes"; then
-       sxemacs_git_version="$(git describe | head -1)"
-fi
-if test -z "$sxemacs_git_version" ; then
-       sxemacs_git_version="[]SXEM4CS_GIT_VERSION[]"
-fi
+AS_IF([test "$have_git" = "yes"], 
+           [sxemacs_git_version=`git describe | head -1`])
+AS_IF([test -z "$sxemacs_git_version"],
+       sxemacs_git_version="[]SXEM4CS_GIT_VERSION[]")
 AC_MSG_RESULT([$sxemacs_git_version])
 version="$sxemacs_git_version"
 cd "$CURDIR"
@@ -1250,9 +1262,8 @@ SXE_CHECK_FILE_LOCK
 
 case "$opsys" in decosf*)
        AC_CHECK_LIB([pthreads], [cma_open])
-       if test "$ac_cv_lib_pthreads_cma_open" = "yes"; then
-               c_switch_site="$c_switch_site -threads"
-       fi
+       AS_IF([test "$ac_cv_lib_pthreads_cma_open" = "yes"],
+               c_switch_site="$c_switch_site -threads")
        ;;
 esac
 
@@ -1674,7 +1685,12 @@ dnl Check for POSIX functions.
 dnl ----------------------------------------------------------------
 
 SXE_CHECK_BASIC_FUNS
-AC_CHECK_FUNCS([alarm cbrt closedir dup2 eaccess endpwent floor fmod fpathconf frexp fsync ftime ftruncate getaddrinfo getcwd gethostbyname gethostname getnameinfo getpagesize getrlimit gettimeofday getwd isascii link logb lrand48 matherr memchr memmove memset mkdir mktime munmap perror poll pow putenv random re_comp readlink regcomp rename res_init rint rmdir select setitimer setlocale setpgid setsid sigblock sighold sigprocmask snprintf socket sqrt stpcpy strcasecmp strchr strdup strerror strlwr strrchr strspn strtol strupr symlink tzset ulimit umask uname usleep utime vlimit vsnprintf waitpid wcscmp wcslen])
+AC_CHECK_FUNCS([alarm cbrt closedir dup2 eaccess endpwent floor fmod fpathconf frexp fsync ftime ftruncate getaddrinfo getcwd gethostbyname gethostname getnameinfo getpagesize getrlimit gettimeofday getwd isascii isatty link logb lrand48 matherr memchr memmove memset mkdir mktime munmap perror poll pow putenv random re_comp readlink regcomp rename res_init rint rmdir select setitimer setlocale setpgid setsid sigblock sighold sigprocmask snprintf socket sqrt stpcpy strncpy strncat strcasecmp strchr strdup strerror strlwr strrchr strspn strtol strupr symlink ttyname tzset ulimit umask uname usleep utime vlimit vsnprintf waitpid wcscmp wcslen])
+
+AS_IF([test "$have_isatty" = "yes"],
+       AC_DEFINE([HAVE_ISATTY], [1], [isatty is available]))
+AS_IF([test "$have_ttyname" = "yes"],
+       AC_DEFINE([HAVE_TTYNAME], [1], [ttyname is available]))
 
 
 ## combines all these time structures and funs
@@ -2375,9 +2391,8 @@ if test "$with_x11" = "yes"; then
        dnl Avoid version mismatch for shared library libXm.so on osf4
        case "$opsys" in
        decosf*)
-               if test "$GCC" = yes -a -d "/usr/shlib"; then
-                       SXE_APPEND([-L/usr/shlib], [X_LIBS]);
-               fi
+               AS_IF([test "$GCC" = yes -a -d "/usr/shlib"],
+                       SXE_APPEND([-L/usr/shlib], [X_LIBS]))
                ;;
        esac
 
@@ -2555,11 +2570,6 @@ fi
 
 dnl Test for features that require X11 support
 if test "$with_x11" != "yes"; then
-  dnl It ought to be reasonable to have no output device at all, and only use
-  dnl SXEmacs in --batch mode.
-  dnl if test "$with_tty" = "no" ; then
-  dnl   AC_MSG_ERROR([No window system support and no TTY support - Unable to proceed.])
-  dnl fi
   for feature in offix wmcommand xim xmu nas_sound
   do
     if eval "test -n \"\$with_${feature}\" -a \"\$with_${feature}\" != no" ; then
@@ -2693,17 +2703,64 @@ dnl ---------------------
 dnl checks for header files
 AC_CHECK_HEADERS([libintl.h nlist.h sgtty.h termio.h termios.h])
 
-if test "$with_tty" != "no"  ; then
-       AS_MESSAGE(checking for TTY-related features)
-       AC_DEFINE([HAVE_TTY], [1], [Description here!])
-       AC_DEFINE([HAVE_UNIXOID_EVENT_LOOP], [1], [Description here!])
-       SXE_ADD_SXEUITTY_OBJS([console-tty.o device-tty.o event-tty.o frame-tty.o objects-tty.o redisplay-tty.o cm.o])
+AS_IF([test "$with_tty" != "no"],[
+   AS_MESSAGE(checking for TTY-related features)
+   dnl Check if needed calls are available at all...
+   tty_libs="ncurses curses terminfo termlib termcap"
+   tty_funcs="tgetent tgetstr tgetflag tparm tgoto tputs"
+   for func in $tty_funcs; do
+       AC_SEARCH_LIBS($func,$tty_libs)
+   done
+   AS_IF([test "$ac_cv_search_tgetent"  = "no" -a \
+              "$ac_cv_search_tgetflag" = "no" -a \
+              "$ac_cv_search_tgetstr"  = "no" -a \
+              "$ac_cv_search_tgoto"    = "no" -a \
+              "$ac_cv_search_tparm"    = "no" -a \
+              "$ac_cv_search_tputs"    = "no" ], 
+                  have_tty=no)
+   AS_IF([test "$with_tty" = "yes" -a "$have_tty" = "no" ],[
+      AC_MSG_ERROR([Your system lacks necessary functions for requested TTY support])])
+],[
+  for feature in ncurses curses termcap terminfo termlib gpm; do
+    if eval "test -n \"\$with_${feature}\" -a \"\$with_${feature}\" != no" ; then
+      AC_MSG_WARN([--with-${feature} ignored:  Not valid without TTY support])
+    fi
+    eval "with_${feature}=no"
+  done
+])
+
+AS_IF([test "$with_tty" != "no" -a "$have_tty" != "no" ],[
+   for lib in $tty_libs; do 
+      SXE_CHECK_LINK_LIB($lib, , eval have_${lib}=no)
+      with_lib_eval=`eval echo \\$with_$lib`
+      have_lib_eval=`eval echo \\$have_$lib`
+      AS_IF([test "$have_lib_eval" = "yes" ], [
+        for func in $tty_funcs; do
+            AC_CHECK_LIB($lib, tgetent)
+            AC_CHECK_LIB($lib, tgetstr)
+            AC_CHECK_LIB($lib, tgetflags)
+            AC_CHECK_LIB($lib, tparm)
+            AC_CHECK_LIB($lib, tgoto)
+            AC_CHECK_LIB($lib, tputs)
+        done
+      ])
+      have_lib_eval=`eval echo \\$have_$lib`
+      AS_IF([test "$with_lib_eval" = "yes" -a \
+                 "$have_lib_eval" = "no" ],
+       AC_MSG_WARN([Errors detected trying to use requested $lib. Continuing with autodetection.]))
+   done
+   AS_IF([test "$sxe_cv_c_lib_ncurses"  = "no" -a \
+               "$sxe_cv_c_lib_curses"   = "no" -a \
+              "$sxe_cv_c_lib_termcap"  = "no" -a \
+              "$sxe_cv_c_lib_terminfo" = "no" -a \
+              "$sxe_cv_c_lib_termlib"  = "no"], 
+                  have_tty=no)
+   AS_IF([test "$with_tty" = "yes" -a "$have_tty" = "no"],
+      AC_MSG_ERROR([Your system lacks necessary libraries for requested TTY support.]))
+])
+
 
-  dnl Autodetect ncurses.
-  AC_CHECK_LIB(ncurses, tgetent, , with_ncurses=no)
-  AC_CHECK_LIB(ncurses, tgetstr, , with_ncurses=no)
-  AC_CHECK_LIB(ncurses, tparm, , with_ncurses=no)
-  if test "$with_ncurses" != "no"; then
+AS_IF([test "$with_tty" != "no" -a "$have_tty" != "no" ],[
     AC_DEFINE([HAVE_NCURSES], [1], [Description here!])
     with_ncurses=yes
     AC_CHECK_HEADER(ncurses/ncurses.h, curses_h_file=ncurses/ncurses.h)
@@ -2744,7 +2801,9 @@ if test "$with_tty" != "no"  ; then
        else c_switch_site="$save_c_switch_site"
       fi
     fi
-  fi
+])
+
+AS_IF([test "$with_tty" != "no" -a "$have_ncurses" != "no" ],[
   if test "$with_ncurses" = "no" -o -z "$curses_h_file" ; then
 
     # Check alternate library includes
@@ -2778,32 +2837,35 @@ if test "$with_tty" != "no"  ; then
   AC_DEFINE_UNQUOTED([CURSES_H_FILE], ["${curses_h_file-curses.h}"], [The curses.h header file])
   AC_DEFINE_UNQUOTED([TERMCAP_H_FILE], ["${termcap_h_file-termcap.h}"], [The termcap.h header file])
   AC_DEFINE_UNQUOTED([TERM_H_FILE], ["${term_h_file-term.h}"], [The term.h header file])
+])
 
+AS_IF([test "$with_tty" != "no" -a "$have_tty" != no], [
+       AC_DEFINE([HAVE_TTY], [1], [Include TTY support for SXEmacs])
+       AC_DEFINE([HAVE_UNIXOID_EVENT_LOOP], [1], [Include Unixoid event loop - TTY provided])
+       SXE_ADD_SXEUITTY_OBJS([console-tty.o device-tty.o event-tty.o frame-tty.o objects-tty.o redisplay-tty.o cm.o])
+])
+AS_IF([test "$with_tty" != "no" -a "$have_tty" != no], [
   dnl General Purpose Mouse (libgpm) support
-  if test "$with_gpm" != "no"; then
+  AS_IF([test "$with_gpm" != "no"], [
     AC_CHECK_HEADER(gpm.h, [
       AC_CHECK_LIB(gpm, Gpm_Open, have_gpm=yes)])
-    if test "$have_gpm" = "yes"; then
+    AS_IF([test "$have_gpm" = "yes"], [
       with_gpm=yes
       AC_DEFINE([HAVE_GPM], [1], [General Purpose Mouse (libgpm) is available])
       SXE_ADD_SXEUITTY_OBJS(gpmevent.o)
-      SXE_PREPEND(-lgpm, LIBS)
-    else
-      with_gpm=no
-    fi
-  fi
-
-else dnl "$with_tty" = "no"
-  for feature in ncurses gpm; do
-    if eval "test -n \"\$with_${feature}\" -a \"\$with_${feature}\" != no" ; then
-      AC_MSG_WARN([--with-${feature} ignored:  Not valid without TTY support])
-    fi
-    eval "with_${feature}=no"
-  done
-fi dnl with_tty
+      SXE_PREPEND(-lgpm, LIBS) ],[ with_gpm=no ])
+  ])
+])
 
 SXE_CHECK_UI_SUFFICIENCY
 
+AS_IF([test -z "$window_system" -o "$window_system" != "none" ], [
+    dnl It ought to be reasonable to have no output device at all, and only use
+    dnl SXEmacs in --batch mode.
+    AS_IF([test "$with_tty" = "no"],
+       AC_MSG_WARN([No window system nor TTY support. You only can use --batch mode.]))
+])
+
 ## Uncertain options
 ## =================
 echo
index 0999b12..f68a4a6 100644 (file)
@@ -7,7 +7,7 @@ File List:
 =========
        do_builds.sh..................automate builds
        git-post-receive-hook.sample..git hook to send email automatically for merge requests
-       git-to-steve.sh...............setup a for-steve branch to send patches to the master branch
+       git-for-steve.sh..............setup a for-steve branch to send patches to the master branch
        make-pkg.sh...................bash script to create a SXEmacs tar package 
        pop3.el.patch.................SXEmacs native OpenSSL goodies 
         report-build-failure.sh.......bash script to send a build report failure 
@@ -71,7 +71,7 @@ script which should come with your git install.
 Nelson Ferreira <njsf@sxemacs.org>
 
 
-git-to-steve.sh
+git-for-steve.sh
 ---------------
 
 This script will check your git configuration, give you some
diff --git a/contrib/git-for-steve.sh b/contrib/git-for-steve.sh
new file mode 100755 (executable)
index 0000000..9bcc9b4
--- /dev/null
@@ -0,0 +1,85 @@
+#!/bin/sh
+#
+# A script to setup your git area to contribute back to SXEmacs
+#
+# (C) 2008 Nelson Ferreira
+#
+# This program is free software; you can redistribute it and/or modify it
+# under a BSD-like licence.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+# Redistributions of source code must retain the above copyright notice, this
+# list of conditions and the following disclaimer.
+# Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+# Neither the name of the Technical University of Berlin nor the names of its
+# contributors may be used to endorse or promote products derived from this
+# software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+USER_EMAIL=$(git config user.email)
+if [ -z "$USER_EMAIL" ]; then
+    echo "You need to setup your email address with:"
+    echo "    git config user.email <your email address>"
+    exit 1
+fi
+USER_NAME=$(git config user.name)
+if [ -z "$USER_NAME" ]; then
+    echo "You need to configure git with your name:"
+    echo "    git config user.name \"John Doe\""
+    exit 1
+fi
+git branch --track for-steve origin/master
+git checkout for-steve
+echo ""
+SIGNKEY=$(git config user.signingkey)
+if [ -z "$SIGNKEY" ]; then
+    echo "OPTIONAL: You might wish to setup your GPG signing key:"
+    echo "    git config user.signingkey <GPG key signature>"
+fi
+CO_ALIAS=$(git config alias.co)
+if [ -z "$CO_ALIAS" ]; then
+    echo "RECOMMENDED: It is recommended you define the 'co' alias"
+    echo "             to quickly switch betwen the master and "
+    echo "             for-steve branches."
+    echo "    git config alias.co checkout"
+fi
+REMOTE=$(git remote | grep -v origin)
+if [ -z "$REMOTE" ]; then
+    echo "MANDATORY: You now must configure your remote repository "
+    echo "           location using:"
+    echo "    git remote add <myremote> <repository location>"
+    echo ""
+    echo "           We recommend that you use 'myremote' explicitly"
+    echo "           for the remote name, but it can be whatever name"
+    echo "           you wish, except origin"
+    echo "           The repository location can be either a git server"
+    echo "               git://example.com/sxemacs.git"
+    echo "           or an ssh accessible location:"
+    echo "               ssh://user@example.com/~/path/to/git"
+    echo "           in this last case it is VERY convenient that you "
+    echo "           setup SSH public key authentication."
+else
+    echo "Please verify that one of these remotes is for your SXEmacs "
+    echo "public repository"
+    for r in $REMOTE; do
+       git remote show $r
+    done
+fi
+echo ""
+echo "Make sure to read the SPPM for more information."
+echo "Info node: (sppm)Setting up a publicly accessible repo"
+echo ""
index 15bad19..3c787fc 100644 (file)
@@ -233,7 +233,12 @@ extern int optind, opterr;
 
 #define bool int
 
-#define xstrncpy(d_,s_,l_) do { char* dst_=d_; dst_[0]='\0'; strncat((dst_),(s_),(l_)-1); } while(0)
+#define xstrncpy(d_,s_,l_)                     \
+       do {                                    \
+               char* dst_=d_;                  \
+               dst_[0]='\0';                   \
+               strncat((dst_),(s_),(l_)-1);    \
+       } while(0)
 
 typedef void Lang_function __P((FILE *));
 
index a2b67b7..9da9121 100644 (file)
@@ -128,6 +128,13 @@ struct linebuffer lb;
 #define MAIL_PROGRAM_NAME "/bin/mail"
 #endif
 
+#define xstrncpy(d_,s_,l_)                     \
+       do {                                    \
+               char* dst_=d_;                  \
+               dst_[0]='\0';                   \
+               strncat((dst_),(s_),(l_)-1);    \
+       } while(0)
+
 static const char *my_name;
 static char *the_date;
 static char *the_user;
@@ -311,23 +318,23 @@ static line_list make_file_preface(void)
        /* the_user */
        the_user_len = strlen(temp);
        the_user = alloc_string(the_user_len + 1);
-       strncpy(the_user, the_user_len, temp);
+       xstrncpy(the_user, the_user_len, temp);
        /* alloc the_string */
        the_string_len = 3 + prefix_length + the_user_len + date_length;
        the_string = alloc_string(the_string_len);
        temp_len = the_string_len;
        temp = the_string;
-       strncpy(temp, temp_len, FROM_PREFIX);
+       xstrncpy(temp, temp_len, FROM_PREFIX);
 
        temp = &temp[prefix_length];
        *temp++ = ' ';
        temp_len -= prefix_length + 1;
-       strncpy(temp, temp_len, the_user);
+       xstrncpy(temp, temp_len, the_user);
 
        temp = &temp[the_user_len];
        *temp++ = ' ';
        temp_len -= the_user_len + 1;
-       strncpy(temp, temp_len, the_date);
+       xstrncpy(temp, temp_len, the_date);
 
        result = new_list();
        result->string = the_string;
@@ -563,7 +570,7 @@ static header read_header(void)
                }
                *next_line = new_list();
                (*next_line)->string = alloc_string((size_t) length);
-               strncpy(((*next_line)->string), length, line);
+               xstrncpy(((*next_line)->string), length, line);
                next_line = &((*next_line)->continuation);
                *next_line = NIL;
 
@@ -610,7 +617,7 @@ int main(int argc, char *argv[])
        the_header = read_header();
        command_line_len = name_length + args_size(the_header);
        command_line = alloc_string(command_line_len);
-       strncpy(command_line, command_line_len, mail_program_name);
+       xstrncpy(command_line, command_line_len, mail_program_name);
        parse_header(the_header, &command_line[name_length]);
 
        the_pipe = popen(command_line, "w");
index 5328b97..203f76d 100644 (file)
@@ -59,6 +59,13 @@ char gnuserv_version[] = "gnuclient version " GNUSERV_VERSION;
 
 #include <signal.h>
 
+#define xstrncpy(d_,s_,l_)                     \
+       do {                                    \
+               char* dst_=d_;                  \
+               dst_[0]='\0';                   \
+               strncat((dst_),(s_),(l_)-1);    \
+       } while(0)
+
 #if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && \
     !defined(INTERNET_DOMAIN_SOCKETS)
 int main(int argc, char *argv[])
@@ -210,21 +217,20 @@ static char *clean_string(const char *s)
 {
        int i = 0;
        char *p, *res;
+       const char *const_p;
 
-       {
-               const char *const_p;
-               for (const_p = s; *const_p; const_p++, i++) {
-                       if (*const_p == '\\' || *const_p == '\"')
-                               ++i;
-                       else if (*const_p == '\004')
-                               i += 3;
-               }
+
+       for (const_p = s; *const_p; const_p++, i++) {
+               if (*const_p == '\\' || *const_p == '\"')
+                       ++i;
+               else if (*const_p == '\004')
+                       i += 3;
        }
 
        p = res = (char *)malloc(i + 2 + 1);
        *p++ = '\"';
-       for (; *s; p++, s++) {
-               switch (*s) {
+       for (const_p = s; *const_p; p++, const_p++) {
+               switch (*const_p) {
                case '\\':
                        *p++ = '\\';
                        *p = '\\';
@@ -240,7 +246,7 @@ static char *clean_string(const char *s)
                        *p = 'd';
                        break;
                default:
-                       *p = *s;
+                       *p = *const_p;
                }
        }
        *p++ = '\"';
@@ -400,7 +406,7 @@ int main(int argc, char *argv[])
                                        break;
                                case 'r':
                                        GET_ARGUMENT(remotearg, "-r");
-                                       strncpy(remotepath, remotearg, sizeof(remotepath));
+                                       xstrncpy(remotepath, remotearg, sizeof(remotepath));
                                        remotepath[sizeof(remotepath)-1]='\0';
                                        rflg = 1;
                                        break;
@@ -545,7 +551,7 @@ int main(int argc, char *argv[])
                                         * to this machine */
                                if ((ptr = getenv("GNU_NODE")) != NULL) {
                                        /* user specified a path */
-                                       strncpy(remotepath, ptr, sizeof(remotepath)-1);
+                                       xstrncpy(remotepath, ptr, sizeof(remotepath)-1);
                                        remotepath[sizeof(remotepath)-1]='\0';
                                }
                        }
index 103765c..08649b7 100644 (file)
@@ -59,6 +59,13 @@ char gnuserv_version[] = "gnuserv version" GNUSERV_VERSION;
 #include <string.h>
 #endif                         /* HAVE_STRING_H */
 
+#define xstrncpy(d_,s_,l_)                     \
+       do {                                    \
+               char* dst_=d_;                  \
+               dst_[0]='\0';                   \
+               strncat((dst_),(s_),(l_)-1);    \
+       } while(0)
+
 
 #if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && \
     !defined(INTERNET_DOMAIN_SOCKETS)
@@ -186,7 +193,7 @@ handle_ipc_request(struct msgbuf *msgp)
        }
        /* if */
        msgctl(ipc_qid, IPC_STAT, &msg_st);
-       strncpy(buf, msgp->mtext, len);
+       xstrncpy(buf, msgp->mtext, len);
        /* terminate buf */
        buf[len] = '\0';
 
index 30c38a4..e85e8a3 100644 (file)
@@ -16,7 +16,7 @@ GNU General Public License for more details.
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
-#include <config.h>
+#include "../src/config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include "../src/systime.h"
index f80b95d..9d75782 100644 (file)
@@ -143,6 +143,14 @@ static int pop_search_top(popserver server, int msgno, int lines,
                          struct re_pattern_buffer *regexp);
 #endif
 
+
+#define xstrncpy(d_,s_,l_)                     \
+       do {                                    \
+               char* dst_=d_;                  \
+               dst_[0]='\0';                   \
+               strncat((dst_),(s_),(l_)-1);    \
+       } while(0)
+
 int verbose = 0;
 #ifdef MAIL_USE_POP
 int reverse = 0;
@@ -681,9 +689,9 @@ static char *concat(char *s1, char *s2, char *s3)
        int len1 = strlen(s1), len2 = strlen(s2), len3 = strlen(s3);
        char *result = (char *)xmalloc(len1 + len2 + len3 + 1);
 
-       strncpy(result, s1, len1+1);
-       strncpy(result + len1, s2, len2+1);
-       strncpy(result + len1 + len2, s3, len3+1);
+       xstrncpy(result, s1, len1+1);
+       xstrncpy(result + len1, s2, len2+1);
+       xstrncpy(result + len1 + len2, s3, len3+1);
        *(result + len1 + len2 + len3) = '\0';
 
        return result;
@@ -847,7 +855,7 @@ pop_retr(popserver server, int msgno, int (*action) (char *, FILE *),
        int ret;
 
        if (pop_retrieve_first(server, msgno, &line)) {
-               strncpy(Errmsg, pop_error, sizeof(Errmsg));
+               xstrncpy(Errmsg, pop_error, sizeof(Errmsg));
                Errmsg[sizeof(Errmsg) - 1] = '\0';
                return (POP_ERROR);
        }
@@ -864,7 +872,7 @@ pop_retr(popserver server, int msgno, int (*action) (char *, FILE *),
        }
 
        if (ret) {
-               strncpy(Errmsg, pop_error, sizeof(Errmsg));
+               xstrncpy(Errmsg, pop_error, sizeof(Errmsg));
                Errmsg[sizeof(Errmsg) - 1] = '\0';
                return (POP_ERROR);
        }
@@ -882,7 +890,7 @@ pop_search_top(popserver server, int msgno, int lines,
        int match = POP_DONE;
 
        if (pop_top_first(server, msgno, lines, &line)) {
-               strncpy(Errmsg, pop_error, sizeof(Errmsg));
+               xstrncpy(Errmsg, pop_error, sizeof(Errmsg));
                Errmsg[sizeof(Errmsg) - 1] = '\0';
                return (POP_ERROR);
        }
@@ -906,7 +914,7 @@ pop_search_top(popserver server, int msgno, int lines,
        }
 
        if (ret) {
-               strncpy(Errmsg, pop_error, sizeof(Errmsg));
+               xstrncpy(Errmsg, pop_error, sizeof(Errmsg));
                Errmsg[sizeof(Errmsg) - 1] = '\0';
                return (POP_ERROR);
        }
index 5f897a6..116bd3f 100644 (file)
@@ -174,6 +174,14 @@ void oo_browser_check_and_clear_structtype(void);
 # define xrnew(op,n,Type) ((Type *) xrealloc ((op), (n) * sizeof (Type)))
 #endif
 
+#define xstrncpy(d_,s_,l_)                     \
+       do {                                    \
+               char* dst_=d_;                  \
+               dst_[0]='\0';                   \
+               strncat((dst_),(s_),(l_)-1);    \
+       } while(0)
+
+
 typedef int bool;
 
 typedef void Lang_function(FILE *);
@@ -2387,7 +2395,7 @@ bool *is_func_or_var;             /* OUT: function or variable found */
                        objdef = omethodtag;
                        methodlen = len;
                        grow_linebuffer(&token_name, methodlen + 1);
-                       strncpy(token_name.buffer, str, len);
+                       xstrncpy(token_name.buffer, str, len);
                        token_name.buffer[methodlen] = '\0';
                        token_name.len = methodlen;
                        return TRUE;
@@ -2829,7 +2837,7 @@ FILE *inf;                        /* input file */
                                                                    (&token_name,
                                                                     toklen +
                                                                     1);
-                                                               strncpy
+                                                               xstrncpy
                                                                    (token_name.
                                                                     buffer,
                                                                     newlb.
@@ -3903,7 +3911,7 @@ FILE *inf;
 
                        /* save all values for later tagging */
                        grow_linebuffer(&tline, lb.len + 1);
-                       strncpy(tline.buffer, lb.buffer, lb.len);
+                       xstrncpy(tline.buffer, lb.buffer, lb.len);
                        save_lineno = lineno;
                        save_lcno = linecharno;
 
@@ -4292,7 +4300,7 @@ FILE *inf;
                        else if (len + 1 > allocated)
                                last = xrnew(last, len + 1, char);
                        allocated = len + 1;
-                       strncpy(last, cp, len);
+                       xstrncpy(last, cp, len);
                        last[len] = '\0';
                }
        }
@@ -4447,7 +4455,7 @@ FILE *inf;
                        else if (len + 1 > allocated)
                                last = xrnew(last, len + 1, char);
                        allocated = len + 1;
-                       strncpy(last, cp, len);
+                       xstrncpy(last, cp, len);
                        last[len] = '\0';
                }
        }
@@ -4746,7 +4754,7 @@ struct re_registers *regs;
                        /* Using "dig2" satisfies my debugger.  Bleah. */
                        dig = *out - '0';
                        diglen = regs->end[dig] - regs->start[dig];
-                       strncpy(t, in + regs->start[dig], diglen);
+                       xstrncpy(t, in + regs->start[dig], diglen);
                        t += diglen;
                } else
                        *t++ = *out;
@@ -4917,7 +4925,7 @@ int len;
        register char *dp;
 
        dp = xnew(len + 1, char);
-       strncpy(dp, cp, len);
+       xstrncpy(dp, cp, len);
        dp[len] = '\0';
        return dp;
 }
index 9945443..931c9b0 100644 (file)
@@ -138,6 +138,13 @@ int pop_debug = 0;
 #define min(a,b) (((a) < (b)) ? (a) : (b))
 #endif
 
+#define xstrncpy(d_,s_,l_)                     \
+       do {                                    \
+               char* dst_=d_;                  \
+               dst_[0]='\0';                   \
+               strncat((dst_),(s_),(l_)-1);    \
+       } while(0)
+
 /*
  * Function: pop_open (char *host, char *username, char *password,
  *                    int flags)
@@ -345,7 +352,7 @@ pop_stat (server, count, size)
 
        if (strncmp (fromserver, "+OK ", 4)) {
                if (0 == strncmp (fromserver, "-ERR", 4)) {
-                       strncpy (pop_error, fromserver, ERROR_MAX);
+                       xstrncpy (pop_error, fromserver, ERROR_MAX);
                } else {
                        strcpy (pop_error,
                                "Unexpected response from POP "
@@ -435,7 +442,7 @@ pop_list (server, message, IDs, sizes)
                }
                if (strncmp (fromserver, "+OK ", 4)) {
                        if (! strncmp (fromserver, "-ERR", 4)) {
-                               strncpy (pop_error, fromserver, ERROR_MAX);
+                               xstrncpy (pop_error, fromserver, ERROR_MAX);
                        } else {
                                strcpy (pop_error,
                                        "Unexpected response from "
@@ -680,7 +687,7 @@ pop_multi_first (server, command, response)
        }
 
        if (0 == strncmp (*response, "-ERR", 4)) {
-               strncpy (pop_error, *response, ERROR_MAX);
+               xstrncpy (pop_error, *response, ERROR_MAX);
                return (-1);
        } else if (0 == strncmp (*response, "+OK", 3)) {
                for (*response += 3; **response == ' ';
@@ -848,7 +855,7 @@ pop_last (server)
                return (-1);
 
        if (! strncmp (fromserver, "-ERR", 4)) {
-               strncpy (pop_error, fromserver, ERROR_MAX);
+               xstrncpy (pop_error, fromserver, ERROR_MAX);
                return (-1);
        } else if (strncmp (fromserver, "+OK ", 4)) {
                strcpy (pop_error, "Unexpected response from server in pop_last");
@@ -1385,7 +1392,7 @@ getok (server)
        if (! strncmp (fromline, "+OK", 3))
                return (0);
        else if (! strncmp (fromline, "-ERR", 4)) {
-               strncpy (pop_error, fromline, ERROR_MAX);
+               xstrncpy (pop_error, fromline, ERROR_MAX);
                pop_error[ERROR_MAX-1] = '\0';
                return (-1);
        } else {
index 3dad330..934f976 100644 (file)
 static void yow(FILE * fp);
 static void setup_yow(FILE * fp);
 
+#define xstrncpy(d_,s_,l_)                     \
+       do {                                    \
+               char* dst_=d_;                  \
+               dst_[0]='\0';                   \
+               strncat((dst_),(s_),(l_)-1);    \
+       } while(0)
+
+
 int
 main(int argc, char *argv[])
 {
@@ -41,8 +49,8 @@ main(int argc, char *argv[])
        char file[BUFSIZ];
 
        if (argc > 2 && !strcmp(argv[1], "-f")) {
-               strncpy(file, argv[2], sizeof(file)-1);
-               file[sizeof(file)-1]='\0';
+               assert(argv[2] != NULL);
+               xstrncpy(file, argv[2], sizeof(file));
        } else {
 #ifdef PATH_DATA
 #ifdef vms
index 274a366..e6e1181 100644 (file)
@@ -347,24 +347,15 @@ Error will be signaled if FO-POINTER is not of pointer type."
 
 (defmacro define-ffi-function (fsym args doc-string ftype ename)
   "Define ffi function visible from Emacs lisp as FSYM."
-  `(progn
-     (declare (special ,fsym))
-     (setq ,fsym (ffi-defun ,ftype ,ename))
-     (defun ,fsym ,args
-       ,doc-string
-       (let ((ffiargs nil)
-            (ret nil))
-        (mapcar* #'(lambda (type arg)
-                     (setq ffiargs (cons
-                                    (if (ffi-object-p arg)
-                                        arg
-                                      (ffi-create-fo type arg))
-                                    ffiargs)))
-                 (cddr ,ftype) (list ,@args))
-        (setq ffiargs (nreverse ffiargs))
-        (setq ret (apply #'ffi-call-function ,fsym ffiargs))
-        (ffi-get ret :from-call t)))))
-
+  `(defun ,fsym ,args ,doc-string
+    (ffi-get (ffi-call-function (load-time-value (ffi-defun ,ftype ,ename))
+                                ,@(mapcar* #'(lambda (type arg)
+                                               `(if (ffi-object-p ,arg)
+                                                    ,arg
+                                                  (ffi-create-fo ',type ,arg)))
+                                           (cddadr ftype) args))
+
+             :from-call t)))
 (put 'define-ffi-function 'lisp-indent-function 'defun)
 
 \f
index 1499c3c..240a09e 100644 (file)
@@ -623,6 +623,7 @@ AC_DEFUN([_SXE_CHECK_PURE_OPT], [dnl
        --enable-largefile | --disable-largefile | \
        --enable-dependency-tracking | --disable-dependency-tracking | \
        --enable-option-checking | --disable-option-checking | \
+       --enable-silent-rules | --disable-silent-rules | \
        --with-x | --x-includes | --x-libraries | \
        --build | --host | \
        --program-prefix | --program-suffix | --program-transform-name | \
index 06d5ac0..aaef866 100644 (file)
@@ -34,6 +34,38 @@ dnl     <ADDITIONAL-FLAGS>)
        fi
 ])dnl SXE_CHECK_LINKER_FLAGS
 
+AC_DEFUN([SXE_CHECK_LINK_LIB], [dnl
+dnl just like SXE_CHECK_LINKER_FLAGS but calls the linker with -l <LIB>
+dnl SXE_CHECK_LINK_LIB(<LIB>, <ACTION-IF-FOUND>, <ACTION-IF-NOT-FOUND>,
+dnl     <ADDITIONAL-FLAGS>)
+       AC_MSG_CHECKING([whether library $1 can be linked])
+
+       dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname:
+       SXE_LANG_WERROR([push+on])
+       AS_LITERAL_IF([$1], [
+               AC_CACHE_VAL(AS_TR_SH(sxe_cv_[]_AC_LANG_ABBREV[]_flags_$1), [
+                       sxe_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
+                       _AC_LANG_PREFIX[]FLAGS="$4 ${XFLAG} -l$1"
+                       AC_LINK_IFELSE([AC_LANG_PROGRAM()],
+                               AS_TR_SH(sxe_cv_[]_AC_LANG_ABBREV[]_lib_$1)="yes",
+                               AS_TR_SH(sxe_cv_[]_AC_LANG_ABBREV[]_lib_$1)="no")
+                       _AC_LANG_PREFIX[]FLAGS=$sxe_save_FLAGS])], [
+               sxe_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
+               _AC_LANG_PREFIX[]FLAGS="$4 ${XFLAG} -l$1"
+               AC_LINK_IFELSE([AC_LANG_PROGRAM()],
+                       eval AS_TR_SH(sxe_cv_[]_AC_LANG_ABBREV[]_lib_$1)="yes",
+                       eval AS_TR_SH(sxe_cv_[]_AC_LANG_ABBREV[]_lib_$1)="no")
+               _AC_LANG_PREFIX[]FLAGS=$sxe_save_FLAGS])
+       eval sxe_check_linker_lib=$AS_TR_SH(sxe_cv_[]_AC_LANG_ABBREV[]_lib_$1)
+       SXE_LANG_WERROR([pop])
+
+       AC_MSG_RESULT([$sxe_check_linker_lib])
+       if test "$sxe_check_linker_lib" = "yes"; then
+               m4_default([$2], :)
+       else
+               m4_default([$3], :)
+       fi
+])dnl SXE_CHECK_LINK_LIB
 
 AC_DEFUN([SXE_CHECK_LD_ZFLAG], [dnl
        pushdef([LD_ZFLAG], [$1])
index fdcdbd7..aee6962 100644 (file)
@@ -207,6 +207,10 @@ esac
 echo "
 TTY:"
 test "$with_ncurses" = yes && echo "  Compiling in support for ncurses."
+test "$with_curses" = yes && echo "  Compiling in support for curses."
+test "$with_terminfo" = yes && echo "  Compiling in support for terminfo ."
+test "$with_termlib" = yes && echo "  Compiling in support for termlib."
+test "$with_termcap" = yes && echo "  Compiling in support for termcap."
 test "$with_gpm" = yes && echo "  Compiling in support for GPM (General Purpose Mouse)."
 
 echo "
index a6ad0e8..922fa9c 100644 (file)
@@ -1734,8 +1734,8 @@ typedef struct {
        Dynarr_declare(Extbyte_dynarr *);
 } Extbyte_dynarr_dynarr;
 
-static Extbyte_dynarr_dynarr *conversion_out_dynarr_list;
-static Bufbyte_dynarr_dynarr *conversion_in_dynarr_list;
+static Extbyte_dynarr_dynarr *conversion_out_dynarr_list = NULL;
+static Bufbyte_dynarr_dynarr *conversion_in_dynarr_list = NULL;
 
 static int dfc_convert_to_external_format_in_use;
 static int dfc_convert_to_internal_format_in_use;
@@ -1764,7 +1764,7 @@ dfc_convert_to_external_format(dfc_conversion_type source_type,
                               dfc_conversion_data * sink)
 {
        int count = specpdl_depth();
-       Extbyte_dynarr *conversion_out_dynarr;
+       Extbyte_dynarr *conversion_out_dynarr = NULL;
 
        type_checking_assert
            (((source_type == DFC_TYPE_DATA) ||
@@ -1778,6 +1778,7 @@ dfc_convert_to_external_format(dfc_conversion_type source_type,
 
        record_unwind_protect(dfc_convert_to_external_format_reset_in_use,
                              make_int(dfc_convert_to_external_format_in_use));
+       assert(conversion_out_dynarr_list != NULL);
        if (Dynarr_length(conversion_out_dynarr_list) <=
            dfc_convert_to_external_format_in_use)
                Dynarr_add(conversion_out_dynarr_list, Dynarr_new(Extbyte));
@@ -1920,7 +1921,7 @@ dfc_convert_to_internal_format(dfc_conversion_type source_type,
                               dfc_conversion_data * sink)
 {
        int count = specpdl_depth();
-       Bufbyte_dynarr *conversion_in_dynarr;
+       Bufbyte_dynarr *conversion_in_dynarr = NULL;
 
        type_checking_assert
            ((source_type == DFC_TYPE_DATA ||
@@ -1931,6 +1932,7 @@ dfc_convert_to_internal_format(dfc_conversion_type source_type,
 
        record_unwind_protect(dfc_convert_to_internal_format_reset_in_use,
                              make_int(dfc_convert_to_internal_format_in_use));
+       assert(conversion_in_dynarr_list != NULL);
        if (Dynarr_length(conversion_in_dynarr_list) <=
            dfc_convert_to_internal_format_in_use)
                Dynarr_add(conversion_in_dynarr_list, Dynarr_new(Bufbyte));
index 422ef45..7a6d331 100644 (file)
@@ -689,14 +689,12 @@ indicated built-in defaults are used.
                /* Connection failed.  Destroy the connection and signal an
                 * error. */
                char buf[BLCKSZ];
-               strncpy(buf, error_message, sizeof(buf)-1);
-               buf[sizeof(buf) - 1] = '\0';
+               xstrncpy(buf, error_message, sizeof(buf));
                if (P) {
                        /* storage for the error message gets erased when
                         * call PQfinish */
                        /* so we must temporarily stash it somewhere */
-                       strncpy(buf, PQerrorMessage(P), sizeof(buf)-1);
-                       buf[sizeof(buf) - 1] = '\0';
+                       xstrncpy(buf, PQerrorMessage(P), sizeof(buf));
                        PQfinish(P);
                }
                error("libpq: %s", buf);
@@ -740,11 +738,9 @@ See `pq-connectdb' for a complete description of conninfo.
        } else {
                /* capture the error message before destroying the object */
                char buf[BLCKSZ];
-               strncpy(buf, error_message, sizeof(buf)-1);
-               buf[sizeof(buf) - 1] = '\0';
+               xstrncpy(buf, error_message, sizeof(buf));
                if (P) {
-                       strncpy(buf, PQerrorMessage(P), sizeof(buf)-1);
-                       buf[sizeof(buf) - 1] = '\0';
+                       xstrncpy(buf, PQerrorMessage(P), sizeof(buf));
                        PQfinish(P);
                }
                error("libpq: %s", buf);
@@ -1253,9 +1249,8 @@ Submit a query to Postgres and wait for the result.
                        case PGRES_FATAL_ERROR:
                                tag = "fatal error [%s]";
                              err:
-                               strncpy(buf, PQresultErrorMessage(R),
+                               xstrncpy(buf, PQresultErrorMessage(R),
                                        sizeof(buf));
-                               buf[sizeof(buf) - 1] = '\0';
                                PQclear(R);
                                error(tag, buf);
                         /*NOTREACHED*/ default:
@@ -1334,8 +1329,7 @@ NIL is returned when no more query work remains.
                case PGRES_FATAL_ERROR:
                        tag = "fatal error [%s]";
                      err:
-                       strncpy(buf, PQresultErrorMessage(R), sizeof(buf));
-                       buf[sizeof(buf) - 1] = '\0';
+                       xstrncpy(buf, PQresultErrorMessage(R), sizeof(buf));
                        PQclear(R);
                        error(tag, buf);
                 /*NOTREACHED*/ default:
index 1b782a9..978fc73 100644 (file)
@@ -1375,7 +1375,7 @@ int pdump_load(const char *argv0)
                /* invocation-name includes a directory component -- presumably it
                   is relative to cwd, not $PATH */
                assert(strlen(dir) < sizeof(exe_path));
-               strncpy(exe_path, dir, sizeof(exe_path)-1);
+               xstrncpy(exe_path, dir, sizeof(exe_path));
                exe_path[sizeof(exe_path)-1]='\0';
        } else {
                const char *path = getenv("PATH");
@@ -1407,7 +1407,7 @@ int pdump_load(const char *argv0)
                                remain--;
                        }
                        if (remain > 0) {
-                               strncpy(w, name, remain);
+                               xstrncpy(w, name, remain);
                                w[remain]='\0';
                        }
 
@@ -1442,7 +1442,7 @@ int pdump_load(const char *argv0)
 
        /* Save exe_path because pdump_file_try() modifies it */
        assert(strlen(exe_path) < sizeof(real_exe_path));
-       strcpy(real_exe_path, exe_path);
+       xstrncpy(real_exe_path, exe_path, sizeof(real_exe_path));
        if (pdump_file_try(exe_path,sizeof(exe_path))
            || (xrealpath(real_exe_path, real_exe_path)
                && pdump_file_try(real_exe_path,sizeof(real_exe_path)))) {
index 0faac7b..83a4cb7 100644 (file)
@@ -617,23 +617,24 @@ On Unix it is obtained from TMPDIR, with /tmp as the default.
                } else {
                        const char* home_env = getenv("HOME");
                        if ( home_env ) {
-                               strncpy(path, home_env, sizeof(path)-1);
-                               strncat(path, "/tmp/", sizeof(path)-1);
+                               xstrncpy(path, home_env, sizeof(path));
+                               xstrncat(path, "/tmp/", sizeof(path));
                                if ( mkdir(path, 0700) >= 0 || errno == EEXIST ) {
                                        int fd;
                                        char warnpath[
                                                /* strlen(".created_by_sxemacs") */
                                                19 + _POSIX_PATH_MAX + 1];
-                                       strncpy(warnpath, path, _POSIX_PATH_MAX);
-                                       warnpath[sizeof(warnpath)-1]=0;
+                                       xstrncpy(warnpath, path, sizeof(warnpath));
 
                                        /* we already are reserved these 20 bytes... */
-                                       strcat(warnpath, ".created_by_sxemacs");
+                                       xstrncat(warnpath, ".created_by_sxemacs", 
+                                                sizeof(warnpath));
                                        if ((fd = open(warnpath, O_WRONLY | O_CREAT,
                                                       0644)) >= 0) {
                                                write(fd, "SXEmacs created this directory "
                                                          "because /tmp/<yourname> "
-                                                         "was unavailable -- \nPlease check !\n",  89);
+                                                         "was unavailable -- \nPlease check !\n",
+                                                     89);
                                                close(fd);
                                        }
                                }
index 761b295..50cac5e 100644 (file)
@@ -609,10 +609,10 @@ $LD_LIBRARY_PATH environment variable or the more global ld.so.cache.
        dotpos = strrchr((char *)XSTRING_DATA(libname),'.');
        if ( dotpos == NULL || strncmp(dotpos, EXT, sizeof(EXT))) {
                ssize_t liblen = XSTRING_LENGTH(libname);
-               ssize_t soname_len = liblen + sizeof(EXT);
-               soname = xmalloc( soname_len + 1);
-               strncpy(soname, (char *)XSTRING_DATA(libname), liblen+1);
-               strncat(soname, EXT, sizeof(EXT)+1);
+               ssize_t soname_len = liblen + sizeof(EXT) + 1;
+               soname = xmalloc( soname_len);
+               xstrncpy(soname, (char *)XSTRING_DATA(libname), soname_len);
+               xstrncpy(soname+liblen, EXT, soname_len-liblen);
        }
 
        if ( soname == NULL ) {
index 0965dbf..c47e6a7 100644 (file)
@@ -1040,9 +1040,27 @@ DOESNT_RETURN main_1(int argc, char **argv, char **envp, int restart)
                if (argmatch
                    (argv, argc, "-t", "--terminal", 4, &term, &skip_args)) {
                        int tdesc = -1;
+#ifdef HAVE_TTYNAME
+                       stderr_out("Opening for terminal usage %s (current: %s)\n", term, ttyname(0));
+#else
+                       stderr_out("Opening for terminal usage %s\n", term, ttyname(0));
+#endif
+#ifdef HAVE_DUP2
+                       tdesc = raw_open(term, O_RDWR | OPEN_BINARY, 2);
+                       if (tdesc < 0)
+                               fatal("%s: %s", term, strerror(errno));
+                       /* Request dup into fd 0 */
+                       if ( dup2(tdesc,0) < 0 )
+                               fatal("%s: %s", term, strerror(errno));
+                       stderr_out("Dup(0) ok\n");
+                       /* Requesr dup into fd 1 */
+                       if ( dup2(tdesc,1) < 0 )
+                               fatal("%s: %s", term, strerror(errno));
+                       close(tdesc);
+#else
                        close(0);
                        close(1);
-                       tdesc = open(term, O_RDWR | OPEN_BINARY, 2);
+                       tdesc = raw_open(term, O_RDWR | OPEN_BINARY, 2);
                        if (tdesc < 0)
                                fatal("%s: %s", term, strerror(errno));
                        assert(tdesc==0);
@@ -1050,14 +1068,20 @@ DOESNT_RETURN main_1(int argc, char **argv, char **envp, int restart)
                        if ( tdesc < 0) {
                                fatal("dup failed %s: %s", term, strerror(errno));
                        }
+                       assert(tdesc==1);
+#endif
+#ifdef HAVE_ISATTY
                        if (!isatty(0)) {
                                fatal("%s: not a tty", term);
                        }
-#if 0
-                       stderr_out("Using %s", ttyname(0));
 #endif
-                       stderr_out("Using %s", term);
-                       inhibit_window_system = 1;      /* -t => -nw */
+#ifdef HAVE_TTYNAME
+                       stderr_out("Using tty %s\n", ttyname(0));
+#else
+                       stderr_out("Using %tty s\n", term);
+#endif
+                       inhibit_window_system = 1;      /* -t => -nw
+                                                        * */
                }
        }
 
index 5bd1f9c..4124dc7 100644 (file)
@@ -157,8 +157,8 @@ __emodng_open_append_exts(const char *filename)
                        continue;
                }
 
-               strncpy(p, (const char*)XSTRING_DATA(XCAR(ext)),
-                       (size_t)XSTRING_LENGTH(XCAR(ext))+1);
+               xstrncpy(p, (const char*)XSTRING_DATA(XCAR(ext)),
+                        name + sizeof(name) - p);
 
                if (__file_exists_p(name)) {
                        EMOD_DEBUG_LOADER("trying %s\n", name);
@@ -189,9 +189,10 @@ __emodng_open_prepend_paths(const char *filename)
                        char *p;
                        p = xstpncpy(name,
                                     (const char*)XSTRING_DATA(XCAR(path)),
-                                    (size_t)XSTRING_LENGTH(XCAR(path)));
+                                    (size_t)XSTRING_LENGTH(XCAR(path)-2));
                        *p++ = '/';
-                       strncpy(p, filename, nfilename+1);
+                       *p = '\0';
+                       xstrncpy(p, filename, name + sizeof(name) - p);
 
                        if (__file_exists_p(name)) {
                                EMOD_DEBUG_LOADER("trying %s\n", name);
@@ -225,11 +226,12 @@ __emodng_open_prepend_paths_append_exts(const char *filename)
                        char *p = xstpncpy(
                                name,
                                (const char*)XSTRING_DATA(XCAR(path)),
-                               (size_t)XSTRING_LENGTH(XCAR(path)));
+                               (size_t)XSTRING_LENGTH(XCAR(path))-2);
                        if (*(p-1) != '/') {
                                *p++ = '/';
+                               *p = '\0';
                        }
-                       p = xstpncpy(p, filename, nfilename);
+                       p = xstpncpy(p, filename, name + sizeof(name) - p);
 
                        /* append all extensions now */
                        for (Lisp_Object ext = Vmodule_extensions;
@@ -238,9 +240,8 @@ __emodng_open_prepend_paths_append_exts(const char *filename)
                                        continue;
                                }
 
-                               strncpy(p,
-                                       (const char*)XSTRING_DATA(XCAR(ext)),
-                                       (size_t)XSTRING_LENGTH(XCAR(ext))+1);
+                               xstrncpy(p,(const char*)XSTRING_DATA(XCAR(ext)),
+                                        name + sizeof(name) - p);
 
                                if (__file_exists_p(name)) {
                                        EMOD_DEBUG_LOADER("trying \"%s\"\n",
index e92bf4c..292b056 100644 (file)
@@ -4531,6 +4531,8 @@ call3_trapping_errors(char *warning_string, Lisp_Object function,
 void grow_specpdl(EMACS_INT reserved)
 {
        EMACS_INT size_needed = specpdl_depth() + reserved;
+       if (specpdl_size == 0)
+               specpdl_size = 1;
        if (size_needed >= max_specpdl_size) {
                if (max_specpdl_size < min_max_specpdl_size)
                        max_specpdl_size = min_max_specpdl_size;
index 58a1284..85c1212 100644 (file)
@@ -3140,12 +3140,12 @@ print_extent_1(Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
                *bp++ = '*';
        *bp++ = (extent_start_open_p(anc) ? '(' : '[');
        if (extent_detached_p(ext))
-               strncpy(bp, "detached", sizeof(buf)-1);
+               xstrncpy(bp, "detached", sizeof(buf)-6);
        else {
-               sz=snprintf(bp, sizeof(buf)-2, "%ld, %ld",
+               sz=snprintf(bp, sizeof(buf)-6, "%ld, %ld",
                            XINT(Fextent_start_position(obj)),
                            XINT(Fextent_end_position(obj)));
-               assert(sz>=0 && (size_t)sz<(sizeof(buf)-2));
+               assert(sz>=0 && (size_t)sz<(sizeof(buf)-6));
        }
        bp += strlen(bp);
        *bp++ = (extent_end_open_p(anc) ? ')' : ']');
index 995a573..bae112a 100644 (file)
@@ -601,17 +601,18 @@ get a current directory to run processes in.
        return Ffile_name_directory(filename);
 }
 \f
-static char *file_name_as_directory(char *out, char *in)
+static char *file_name_as_directory(char *out, const char *in, size_t len)
 {
        /* This function cannot GC */
        int size = strlen(in);
 
        if (size == 0) {
+               assert(len >= 3);
                out[0] = '.';
                out[1] = DIRECTORY_SEP;
                out[2] = '\0';
        } else {
-               strcpy(out, in);
+               xstrncpy(out, in, len);
                /* Append a slash if necessary */
                if (!IS_ANY_SEP(out[size - 1])) {
                        out[size] = DIRECTORY_SEP;
@@ -633,8 +634,9 @@ except for (file-name-as-directory \"\") => \"./\".
       (filename))
 {
        /* This function can GC.  GC checked 2000-07-28 ben */
-       char *buf;
-       Lisp_Object handler;
+       size_t len = 0;
+       char *buf = NULL;
+       Lisp_Object handler = Qnil;
 
        CHECK_STRING(filename);
 
@@ -645,9 +647,10 @@ except for (file-name-as-directory \"\") => \"./\".
                return call2_check_string(handler, Qfile_name_as_directory,
                                          filename);
 
-       buf = (char *)alloca(XSTRING_LENGTH(filename) + 10);
+       len = XSTRING_LENGTH(filename) + 10;
+       buf = (char *)alloca(len);
        return build_string(file_name_as_directory
-                           (buf, (char *)XSTRING_DATA(filename)));
+                           (buf, (char*)XSTRING_DATA(filename), len));
 }
 \f
 /*
@@ -657,13 +660,13 @@ except for (file-name-as-directory \"\") => \"./\".
  * Value is nonzero if the string output is different from the input.
  */
 
-static int directory_file_name(const char *src, char *dst)
+static int directory_file_name(const char *src, char *dst, size_t len)
 {
        /* This function cannot GC */
        long slen = strlen(src);
        /* Process as Unix format: just remove any final slash.
           But leave "/" unchanged; do not change it to "".  */
-       strcpy(dst, src);
+       xstrncpy(dst, src, len);
        if (slen > 1 && IS_DIRECTORY_SEP(dst[slen - 1])
            )
                dst[slen - 1] = 0;
@@ -680,7 +683,8 @@ In Unix-syntax, this function just removes the final slash.
       (directory))
 {
        /* This function can GC.  GC checked 2000-07-28 ben */
-       char *buf;
+       size_t len = 0;
+       char *buf = NULL;
        Lisp_Object handler;
 
        CHECK_STRING(directory);
@@ -696,8 +700,9 @@ In Unix-syntax, this function just removes the final slash.
        if (!NILP(handler))
                return call2_check_string(handler, Qdirectory_file_name,
                                          directory);
-       buf = (char *)alloca(XSTRING_LENGTH(directory) + 20);
-       directory_file_name((char *)XSTRING_DATA(directory), buf);
+       len = XSTRING_LENGTH(directory) + 20;
+       buf = (char *)alloca(len);
+       directory_file_name((char *)XSTRING_DATA(directory), buf, len);
        return build_string(buf);
 }
 \f
@@ -1024,12 +1029,12 @@ See also the function `substitute-in-file-name'.
 
        if (newdir) {
                if (nm[0] == 0 || IS_DIRECTORY_SEP(nm[0]))
-                       strcpy((char *)target, (char *)newdir);
+                       xstrncpy((char *)target, (char *)newdir, tlen);
                else
-                       file_name_as_directory((char *)target, (char *)newdir);
+                       file_name_as_directory((char *)target, (char *)newdir, tlen);
        }
 
-       strcat((char *)target, (char *)nm);
+       xstrncat((char *)target, (char *)nm, tlen);
 
        /* ASSERT (IS_DIRECTORY_SEP (target[0])) if not VMS */
 
@@ -1245,6 +1250,7 @@ If `/~' appears, all of FILENAME through that `/' is discarded.
        Bufbyte *target = 0;
        int total = 0;
        int substituted = 0;
+       size_t avail = 0;
        Bufbyte *xnm;
        Lisp_Object handler;
 
@@ -1321,19 +1327,22 @@ If `/~' appears, all of FILENAME through that `/' is discarded.
 
        /* If substitution required, recopy the filename and do it */
        /* Make space in stack frame for the new copy */
-       xnm = (Bufbyte *) alloca(XSTRING_LENGTH(filename) + total + 1);
+       avail = XSTRING_LENGTH(filename) + total + 1;
+       xnm = (Bufbyte *) alloca(avail);
        x = xnm;
 
        /* Copy the rest of the name through, replacing $ constructs with values */
        for (p = nm; *p;)
-               if (*p != '$')
+               if (*p != '$') {
                        *x++ = *p++;
-               else {
+                       avail--;
+               } else {
                        p++;
                        if (p == endp)
                                goto badsubst;
                        else if (*p == '$') {
                                *x++ = *p++;
+                               avail--;
                                continue;
                        } else if (*p == '{') {
                                o = ++p;
@@ -1359,8 +1368,9 @@ If `/~' appears, all of FILENAME through that `/' is discarded.
                        if (!o)
                                goto badvar;
 
-                       strcpy((char *)x, (char *)o);
+                       xstrncpy((char *)x, (char *)o, avail);
                        x += strlen((char *)o);
+                       avail -= strlen((char *)o);
                }
 
        *x = 0;
index 1f0b96d..715db6f 100644 (file)
@@ -1079,7 +1079,7 @@ the second element to the second one and so on.
             (mss = media_substream_next(mss))) {
                mtype_video_properties *mtvp;
                long int num = 0, den = 0;
-               Lisp_Object tmp;
+               Lisp_Object tmp = Qnil;
 
                if (LIKELY(media_substream_type(mss) != MTYPE_VIDEO)) {
                        continue;
index 2a16094..d1e6488 100644 (file)
@@ -465,6 +465,14 @@ sound_oss_play(audio_job_t aj)
                SXE_MUTEX_UNLOCK(&sod->mtx);
                return 0;
        }
+       if(sosd->channels!=0) {
+               message(GETTEXT("audio-oss: "
+                               "No channels."));
+               sound_oss_close_device(sod);
+               SXE_MUTEX_UNLOCK(&sod->mtx);
+               return 0;
+       }
+
 
        /* the volume effect */
        ADD_MEDIA_SAMPLE_EFFECT(
@@ -482,6 +490,7 @@ sound_oss_play(audio_job_t aj)
        OSS_DEBUG_COE("have %d coerce functions in my chain.\n",
                      sosd->coe_ch_cnt);
 
+
        XAUDIO_DEVICE_STATE(device) = ASTATE_ALIVE;
        SXE_MUTEX_UNLOCK(&sod->mtx);
 
index 2c1e019..c1301a9 100644 (file)
@@ -46,9 +46,11 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>. */
  (!NILP (table) ? TRT_TABLE_OF (table, (Emchar) pos) : pos)
 \f
 #include "elhash.h"
+/* Make sure these are ALWAYS powers of 2 */
 #define REGEXP_CACHE_SIZE 0x80
 #define REGEXP_CACHE_HASH_MASK (REGEXP_CACHE_SIZE-1)
 #define REGEXP_FASTMAP_SIZE 0400
+#define REGEXP_FASTMAP_MASK (REGEXP_FASTMAP_SIZE-1)
 
 #define __REGEXP_DEBUG__(args...)      fprintf(stderr, "REGEXP " args)
 #ifndef REGEXP_DEBUG_FLAG
@@ -1867,9 +1869,9 @@ boyer_moore(struct buffer *buf, Bufbyte * base_pat, Bytecount len,
                                this_translated = 0;
                        }
                        if (ch > REGEXP_FASTMAP_SIZE)
-                               j = ((unsigned char)ch | 0200);
+                               j = ((unsigned char)(ch & REGEXP_FASTMAP_SIZE)| 0200);
                        else
-                               j = (unsigned char)ch;
+                               j = (unsigned char)(ch & REGEXP_FASTMAP_SIZE);
 
                        if (i == infinity)
                                stride_for_teases = BM_tab[j];
@@ -1882,9 +1884,9 @@ boyer_moore(struct buffer *buf, Bufbyte * base_pat, Bytecount len,
                                while (1) {
                                        ch = TRANSLATE(inverse_trt, ch);
                                        if (ch > REGEXP_FASTMAP_SIZE)
-                                               j = ((unsigned char)ch | 0200);
+                                               j = ((unsigned char)(ch & REGEXP_FASTMAP_SIZE) | 0200);
                                        else
-                                               j = (unsigned char)ch;
+                                               j = (unsigned char)(ch & REGEXP_FASTMAP_SIZE);
 
                                        /* For all the characters that map into CH,
                                           set up simple_translate to map the last byte
index 7f6bfe0..8bc985f 100644 (file)
@@ -391,4 +391,119 @@ char *xstrdup(const char *);
 # endif         /* ERROR_CHECK_MALLOC */
 #endif /* BDWGC */
 
+\f
+/* str funs */
+#define xstrlen                strlen
+#define xstrcmp                strcmp
+#define xstrncmp       strncmp
+#define xstrncat       strncat
+
+extern_inline char*
+xstrncpy(char* target, const char*source, size_t len)
+       __attribute__((always_inline));
+extern_inline char*
+xstrncpy(char* target, const char*source, size_t len)
+{
+       *target ='\0';
+       return strncat(target,source,len-1);
+}
+
+#if !defined(FORBID_STRCPY)
+#  define xstrcat              strcat
+#  define xstrcpy              strcpy
+#  if defined(HAVE_STPCPY)
+#     define xstpcpy   stpcpy
+#   else
+extern_inline char*
+xstpcpy(char *target, const char *source)
+       __attribute__((always_inline));
+extern_inline char*
+xstpcpy(char *target, const char *source)
+{
+       char *p = target;
+       size_t len = xstrlen(source);
+
+       strcpy(target, source);
+       p += len;
+       return p;
+}
+#   endif
+#else
+#  if defined(strcpy)
+#    undef strcpy
+#  endif
+#  define strcpy  no_strcpy
+extern_inline char*
+no_strcpy(char*,const char*)
+       __attribute__((always_inline));
+extern_inline char*
+no_strcpy(char * SXE_UNUSED(target),const char * SXE_UNUSED(source))
+{
+       assert(0);
+       return NULL;
+}
+#  if defined(strcat)
+#    undef strcat
+#  endif
+#  define strcat  no_strcat
+extern_inline char*
+no_strcat(char*,const char*)
+       __attribute__((always_inline));
+extern_inline char*
+no_strcat(char * SXE_UNUSED(target), const char* SXE_UNUSED(source))
+{
+       assert(0);
+       return NULL;
+}
+#  if defined(stpcpy)
+#    undef stpcpy
+#  endif
+#  define stpcpy       no_stpcpy
+#  define xstpcpy      no_stpcpy
+extern_inline char*
+no_stpcpy(char*,const char*)
+       __attribute__((always_inline));
+extern_inline char*
+no_stpcpy(char* SXE_UNUSED(target),const char* SXE_UNUSED(source))
+{
+       assert(0);
+       return NULL;
+}
+#endif
+
+
+#if defined HAVE_STPNCPY
+# define xstpncpy      stpncpy
+#else
+extern_inline char*
+xstpncpy(char *target, const char *source, size_t len)
+       __attribute__((always_inline));
+extern_inline char*
+xstpncpy(char *target, const char *source, size_t len)
+{
+       char *p = target;
+       xstrncpy(target, source, len);
+       p += len;
+       return p;
+}
+#endif /* !HAVE_STPNCPY */
+
+#define xmemcmp                memcmp
+#define xmemcpy                memcpy
+
+
+
+extern_inline size_t
+xmin_size_t(size_t a, size_t b)
+       __attribute__((always_inline));
+extern_inline size_t
+xmin_size_t(size_t a, size_t b)
+{
+       if (a < b) {
+               return a;
+       } else {
+               return b;
+       }
+}
+
 #endif
index 7d0536b..292ae01 100644 (file)
@@ -2102,6 +2102,7 @@ void init_system_name(void)
 #   endif
                        if (hp) {
                                const char *fqdn = (const char *)hp->h_name;
+                               size_t len = 0;
 
                                if (!strchr(fqdn, '.')) {
                                        /* We still don't have a fully qualified domain name.
@@ -2112,8 +2113,9 @@ void init_system_name(void)
                                        if (*alias)
                                                fqdn = *alias;
                                }
-                               hostname = (char *)alloca(strlen(fqdn) + 1);
-                               strcpy(hostname, fqdn);
+                               len = strlen(fqdn) + 1;
+                               hostname = (char *)alloca(len);
+                               xstrncpy(hostname, fqdn,len);
                        }
 #  else                                /* !(HAVE_GETADDRINFO && HAVE_GETNAMEINFO) */
                        struct addrinfo hints, *res;
@@ -2131,7 +2133,7 @@ void init_system_name(void)
                                ssize_t canon_len=strlen(res->ai_canonname)+1;
 
                                hostname = (char *)alloca(canon_len);
-                               strncpy(hostname, res->ai_canonname, canon_len);
+                               xstrncpy(hostname, res->ai_canonname, canon_len);
                                freeaddrinfo(res);
                        }
 #  endif                       /* !(HAVE_GETADDRINFO && HAVE_GETNAMEINFO) */
@@ -2298,6 +2300,19 @@ const char *strerror(int errnum)
    Jamie's home page (http://www.jwz.org/worse-is-better.html). */
 
 #ifdef ENCAPSULATE_OPEN
+
+int raw_open(const char *path, int oflag, ...)
+{
+       int mode;
+       va_list ap;
+       char *pout;
+
+       va_start(ap, oflag);
+       mode = va_arg(ap, int);
+       va_end(ap);
+       return open(pout, oflag, mode);
+}
+
 int sys_open(const char *path, int oflag, ...)
 {
        int mode;
@@ -3281,7 +3296,7 @@ struct direct *readdir(DIR * dirp)
 
                if (dp->od_ino != 0) {  /* not deleted entry */
                        dir_static.d_ino = dp->od_ino;
-                       strncpy(dir_static.d_name, dp->od_name, DIRSIZ);
+                       xstrncpy(dir_static.d_name, dp->od_name, DIRSIZ);
                        dir_static.d_name[DIRSIZ] = '\0';
                        dir_static.d_namlen = strlen(dir_static.d_name);
                        dir_static.d_reclen = sizeof(struct direct)
index c506d26..4ee497d 100644 (file)
@@ -177,66 +177,10 @@ extern int h_errno;
 char *xrealpath(const char *path, char restrict resolved_path[]);
 #endif
 
-extern_inline size_t xmin_size_t(size_t a, size_t b);
 extern_inline void x__dirname(char *restrict res, const char *file, size_t len);
 extern_inline size_t x__dirlen(const char *file, size_t len);
 extern_inline char *xdirname(const char *file);
 
-\f
-/* str funs */
-/* thought these were defined already :O */
-#define xstrlen                strlen
-#define xstrcmp                strcmp
-#define xstrcat                strcat
-#define xstrncmp       strncmp
-#define xstrncpy       strncpy
-#define xstrncat       strncat
-#if defined HAVE_STPCPY
-# define xstpcpy       stpcpy
-#else
-extern_inline char*
-xstpcpy(char *target, const char *source)
-       __attribute__((always_inline));
-extern_inline char*
-xstpcpy(char *target, const char *source)
-{
-       char *p = target;
-       size_t len = xstrlen(source);
-
-       strcpy(target, source);
-       p += len;
-       return p;
-}
-#endif /* !HAVE_STPCPY */
-#if defined HAVE_STPNCPY
-# define xstpncpy      stpncpy
-#else
-extern_inline char*
-xstpncpy(char *target, const char *source, size_t len)
-       __attribute__((always_inline));
-extern_inline char*
-xstpncpy(char *target, const char *source, size_t len)
-{
-       char *p = target;
-       strncpy(target, source, len);
-       p += len;
-       return p;
-}
-#endif /* !HAVE_STPNCPY */
-
-#define xmemcmp                memcmp
-#define xmemcpy                memcpy
-
-extern_inline size_t
-xmin_size_t(size_t a, size_t b)
-{
-       if (a < b) {
-               return a;
-       } else {
-               return b;
-       }
-}
-
 \f
 /* big dirname magic, some of it stolen from dirname.c from coreutils 6.9 */
 /* POSIX says:
@@ -257,6 +201,9 @@ xmin_size_t(size_t a, size_t b)
 #define ISSLASH(C)     ((C) == DIRECTORY_SEPARATOR)
 #endif
 
+extern_inline size_t
+x__dirlen(const char *file, size_t len)
+       __attribute__((always_inline));
 extern_inline size_t
 x__dirlen(const char *file, size_t len)
 {
@@ -273,6 +220,9 @@ x__dirlen(const char *file, size_t len)
        return len;
 }
 
+extern_inline void
+x__dirname(char *restrict res, const char *file, size_t len)
+       __attribute__((always_inline));
 #if defined(HAVE_DIRNAME) && defined(DIRNAME_SIDE_EFFECT)
 extern_inline void
 x__dirname(char *restrict res, const char *file, size_t len)
@@ -305,6 +255,9 @@ x__dirname(char *restrict res, const char *file, size_t len)
 }
 #endif
 
+extern_inline char*
+xdirname(const char *file)
+       __attribute__((always_inline));
 extern_inline char*
 xdirname(const char *file)
 {
index 254252f..df59f91 100644 (file)
@@ -304,6 +304,7 @@ ssize_t sys_write(int, const void *, size_t);
 
 #ifdef ENCAPSULATE_OPEN
 int sys_open(const char *, int, ...);
+int raw_open(const char *, int, ...);
 #endif
 #if defined (ENCAPSULATE_OPEN) && !defined (DONT_ENCAPSULATE)
 # undef open
@@ -311,6 +312,7 @@ int sys_open(const char *, int, ...);
 #endif
 #if !defined (ENCAPSULATE_OPEN) && defined (DONT_ENCAPSULATE)
 # define sys_open open
+# define raw_open open
 #endif
 
 #ifdef ENCAPSULATE_CLOSE
index d6d0157..57b6317 100644 (file)
@@ -1095,7 +1095,7 @@ static prop_block_dynarr *add_bufbyte_string_runes(pos_data * data,
                                pb.type = PROP_STRING;
                                pb.data.p_string.str =
                                        xnew_atomic_array(Bufbyte, len);
-                               strncpy((char *)pb.data.p_string.str,
+                               xstrncpy((char *)pb.data.p_string.str,
                                        (char *)pos, len);
                                pb.data.p_string.len = len;
 
index 4ec1d6d..92fe992 100644 (file)
@@ -1422,14 +1422,16 @@ is non-nil, do not include space occupied by clipped lines.
                            || Dynarr_atp(cache, i)->end >= eobuf)
                                return make_int(height);
                }
-
+               
                /* get here => need more cache lines.  try again. */
                assert(height > prev_height);   /* progress? */
                prev_height = height;
-
-               needed +=
-                   ((hlimit - height) * (nelt - elt) + height - 1) / height +
-                   3;
+               
+               needed += 3;
+               if ( height != 0)
+                       needed += ((hlimit - height) * 
+                                  (nelt - elt) + 
+                                  height - 1) / height;
        }
 
        RETURN_NOT_REACHED(make_int(0)) /* shut up compiler */