Re: [PATCH] support XDG_CONFIG_HOME on macOS

Jun T <[email protected]>
Newsgroups gmane.comp.graphics.gnuplot.devel
Message-ID <[email protected]>
Sorry, this should be better.
Define USE_XDG_BASEDIR in xdg.h.

Jun


diff --git a/src/plot.c b/src/plot.c
index 8e91239cf..66fdb6e45 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__
+#ifdef USE_XDG_BASEDIR
 	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..e6652d329 100644
--- a/src/xdg.c
+++ b/src/xdg.c
@@ -2,7 +2,7 @@
 #include "plot.h"
 #include "util.h"
 
-#ifdef __unix__
+#ifdef USE_XDG_BASEDIR
 
 #include <assert.h>
 #include <stdio.h>
@@ -57,4 +57,4 @@ char *xdg_get_var(const XDGVarType idx) {
     return XDGVar;
 }
 
-#endif /* __unix__ */
+#endif /* USE_XDG_BASEDIR */
diff --git a/src/xdg.h b/src/xdg.h
index acfdda19d..cab5e1415 100644
--- a/src/xdg.h
+++ b/src/xdg.h
@@ -1,7 +1,9 @@
 #ifndef GNUPLOT_XDG_H
 #define GNUPLOT_XDG_H
 
-#ifdef __unix__
+#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
+
+#define USE_XDG_BASEDIR
 
 /* List of possible XDG variables */
 typedef enum {
@@ -16,7 +18,7 @@ typedef enum {
 
 char *xdg_get_var(const XDGVarType idx);
 
-#endif /* __unix__ */
+#endif /* USE_XDG_BASEDIR */
 
 #endif /* GNUPLOT_XDG_H */

_______________________________________________
gnuplot-beta mailing list
[email protected]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-beta
macOS-xdg-v2.patch (application/octet-stream, 1.3 KB)
diff --git a/src/plot.c b/src/plot.c
index 8e91239cf..66fdb6e45 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__
+#ifdef USE_XDG_BASEDIR
 	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..e6652d329 100644
--- a/src/xdg.c
+++ b/src/xdg.c
@@ -2,7 +2,7 @@
 #include "plot.h"
 #include "util.h"
 
-#ifdef __unix__
+#ifdef USE_XDG_BASEDIR
 
 #include <assert.h>
 #include <stdio.h>
@@ -57,4 +57,4 @@ char *xdg_get_var(const XDGVarType idx) {
     return XDGVar;
 }
 
-#endif /* __unix__ */
+#endif /* USE_XDG_BASEDIR */
diff --git a/src/xdg.h b/src/xdg.h
index acfdda19d..cab5e1415 100644
--- a/src/xdg.h
+++ b/src/xdg.h
@@ -1,7 +1,9 @@
 #ifndef GNUPLOT_XDG_H
 #define GNUPLOT_XDG_H
 
-#ifdef __unix__
+#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
+
+#define USE_XDG_BASEDIR
 
 /* List of possible XDG variables */
 typedef enum {
@@ -16,7 +18,7 @@ typedef enum {
 
 char *xdg_get_var(const XDGVarType idx);
 
-#endif /* __unix__ */
+#endif /* USE_XDG_BASEDIR */
 
 #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.