pkgsrc/x11/xview-lib/patches/patch-de
2012-11-16 00:29:39 +00:00

152 lines
4.1 KiB
Text

$NetBSD: patch-de,v 1.6 2012/11/16 00:29:40 joerg Exp $
--- lib/libxview/textsw/es_file.c.orig 1993-06-29 05:17:34.000000000 +0000
+++ lib/libxview/textsw/es_file.c
@@ -85,18 +85,15 @@ static char sccsid[] = "@(#)es_file.
#include <string.h>
#include <fcntl.h>
-#ifdef SVR4
#include <stdlib.h>
#include <dirent.h>
-#else
-#include <sys/dir.h>
-#endif /* SVR4 */
-#include <sys/errno.h>
+#include <errno.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <stdio.h>
+#include <limits.h>
#include <xview/pkg.h>
#include <xview/attrol.h>
#include <xview_private/primal.h>
@@ -109,9 +106,14 @@ static char sccsid[] = "@(#)es_file.
#include <xview_private/txt_18impl.h>
+#if (defined(BSD) && (BSD >= 199306))
+extern const char *const sys_err_list[];
+extern off_t lseek();
+#else
extern int errno, sys_nerr;
extern char *sys_errlist[];
extern long lseek();
+#endif
static void update_read_buf(); /* update the read buf if overlaps write buf */
static Es_status es_file_commit();
@@ -216,7 +218,7 @@ update_read_buf(private,start,end,buf)
}
}
-Pkg_private int
+Pkg_private void
es_file_append_error(error_buf, file_name, status)
char *error_buf;
CHAR *file_name;
@@ -330,6 +332,16 @@ es_file_create(name, options, status)
int open_option;
struct stat buf;
Es_status dummy_status;
+#ifdef NAME_MAX
+#ifndef BACKUP_AT_HEAD_OF_LINK
+ char *temp_name, true_name[NAME_MAX];
+ int link_count, true_name_len;
+#endif
+#ifdef OW_I18N
+ char name[NAME_MAX];
+ (void) wcstombs(name, name_wc, NAME_MAX);
+#endif /* OW_I18N */
+#else
#ifndef BACKUP_AT_HEAD_OF_LINK
char *temp_name, true_name[MAXNAMLEN];
int link_count, true_name_len;
@@ -338,6 +350,7 @@ es_file_create(name, options, status)
char name[MAXNAMLEN];
(void) wcstombs(name, name_wc, MAXNAMLEN);
#endif /* OW_I18N */
+#endif
if (status == 0)
status = &dummy_status;
@@ -473,7 +486,7 @@ Error_Return:
}
/* ARGSUSED */
-static caddr_t
+caddr_t
#ifdef ANSI_FUNC_PROTO
es_file_get(Es_handle esh, Es_attribute attribute, ...)
#else
@@ -1146,9 +1159,16 @@ es_file_copy_status(esh, to)
Es_file_data private = ABS_TO_REP(esh);
int dummy;
#ifdef OW_I18N
+#ifdef NAME_MAX
+ char to_mb[NAME_MAX];
+
+ (void) wcstombs(to_mb,to,NAME_MAX);
+#else
char to_mb[MAXNAMLEN];
(void) wcstombs(to_mb,to,MAXNAMLEN);
+#endif
+
return (es_copy_status(to_mb,private->fd, &dummy));
#else
return (es_copy_status(to, private->fd, &dummy));
@@ -1163,7 +1183,11 @@ es_file_make_backup(esh, backup_pattern,
/* Currently backup_pattern must be of the form "%s<suffix>" */
{
register Es_file_data private;
+#ifdef NAME_MAX
+ CHAR backup_name[NAME_MAX];
+#else
CHAR backup_name[MAXNAMLEN];
+#endif
int fd, len, retrying = FALSE;
Es_status dummy_status;
Es_handle result;
@@ -1200,9 +1224,15 @@ Retry:
* cannot be overwritten, so try to remove it first.
*/
#ifdef OW_I18N
+#ifdef NAME_MAX
+ char dummy[NAME_MAX];
+
+ (void) wcstombs(dummy, backup_name, MAXNAMLEN);
+#else
char dummy[MAXNAMLEN];
(void) wcstombs(dummy, backup_name, MAXNAMLEN);
+#endif
if (unlink(dummy) == 0) { /* } for match */
#else
if (unlink(backup_name) == 0) {
@@ -1239,7 +1269,11 @@ es_file_make_wchar_file(esh, open_option
{
register Es_file_data private;
char *filename;
+#ifdef NAME_MAX
+ char old_filename[NAME_MAX];
+#else
char old_filename[MAXNAMLEN];
+#endif
int fd, new_fd, len;
extern int es_mb_to_wc_fd();
@@ -1255,7 +1289,11 @@ es_file_make_wchar_file(esh, open_option
filename = tempnam(NULL,NULL);
+#ifdef NAME_MAX
+ (void)wcstombs(old_filename, private->name, NAME_MAX);
+#else
(void)wcstombs(old_filename, private->name, MAXNAMLEN);
+#endif
private->skipped = 0;
if (es_mb_to_wc_fd(old_filename, filename, fd, &private->skipped) == 0) {