Hello community,
here is the log from the commit of package sed
checked in at Sun Mar 11 00:09:22 CET 2007.
--------
--- sed/sed.changes 2006-08-07 14:36:02.000000000 +0200
+++ /mounts/work_src_done/STABLE/sed/sed.changes 2007-03-09 17:52:43.000000000 +0100
@@ -1,0 +2,6 @@
+Fri Mar 9 17:31:50 CET 2007 - mkoenig@suse.de
+
+- add --follow-symlinks option [#200082]
+- fix 'used uninitialized' warnings [#248721]
+
+-------------------------------------------------------------------
New:
----
sed-4.1.5-fix_warnings.patch
sed-follow_symlinks.patch
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ sed.spec ++++++
--- /var/tmp/diff_new_pack.xw9688/_old 2007-03-11 00:08:59.000000000 +0100
+++ /var/tmp/diff_new_pack.xw9688/_new 2007-03-11 00:08:59.000000000 +0100
@@ -1,7 +1,7 @@
#
# spec file for package sed (Version 4.1.5)
#
-# Copyright (c) 2006 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2007 SUSE LINUX Products GmbH, Nuernberg, Germany.
# This file and all modifications and additions to the pristine
# package are under the same license as the package itself.
#
@@ -13,21 +13,23 @@
Name: sed
URL: http://www.gnu.org/directory/sed.html
Version: 4.1.5
-Release: 2
-License: GPL
+Release: 29
+License: GNU General Public License (GPL)
Group: System/Base
Summary: A Stream-Oriented Noninteractive Text Editor
Provides: base:/bin/sed
PreReq: %install_info_prereq
Autoreqprov: on
Source: %name-%version.tar.bz2
+Patch0: sed-follow_symlinks.patch
+Patch1: sed-4.1.5-fix_warnings.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
Sed takes text input, performs some operation (or set of operations) on
-it and outputs the modified text. Sed is typically used for extracting
+it, and outputs the modified text. Sed is typically used for extracting
part of a file using pattern matching or substituting multiple
-occurences of a string within a file.
+occurrences of a string within a file.
@@ -35,7 +37,7 @@
--------
Francois Pinard
Tom Lord
- David J. MacKenzie
+ David J. MacKenzie
Akiko Matsushita
Alan Magnuson
Alexander Lehmann
@@ -76,15 +78,15 @@
Mike Lijewski
Nick S. Kanakakor
Nicolas Pioch
- Noah Friedman
+ Noah Friedman
Pete Chown
Pierre Gaumond
Pierre Mathieu
Robert Bernstein
Rene' Seindal
- Richard Stallman
+ Richard Stallman
Roland H. Pesch
- Roland McGrath
+ Roland McGrath
Scott Bartram
Simon Leinen
Skip Montanaro
@@ -94,7 +96,7 @@
Tom McConnell
Tom Quinn
Tom Tromey
- Ulrich Drepper
+ Ulrich Drepper
Vern Paxson
Vivek P. Singhal
Walter Wong
@@ -103,6 +105,8 @@
%prep
%setup -q
+%patch0 -p1
+%patch1 -p1
%build
%define warn_flags -Wall -Wstrict-prototypes -Wpointer-arith -Wformat-security
@@ -154,7 +158,10 @@
%postun
%install_info_delete --info-dir=%_infodir %_infodir/%name.info.gz
-%changelog -n sed
+%changelog
+* Fri Mar 09 2007 - mkoenig@suse.de
+- add --follow-symlinks option [#200082]
+- fix 'used uninitialized' warnings [#248721]
* Mon Aug 07 2006 - jsmeix@suse.de
- Updated to version 4.1.5:
Fix parsing of a negative character class not including a closed
@@ -246,7 +253,7 @@
POSIXLY_CORRECT only disables GNU extensions that violate the
POSIX standard.
o options -h and -V are not supported anymore, use --help and
---version.
+ --version.
o removed documentation for \s and \S which worked incorrectly
o restored correct behavior for \w and \W: match [[:alnum:]_]
and [^[:alnum:]_] (they used to match [[:alpha:]_] and
++++++ sed-4.1.5-fix_warnings.patch ++++++
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)
®s, 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);
++++++ sed-follow_symlinks.patch ++++++
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
#endif /* HAVE_STDLIB_H */
+#ifdef ENABLE_FOLLOW_SYMLINKS
+# include
+# include
+# include
+# include
+#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)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remember to have fun...
---------------------------------------------------------------------
To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit+help@opensuse.org