aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2018-01-12 16:07:45 +0100
committerGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2018-01-12 16:07:45 +0100
commit038389d4937898608dcb5d437d60cd18446c27f7 (patch)
tree50e78736440c0f9472de31ea6d8a77cacfb6743f
parente05230d09fbe04c365beb6b7f20a5f386daba032 (diff)
downloadsynthpod-038389d4937898608dcb5d437d60cd18446c27f7.zip
synthpod-038389d4937898608dcb5d437d60cd18446c27f7.tar.gz
synthpod-038389d4937898608dcb5d437d60cd18446c27f7.tar.bz2
synthpod-038389d4937898608dcb5d437d60cd18446c27f7.tar.xz
app: replace strtok with strsep.
-rw-r--r--VERSION2
-rw-r--r--app/synthpod_app_mod.c25
-rw-r--r--bin/synthpod_bin.c5
3 files changed, 24 insertions, 8 deletions
diff --git a/VERSION b/VERSION
index fffbe83..319be0e 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.1.5459
+0.1.5461
diff --git a/app/synthpod_app_mod.c b/app/synthpod_app_mod.c
index cd35813..97859c3 100644
--- a/app/synthpod_app_mod.c
+++ b/app/synthpod_app_mod.c
@@ -43,6 +43,22 @@ urn_uuid_unparse_random(urn_uuid_t urn_uuid)
bytes[0xa], bytes[0xb], bytes[0xc], bytes[0xd], bytes[0xe], bytes[0xf]);
}
+#if defined(_WIN32)
+static inline char *
+strsep(char **sp, char *sep)
+{
+ char *p, *s;
+ if(sp == NULL || *sp == NULL || **sp == '\0')
+ return(NULL);
+ s = *sp;
+ p = s + strcspn(s, sep);
+ if(*p != '\0')
+ *p++ = '\0';
+ *sp = p;
+ return(s);
+}
+#endif
+
//FIXME is actually __realtime
__non_realtime static int
_log_vprintf(LV2_Log_Handle handle, LV2_URID type, const char *fmt, va_list args)
@@ -59,12 +75,13 @@ _log_vprintf(LV2_Log_Handle handle, LV2_URID type, const char *fmt, va_list args
snprintf(prefix, sizeof(prefix), "{%s} ", mod->urn_uri);
vsnprintf(buf, sizeof(buf), fmt, args);
- char *pch = strtok(buf, "\n");
- while(pch)
+ const char *sep = "\n";
+ for(char *bufp = buf, *pch = strsep(&bufp, sep);
+ pch;
+ pch = strsep(&bufp, sep) )
{
- if(app->driver->log)
+ if(strlen(pch) && app->driver->log)
app->driver->log->printf(app->driver->log->handle, type, "%s%s\n", prefix, pch);
- pch = strtok(NULL, "\n");
}
return 0;
diff --git a/bin/synthpod_bin.c b/bin/synthpod_bin.c
index 3722b70..85f75d8 100644
--- a/bin/synthpod_bin.c
+++ b/bin/synthpod_bin.c
@@ -191,8 +191,7 @@ _log_vprintf(void *data, LV2_URID type, const char *fmt, va_list args)
const bool is_worker_thread = _is_worker_thread(bin);
// check for trace mode AND DSP thread ID
- if( (type == bin->log_trace)
- && !is_worker_thread)
+ if(!is_worker_thread)
{
size_t written = -1;
if(_atomic_try_lock(&bin->trace_lock)) //FIXME use per-dsp-thread ringbuffer
@@ -211,7 +210,7 @@ _log_vprintf(void *data, LV2_URID type, const char *fmt, va_list args)
_atomic_unlock(&bin->trace_lock);
return written;
}
- else if(is_worker_thread)
+ else
{
// !log_trace OR not DSP thread ID
int idx = COLOR_LOG;