Fix warnings from Ghostview file-browser dialog
authorH.G. Muller <h.g.muller@hccnet.nl>
Thu, 7 Jan 2010 16:31:48 +0000 (17:31 +0100)
committerH.G. Muller <h.g.muller@hccnet.nl>
Thu, 7 Jan 2010 16:31:48 +0000 (17:31 +0100)
The Ghostview dialog was using some deprecated variables for error
printing, and conditionally used getwd() on some systems that presumably
do not have getcwd(), but it did not assess the latter properly.

selfile.c

index 422cf7b..4298e30 100644 (file)
--- a/selfile.c
+++ b/selfile.c
@@ -45,7 +45,7 @@
 #include <errno.h>
 /* BSD 4.3 errno.h does not declare errno */
 extern int errno;
-extern int sys_nerr;
+//extern int sys_nerr;
 //extern char *sys_errlist[]; // [HGM] this produced a compile error in Ubuntu 8.04
 
 #include <sys/param.h>
@@ -567,11 +567,11 @@ SFopenFile(name, mode, prompt, failed)
     SFchdir(SFstartDir);
     if ((fp = fopen(name, mode)) == NULL) {
        char *buf;
-       if (errno <= sys_nerr) {
-           buf = XtMalloc(strlen(failed) + strlen(sys_errlist[errno]) + 
+       if (1) { // [HGM] always use strerror
+           buf = XtMalloc(strlen(failed) + strlen(strerror(errno)) + 
                           strlen(prompt) + 2);
            strcpy(buf, failed);
-           strcat(buf, sys_errlist[errno]);
+           strcat(buf, strerror(errno));
            strcat(buf, "\n");
            strcat(buf, prompt);
        } else {
@@ -685,8 +685,8 @@ XsraSelFile(toplevel, prompt, ok, cancel, failed,
        SFpositionWidget(selFile);
        XtMapWidget(selFile);
 
-#if defined(SVR4) || defined(SYSV) || defined(USG)
-       if (!getcwd(SFstartDir, MAXPATHLEN)) {
+#if defined(SVR4) || defined(SYSV) || defined(USG) || 1
+       if (!getcwd(SFstartDir, MAXPATHLEN)) { // [HGM] always do this, as I do not know when exactly to do it
 #else /* defined(SVR4) || defined(SYSV) || defined(USG) */
        if (!getwd(SFstartDir)) {
 #endif /* defined(SVR4) || defined(SYSV) || defined(USG) */