1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
$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) {
|