Accepting request 109055 from home:elvigia:branches:devel:libraries:c_c++

-  open all FDs with O_CLOEXEC in the library code.
-  use gcc visibility by just reusing upstream macros "public"
   and "protected"

OBS-URL: https://build.opensuse.org/request/show/109055
OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/libedit?expand=0&rev=47
This commit is contained in:
Ismail Dönmez 2012-03-13 11:11:23 +00:00 committed by Git OBS Bridge
parent 1aea2acc31
commit 2b87906d0d
4 changed files with 113 additions and 3 deletions

79
libedit-ocloexec.patch Normal file
View File

@ -0,0 +1,79 @@
Index: libedit-20110802-3.0/src/readline.c
===================================================================
--- libedit-20110802-3.0.orig/src/readline.c
+++ libedit-20110802-3.0/src/readline.c
@@ -1175,15 +1175,15 @@ history_truncate_file (const char *filen
if (filename == NULL && (filename = _default_history_file()) == NULL)
return errno;
- if ((fp = fopen(filename, "r+")) == NULL)
+ if ((fp = fopen(filename, "r+e")) == NULL)
return errno;
strcpy(template, _history_tmp_template);
- if ((fd = mkstemp(template)) == -1) {
+ if ((fd = mkostemp(template, O_CLOEXEC)) == -1) {
ret = errno;
goto out1;
}
- if ((tp = fdopen(fd, "r+")) == NULL) {
+ if ((tp = fdopen(fd, "r+e")) == NULL) {
close(fd);
ret = errno;
goto out2;
Index: libedit-20110802-3.0/src/vi.c
===================================================================
--- libedit-20110802-3.0.orig/src/vi.c
+++ libedit-20110802-3.0/src/vi.c
@@ -37,6 +37,7 @@
#include <unistd.h>
#include <limits.h>
#include <sys/wait.h>
+#include <fcntl.h>
#if !defined(lint) && !defined(SCCSID)
#if 0
@@ -1015,7 +1016,7 @@ vi_histedit(EditLine *el, Int c __attrib
return CC_ERROR;
}
- fd = mkstemp(tempfile);
+ fd = mkostemp(tempfile, O_CLOEXEC);
if (fd < 0)
return CC_ERROR;
len = (size_t)(el->el_line.lastchar - el->el_line.buffer);
Index: libedit-20110802-3.0/src/el.c
===================================================================
--- libedit-20110802-3.0.orig/src/el.c
+++ libedit-20110802-3.0/src/el.c
@@ -539,7 +539,7 @@ el_source(EditLine *el, const char *fnam
#endif
}
if (fp == NULL)
- fp = fopen(fname, "r");
+ fp = fopen(fname, "re");
if (fp == NULL) {
el_free(path);
return -1;
Index: libedit-20110802-3.0/src/history.c
===================================================================
--- libedit-20110802-3.0.orig/src/history.c
+++ libedit-20110802-3.0/src/history.c
@@ -741,7 +741,7 @@ history_load(TYPE(History) *h, const cha
static ct_buffer_t conv;
#endif
- if ((fp = fopen(fname, "r")) == NULL)
+ if ((fp = fopen(fname, "re")) == NULL)
return i;
if ((line = fgetln(fp, &sz)) == NULL)
@@ -802,7 +802,7 @@ history_save(TYPE(History) *h, const cha
static ct_buffer_t conv;
#endif
- if ((fp = fopen(fname, "w")) == NULL)
+ if ((fp = fopen(fname, "we")) == NULL)
return -1;
if (fchmod(fileno(fp), S_IRUSR|S_IWUSR) == -1)

22
libedit-visibility.patch Normal file
View File

@ -0,0 +1,22 @@
Index: libedit-20110802-3.0/src/sys.h
===================================================================
--- libedit-20110802-3.0.orig/src/sys.h
+++ libedit-20110802-3.0/src/sys.h
@@ -63,7 +63,7 @@
#endif
#ifndef public
-# define public /* Externally visible functions/variables */
+# define public __attribute__ ((visibility ("default"))) /* Externally visible functions/variables */
#endif
#ifndef private
@@ -71,7 +71,7 @@
#endif
#ifndef protected
-# define protected /* Redefined from elsewhere to "static" */
+# define protected __attribute__ ((visibility ("hidden"))) /* Redefined from elsewhere to "static" */
/* When we want to hide everything */
#endif

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Tue Mar 13 01:51:31 UTC 2012 - crrodriguez@opensuse.org
- open all FDs with O_CLOEXEC in the library code.
- use gcc visibility by just reusing upstream macros "public"
and "protected"
-------------------------------------------------------------------
Thu Feb 23 18:56:27 UTC 2012 - crrodriguez@opensuse.org

View File

@ -35,7 +35,8 @@ Source: %{pkg_name}-%{pkg_version}.tar.gz
Source1: README.SuSE
Source2: baselibs.conf
Patch2: libedit-20100424-3.0-ncurses.patch
#
Patch3: libedit-ocloexec.patch
Patch4: libedit-visibility.patch
Summary: Command Line Editing and History Library
License: BSD-3-Clause
Group: Development/Libraries/C and C++
@ -74,10 +75,11 @@ at a terminal prompt.
This package holds the development files for libedit.
%prep
%setup -n %{pkg_name}-%{pkg_version}
%setup -q -n %{pkg_name}-%{pkg_version}
%{__cp} %{S:1} .
%patch2
%patch3 -p1
%patch4 -p1
%build
NOCONFIGURE=1 autoreconf -fiv
%configure --disable-static --with-pic \