From 44a6d21a3ff14c20d1a99ba3aa81a84ee35c1ad4 Mon Sep 17 00:00:00 2001
From: "Silas S. Brown" <ssb22@cam.ac.uk>
Date: Fri, 4 Dec 2020 12:34:44 +0000
Subject: [PATCH] use TMPDIR on BSD systems

---
 gradint-build/Makefile          | 2 +-
 gradint-build/src/booktime.py   | 2 +-
 gradint-build/src/filescan.py   | 2 +-
 gradint-build/src/frontend.py   | 2 +-
 gradint-build/src/lessonplan.py | 2 +-
 gradint-build/src/loop.py       | 2 +-
 gradint-build/src/makeevent.py  | 2 +-
 gradint-build/src/play.py       | 2 +-
 gradint-build/src/recording.py  | 2 +-
 gradint-build/src/sequence.py   | 2 +-
 gradint-build/src/synth.py      | 2 +-
 gradint-build/src/system.py     | 5 ++++-
 gradint-build/src/top.py        | 2 +-
 gradint-build/src/users.py      | 2 +-
 gradint-build/thindown.py       | 2 +-
 15 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/gradint-build/Makefile b/gradint-build/Makefile
index 793ef0d..cb2f177 100644
--- a/gradint-build/Makefile
+++ b/gradint-build/Makefile
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v3.06 (c) 2002-20 Silas S. Brown. GPL v3+.
+# gradint v3.061 (c) 2002-20 Silas S. Brown. GPL v3+.
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
 #    the Free Software Foundation; either version 3 of the License, or
diff --git a/gradint-build/src/booktime.py b/gradint-build/src/booktime.py
index 4733867..828ff80 100644
--- a/gradint-build/src/booktime.py
+++ b/gradint-build/src/booktime.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v3.06 (c) 2002-20 Silas S. Brown. GPL v3+.
+# gradint v3.061 (c) 2002-20 Silas S. Brown. GPL v3+.
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
 #    the Free Software Foundation; either version 3 of the License, or
diff --git a/gradint-build/src/filescan.py b/gradint-build/src/filescan.py
index 58cfcde..ae0491c 100644
--- a/gradint-build/src/filescan.py
+++ b/gradint-build/src/filescan.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v3.06 (c) 2002-20 Silas S. Brown. GPL v3+.
+# gradint v3.061 (c) 2002-20 Silas S. Brown. GPL v3+.
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
 #    the Free Software Foundation; either version 3 of the License, or
diff --git a/gradint-build/src/frontend.py b/gradint-build/src/frontend.py
index 464d1fb..fbea111 100644
--- a/gradint-build/src/frontend.py
+++ b/gradint-build/src/frontend.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v3.06 (c) 2002-20 Silas S. Brown. GPL v3+.
+# gradint v3.061 (c) 2002-20 Silas S. Brown. GPL v3+.
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
 #    the Free Software Foundation; either version 3 of the License, or
diff --git a/gradint-build/src/lessonplan.py b/gradint-build/src/lessonplan.py
index 5dedc64..4120b3e 100644
--- a/gradint-build/src/lessonplan.py
+++ b/gradint-build/src/lessonplan.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v3.06 (c) 2002-20 Silas S. Brown. GPL v3+.
+# gradint v3.061 (c) 2002-20 Silas S. Brown. GPL v3+.
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
 #    the Free Software Foundation; either version 3 of the License, or
diff --git a/gradint-build/src/loop.py b/gradint-build/src/loop.py
index 10c16a1..f4ad142 100644
--- a/gradint-build/src/loop.py
+++ b/gradint-build/src/loop.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v3.06 (c) 2002-20 Silas S. Brown. GPL v3+.
+# gradint v3.061 (c) 2002-20 Silas S. Brown. GPL v3+.
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
 #    the Free Software Foundation; either version 3 of the License, or
diff --git a/gradint-build/src/makeevent.py b/gradint-build/src/makeevent.py
index 88617d3..a5c28a2 100644
--- a/gradint-build/src/makeevent.py
+++ b/gradint-build/src/makeevent.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v3.06 (c) 2002-20 Silas S. Brown. GPL v3+.
+# gradint v3.061 (c) 2002-20 Silas S. Brown. GPL v3+.
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
 #    the Free Software Foundation; either version 3 of the License, or
diff --git a/gradint-build/src/play.py b/gradint-build/src/play.py
index cf44019..92b1a1a 100644
--- a/gradint-build/src/play.py
+++ b/gradint-build/src/play.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v3.06 (c) 2002-20 Silas S. Brown. GPL v3+.
+# gradint v3.061 (c) 2002-20 Silas S. Brown. GPL v3+.
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
 #    the Free Software Foundation; either version 3 of the License, or
diff --git a/gradint-build/src/recording.py b/gradint-build/src/recording.py
index 7205734..2885586 100644
--- a/gradint-build/src/recording.py
+++ b/gradint-build/src/recording.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v3.06 (c) 2002-20 Silas S. Brown. GPL v3+.
+# gradint v3.061 (c) 2002-20 Silas S. Brown. GPL v3+.
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
 #    the Free Software Foundation; either version 3 of the License, or
diff --git a/gradint-build/src/sequence.py b/gradint-build/src/sequence.py
index f1345dd..a57a8d1 100644
--- a/gradint-build/src/sequence.py
+++ b/gradint-build/src/sequence.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v3.06 (c) 2002-20 Silas S. Brown. GPL v3+.
+# gradint v3.061 (c) 2002-20 Silas S. Brown. GPL v3+.
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
 #    the Free Software Foundation; either version 3 of the License, or
diff --git a/gradint-build/src/synth.py b/gradint-build/src/synth.py
index e8874f2..ca9d437 100644
--- a/gradint-build/src/synth.py
+++ b/gradint-build/src/synth.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v3.06 (c) 2002-20 Silas S. Brown. GPL v3+.
+# gradint v3.061 (c) 2002-20 Silas S. Brown. GPL v3+.
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
 #    the Free Software Foundation; either version 3 of the License, or
diff --git a/gradint-build/src/system.py b/gradint-build/src/system.py
index e34d21c..be46093 100644
--- a/gradint-build/src/system.py
+++ b/gradint-build/src/system.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v3.06 (c) 2002-20 Silas S. Brown. GPL v3+.
+# gradint v3.061 (c) 2002-20 Silas S. Brown. GPL v3+.
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
 #    the Free Software Foundation; either version 3 of the License, or
@@ -443,6 +443,9 @@ if winsound or winCEsound or mingw32 or riscos_sound or not hasattr(os,"tempnam"
         global tempnam_no ; tempnam_no += 1
         return tmpPrefix+str(tempnam_no)
     os.tempnam = os.tmpnam = tempnam
+elif (macsound or sys.platform.lower().find("bsd")>0) and os.environ.get("TMPDIR",""): # BSD tempnam uses P_tmpdir instead, override
+    tempnam0 = os.tempnam
+    os.tempnam=lambda *args:tempnam0(os.environ["TMPDIR"])
 
 if disable_once_per_day==1:
   if once_per_day==3: sys.exit()
diff --git a/gradint-build/src/top.py b/gradint-build/src/top.py
index c3c7a17..7fd3033 100644
--- a/gradint-build/src/top.py
+++ b/gradint-build/src/top.py
@@ -2,7 +2,7 @@
 # -*- coding: utf-8 -*-
 #   (Python 2 or Python 3, but more fully tested on 2)
 
-program_name = "gradint v3.06 (c) 2002-20 Silas S. Brown. GPL v3+."
+program_name = "gradint v3.061 (c) 2002-20 Silas S. Brown. GPL v3+."
 
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
diff --git a/gradint-build/src/users.py b/gradint-build/src/users.py
index cfdedeb..ba44b4a 100644
--- a/gradint-build/src/users.py
+++ b/gradint-build/src/users.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v3.06 (c) 2002-20 Silas S. Brown. GPL v3+.
+# gradint v3.061 (c) 2002-20 Silas S. Brown. GPL v3+.
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
 #    the Free Software Foundation; either version 3 of the License, or
diff --git a/gradint-build/thindown.py b/gradint-build/thindown.py
index c0c02b5..32c70d0 100644
--- a/gradint-build/thindown.py
+++ b/gradint-build/thindown.py
@@ -1,5 +1,5 @@
 # This file is part of the source code of
-# gradint v3.06 (c) 2002-20 Silas S. Brown. GPL v3+.
+# gradint v3.061 (c) 2002-20 Silas S. Brown. GPL v3+.
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
 #    the Free Software Foundation; either version 3 of the License, or
-- 
GitLab