rpms/sed/F-13 sed-4.2.1-copy.patch, NONE, 1.1 sed-4.2.1-makecheck.patch, NONE, 1.1 sed.spec, 1.51, 1.52 sed-4.1.5-copy.patch, 1.1, NONE sed-4.1.5-follow.patch, 1.2, NONE sed-4.1.5-utf8performance.patch, 1.1, NONE sed-4.2.1-dummyparam.diff, 1.1, NONE
Jan Görig
jgorig at fedoraproject.org
Mon Mar 22 13:02:37 UTC 2010
Author: jgorig
Update of /cvs/pkgs/rpms/sed/F-13
In directory cvs01.phx2.fedoraproject.org:/tmp/cvs-serv17187
Modified Files:
sed.spec
Added Files:
sed-4.2.1-copy.patch sed-4.2.1-makecheck.patch
Removed Files:
sed-4.1.5-copy.patch sed-4.1.5-follow.patch
sed-4.1.5-utf8performance.patch sed-4.2.1-dummyparam.diff
Log Message:
- fixed make check on non UTF-8 locale - upstream patch rhbz#550731
- readded -c option (thanks Paolo Bonzini) rhbz#566455
- removed previous -c dummy patch
- changed license to GPLv3+
sed-4.2.1-copy.patch:
doc/sed.1 | 6 +++
sed/execute.c | 6 ++-
sed/sed.c | 21 +++++++++++--
sed/sed.h | 4 ++
sed/utils.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++++---------
sed/utils.h | 1
6 files changed, 113 insertions(+), 18 deletions(-)
--- NEW FILE sed-4.2.1-copy.patch ---
diff --git a/doc/sed.1 b/doc/sed.1
index 42a0a28..bb235c8 100644
--- a/doc/sed.1
+++ b/doc/sed.1
@@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.28.
-.TH SED "1" "June 2009" "sed version 4.2.1" "User Commands"
+.TH SED "1" "February 2010" "sed version 4.2.1" "User Commands"
.SH NAME
sed \- stream editor for filtering and transforming text
.SH SYNOPSIS
@@ -40,6 +40,10 @@ follow symlinks when processing in place
.IP
edit files in place (makes backup if extension supplied)
.HP
+\fB\-c\fR, \fB\-\-copy\fR
+.IP
+use copy instead of rename when shuffling files in \fB\-i\fR mode
+.HP
\fB\-l\fR N, \fB\-\-line\-length\fR=\fIN\fR
.IP
specify the desired line-wrap length for the `l' command
diff --git a/sed/execute.c b/sed/execute.c
index af8c4d2..c05b418 100644
--- a/sed/execute.c
+++ b/sed/execute.c
@@ -822,11 +822,13 @@ closedown(input)
if (strcmp(in_place_extension, "*") != 0)
{
char *backup_file_name = get_backup_file_name(target_name);
- ck_rename (target_name, backup_file_name, input->out_file_name);
+ (copy_instead_of_rename?ck_fcmove:ck_rename)
+ (target_name, backup_file_name, input->out_file_name);
free (backup_file_name);
}
- ck_rename (input->out_file_name, target_name, input->out_file_name);
+ (copy_instead_of_rename?ck_fcmove:ck_rename)
+ (input->out_file_name, target_name, input->out_file_name);
free (input->out_file_name);
}
else
diff --git a/sed/sed.c b/sed/sed.c
index 723958d..1fbb279 100644
--- a/sed/sed.c
+++ b/sed/sed.c
@@ -75,6 +75,10 @@ bool follow_symlinks = false;
/* How do we edit files in-place? (we don't if NULL) */
char *in_place_extension = NULL;
+/* Do we use copy or rename when in in-place edit mode? (boolean
+ value, non-zero for copy, zero for rename).*/
+int copy_instead_of_rename = 0;
+
/* The mode to use to read files, either "rt" or "rb". */
char *read_mode = "rt";
@@ -135,6 +139,8 @@ Usage: %s [OPTION]... {script-only-if-no-other-script} [input-file]...\n\
#endif
fprintf(out, _(" -i[SUFFIX], --in-place[=SUFFIX]\n\
edit files in place (makes backup if extension supplied)\n"));
+ fprintf(out, _(" -c, --copy\n\
+ use copy instead of rename when shuffling files in -i mode\n"));
#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(MSDOS) || defined(__EMX__)
fprintf(out, _(" -b, --binary\n\
open files in binary mode (CR+LFs are not processed specially)\n"));
@@ -174,9 +180,9 @@ main(argc, argv)
char **argv;
{
#ifdef REG_PERL
-#define SHORTOPTS "bsnrRuEe:f:l:i::V:"
+#define SHORTOPTS "bcsnrRuEe:f:l:i::V:"
#else
-#define SHORTOPTS "bsnruEe:f:l:i::V:"
+#define SHORTOPTS "bcsnruEe:f:l:i::V:"
#endif
static struct option longopts[] = {
@@ -188,6 +194,7 @@ main(argc, argv)
{"expression", 1, NULL, 'e'},
{"file", 1, NULL, 'f'},
{"in-place", 2, NULL, 'i'},
+ {"copy", 0, NULL, 'c'},
{"line-length", 1, NULL, 'l'},
{"quiet", 0, NULL, 'n'},
{"posix", 0, NULL, 'p'},
@@ -254,6 +261,10 @@ main(argc, argv)
case 'F':
follow_symlinks = true;
+ break;
+
+ case 'c':
+ copy_instead_of_rename = true;
break;
case 'i':
@@ -334,6 +345,12 @@ to the extent permitted by law.\n\
}
}
+ if (copy_instead_of_rename && in_place_extension == NULL)
+ {
+ fprintf (stderr, _("Error: -c used without -i.\n"));
+ usage(4);
+ }
+
if (!the_program)
{
if (optind < argc)
diff --git a/sed/sed.h b/sed/sed.h
index 6b4101d..d4d9aa9 100644
--- a/sed/sed.h
+++ b/sed/sed.h
@@ -233,6 +233,10 @@ extern countT lcmd_out_line_len;
/* How do we edit files in-place? (we don't if NULL) */
extern char *in_place_extension;
+/* Do we use copy or rename when in in-place edit mode? (boolean
+ value, non-zero for copy, zero for rename).*/
+extern int copy_instead_of_rename;
+
/* The mode to use to read files, either "rt" or "rb". */
extern char *read_mode;
diff --git a/sed/utils.c b/sed/utils.c
index 241ef1d..ebe6030 100644
--- a/sed/utils.c
+++ b/sed/utils.c
@@ -39,6 +39,7 @@
#include <sys/stat.h>
#include <unistd.h>
#include <limits.h>
+#include <fcntl.h>
#include "utils.h"
#include "pathmax.h"
@@ -408,33 +409,99 @@ follow_symlink(const char *fname)
return fname;
#endif /* ENABLE_FOLLOW_SYMLINKS */
}
+
-/* Panic on failing rename */
+/* Panic on failing unlink */
void
-ck_rename (from, to, unlink_if_fail)
- const char *from, *to;
- const char *unlink_if_fail;
+ck_unlink (name)
+ const char *name;
{
- int rd = rename (from, to);
- if (rd != -1)
- return;
+ if (unlink (name) == -1)
+ panic (_("cannot remove %s: %s"), name, strerror (errno));
+}
- if (unlink_if_fail)
+/* Attempt to unlink denoted file if operation rd failed. */
+static int
+_unlink_if_fail (rd, unlink_if_fail)
+ int rd;
+ const char *unlink_if_fail;
+{
+ if (rd == -1 && unlink_if_fail)
{
int save_errno = errno;
+ ck_unlink (unlink_if_fail);
+ errno = save_errno;
+ }
+
+ return rd != -1;
+}
+
+/* Copy contents between files. */
+static int
+_copy (from, to)
+ const char *from, *to;
+{
+ static char buf[4096];
+
+ FILE *infile, *outfile;
+ int c, retval = 0;
errno = 0;
- unlink (unlink_if_fail);
- /* Failure to remove the temporary file is more severe, so trigger it first. */
- if (errno != 0)
- panic (_("cannot remove %s: %s"), unlink_if_fail, strerror (errno));
+ infile = fopen (from, "r");
+ if (infile == NULL)
+ return -1;
- errno = save_errno;
+ outfile = fopen (to, "w");
+ if (outfile == NULL)
+ {
+ fclose (infile);
+ return -1;
+ }
+
+ while (1)
+ {
+ size_t bytes_in = fread (buf, 1, sizeof (buf), infile);
+ size_t bytes_out;
+ if (bytes_in == 0)
+ {
+ if (ferror (infile))
+ retval = -1;
+ break;
+ }
+
+ bytes_out = fwrite (buf, 1, bytes_in, outfile);
+ if (bytes_out != bytes_in)
+ {
+ retval = -1;
+ break;
+ }
}
+ fclose (outfile);
+ fclose (infile);
+
+ return retval;
+}
+
+/* Panic on failing rename */
+void
+ck_rename (from, to, unlink_if_fail)
+ const char *from, *to;
+ const char *unlink_if_fail;
+{
+ if (!_unlink_if_fail (rename (from, to), unlink_if_fail))
panic (_("cannot rename %s: %s"), from, strerror (errno));
}
+/* Attempt to copy file contents between the files. */
+void
+ck_fcmove (from, to, unlink_if_fail)
+ const char *from, *to;
+ const char *unlink_if_fail;
+{
+ if (!_unlink_if_fail (_copy (from, to), unlink_if_fail))
+ panic (_("cannot copy %s to %s: %s"), from, to, strerror (errno));
+}
diff --git a/sed/utils.h b/sed/utils.h
index d3f431d..b915596 100644
--- a/sed/utils.h
+++ b/sed/utils.h
@@ -32,6 +32,7 @@ const char *follow_symlink P_((const char *path));
size_t ck_getline P_((char **text, size_t *buflen, FILE *stream));
FILE * ck_mkstemp P_((char **p_filename, char *tmpdir, char *base));
void ck_rename P_((const char *from, const char *to, const char *unlink_if_fail));
+void ck_fcmove P_((const char *from, const char *to, const char *unlink_if_fail));
VOID *ck_malloc P_((size_t size));
VOID *xmalloc P_((size_t size));
sed-4.2.1-makecheck.patch:
ChangeLog | 4 ++++
testsuite/Makefile.tests | 12 ++++++------
2 files changed, 10 insertions(+), 6 deletions(-)
--- NEW FILE sed-4.2.1-makecheck.patch ---
diff --git a/ChangeLog b/ChangeLog
index 06956a7..30d9fca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-10-14 Yuri G. Kudryashov <urkud.urkud at gmail.com> (tiny change)
+
+ * testsuite/Makefile.tests: Override LC_ALL, not LANG.
+
2009-06-27 Paolo Bonzini <bonzini at gnu.org>
* configure.ac: Bump version.
diff --git a/testsuite/Makefile.tests b/testsuite/Makefile.tests
index 1f04290..c0910dc 100644
--- a/testsuite/Makefile.tests
+++ b/testsuite/Makefile.tests
@@ -34,16 +34,16 @@ y-bracket y-newline insert brackets::
@$(RM) $@.out
badenc::
- LANG=ru_RU.UTF-8 $(TIME) $(SED) -nf $(srcdir)/$@.sed \
+ LC_ALL=ru_RU.UTF-8 $(TIME) $(SED) -nf $(srcdir)/$@.sed \
< $(srcdir)/$@.inp | $(TR) -d \\r > $@.out
$(CMP) $(srcdir)/$@.good $@.out
- LANG=it_IT.UTF-8 $(TIME) $(SED) -nf $(srcdir)/$@.sed \
+ LC_ALL=it_IT.UTF-8 $(TIME) $(SED) -nf $(srcdir)/$@.sed \
< $(srcdir)/$@.inp | $(TR) -d \\r > $@.out
$(CMP) $(srcdir)/$@.good $@.out
- LANG=en_US.UTF-8 $(TIME) $(SED) -nf $(srcdir)/$@.sed \
+ LC_ALL=en_US.UTF-8 $(TIME) $(SED) -nf $(srcdir)/$@.sed \
< $(srcdir)/$@.inp | $(TR) -d \\r > $@.out
$(CMP) $(srcdir)/$@.good $@.out
- LANG=en_GB.UTF-8 $(TIME) $(SED) -nf $(srcdir)/$@.sed \
+ LC_ALL=en_GB.UTF-8 $(TIME) $(SED) -nf $(srcdir)/$@.sed \
< $(srcdir)/$@.inp | $(TR) -d \\r > $@.out
$(CMP) $(srcdir)/$@.good $@.out
@$(RM) $@.out
@@ -51,10 +51,10 @@ badenc::
# Try with ru_RU.UTF-8. If it is presumably not installed, see if the current
# locale is UTF-8 and run it in the current locale.
utf8-1 utf8-2 utf8-3 utf8-4::
- echo "LANG=ru_RU.UTF-8" \
+ echo "LC_ALL=ru_RU.UTF-8" \
"$(TIME) $(SED) -f $(srcdir)/$@.sed" \
"< $(srcdir)/$@.inp | $(TR) -d \\r > $@.out"; \
- LANG=ru_RU.UTF-8 \
+ LC_ALL=ru_RU.UTF-8 \
$(TIME) $(SED) -f $(srcdir)/$@.sed \
< $(srcdir)/$@.inp | $(TR) -d \\r > $@.out; \
$(CMP) $(srcdir)/$@.good $@.out && exit 0; \
Index: sed.spec
===================================================================
RCS file: /cvs/pkgs/rpms/sed/F-13/sed.spec,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -p -r1.51 -r1.52
--- sed.spec 16 Oct 2009 09:12:45 -0000 1.51
+++ sed.spec 22 Mar 2010 13:02:37 -0000 1.52
@@ -6,13 +6,14 @@
Summary: A GNU stream text editor
Name: sed
Version: 4.2.1
-Release: 4%{?dist}
-License: GPLv2+
+Release: 5%{?dist}
+License: GPLv3+
Group: Applications/Text
URL: http://sed.sourceforge.net/
Source0: ftp://ftp.gnu.org/pub/gnu/sed/sed-%{version}.tar.bz2
Source1: http://sed.sourceforge.net/sedfaq.txt
-Patch0: sed-4.2.1-dummyparam.diff
+Patch0: sed-4.2.1-copy.patch
+Patch1: sed-4.2.1-makecheck.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: glibc-devel, libselinux-devel
Requires(post): /sbin/install-info
@@ -28,6 +29,7 @@ specified in a script file or from the c
%prep
%setup -q
%patch0 -p1
+%patch1 -p1
%build
%configure --without-included-regex
@@ -68,6 +70,12 @@ rm -rf ${RPM_BUILD_ROOT}
%{_mandir}/man*/*
%changelog
+* Wed Mar 17 2010 Jan Görig <jgorig at redhat.com> 4.2.1-5
+- fixed make check on non UTF-8 locale - upstream patch rhbz#550731
+- readded -c option (thanks Paolo Bonzini) rhbz#566455
+- removed previous -c dummy patch
+- changed license to GPLv3+
+
* Fri Oct 16 2009 Jiri Moskovcak <jmoskovc at redhat.com> 4.2.1-4
- added libselinux-devel to buildrequires rhbz#514182
- fixed problem with --excludedocs rhbz#515913
--- sed-4.1.5-copy.patch DELETED ---
--- sed-4.1.5-follow.patch DELETED ---
--- sed-4.1.5-utf8performance.patch DELETED ---
--- sed-4.2.1-dummyparam.diff DELETED ---
More information about the scm-commits
mailing list