SHA256
3
0
forked from pool/sed

Accepting request 45626 from Base:System

Copy from Base:System/sed based on submit request 45626 from user dirkmueller

OBS-URL: https://build.opensuse.org/request/show/45626
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/sed?expand=0&rev=12
This commit is contained in:
OBS User autobuild 2010-08-24 15:59:03 +00:00 committed by Git OBS Bridge
commit 43b71253d4
6 changed files with 53 additions and 439 deletions

View File

@ -1,110 +0,0 @@
Index: sed-4.1.5/lib/utils.c
===================================================================
--- sed-4.1.5.orig/lib/utils.c
+++ sed-4.1.5/lib/utils.c
@@ -97,7 +97,6 @@ panic(const char *str, ...)
{
if (open_files->temp)
{
- int fd = fileno (open_files->fp);
fclose (open_files->fp);
errno = 0;
unlink (open_files->name);
@@ -250,7 +249,7 @@ ck_getline(text, buflen, stream)
size_t *buflen;
FILE *stream;
{
- int result;
+ int result = -1;
if (!ferror (stream))
result = getline (text, buflen, stream);
@@ -312,7 +311,6 @@ void
do_ck_fclose(fp)
FILE *fp;
{
- int fd;
ck_fflush(fp);
clearerr(fp);
Index: sed-4.1.5/sed/compile.c
===================================================================
--- sed-4.1.5.orig/sed/compile.c
+++ sed-4.1.5/sed/compile.c
@@ -384,7 +384,6 @@ get_openfile(file_ptrs, mode, fail)
struct buffer *b;
char *file_name;
struct output *p;
- int is_stderr;
b = read_filename();
file_name = get_buffer(b);
@@ -457,7 +456,7 @@ snarf_char_class(b, cur_stat)
{
int ch;
int state = 0;
- int delim;
+ int delim = 0;
bool pending_mb = 0;
ch = inchar();
@@ -1581,7 +1580,6 @@ compile_file(cur_program, cmdfile)
struct vector *cur_program;
const char *cmdfile;
{
- size_t len;
struct vector *ret;
prog.file = stdin;
Index: sed-4.1.5/sed/execute.c
===================================================================
--- sed-4.1.5.orig/sed/execute.c
+++ sed-4.1.5/sed/execute.c
@@ -1062,7 +1062,7 @@ append_replacement (buf, p, regs, repl_m
curr_type &= ~REPL_MODIFIERS;
}
- if (0 <= i)
+ if (0 <= i) {
if (regs->end[i] == regs->start[i] && p->repl_type & REPL_MODIFIERS)
/* Save this modifier, we shall apply it later.
e.g. in s/()([a-z])/\u\1\2/
@@ -1073,6 +1073,7 @@ append_replacement (buf, p, regs, repl_m
str_append_modified(buf, line.active + regs->start[i],
CAST(size_t)(regs->end[i] - regs->start[i]),
curr_type);
+ }
}
return repl_mod;
@@ -1100,7 +1101,7 @@ do_subst(sub)
&regs, sub->max_id + 1))
return;
- if (!sub->replacement && sub->numb <= 1)
+ if (!sub->replacement && sub->numb <= 1) {
if (regs.start[0] == 0 && !sub->global)
{
/* We found a match, set the `replaced' flag. */
@@ -1119,6 +1120,7 @@ do_subst(sub)
line.length = regs.start[0];
goto post_subst;
}
+ }
do
{
@@ -1377,11 +1379,12 @@ execute_program(vec, input)
{
char buf[4096];
int n = fread (buf, sizeof(char), 4096, pipe);
- if (n > 0)
+ if (n > 0) {
if (!cmd_length)
str_append(&s_accum, buf, n);
else
ck_fwrite(buf, 1, n, output_file.fp);
+ }
}
pclose (pipe);

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9c4ba29b4674984bb534cbef3b9513895940d728a5b623f36d5c7529c71908c2
size 645997

3
sed-4.2.1.tar.bz2 Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:2ac3b36ca37bfeb43c4ef4025778cd66d89c77abb843d90552a515a7c9d2948f
size 899091

View File

@ -1,224 +0,0 @@
Index: sed-4.1.5/sed/sed.c
===================================================================
--- sed-4.1.5.orig/sed/sed.c
+++ sed-4.1.5/sed/sed.c
@@ -70,6 +70,11 @@ bool no_default_output = false;
/* If set, reset line counts on every new file. */
bool separate_files = false;
+#ifdef ENABLE_FOLLOW_SYMLINKS
+/* If set, follow symlinks when processing in place */
+bool follow_symlinks = false;
+#endif
+
/* How do we edit files in-place? (we don't if NULL) */
char *in_place_extension = NULL;
@@ -105,6 +110,10 @@ Usage: %s [OPTION]... {script-only-if-no
add the script to the commands to be executed\n"));
fprintf(out, _(" -f script-file, --file=script-file\n\
add the contents of script-file to the commands to be executed\n"));
+#ifdef ENABLE_FOLLOW_SYMLINKS
+ fprintf(out, _(" --follow-symlinks\n\
+ follow symlinks when processing in place\n"));
+#endif
fprintf(out, _(" -i[SUFFIX], --in-place[=SUFFIX]\n\
edit files in place (makes backup if extension supplied)\n"));
fprintf(out, _(" -l N, --line-length=N\n\
@@ -163,6 +172,9 @@ main(argc, argv)
{"unbuffered", 0, NULL, 'u'},
{"version", 0, NULL, 'v'},
{"help", 0, NULL, 'h'},
+#ifdef ENABLE_FOLLOW_SYMLINKS
+ {"follow-symlinks", 0, NULL, 'F'},
+#endif
{NULL, 0, NULL, 0}
};
@@ -215,6 +227,12 @@ main(argc, argv)
the_program = compile_file(the_program, optarg);
break;
+#ifdef ENABLE_FOLLOW_SYMLINKS
+ case 'F':
+ follow_symlinks = true;
+ break;
+#endif
+
case 'i':
separate_files = true;
if (optarg == NULL)
Index: sed-4.1.5/lib/utils.c
===================================================================
--- sed-4.1.5.orig/lib/utils.c
+++ sed-4.1.5/lib/utils.c
@@ -35,6 +35,13 @@
# include <stdlib.h>
#endif /* HAVE_STDLIB_H */
+#ifdef ENABLE_FOLLOW_SYMLINKS
+# include <sys/types.h>
+# include <sys/stat.h>
+# include <unistd.h>
+# include <libgen.h>
+#endif /* ENABLE_FOLLOW_SYMLINKS */
+
#include "utils.h"
const char *myname;
@@ -315,6 +322,65 @@ do_ck_fclose(fp)
}
+#ifdef ENABLE_FOLLOW_SYMLINKS
+static char buf[2048], buf2[2048];
+static size_t bufsize = sizeof (buf);
+
+/* Follow symlink and panic if something fails. Returned value is
+ ultimate symlink target, stored in temporary buffer. You need to
+ strdup the return value, if you intend to use it later.*/
+const char *
+ck_follow_symlink(const char * fname)
+{
+ static struct stat statbuf;
+ int err;
+ char * dir;
+
+ if (strlen (fname) >= bufsize)
+ panic("ck_follow_symlink: file name too long");
+ strcpy (buf, fname);
+
+ while (1)
+ {
+ err = lstat (buf, &statbuf);
+
+ if (err != 0)
+ panic("ck_follow_symlink: couldn't lstat %s: %s", buf, strerror(errno));
+
+ if ((statbuf.st_mode & S_IFLNK) == S_IFLNK)
+ {
+ err = readlink (buf, buf2, bufsize);
+
+ if (err < 0)
+ panic("ck_follow_symlink: readlink failed on %s: %s", buf, strerror(errno));
+ else if (err == bufsize)
+ panic("ck_follow_symlink: pointee name too long");
+ else
+ buf2 [err] = '\0';
+
+ /* need to handle relative paths with care */
+ if (buf2[0] != '/')
+ {
+ dir = dirname (buf); // dir part of orig path
+ int len = strlen (dir); // orig path len
+ buf[len] = '/';
+ strncpy (buf+len+1, buf2, bufsize - len - 1);
+ if (buf[bufsize-1] != 0)
+ panic("ck_follow_symlink: pointee name too long");
+ }
+ else
+ {
+ strcpy (buf, buf2);
+ }
+ }
+ else
+ break;
+ }
+
+ return buf;
+}
+#endif /* ENABLE_FOLLOW_SYMLINKS */
+
/* Panic on failing rename */
void
ck_rename (from, to, unlink_if_fail)
Index: sed-4.1.5/lib/utils.h
===================================================================
--- sed-4.1.5.orig/lib/utils.h
+++ sed-4.1.5/lib/utils.h
@@ -27,6 +27,9 @@ void ck_fwrite P_((const VOID *ptr, size
size_t ck_fread P_((VOID *ptr, size_t size, size_t nmemb, FILE *stream));
void ck_fflush P_((FILE *stream));
void ck_fclose P_((FILE *stream));
+#ifdef ENABLE_FOLLOW_SYMLINKS
+const char *ck_follow_symlink P_((const char *path));
+#endif
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));
Index: sed-4.1.5/sed/execute.c
===================================================================
--- sed-4.1.5.orig/sed/execute.c
+++ sed-4.1.5/sed/execute.c
@@ -711,16 +711,34 @@ closedown(input)
if (in_place_extension && output_file.fp != NULL)
{
+#ifdef ENABLE_FOLLOW_SYMLINKS
+ char *target_name;
+
+ if (follow_symlinks)
+ target_name = ck_strdup(ck_follow_symlink(input->in_file_name));
+ else
+ target_name = ck_strdup(input->in_file_name);
+#else
+ const char *target_name;
+
+ target_name = input->in_file_name;
+#endif
+
ck_fclose (output_file.fp);
if (strcmp(in_place_extension, "*") != 0)
{
- char *backup_file_name = get_backup_file_name(input->in_file_name);
- ck_rename (input->in_file_name, backup_file_name, input->out_file_name);
+ char *backup_file_name = get_backup_file_name(target_name);
+ ck_rename (target_name, backup_file_name, input->out_file_name);
+
free (backup_file_name);
}
- ck_rename (input->out_file_name, input->in_file_name, input->out_file_name);
+ ck_rename (input->out_file_name, target_name, input->out_file_name);
+
free (input->out_file_name);
+#ifdef ENABLE_FOLLOW_SYMLINKS
+ free (target_name);
+#endif
}
input->fp = NULL;
Index: sed-4.1.5/sed/sed.h
===================================================================
--- sed-4.1.5.orig/sed/sed.h
+++ sed-4.1.5/sed/sed.h
@@ -219,6 +219,11 @@ extern bool no_default_output;
/* If set, reset line counts on every new file. */
extern bool separate_files;
+#ifdef ENABLE_FOLLOW_SYMLINKS
+/* If set, follow symlinks when invoked with -i option */
+extern bool follow_symlinks;
+#endif
+
/* Do we need to be pedantically POSIX compliant? */
extern enum posixicity_types posixicity;
Index: sed-4.1.5/configure.ac
===================================================================
--- sed-4.1.5.orig/configure.ac
+++ sed-4.1.5/configure.ac
@@ -117,6 +117,13 @@ enable_html=no)
AM_CONDITIONAL(BUILD_HTML, test "x$enable_html" != xno)
+# follow symlinks
+AC_CHECK_FUNC(lstat, have_lstat=yes)
+AC_CHECK_FUNC(readlink, have_readlink=yes)
+if test "x$have_lstat" = xyes -a "x$have_readlink" = xyes; then
+ AC_DEFINE(ENABLE_FOLLOW_SYMLINKS, ,[Follow symlinks when processing in place])
+fi
+
: ${TEXI2HTML=texi2html -monolithic}
AC_SUBST(TEXI2HTML)

View File

@ -1,3 +1,33 @@
-------------------------------------------------------------------
Fri Aug 13 11:10:53 CEST 2010 - dimstar@opensuse.org
- Update to version 4.2.1:
+ fix parsing of s/[[[[[[[[[]//
+ security contexts are preserved by -i too under SELinux
+ temporary files for sed -i are not made group/world-readable
until they are complete
- Changes from version 4.2:
+ now released under GPLv3
+ added a new extension `z` to clear pattern space even in the
presence of invalid multibyte sequences
+ a preexisting GNU gettext installation is needed in order to
compile GNU sed with NLS support
+ new option --follow-symlinks, available when editing a file
in-place.
+ hold-space is reset between different files in -i and -s modes.
+ multibyte processing fixed
+ fixed bug in 'i\' giving a segmentation violation if given
alone.
+ much improved portability
+ much faster in UTF-8 locales
+ will correctly replace ACLs when using -i
+ will now accept NUL bytes for `.'
- Drop upstream included [atches:
+ sed-follow_symlinks.patch
+ sed-4.1.5-fix_warnings.patch
- Remove --enable-html from configure: the option is no longer
supported and sed.html no longer created.
-------------------------------------------------------------------
Mon Jun 28 06:38:35 UTC 2010 - jengelh@medozas.de

122
sed.spec
View File

@ -1,5 +1,5 @@
#
# spec file for package sed (Version 4.1.5)
# spec file for package sed (Version 4.2.1)
#
# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
@ -15,22 +15,18 @@
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
# norootforbuild
Name: sed
Url: http://www.gnu.org/directory/sed.html
Version: 4.1.5
Release: 137
License: GPLv2+
Group: System/Base
Version: 4.2.1
Release: 1
License: GPLv3
Summary: A Stream-Oriented Non-Interactive Text Editor
Provides: base:/bin/sed
PreReq: %install_info_prereq
AutoReqProv: on
Url: http://www.gnu.org/directory/sed.html
Group: System/Base
Source: %name-%version.tar.bz2
Patch0: sed-follow_symlinks.patch
Patch1: sed-4.1.5-fix_warnings.patch
PreReq: %install_info_prereq
Provides: base:/bin/sed
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
@ -39,82 +35,8 @@ outputs the modified text. Sed is typically used for extracting parts
of a file using pattern matching or for substituting multiple
occurrences of a string within a file.
Authors:
--------
Francois Pinard <pinard@iro.umontreal.ca>
Tom Lord <lord@cygnus.com>
David J. MacKenzie <djm@gnu.org>
Akiko Matsushita <matusita@sra.co.jp>
Alan Magnuson <awm@osc.edu>
Alexander Lehmann <alex@hal.rhein-main.de>
Amos Shapira <amoss@cs.huji.ac.il>
Andreas Gustafsson <gson@niksula.hut.fi>
Andreas Schwab <schwab@suse.de>
Assar Westerlund <assar@nada.kth.se>
Ben A. Mesander <ben@piglet.cr.usgs.gov>
Bengt Mertensson <bengt@mathematik.uni-bremen.de>
Bernhard Daeubler <Bernhard.Daeubler@physik.uni-ulm.de>
Bjorn R. Bjornsson <brb@falcon.is>
Brendan Kehoe <brendan@cygnus.com>
Erez Zadok <ezk@cs.columbia.edu>
Eric Allman <sendmail@sendmail.ORG>
Eric Backus <ericb@lsid.hp.com>
Geoff Russell <grussell@guest.adelaide.edu.au>
Greg A. Woods <woods@web.apc.org>
Hal Peterson <hrp@pecan.cray.com>
Hoang Uong <hoang@ornews.intel.com>
Ian Lance Taylor <ian@cygnus.com>
Jason Merrill <jason@cygnus.com>
Jim Avera <jima@netcom.com>
Jim Kingdon <kingdon@cygnus.com>
Jim Meyering <meyering@na-net.ornl.gov>
Joel Sherrill <jsherril@uahcs2.cs.uah.edu>
John David Anglin <dave@hiauly1.hia.nrc.ca>
Joseph E. Sacco <jsacco@ssl.com>
Karl Berry <karl@cs.umb.edu>
Karl Vogel <vogelke@c-17igp.wpafb.af.mil>
Kaveh R. Ghazi <ghazi@noc.rutgers.edu>
Kristine Lund <lund@lpnaxp.in2p3.fr>
Krste Asanovic <krste@icsi.berkeley.edu>
Marion Hakanson <hakanson@cse.ogi.edu>
Mark Seiden <mis@seiden.com>
Matthias Rabe <rabe@mathematik.uni-bielefeld.de>
Michael Fetterman <mafetter@ichips.intel.com>
Michael L. Welcome <welcome@bigbird.llnl.gov>
Mike Lijewski <lijewski@theory.tc.cornell.edu>
Nick S. Kanakakor <skanan@otl.scu.edu>
Nicolas Pioch <pioch@inf.enst.fr>
Noah Friedman <friedman@gnu.org>
Pete Chown <pete.chown@dale.dircon.co.uk>
Pierre Gaumond <gaumondp@ere.umontreal.ca>
Pierre Mathieu <mathieu@geod.emr.ca>
Robert Bernstein <rocky@panix.com>
Rene' Seindal <seindal@kb.dk>
Richard Stallman <rms@gnu.org>
Roland H. Pesch <roland@wrs.com>
Roland McGrath <roland@gnu.org>
Scott Bartram
Simon Leinen <simon@lia.di.epfl.ch>
Skip Montanaro <skip@automatrix.com>
Stephen Perkins <perkins@cps.msu.edu>
Steve Williamson <willy@uinpla.npl.uiuc.edu>
Thorsten Ohl <ohl@physics.harvard.edu>
Tom McConnell <tmcconne@sedona.intel.com>
Tom Quinn <trq@dionysos.thphys.ox.ac.uk>
Tom Tromey <tromey@cns.caltech.edu>
Ulrich Drepper <drepper@gnu.org>
Vern Paxson <vern@ee.lbl.gov>
Vivek P. Singhal <singhal@cs.utexas.edu>
Walter Wong <wcw+@cmu.edu>
Paolo Bonzini (bonzini@gnu.org)
Philip Hazel (ph10@cam.ac.uk)
%prep
%setup -q
%patch0 -p1
%patch1 -p1
%build
%define warn_flags -Wall -Wstrict-prototypes -Wpointer-arith -Wformat-security
@ -122,12 +44,11 @@ Authors:
cp /usr/share/gettext/config.rpath config
autoreconf --force --install
test -f po/Makevars.template && mv po/Makevars.template po/Makevars
export CFLAGS="$RPM_OPT_FLAGS %warn_flags"
export CFLAGS="%{optflags} %warn_flags"
./configure --prefix=/usr \
--mandir=%_mandir \
--infodir=%_infodir \
--mandir=%{_mandir} \
--infodir=%{_infodir} \
--without-included-regex \
--enable-html \
%{_target_cpu}-suse-linux
%if %do_profiling
make %{?_smp_mflags} CFLAGS="$CFLAGS "%cflags_profile_generate
@ -142,26 +63,23 @@ make %{?_smp_mflags} check
%install
%makeinstall
# Move sed to /bin:
mkdir -p $RPM_BUILD_ROOT/bin
mv $RPM_BUILD_ROOT/usr/bin/sed $RPM_BUILD_ROOT/bin
ln -s ../../bin/sed $RPM_BUILD_ROOT/usr/bin/sed
# Remove installed documentation (it is packaged directly in the files section).
# The actual directory depends on the build environment on the different architectures:
rm -f $RPM_BUILD_ROOT/usr/share/doc/sed.html $RPM_BUILD_ROOT/usr/share/doc/sed-4.1.5/sed.html
mkdir -p %{buildroot}/bin
mv %{buildroot}%{_bindir}/sed %{buildroot}/bin
ln -s ../../bin/sed %{buildroot}%{_bindir}/sed
%find_lang %name
%files -f %name.lang
%defattr(-, root, root)
/bin/sed
/usr/bin/sed
%doc AUTHORS BUGS COPYING* INSTALL NEWS README* THANKS doc/sed.html
%_infodir/sed.info*.gz
%_mandir/man*/*.gz
%{_bindir}/sed
%doc AUTHORS BUGS COPYING* INSTALL NEWS README* THANKS
%{_infodir}/sed.info*.gz
%{_mandir}/man*/*.gz
%post
%install_info --info-dir=%_infodir %_infodir/%name.info.gz
%install_info --info-dir=%{_infodir} %{_infodir}/%name.info.gz
%postun
%install_info_delete --info-dir=%_infodir %_infodir/%name.info.gz
%install_info_delete --info-dir=%{_infodir} %{_infodir}/%name.info.gz
%changelog