From 95155a2796fc820594c522f36a1a7dfd273d2020 Mon Sep 17 00:00:00 2001 From: jjgarcia Date: Sat, 23 Nov 2002 18:12:31 +0000 Subject: [PATCH] Detect automatically, to what characters \n is translated. For instance, under MSDOS \n -> \r\n, and under Apple, \n -> \n\r. --- src/aclocal.m4 | 44 +++++++++++++++++++++++++ src/configure | 84 ++++++++++++++++++++++++++++++++++++++++++++++-- src/configure.in | 1 + 3 files changed, 127 insertions(+), 2 deletions(-) diff --git a/src/aclocal.m4 b/src/aclocal.m4 index a5fb47356..06b47dce1 100644 --- a/src/aclocal.m4 +++ b/src/aclocal.m4 @@ -1,3 +1,4 @@ +25210: Permission denied, please try again. dnl -------------------------------------------------------------- dnl Make srcdir absolute, if it isn't already. It's important to dnl avoid running the path through pwd unnecessarily, since pwd can @@ -235,3 +236,46 @@ AC_SUBST(CL_FIXNUM_MAX) AC_SUBST(CL_FIXNUM_MIN), AC_MSG_ERROR(There is no appropiate integer type for the cl_fixnum type)) ]) + +dnl +dnl ------------------------------------------------------------ +dnl Find out what is written for every '\n' character, when +dnl opening a text file. +dnl +AC_DEFUN(ECL_LINEFEED_MODE,[ +AC_MSG_CHECKING(character sequence for end of line) +AC_TRY_RUN([#include +int main() { + FILE *f = fopen("conftestval","w"); + int c1, c2; + if (f == NULL) exit(1); + fprintf(f, "\n"); + fclose(f); + f = fopen("conftestval","rb"); + if (f == NULL) exit(1); + c1 = fgetc(f); + c2 = fgetc(f); + fclose(f); + f = fopen("conftestval","w"); + if (f == NULL) exit(1); + if (c1 == '\r') + fprintf(f,"crlf"); + else if (c2 == '\r') + fprintf(f,"lfcr"); + else + fprintf(f,"unix"); + fclose(f); +} +], +if test `cat conftestval` = "crlf"; then + AC_DEFINE(ECL_NEWLINE_IS_CRLF) + AC_MSG_RESULT(CR + LF) +elif test `cat conftestval` = "lfcr"; then + AC_DEFINE(ECL_NEWLINE_IS_LFCR) + AC_MSG_RESULT(LF + CR) +else + AC_MSG_RESULT(LF) +fi, +AC_MSG_ERROR(unable to determine)) +]) + diff --git a/src/configure b/src/configure index b5a1ef243..53ba6e173 100755 --- a/src/configure +++ b/src/configure @@ -904,7 +904,7 @@ esac # Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be # absolute. ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` -ac_abs_top_builddir=`cd "$ac_dir" && cd $ac_top_builddir && pwd` +ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` @@ -1284,6 +1284,8 @@ build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +test -z "$build_alias" && + build_alias=$ac_cv_build echo "$as_me:$LINENO: checking host system type" >&5 echo $ECHO_N "checking host system type... $ECHO_C" >&6 @@ -1306,6 +1308,8 @@ host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +test -z "$host_alias" && + host_alias=$ac_cv_host @@ -3871,6 +3875,82 @@ rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi +echo "$as_me:$LINENO: checking character sequence for end of line" >&5 +echo $ECHO_N "checking character sequence for end of line... $ECHO_C" >&6 +if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling" >&5 +echo "$as_me: error: cannot run test program while cross compiling" >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include +int main() { + FILE *f = fopen("conftestval","w"); + int c1, c2; + if (f == NULL) exit(1); + fprintf(f, "\n"); + fclose(f); + f = fopen("conftestval","rb"); + if (f == NULL) exit(1); + c1 = fgetc(f); + c2 = fgetc(f); + fclose(f); + f = fopen("conftestval","w"); + if (f == NULL) exit(1); + if (c1 == '\r') + fprintf(f,"crlf"); + else if (c2 == '\r') + fprintf(f,"lfcr"); + else + fprintf(f,"unix"); + fclose(f); +} + +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + if test `cat conftestval` = "crlf"; then + cat >>confdefs.h <<\_ACEOF +#define ECL_NEWLINE_IS_CRLF 1 +_ACEOF + + echo "$as_me:$LINENO: result: CR + LF" >&5 +echo "${ECHO_T}CR + LF" >&6 +elif test `cat conftestval` = "lfcr"; then + cat >>confdefs.h <<\_ACEOF +#define ECL_NEWLINE_IS_LFCR 1 +_ACEOF + + echo "$as_me:$LINENO: result: LF + CR" >&5 +echo "${ECHO_T}LF + CR" >&6 +else + echo "$as_me:$LINENO: result: LF" >&5 +echo "${ECHO_T}LF" >&6 +fi +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +( exit $ac_status ) +{ { echo "$as_me:$LINENO: error: unable to determine" >&5 +echo "$as_me: error: unable to determine" >&2;} + { (exit 1); exit 1; }; } +fi +rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + if test "x$prefix" = "xNONE"; then prefix=${ac_default_prefix}; fi if test "x$exec_prefix" = "xNONE"; then exec_prefix=${prefix}; fi bindir="${exec_prefix}/bin" @@ -6369,7 +6449,7 @@ esac # Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be # absolute. ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` -ac_abs_top_builddir=`cd "$ac_dir" && cd $ac_top_builddir && pwd` +ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` diff --git a/src/configure.in b/src/configure.in index 99abb6956..935bc0691 100644 --- a/src/configure.in +++ b/src/configure.in @@ -142,6 +142,7 @@ dnl ECL_MAKE_ABSOLUTE_SRCDIR() ECL_GUESS_HOST_OS() ECL_PROCESS_MACHINES_H() +ECL_LINEFEED_MODE() dnl ---------------------------------------------------------------------- dnl Set options