OBS User unknown 2007-11-14 21:10:26 +00:00 committed by Git OBS Bridge
parent b8a717a60d
commit 2f74b01825
3 changed files with 162 additions and 1 deletions

150
less-409-speed.patch Normal file
View File

@ -0,0 +1,150 @@
--- cmdbuf.c
+++ cmdbuf.c 2007-11-14 19:07:11.216430000 +0100
@@ -14,11 +14,16 @@
* Used only by command() and related functions.
*/
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
#include "less.h"
#include "cmd.h"
#include "charset.h"
#if HAVE_STAT
+#include <sys/types.h>
#include <sys/stat.h>
+#include <fcntl.h>
#endif
extern int sc_width;
@@ -1361,6 +1366,7 @@ init_cmdhist()
#if CMD_HISTORY
struct mlist *ml = NULL;
char line[CMDBUF_SIZE];
+ char buf[BUFSIZ];
char *filename;
FILE *f;
char *p;
@@ -1372,6 +1378,7 @@ init_cmdhist()
free(filename);
if (f == NULL)
return;
+ setbuf(f, buf);
if (fgets(line, sizeof(line), f) == NULL ||
strncmp(line, HISTFILE_FIRST_LINE, strlen(HISTFILE_FIRST_LINE)) != 0)
{
@@ -1446,8 +1453,16 @@ save_cmdhist()
{
#if CMD_HISTORY
char *filename;
+ char *tempname;
+ char buf[BUFSIZ];
FILE *f;
- int modified = 0;
+ int modified = 0, fd;
+ mode_t umask_save;
+#if HAVE_STAT
+ struct stat st;
+ uid_t uid;
+ gid_t gid;
+#endif
filename = histfile_name();
if (filename == NULL)
@@ -1460,25 +1475,50 @@ save_cmdhist()
#endif
if (!modified)
return;
- f = fopen(filename, "w");
- free(filename);
- if (f == NULL)
+#if HAVE_STAT
+ /* Do not overwrite other users history files due `su' */
+ st.st_dev = st.st_ino = 0;
+ st.st_mode = 0600;
+ uid = getuid();
+ gid = getgid();
+ if ((stat(filename, &st) == 0) && (uid != 0) &&
+ !((st.st_uid == uid) ? (st.st_mode & 0200)
+ : ((st.st_gid == gid)
+ ? (st.st_mode & 0020)
+ : (st.st_mode & 0002))))
+ {
return;
-#if HAVE_FCHMOD
- /* Make history file readable only by owner. */
- fchmod(fileno(f), 0600);
+ }
#endif
+ tempname = malloc((strlen(filename)+strlen("XXXXXX"))*sizeof(char)+2);
+ if (tempname == NULL)
+ return;
+ sprintf(tempname, "%s.XXXXXX", filename);
+ (void)mktemp(tempname);
- fprintf(f, "%s\n", HISTFILE_FIRST_LINE);
+ umask_save = umask(077);
+#if HAVE_STAT
+ fd = open(tempname, O_CREAT|O_EXCL|O_WRONLY|O_NOFOLLOW, (int)((st.st_mode & 0777) | 0600));
+#else
+ fd = open(tempname, O_CREAT|O_EXCL|O_WRONLY|O_NOFOLLOW, 0600));
+#endif
+ (void)umask(umask_save);
+ f = fdopen(fd, "w");
+ if (f == NULL)
+ return;
+ setbuf(f, buf);
+ fprintf(f, "%s\n", HISTFILE_FIRST_LINE);
fprintf(f, "%s\n", HISTFILE_SEARCH_SECTION);
save_mlist(&mlist_search, f);
-
#if SHELL_ESCAPE || PIPEC
fprintf(f, "%s\n", HISTFILE_SHELL_SECTION);
save_mlist(&mlist_shell, f);
#endif
-
fclose(f);
+ if (rename(tempname, filename) < 0)
+ unlink(tempname);
+ free(filename);
+ free(tempname);
#endif /* CMD_HISTORY */
}
--- configure.ac
+++ configure.ac 2007-11-14 17:49:06.120100000 +0100
@@ -227,7 +227,7 @@ AC_TRY_COMPILE([#include <time.h>], [tim
# Checks for library functions.
AC_TYPE_SIGNAL
-AC_CHECK_FUNCS([fsync popen _setjmp sigprocmask sigsetmask snprintf stat system fchmod])
+AC_CHECK_FUNCS([tcdrain popen _setjmp sigprocmask sigsetmask snprintf stat system fchmod])
# AC_CHECK_FUNCS may not work for inline functions, so test these separately.
AC_MSG_CHECKING(for memcpy)
--- defines.h.in
+++ defines.h.in 2007-11-14 17:48:52.622384000 +0100
@@ -219,8 +219,8 @@
/* Define HAVE_FILENO if you have the fileno() macro. */
#undef HAVE_FILENO
-/* Define to 1 if you have the `fsync' function. */
-#undef HAVE_FSYNC
+/* Define to 1 if you have the `tcdrain' function. */
+#undef HAVE_TCDRAIN
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
--- screen.c
+++ screen.c 2007-11-14 17:31:21.752727000 +0100
@@ -431,8 +431,8 @@ raw_mode(on)
*/
s = save_term;
}
-#if HAVE_FSYNC
- fsync(tty);
+#ifdef HAVE_TCDRAIN
+ tcdrain(tty);
#endif
tcsetattr(tty, TCSADRAIN, &s);
#if MUST_SET_LINE_DISCIPLINE

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Wed Nov 14 19:10:18 CET 2007 - werner@suse.de
- Speed up the history save by using a temorary file and make the
stream of that file a full buffered one.
------------------------------------------------------------------- -------------------------------------------------------------------
Wed Oct 31 15:53:34 CET 2007 - anosek@suse.cz Wed Oct 31 15:53:34 CET 2007 - anosek@suse.cz

View File

@ -21,7 +21,7 @@ Provides: normal-less jless
Requires: file Requires: file
AutoReqProv: on AutoReqProv: on
Version: 409 Version: 409
Release: 1 Release: 5
Summary: Text File Browser and Pager Similar to more Summary: Text File Browser and Pager Similar to more
Url: http://www.greenwoodsoftware.com/less/ Url: http://www.greenwoodsoftware.com/less/
Source: %{name}-%{version}.tar.bz2 Source: %{name}-%{version}.tar.bz2
@ -31,6 +31,7 @@ Source3: lessclose.sh
Source4: lesskey.src Source4: lesskey.src
Patch1: %{name}-%{version}.patch Patch1: %{name}-%{version}.patch
Patch2: %{name}-%{version}-lessecho-man.patch Patch2: %{name}-%{version}-lessecho-man.patch
Patch3: %{name}-%{version}-speed.patch
Patch22: %{name}-%{version}-strict_aliasing.patch Patch22: %{name}-%{version}-strict_aliasing.patch
Patch23: %{name}-%{version}-mouse.patch Patch23: %{name}-%{version}-mouse.patch
Patch24: %{name}-%{version}-terminate.patch Patch24: %{name}-%{version}-terminate.patch
@ -56,6 +57,7 @@ Authors:
%setup -q %setup -q
%patch1 %patch1
%patch2 %patch2
%patch3
%patch22 %patch22
%patch23 %patch23
%patch24 %patch24
@ -107,6 +109,9 @@ rm -rf $RPM_BUILD_ROOT
%config %{sysconfdir}/* %config %{sysconfdir}/*
%{prefix}/bin/* %{prefix}/bin/*
%changelog %changelog
* Wed Nov 14 2007 - werner@suse.de
- Speed up the history save by using a temorary file and make the
stream of that file a full buffered one.
* Wed Oct 31 2007 - anosek@suse.cz * Wed Oct 31 2007 - anosek@suse.cz
- udpated to version 409 - udpated to version 409
* fixed crash when searching text containing certain * fixed crash when searching text containing certain