From 55ef0aec3c26d13bef4cd66bce9fbc2cf0357335 Mon Sep 17 00:00:00 2001
From: Sojourner Truth <jon.w.wilkes@gmail.com>
Date: Mon, 27 Jun 2016 18:48:33 -0400
Subject: [PATCH] fix #76: fluid~-help.pd can't be opened escape "\r" coming
 from Pd before evaluating

---
 pd/nw/pdgui.js   |  5 +++++
 pd/src/s_inter.c | 28 +++++++++++++++-------------
 2 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js
index fccad4ea6..80664e7af 100644
--- a/pd/nw/pdgui.js
+++ b/pd/nw/pdgui.js
@@ -346,6 +346,10 @@ function gui_post_error(objectid, loglevel, errormsg) {
     }
 }
 
+function gui_legacy_tcl_command(file, line_number, text) {
+    post("legacy tcl command at " + line_number + " of " + file + ": " + text);
+}
+
 function clear_console() {
     var container = pd_window.document.getElementById("p1");
     container.textContent = "";
@@ -1182,6 +1186,7 @@ function init_socket_events () {
                 // Turn newlines into backslash + "n" so
                 // eval will do the right thing with them
                 next_command = next_command.replace(/\n/g, "\\n");
+                next_command = next_command.replace(/\r/g, "\\r");
                 selector = next_command.slice(0, next_command.indexOf(" "));
                 args = next_command.slice(selector.length + 1);
                 next_command = "";
diff --git a/pd/src/s_inter.c b/pd/src/s_inter.c
index 8b6341a80..114a07076 100644
--- a/pd/src/s_inter.c
+++ b/pd/src/s_inter.c
@@ -745,17 +745,6 @@ void sys_vvguid(const char *file, int line, const char *fmt, va_list ap) {
     sys_vvgui(fmt,ap);
 }
 
-/* Old GUI command interface... */
-void sys_vguid(const char *file, int line, const char *fmt, ...) {
-    va_list ap;
-    char buf[MAXPDSTRING];
-    va_start(ap, fmt);
-    vsnprintf(buf, MAXPDSTRING-1, fmt, ap);
-    va_end(ap);
-    /* For old commands, we're just posting them to the pd console */
-    post("Old command at %s:%d:%s", file, line, buf);
-    //sys_vvguid(file,line,fmt,ap);
-}
 void sys_gui(const char *s)
 {
     sys_vgui("%s", s);
@@ -943,6 +932,19 @@ void gui_end_array(void)
     gui_array_tail = 1;
 }
 
+/* Old GUI command interface... */
+void sys_vguid(const char *file, int line, const char *fmt, ...) {
+    va_list ap;
+    char buf[MAXPDSTRING];
+    va_start(ap, fmt);
+    vsnprintf(buf, MAXPDSTRING-1, fmt, ap);
+    va_end(ap);
+    /* For old commands, we're just posting them to the pd console */
+    gui_vmess("gui_legacy_tcl_command", "sis",
+        file, line, buf);
+    //sys_vvguid(file,line,fmt,ap);
+}
+
 int sys_flushtogui( void)
 {
     int writesize = sys_guibufhead - sys_guibuftail, nwrote = 0;
@@ -1347,8 +1349,8 @@ fprintf(stderr, "guidir is %s\n", guidir);
             sprintf(cmdbuf,
                 "%s/nw/nw %s %d localhost %s %s\n",
                 guidir,
-                guidir,
-//                "/home/user/pd-nw/pd/nw",
+//                guidir,
+                "/home/user/purr-data/pd/nw",
                 portno,
                 (sys_k12_mode ? "pd-l2ork-k12" : "pd-l2ork"),
                 guidir);
-- 
GitLab