Function Aliases (from Erigol's scripts) DB population

This commit is contained in:
Sean Coates
2005-02-07 00:38:20 +00:00
parent 043c7da0eb
commit 37cb0039d6
5 changed files with 240 additions and 1 deletions

6
cron/weekly/meta_info Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
. `dirname $0`/../../build-ops
cd ${SCRIPTSDIR}
${PHP} gen_function_aliases.php

View File

@ -0,0 +1,83 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
+----------------------------------------------------------------------+
| PHP Documentation Site Source Code |
+----------------------------------------------------------------------+
| Copyright (c) 2005 The PHP Group |
| Copyright (c) 1997-2004 Dave Barr |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_0.txt. |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Sean Coates <sean@php.net> |
+----------------------------------------------------------------------+
$Id$
*/
require_once 'docweb_dao_common.class.php';
class DocWeb_DAO_MetaInfo extends DocWeb_DAO_Common
{
/**
* Constructor - instanciate parent
*
* @param bool Check the schema & create missing tables? (set to true
* from generation scripts)
*/
function DocWeb_DAO_MetaInfo($checkSchema = FALSE)
{
$this->DocWeb_DAO_Common($checkSchema);
}
/**
* Store function alias data
*
* @param string $ext Extension to which this alias belongs
* @param string $alias Alias function name
* @param string $func Reference function name
* @return bool
*/
function storeFunctionAlias($ext, $alias, $func)
{
$sql = "
INSERT
INTO
function_aliases
(
extension,
alias,
function
)
VALUES
(
'". $this->DB->escapeSimple($ext) ."',
'". $this->DB->escapeSimple($alias) ."',
'". $this->DB->escapeSimple($func) ."'
)
";
if (PEAR::isError($this->DB->query($sql))) {
echo " ** Query failed.\n";
return FALSE;
}
return TRUE;
}
function purgeAliases()
{
$sql = "
DELETE
FROM
function_aliases
";
if (PEAR::isError($this->DB->query($sql))) {
echo " ** Purge Query failed.\n";
return FALSE;
}
return TRUE;
}
}
?>

View File

@ -0,0 +1,51 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
+----------------------------------------------------------------------+
| PHP Documentation Tools Site Source Code |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2004 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_0.txt. |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Dave Barr <dave@php.net> |
| DocWeb port: Sean Coates <sean@php.net> |
+----------------------------------------------------------------------+
$Id$
*/
/**
* Finds aliases in the passed file
*
* @param string $filename filename to parse
* @param string $ext extension to which this file belongs
*
*/
function find_alias_file($filename, $ext)
{
global $aliases, $total;
$file = file_get_contents($filename);
$matchRegex = "/(?:PHP|ZEND)_FALIAS\(\s*(\w+)\s*,\s*(\w+)\s*,/";
if (preg_match_all($matchRegex, $file, $matches)) {
foreach ($matches[1] as $k => $alias) {
$func = $matches[2][$k];
if (!(isset($aliases[$ext]) && is_array($aliases[$ext]))) {
$aliases[$ext] = array();
}
$aliases[$ext][$alias] = $func;
$total++;
}
}
}
?>

View File

@ -0,0 +1,97 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
+----------------------------------------------------------------------+
| PHP Documentation Site Source Code |
+----------------------------------------------------------------------+
| Copyright (c) 2005 The PHP Group |
| Copyright (c) 1997-2004 Dave Barr |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_0.txt. |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Dave Barr <dave@php.net> |
| DocWeb Port: Sean Coates <sean@php.net> |
+----------------------------------------------------------------------+
$Id$
*/
set_time_limit(0);
$scriptBegin = time();
$inCli = true;
require_once '../include/init.inc.php';
require_once '../include/lib_meta_info.inc.php';
require_once '../include/docweb_dao_metainfo.class.php';
$DAO = new DocWeb_DAO_MetaInfo(TRUE);
// Special places to look for aliases */
$special = array(
'info' => 'ZendEngine2/zend_builtin_functions.c',
'apache' => 'sapi/apache/php_apache.c',
);
$phpsrc = CVS_DIR . '/php-src/';
// search the extensions
$exts = array();
$dir = opendir("$phpsrc/ext");
while ($entry = readdir($dir)) {
if (in_array($entry, array('.','..'))) {
continue;
}
if (is_dir("$phpsrc/ext/$entry")) {
$exts[] = $entry;
}
}
closedir($dir);
$aliases = array();
$total = 0;
foreach ($exts as $ext) {
$extdir = "$phpsrc/ext/$ext";
$dir = opendir($extdir);
while ($entry = readdir($dir)) {
if (in_array($entry, array('.','..'))) {
continue;
}
if (is_file("$extdir/$entry") &&
substr("$extdir/$entry", -2) == ".c") {
// file is a C file, check it for function aliases
find_alias_file("$extdir/$entry", $ext);
}
}
closedir($dir);
}
foreach ($special as $ext => $filename) {
if (is_file("$phpsrc/$filename")) {
find_alias_file("$phpsrc/$filename", $ext);
}
}
ksort($aliases, SORT_STRING);
$DAO->metaLogStartTime('aliases');
$DAO->purgeAliases();
foreach ($aliases AS $ext => $aliasData) {
foreach ($aliasData AS $alias => $func) {
echo "[$ext] $alias -> $func\n";
$DAO->storeFunctionAlias($ext, $alias, $func);
}
}
$DAO->metaLogEndTime('aliases');
echo "** Done.\n";
?>

View File

@ -15,7 +15,7 @@
# | Authors: Jacques Marneweck <jacques@php.net> | # | Authors: Jacques Marneweck <jacques@php.net> |
# +----------------------------------------------------------------------+ # +----------------------------------------------------------------------+
# #
# $Id: populatedocs.sh,v 1.7 2005-01-16 10:55:40 nlopess Exp $ # $Id: populatedocs.sh,v 1.8 2005-02-07 00:38:20 sean Exp $
pushd . pushd .
@ -37,6 +37,8 @@ echo "Checking out Smarty docs..."
/usr/bin/cvs -d :pserver:cvsread@cvs.php.net:/repository co smarty/docs /usr/bin/cvs -d :pserver:cvsread@cvs.php.net:/repository co smarty/docs
echo "Checking out PEAR docs..." echo "Checking out PEAR docs..."
/usr/bin/cvs -d :pserver:cvsread@cvs.php.net:/repository co peardoc /usr/bin/cvs -d :pserver:cvsread@cvs.php.net:/repository co peardoc
echo "Checking out php-src..."
/usr/bin/cvs -d :pserver:cvsread@cvs.php.net:/repository co php-src
popd popd