[PATCH 15/23] wmgeneral, wmsun: Use threadsafe functions.

Doug Torrance <[email protected]>
Newsgroups gmane.compw.window-managers.windowmaker.devel
Message-ID <[email protected]>
---
 wmSMPmon/wmgeneral/wmgeneral.c  | 4 ++--
 wmckgmail/wmgeneral/wmgeneral.c | 4 ++--
 wmcpufreq/wmgeneral/wmgeneral.c | 4 ++--
 wmfsm/wmgeneral/wmgeneral.c     | 4 ++--
 wmifs/wmgeneral/wmgeneral.c     | 4 ++--
 wmitime/wmgeneral/wmgeneral.c   | 4 ++--
 wmkeys/wmgeneral/wmgeneral.c    | 4 ++--
 wmmon/wmgeneral/wmgeneral.c     | 4 ++--
 wmppp.app/wmgeneral/wmgeneral.c | 4 ++--
 wmsm.app/wmgeneral/wmgeneral.c  | 4 ++--
 wmsun/wmSun.c                   | 8 ++++++--
 wmsun/wmgeneral/wmgeneral.c     | 4 ++--
 wmtime/wmgeneral/wmgeneral.c    | 4 ++--
 wmtz/wmgeneral/wmgeneral.c      | 4 ++--
 14 files changed, 32 insertions(+), 28 deletions(-)

diff --git a/wmSMPmon/wmgeneral/wmgeneral.c b/wmSMPmon/wmgeneral/wmgeneral.c
index f707e7f..c624193 100644
--- a/wmSMPmon/wmgeneral/wmgeneral.c
+++ b/wmSMPmon/wmgeneral/wmgeneral.c
@@ -124,13 +124,13 @@ void parse_rcfile(const char *filename, rckeys *keys) {
 		char temp[128];
 
 		while (fgets(temp, 128, fp)) {
-			char *q;
+			char *q, *saveptr;
 			char *tokens = " :\t\n";
 			int key;
 
 			key = 0;
 			q = strdup(temp);
-			q = strtok(q, tokens);
+			q = strtok_r(q, tokens, &saveptr);
 			if(!q)
 				continue;
 			while (key >= 0 && keys[key].label) {
diff --git a/wmckgmail/wmgeneral/wmgeneral.c b/wmckgmail/wmgeneral/wmgeneral.c
index f707e7f..c624193 100644
--- a/wmckgmail/wmgeneral/wmgeneral.c
+++ b/wmckgmail/wmgeneral/wmgeneral.c
@@ -124,13 +124,13 @@ void parse_rcfile(const char *filename, rckeys *keys) {
 		char temp[128];
 
 		while (fgets(temp, 128, fp)) {
-			char *q;
+			char *q, *saveptr;
 			char *tokens = " :\t\n";
 			int key;
 
 			key = 0;
 			q = strdup(temp);
-			q = strtok(q, tokens);
+			q = strtok_r(q, tokens, &saveptr);
 			if(!q)
 				continue;
 			while (key >= 0 && keys[key].label) {
diff --git a/wmcpufreq/wmgeneral/wmgeneral.c b/wmcpufreq/wmgeneral/wmgeneral.c
index f707e7f..c624193 100755
--- a/wmcpufreq/wmgeneral/wmgeneral.c
+++ b/wmcpufreq/wmgeneral/wmgeneral.c
@@ -124,13 +124,13 @@ void parse_rcfile(const char *filename, rckeys *keys) {
 		char temp[128];
 
 		while (fgets(temp, 128, fp)) {
-			char *q;
+			char *q, *saveptr;
 			char *tokens = " :\t\n";
 			int key;
 
 			key = 0;
 			q = strdup(temp);
-			q = strtok(q, tokens);
+			q = strtok_r(q, tokens, &saveptr);
 			if(!q)
 				continue;
 			while (key >= 0 && keys[key].label) {
diff --git a/wmfsm/wmgeneral/wmgeneral.c b/wmfsm/wmgeneral/wmgeneral.c
index f707e7f..c624193 100644
--- a/wmfsm/wmgeneral/wmgeneral.c
+++ b/wmfsm/wmgeneral/wmgeneral.c
@@ -124,13 +124,13 @@ void parse_rcfile(const char *filename, rckeys *keys) {
 		char temp[128];
 
 		while (fgets(temp, 128, fp)) {
-			char *q;
+			char *q, *saveptr;
 			char *tokens = " :\t\n";
 			int key;
 
 			key = 0;
 			q = strdup(temp);
-			q = strtok(q, tokens);
+			q = strtok_r(q, tokens, &saveptr);
 			if(!q)
 				continue;
 			while (key >= 0 && keys[key].label) {
diff --git a/wmifs/wmgeneral/wmgeneral.c b/wmifs/wmgeneral/wmgeneral.c
index f707e7f..c624193 100644
--- a/wmifs/wmgeneral/wmgeneral.c
+++ b/wmifs/wmgeneral/wmgeneral.c
@@ -124,13 +124,13 @@ void parse_rcfile(const char *filename, rckeys *keys) {
 		char temp[128];
 
 		while (fgets(temp, 128, fp)) {
-			char *q;
+			char *q, *saveptr;
 			char *tokens = " :\t\n";
 			int key;
 
 			key = 0;
 			q = strdup(temp);
-			q = strtok(q, tokens);
+			q = strtok_r(q, tokens, &saveptr);
 			if(!q)
 				continue;
 			while (key >= 0 && keys[key].label) {
diff --git a/wmitime/wmgeneral/wmgeneral.c b/wmitime/wmgeneral/wmgeneral.c
index f707e7f..c624193 100644
--- a/wmitime/wmgeneral/wmgeneral.c
+++ b/wmitime/wmgeneral/wmgeneral.c
@@ -124,13 +124,13 @@ void parse_rcfile(const char *filename, rckeys *keys) {
 		char temp[128];
 
 		while (fgets(temp, 128, fp)) {
-			char *q;
+			char *q, *saveptr;
 			char *tokens = " :\t\n";
 			int key;
 
 			key = 0;
 			q = strdup(temp);
-			q = strtok(q, tokens);
+			q = strtok_r(q, tokens, &saveptr);
 			if(!q)
 				continue;
 			while (key >= 0 && keys[key].label) {
diff --git a/wmkeys/wmgeneral/wmgeneral.c b/wmkeys/wmgeneral/wmgeneral.c
index f707e7f..c624193 100644
--- a/wmkeys/wmgeneral/wmgeneral.c
+++ b/wmkeys/wmgeneral/wmgeneral.c
@@ -124,13 +124,13 @@ void parse_rcfile(const char *filename, rckeys *keys) {
 		char temp[128];
 
 		while (fgets(temp, 128, fp)) {
-			char *q;
+			char *q, *saveptr;
 			char *tokens = " :\t\n";
 			int key;
 
 			key = 0;
 			q = strdup(temp);
-			q = strtok(q, tokens);
+			q = strtok_r(q, tokens, &saveptr);
 			if(!q)
 				continue;
 			while (key >= 0 && keys[key].label) {
diff --git a/wmmon/wmgeneral/wmgeneral.c b/wmmon/wmgeneral/wmgeneral.c
index f707e7f..c624193 100644
--- a/wmmon/wmgeneral/wmgeneral.c
+++ b/wmmon/wmgeneral/wmgeneral.c
@@ -124,13 +124,13 @@ void parse_rcfile(const char *filename, rckeys *keys) {
 		char temp[128];
 
 		while (fgets(temp, 128, fp)) {
-			char *q;
+			char *q, *saveptr;
 			char *tokens = " :\t\n";
 			int key;
 
 			key = 0;
 			q = strdup(temp);
-			q = strtok(q, tokens);
+			q = strtok_r(q, tokens, &saveptr);
 			if(!q)
 				continue;
 			while (key >= 0 && keys[key].label) {
diff --git a/wmppp.app/wmgeneral/wmgeneral.c b/wmppp.app/wmgeneral/wmgeneral.c
index f707e7f..c624193 100644
--- a/wmppp.app/wmgeneral/wmgeneral.c
+++ b/wmppp.app/wmgeneral/wmgeneral.c
@@ -124,13 +124,13 @@ void parse_rcfile(const char *filename, rckeys *keys) {
 		char temp[128];
 
 		while (fgets(temp, 128, fp)) {
-			char *q;
+			char *q, *saveptr;
 			char *tokens = " :\t\n";
 			int key;
 
 			key = 0;
 			q = strdup(temp);
-			q = strtok(q, tokens);
+			q = strtok_r(q, tokens, &saveptr);
 			if(!q)
 				continue;
 			while (key >= 0 && keys[key].label) {
diff --git a/wmsm.app/wmgeneral/wmgeneral.c b/wmsm.app/wmgeneral/wmgeneral.c
index f707e7f..c624193 100644
--- a/wmsm.app/wmgeneral/wmgeneral.c
+++ b/wmsm.app/wmgeneral/wmgeneral.c
@@ -124,13 +124,13 @@ void parse_rcfile(const char *filename, rckeys *keys) {
 		char temp[128];
 
 		while (fgets(temp, 128, fp)) {
-			char *q;
+			char *q, *saveptr;
 			char *tokens = " :\t\n";
 			int key;
 
 			key = 0;
 			q = strdup(temp);
-			q = strtok(q, tokens);
+			q = strtok_r(q, tokens, &saveptr);
 			if(!q)
 				continue;
 			while (key >= 0 && keys[key].label) {
diff --git a/wmsun/wmSun.c b/wmsun/wmSun.c
index f3fc778..a0ad31b 100644
--- a/wmsun/wmSun.c
+++ b/wmsun/wmSun.c
@@ -69,6 +69,7 @@
 /*
  *   Includes
  */
+#define _POSIX_C_SOURCE 1
 #include <stdio.h>
 #include <math.h>
 #include <unistd.h>
@@ -177,12 +178,14 @@ int main(int argc, char *argv[]) {
 	 *
 	 */
 	if (n>nMAX){
+	    struct tm result;
 
 	    n = 0;
 	    nMAX = 1000;
 
 
-            CurrentGMTTime = time(CurrentTime); GMTTime = gmtime(&CurrentGMTTime);
+	    CurrentGMTTime = time(CurrentTime);
+	    GMTTime = gmtime_r(&CurrentGMTTime, &result);
 	    DayOfMonth = GMTTime->tm_mday;
 
 	    UT = GMTTime->tm_hour + GMTTime->tm_min/60.0 + GMTTime->tm_sec/3600.0;
@@ -190,7 +193,8 @@ int main(int argc, char *argv[]) {
 	    Month = GMTTime->tm_mon+1;
 
 
-	    CurrentLocalTime = CurrentGMTTime; LocalTime = localtime(&CurrentLocalTime);
+	    CurrentLocalTime = CurrentGMTTime;
+	    LocalTime = localtime_r(&CurrentLocalTime, &result);
 	    LocalDayOfMonth = LocalTime->tm_mday;
 
 	    if ((OldLocalDayOfMonth != LocalDayOfMonth)||(Flag)){
diff --git a/wmsun/wmgeneral/wmgeneral.c b/wmsun/wmgeneral/wmgeneral.c
index f707e7f..c624193 100644
--- a/wmsun/wmgeneral/wmgeneral.c
+++ b/wmsun/wmgeneral/wmgeneral.c
@@ -124,13 +124,13 @@ void parse_rcfile(const char *filename, rckeys *keys) {
 		char temp[128];
 
 		while (fgets(temp, 128, fp)) {
-			char *q;
+			char *q, *saveptr;
 			char *tokens = " :\t\n";
 			int key;
 
 			key = 0;
 			q = strdup(temp);
-			q = strtok(q, tokens);
+			q = strtok_r(q, tokens, &saveptr);
 			if(!q)
 				continue;
 			while (key >= 0 && keys[key].label) {
diff --git a/wmtime/wmgeneral/wmgeneral.c b/wmtime/wmgeneral/wmgeneral.c
index f707e7f..c624193 100644
--- a/wmtime/wmgeneral/wmgeneral.c
+++ b/wmtime/wmgeneral/wmgeneral.c
@@ -124,13 +124,13 @@ void parse_rcfile(const char *filename, rckeys *keys) {
 		char temp[128];
 
 		while (fgets(temp, 128, fp)) {
-			char *q;
+			char *q, *saveptr;
 			char *tokens = " :\t\n";
 			int key;
 
 			key = 0;
 			q = strdup(temp);
-			q = strtok(q, tokens);
+			q = strtok_r(q, tokens, &saveptr);
 			if(!q)
 				continue;
 			while (key >= 0 && keys[key].label) {
diff --git a/wmtz/wmgeneral/wmgeneral.c b/wmtz/wmgeneral/wmgeneral.c
index f707e7f..c624193 100644
--- a/wmtz/wmgeneral/wmgeneral.c
+++ b/wmtz/wmgeneral/wmgeneral.c
@@ -124,13 +124,13 @@ void parse_rcfile(const char *filename, rckeys *keys) {
 		char temp[128];
 
 		while (fgets(temp, 128, fp)) {
-			char *q;
+			char *q, *saveptr;
 			char *tokens = " :\t\n";
 			int key;
 
 			key = 0;
 			q = strdup(temp);
-			q = strtok(q, tokens);
+			q = strtok_r(q, tokens, &saveptr);
 			if(!q)
 				continue;
 			while (key >= 0 && keys[key].label) {
-- 
2.1.4


-- 
To unsubscribe, send mail to [email protected].
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.