[PATCH] support XDG_CONFIG_HOME on macOS

Jun T <[email protected]>
Newsgroups gmane.comp.graphics.gnuplot.devel
Message-ID <[email protected]>
macOS does not define __unix__ but it can support XDG_CONFIG_HOME.

I believe just checking for __APPLE__ is enough, but added a check for
__MACH__ since it is the method recommended by Apple (and used in m4/apple.m4).


diff --git a/src/plot.c b/src/plot.c
index 8e91239cf..f41a192b0 100644
--- a/src/plot.c
+++ b/src/plot.c
@@ -789,7 +789,7 @@ load_rcfile(int where)
 	PATH_CONCAT(rcfile, PLOTRC);
 	plotrc = fopen(rcfile, "r");
     } else if (where == 3) {
-#ifdef __unix__
+#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
 	char * XDGConfigHome = xdg_get_var(kXDGConfigHome);
 	size_t len = strlen(XDGConfigHome);
 	rcfile = gp_alloc(len + 1 + sizeof("gnuplot/gnuplotrc"), "rcfile");
diff --git a/src/xdg.c b/src/xdg.c
index 93e4c227d..985dc77d4 100644
--- a/src/xdg.c
+++ b/src/xdg.c
@@ -2,7 +2,7 @@
 #include "plot.h"
 #include "util.h"
 
-#ifdef __unix__
+#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
 
 #include <assert.h>
 #include <stdio.h>
@@ -57,4 +57,4 @@ char *xdg_get_var(const XDGVarType idx) {
     return XDGVar;
 }
 
-#endif /* __unix__ */
+#endif /* __unix__ || macOS */
diff --git a/src/xdg.h b/src/xdg.h
index acfdda19d..8460edfa0 100644
--- a/src/xdg.h
+++ b/src/xdg.h
@@ -1,7 +1,7 @@
 #ifndef GNUPLOT_XDG_H
 #define GNUPLOT_XDG_H
 
-#ifdef __unix__
+#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
 
 /* List of possible XDG variables */
 typedef enum {
@@ -16,7 +16,7 @@ typedef enum {
 
 char *xdg_get_var(const XDGVarType idx);
 
-#endif /* __unix__ */
+#endif /* __unix__ || macOS */
 
 #endif /* GNUPLOT_XDG_H */

_______________________________________________
gnuplot-beta mailing list
[email protected]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-beta
macOS-xdg.patch (application/octet-stream, 1.4 KB)
diff --git a/src/plot.c b/src/plot.c
index 8e91239cf..f41a192b0 100644
--- a/src/plot.c
+++ b/src/plot.c
@@ -789,7 +789,7 @@ load_rcfile(int where)
 	PATH_CONCAT(rcfile, PLOTRC);
 	plotrc = fopen(rcfile, "r");
     } else if (where == 3) {
-#ifdef __unix__
+#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
 	char * XDGConfigHome = xdg_get_var(kXDGConfigHome);
 	size_t len = strlen(XDGConfigHome);
 	rcfile = gp_alloc(len + 1 + sizeof("gnuplot/gnuplotrc"), "rcfile");
diff --git a/src/xdg.c b/src/xdg.c
index 93e4c227d..985dc77d4 100644
--- a/src/xdg.c
+++ b/src/xdg.c
@@ -2,7 +2,7 @@
 #include "plot.h"
 #include "util.h"
 
-#ifdef __unix__
+#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
 
 #include <assert.h>
 #include <stdio.h>
@@ -57,4 +57,4 @@ char *xdg_get_var(const XDGVarType idx) {
     return XDGVar;
 }
 
-#endif /* __unix__ */
+#endif /* __unix__ || macOS */
diff --git a/src/xdg.h b/src/xdg.h
index acfdda19d..8460edfa0 100644
--- a/src/xdg.h
+++ b/src/xdg.h
@@ -1,7 +1,7 @@
 #ifndef GNUPLOT_XDG_H
 #define GNUPLOT_XDG_H
 
-#ifdef __unix__
+#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
 
 /* List of possible XDG variables */
 typedef enum {
@@ -16,7 +16,7 @@ typedef enum {
 
 char *xdg_get_var(const XDGVarType idx);
 
-#endif /* __unix__ */
+#endif /* __unix__ || macOS */
 
 #endif /* GNUPLOT_XDG_H */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.