$NetBSD: patch-de,v 1.3 2006/01/05 18:25:57 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 #include -#ifdef SVR4 #include #include -#else -#include -#endif /* SVR4 */ -#include +#include #include #include #include #include #include +#include #include #include #include @@ -109,9 +106,14 @@ static char sccsid[] = "@(#)es_file. #include +#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(); @@ -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; @@ -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" */ { 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) {