diff --git a/gen-phpweb-sqlite-db.php b/gen-phpweb-sqlite-db.php index 0ef04b6..be36df5 100644 --- a/gen-phpweb-sqlite-db.php +++ b/gen-phpweb-sqlite-db.php @@ -81,7 +81,7 @@ function scan($dir, $lang) 'control-structures.', 'language.', 'about.', 'faq.', 'features.', ); - + $count = 0; echo "Lang: $lang\n"; @@ -115,7 +115,7 @@ function scan($dir, $lang) if ($x !== false) { $keyword = substr($keyword, 0, $x); } - + // Skip PHP 4 domxml (book.domxml). It uses function. syntax, unlike book.dom if (0 === strpos($keyword, 'function.dom') && false === strpos($keyword, 'simplexml')) { continue; @@ -164,9 +164,33 @@ function scan($dir, $lang) $dbh->exec("INSERT INTO fs (lang, prefix, keyword, name, prio) values ('$lang', '$prefix', '" . metaphone($keyword) . "', '$doc_rel', ".($prio+10).")"); } + + if ($f === 'reserved.keywords.php' && $handle = fopen($file, 'r')) { + // Yes, this is fragile. + $stm = $dbh->prepare('INSERT INTO fs (lang, prefix, keyword, name, prio) VALUES (?, ?, ?, ?, ?)'); + $path_base = dirname($doc_rel); + while ($stm && false !== ($line = fgets($handle))) { + if (strpos($line, '([^<]+)!', $line, $matches)) { + continue; + } + + $keyword = strtolower(rtrim($matches[2], '()')); + $href = $matches[1]; + + if ($x = strpos($href, '#')) { + $href = substr($href, 0, $x); + } + + $stm->execute([$lang, $prefix ?? '', $keyword, $path_base . '/' . $href, $prio ?? 200]); + } + } } closedir($d); - + echo "Added entries for $count files\n"; echo "\n"; } @@ -195,4 +219,3 @@ function scan_langs($root) } closedir($d); } -