From e53244df1f9b8d7838de7f612788ad0a6961a070 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 7 Dec 2018 11:45:12 -0600 Subject: [PATCH 1/2] Cherry-pick Dirk's dbState NULL checks from the 7.0 branch Prevent segfaults in iocsh --- src/ioc/db/dbState.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ioc/db/dbState.c b/src/ioc/db/dbState.c index 6de7735cd..60819a023 100644 --- a/src/ioc/db/dbState.c +++ b/src/ioc/db/dbState.c @@ -37,6 +37,9 @@ dbStateId dbStateFind(const char *name) ELLNODE *node; dbStateId id; + if (!name) + return NULL; + for (node = ellFirst(&states); node; node = ellNext(node)) { id = CONTAINER(node, dbState, node); if (strcmp(id->name, name) == 0) @@ -49,6 +52,9 @@ dbStateId dbStateCreate(const char *name) { dbStateId id; + if (!name) + return NULL; + if ((id = dbStateFind(name))) return id; From 64d9d1a4c9885847981669032701b3724635ccad Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 7 Dec 2018 13:16:06 -0600 Subject: [PATCH 2/2] Fix field links to local menu anchors Anchor IDs are different for XHTML vs HTML generation. --- src/tools/dbdToHtml.pl | 49 ++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/src/tools/dbdToHtml.pl b/src/tools/dbdToHtml.pl index d30779dcf..636292a52 100644 --- a/src/tools/dbdToHtml.pl +++ b/src/tools/dbdToHtml.pl @@ -124,6 +124,33 @@ if ($opt_D) { # Output dependencies only open my $out, '>', $opt_o or die "Can't create $opt_o: $!\n"; +my $podHtml; +my $idify; + +if ($::XHTML) { + $podHtml = Pod::Simple::XHTML->new(); + $podHtml->html_doctype(<< '__END_DOCTYPE'); + + +__END_DOCTYPE + $podHtml->html_header_tags($podHtml->html_header_tags . + "\n"); + + $idify = sub { + my $title = shift; + return $podHtml->idify($title, 1); + } +} else { # Fall back to HTML + $podHtml = Pod::Simple::HTML->new(); + $podHtml->html_css('style.css'); + + $idify = sub { + my $title = shift; + return Pod::Simple::HTML::esc($podHtml->section_escape($title)); + } +} + # Parse the Pod text from the root DBD object my $pod = join "\n", '=for html
', '', map { @@ -153,22 +180,6 @@ my $pod = join "\n", '=for html
', '', } $dbd->pod, '=for html
', ''; -my $podHtml; - -if ($::XHTML) { - $podHtml = Pod::Simple::XHTML->new(); - $podHtml->html_doctype(<< '__END_DOCTYPE'); - - -__END_DOCTYPE - $podHtml->html_header_tags($podHtml->html_header_tags . - "\n"); -} else { # Fall back to HTML - $podHtml = Pod::Simple::HTML->new(); - $podHtml->html_css('style.css'); -} - $podHtml->force_title(encode_entities($title)); $podHtml->perldoc_url_prefix(''); $podHtml->perldoc_url_postfix('.html'); @@ -246,7 +257,7 @@ sub fieldTableRow { if ($type eq 'MENU') { my $mn = $fld->attribute('menu'); my $menu = $dbd->menu($mn); - my $url = $menu ? "#Menu_$mn" : "${mn}.html"; + my $url = $menu ? '#' . &$idify("Menu $mn") : "${mn}.html"; $html .= " ($mn)"; } $html .= ''; @@ -374,6 +385,8 @@ can be found in the aai and aSub record types. If you look at the L file you'll see that the POD there starts by documenting a record-specific menu definition. The "menu" keyword generates a -table that lists all the choices found in the named menu. +table that lists all the choices found in the named menu. Any MENU fields in the +field tables that refer to a locally-defined menu will generate a link to a +document section which must be titled "Menu [menuName]". =cut