do not open input files with "rt" mode, do not assume "rt" is supported

2012-02-13  Paolo Bonzini  <bonzini@gnu.org>

	* configure.ac: Test whether fopen("foo", "rt") works.
	* sed/compile.c: Do not open scripts with "rt" mode if it doesn't.
	* sed/sed.c: Never open input files with "rt" mode.
This commit is contained in:
Paolo Bonzini committed 2012-02-13 15:46:14 +01:00
1 parent a085906489
commit e8066f09db
4 files changed
+39 -3

No files matched your search

+6
View File
@@ -1,3 +1,9 @@
2012-02-13 Paolo Bonzini <bonzini@gnu.org>
* configure.ac: Test whether fopen("foo", "rt") works.
* sed/compile.c: Do not open scripts with "rt" mode if it doesn't.
* sed/sed.c: Never open input files with "rt" mode.
2012-02-05 Paolo Bonzini <bonzini@gnu.org>
Jim Hill <gjthill@gmail.com>
+24
View File
@@ -15,6 +15,30 @@ AC_PROG_CC
gl_EARLY
gl_INIT
gl_DISABLE_THREADS
AC_CACHE_CHECK([whether "rt" can be used with fopen], [sed_cv_fopen_rt], [
AC_TRY_RUN([
#include <stdio.h>
#include <errno.h>
int main()
{
FILE *fp;
int result;
errno = 0;
fp = fopen ("conftest.c", "rt");
if (fp) fclose (fp);
return fp ? 0 : 1;
}], [sed_cv_fopen_rt=yes],
[sed_cv_fopen_rt=no],
[case $host in
*cygwin* | *mingw*) sed_cv_fopen_rt=yes ;;
*) sed_cv_fopen_rt='assuming no' ;;
esac])])
if test "$sed_cv_fopen_rt" = yes; then
AC_DEFINE([HAVE_FOPEN_RT], [1],
[Defined if "rt" can be used as a mode to fopen.])
fi
AC_CACHE_CHECK([whether -lcP is needed], [sed_cv_libcp_needed], [
AC_TRY_RUN([
#include <stdio.h>
+7 -1
View File
@@ -1610,7 +1610,13 @@ compile_file(cur_program, cmdfile)
prog.file = stdin;
if (cmdfile[0] != '-' || cmdfile[1] != '\0')
prog.file = ck_fopen(cmdfile, "rt", true);
{
#ifdef HAVE_FOPEN_RT
prog.file = ck_fopen(cmdfile, "rt", true);
#else
prog.file = ck_fopen(cmdfile, "r", true);
#endif
}
cur_input.line = 1;
cur_input.name = cmdfile;
+2 -2
View File
@@ -86,8 +86,8 @@ bool follow_symlinks = false;
/* How do we edit files in-place? (we don't if NULL) */
char *in_place_extension = NULL;
/* The mode to use to read/write files, either "rt"/"w" or "rb"/"wb". */
char *read_mode = "rt";
/* The mode to use to read/write files, either "r"/"w" or "rb"/"wb". */
char *read_mode = "r";
char *write_mode = "w";
/* Do we need to be pedantically POSIX compliant? */