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
#### 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
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,
[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.]),
## -------------------------------------------------------------------------
## 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
SXE_CHECK_COMMAND_LINE
AM_INIT_AUTOMAKE([foreign -Wall])
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
SXE_CHECK_BUILDCHAIN
AC_SUBST(EGREP)
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"
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
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
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
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
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)
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
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
=========
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
Nelson Ferreira <njsf@sxemacs.org>
-git-to-steve.sh
+git-for-steve.sh
---------------
This script will check your git configuration, give you some
--- /dev/null
+#!/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 ""
#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 *));
#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;
/* 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;
}
*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;
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");
#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[])
{
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 = '\\';
*p = 'd';
break;
default:
- *p = *s;
+ *p = *const_p;
}
}
*p++ = '\"';
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;
* 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';
}
}
#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)
}
/* if */
msgctl(ipc_qid, IPC_STAT, &msg_st);
- strncpy(buf, msgp->mtext, len);
+ xstrncpy(buf, msgp->mtext, len);
/* terminate buf */
buf[len] = '\0';
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"
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;
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;
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);
}
}
if (ret) {
- strncpy(Errmsg, pop_error, sizeof(Errmsg));
+ xstrncpy(Errmsg, pop_error, sizeof(Errmsg));
Errmsg[sizeof(Errmsg) - 1] = '\0';
return (POP_ERROR);
}
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);
}
}
if (ret) {
- strncpy(Errmsg, pop_error, sizeof(Errmsg));
+ xstrncpy(Errmsg, pop_error, sizeof(Errmsg));
Errmsg[sizeof(Errmsg) - 1] = '\0';
return (POP_ERROR);
}
# 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 *);
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;
(&token_name,
toklen +
1);
- strncpy
+ xstrncpy
(token_name.
buffer,
newlb.
/* 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;
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';
}
}
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';
}
}
/* 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;
register char *dp;
dp = xnew(len + 1, char);
- strncpy(dp, cp, len);
+ xstrncpy(dp, cp, len);
dp[len] = '\0';
return dp;
}
#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)
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 "
}
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 "
}
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 == ' ';
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");
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 {
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[])
{
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
(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
--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 | \
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])
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 "
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;
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) ||
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));
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 ||
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));
/* 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);
} 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);
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:
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:
/* 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");
remain--;
}
if (remain > 0) {
- strncpy(w, name, remain);
+ xstrncpy(w, name, remain);
w[remain]='\0';
}
/* 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)))) {
} 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);
}
}
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 ) {
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);
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
+ * */
}
}
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);
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);
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;
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",
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;
*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) ? ')' : ']');
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;
(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);
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
/*
* 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;
(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);
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
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 */
Bufbyte *target = 0;
int total = 0;
int substituted = 0;
+ size_t avail = 0;
Bufbyte *xnm;
Lisp_Object handler;
/* 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;
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;
(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;
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(
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);
(!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
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];
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
# 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
# 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.
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;
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) */
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;
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)
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:
#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)
{
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)
}
#endif
+extern_inline char*
+xdirname(const char *file)
+ __attribute__((always_inline));
extern_inline char*
xdirname(const char *file)
{
#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
#endif
#if !defined (ENCAPSULATE_OPEN) && defined (DONT_ENCAPSULATE)
# define sys_open open
+# define raw_open open
#endif
#ifdef ENCAPSULATE_CLOSE
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;
|| 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 */