texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]


From: Gavin D. Smith
Date: Wed, 30 Nov 2022 13:36:35 -0500 (EST)

branch: old/qt-info
commit fdf0d5d1edf547ae7be7aa7b8084d92d710ddc7e
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Mon Apr 8 17:56:50 2019 +0100

    parse url
---
 js/docbrowser/core.cpp   | 21 ++++++++++++++++-----
 js/docbrowser/infopath.c | 38 ++++++++++++++++++++++++++++++++++++++
 js/docbrowser/infopath.h |  1 +
 js/fdl.texi              |  4 ++--
 4 files changed, 57 insertions(+), 7 deletions(-)

diff --git a/js/docbrowser/core.cpp b/js/docbrowser/core.cpp
index 333d1675d0..c5f58f93b9 100644
--- a/js/docbrowser/core.cpp
+++ b/js/docbrowser/core.cpp
@@ -12,17 +12,24 @@ Core::Core(Ui::MainWindow *ui, QObject *parent)
 {
 }
 
-/* slot */
 void
 Core::external_manual (const QString &url)
 {
     qDebug() << "sent url" << url;
 
-    // We should send it back into the browser for the JavaScript code to 
track 
-    // multiple manuals at once.
-    // emit setUrl (url);
-
     // Repace the file being viewed
+    char *manual, *node;
+    parse_external_url (qPrintable(url), &manual, &node);
+
+    if (manual)
+      {
+        load_manual (manual);
+        // and set node to node
+        qDebug () << "got node" << node;
+        //emit setNode (node);
+     }
+
+    free (manual); free (node);
 }
 
 bool
@@ -30,6 +37,10 @@ Core::load_manual (const char *manual)
 {
     char *path = locate_manual (manual);
 
+    // TODO: we should send it back into the browser for the JavaScript code 
to 
+    // track multiple manuals at once.
+    // emit setUrl (url);
+
     if (path)
       {
         qDebug() << "got path" << path;
diff --git a/js/docbrowser/infopath.c b/js/docbrowser/infopath.c
index b56bd4c48c..289b4e46fc 100644
--- a/js/docbrowser/infopath.c
+++ b/js/docbrowser/infopath.c
@@ -58,3 +58,41 @@ locate_manual (const char *manual)
     }
   return s;
 }
+
+/* Extract the manual and node from a URL like "../MANUAL/NODE.html" */
+void
+parse_external_url (const char *url, char **manual, char **node)
+{
+  char *m = 0, *n = 0;
+
+  char *p = strchr (url, '/') + 1; /* after "../" */
+  if (!p)
+    goto failure;
+  char *q = strchr (p, '/');
+  if (!q)
+    goto failure;
+
+  m = malloc (q - p + 1);
+  memcpy (m, p, q - p);
+  m[q - p] = '\0';
+
+  *manual = m;
+
+  q++; /* after '/' */
+  p = strchr (q, '.');
+  if (memcmp (p, ".html", 5) != 0)
+    goto failure;
+  n = malloc (p - q + 1);
+  memcpy (n, q, p - q);
+  n[p - q] = '\0';
+
+  *node = n;
+
+  return;
+
+failure:
+  free (m); free(n);
+  *manual = 0;
+  *node = 0;
+  return;
+}
diff --git a/js/docbrowser/infopath.h b/js/docbrowser/infopath.h
index cc3ded2746..4749cef45d 100644
--- a/js/docbrowser/infopath.h
+++ b/js/docbrowser/infopath.h
@@ -7,6 +7,7 @@ extern "C"
 #endif
 
 char *locate_manual (const char *manual);
+void parse_external_url (const char *url, char **manual, char **node);
 
 #ifdef __cplusplus
 } // extern "C"
diff --git a/js/fdl.texi b/js/fdl.texi
index 9c3bbe56e9..542edaad25 100644
--- a/js/fdl.texi
+++ b/js/fdl.texi
@@ -6,7 +6,7 @@
 
 @display
 Copyright @copyright{} 2000, 2001, 2002, 2007, 2008 Free Software Foundation, 
Inc.
-@uref{http://fsf.org/}
+@uref{https://fsf.org/}
 
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.
@@ -414,7 +414,7 @@ The Free Software Foundation may publish new, revised 
versions
 of the GNU Free Documentation License from time to time.  Such new
 versions will be similar in spirit to the present version, but may
 differ in detail to address new problems or concerns.  See
-@uref{http://www.gnu.org/copyleft/}.
+@uref{https://www.gnu.org/copyleft/}.
 
 Each version of the License is given a distinguishing version number.
 If the Document specifies that a particular numbered version of this



reply via email to

[Prev in Thread] Current Thread [Next in Thread]