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; 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