[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Gavin D. Smith |
Date: |
Sun, 20 Mar 2022 04:55:29 -0400 (EDT) |
branch: master
commit dfcd991c9839e0157228ee745dd32c56a96e2978
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sat Oct 17 11:12:25 2020 +0100
change search path to /usr/share/doc plus an extra level
of directories. Allow name of directory containing manual to
end with .html. Error message if manual not found.
---
js/infog/extension.c | 7 +++++++
js/infog/infopath.c | 40 ++++++++++++++++++++--------------------
js/infog/main.c | 9 +++++++++
3 files changed, 36 insertions(+), 20 deletions(-)
diff --git a/js/infog/extension.c b/js/infog/extension.c
index 3a6a75278f..994d9b08b6 100644
--- a/js/infog/extension.c
+++ b/js/infog/extension.c
@@ -139,6 +139,13 @@ request_callback (WebKitWebPage *web_page,
"../MANUAL/NODE.html" but by the time this function is called
they are absolute paths beginning "file:/". */
parse_external_url (uri, &manual, &node);
+ if (!manual || !node)
+ {
+ /* Possibly a *.css file or malformed link. */
+ free (manual); free (node);
+ return FALSE;
+ }
+
debug (1, "finding manual and node %s:%s\n", manual, node);
if (!current_manual || strcmp(manual, current_manual) != 0)
diff --git a/js/infog/infopath.c b/js/infog/infopath.c
index 4d6744c540..617ec952df 100644
--- a/js/infog/infopath.c
+++ b/js/infog/infopath.c
@@ -1,3 +1,5 @@
+#define _GNU_SOURCE
+
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -8,8 +10,10 @@
#include "infopath.h"
-char *default_path[] = { "/usr/share/info/html",
- "/usr/local/share/info/html",
+void debug (int level, char *fmt, ...);
+
+char *default_path[] = { "/usr/share/doc",
+ "/usr/local/share/doc",
NULL };
static GArray *dirs;
@@ -36,7 +40,7 @@ init_infopath (void)
}
}
-/* Return pathname of the idirectory containing an HTML manual.*/
+/* Return file name of the directory containing an HTML manual.*/
char *
locate_manual (const char *manual)
{
@@ -54,30 +58,21 @@ locate_manual (const char *manual)
continue;
closedir (d);
- char *s = malloc (strlen (datadir) + strlen ("/") + strlen (manual) + 1);
- sprintf (s, "%s/%s", datadir, manual);
+ char *s = 0, *s2 = 0;
- d = opendir (s);
- if (!d)
- {
- free (s);
- continue;
- }
- closedir (d);
+ asprintf(&s, "%s/%s/%s.html", datadir, manual, manual);
+ asprintf(&s2, "%s/index.html", s);
- char *s2 = malloc (strlen (datadir) + strlen ("/")
- + strlen (manual) + strlen ("/index.html") + 1);
- sprintf (s2, "%s/%s/index.html", datadir, manual);
+ debug (1, "CHECK %s\n", s);
struct stat dummy;
- if (stat (s2, &dummy) == -1)
+ if (stat (s, &dummy) != -1)
{
- free (s); free (s2);
- continue;
+ free (s2);
+ return s;
}
- free (s2);
- return s;
+ free (s); free (s2);
}
return 0;
}
@@ -118,6 +113,11 @@ parse_external_url (const char *url, char **manual, char
**node)
memcpy (m, p, q - p);
m[q - p] = '\0';
+ /* Strip a .html extension off the directory if there is one. */
+ char *e;
+ if ((e = strstr (m, ".html")))
+ *e = '\0';
+
*manual = m;
q++; /* after '/' */
diff --git a/js/infog/main.c b/js/infog/main.c
index 1e1800cff3..a8e6977cdb 100644
--- a/js/infog/main.c
+++ b/js/infog/main.c
@@ -416,6 +416,15 @@ new_manual (char *manual)
if (!current_manual_dir)
{
debug (1, "MANUAL NOT FOUND\n");
+ GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT;
+ GtkWidget *dialog = gtk_message_dialog_new (
+ GTK_WINDOW(main_window),
+ flags,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ "Manual '%s' not found", manual);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
return 0;
}
debug (1, "NEW MANUAL AT %s\n", current_manual_dir);
- [no subject], (continued)
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject],
Gavin D. Smith <=