cvs: docweb /cron/weekly meta_info /include docweb_dao_metainfo.class.php lib_meta_info.inc.php /scripts gen_function_aliases.php populatedocs.sh

[email protected] ("Sean Coates")
Newsgroups php.doc.web
Message-ID <cvssean1107736700@cvsserver>
sean		Sun Feb  6 19:38:20 2005 EDT

  Added files:                 
    /docweb/cron/weekly	meta_info 
    /docweb/include	docweb_dao_metainfo.class.php lib_meta_info.inc.php 
    /docweb/scripts	gen_function_aliases.php 

  Modified files:              
    /docweb/scripts	populatedocs.sh 
  Log:
  Function Aliases (from Erigol's scripts) DB population
sean-20050206193820.txt (text/plain, 9.2 KB)
http://cvs.php.net/diff.php/docweb/scripts/populatedocs.sh?r1=1.7&r2=1.8&ty=u
Index: docweb/scripts/populatedocs.sh
diff -u docweb/scripts/populatedocs.sh:1.7 docweb/scripts/populatedocs.sh:1.8
--- docweb/scripts/populatedocs.sh:1.7	Sun Jan 16 05:55:40 2005
+++ docweb/scripts/populatedocs.sh	Sun Feb  6 19:38:20 2005
@@ -15,7 +15,7 @@
 # | Authors: Jacques Marneweck <[email protected]>                         |
 # +----------------------------------------------------------------------+
 #
-# $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 .
 
@@ -37,6 +37,8 @@
 /usr/bin/cvs -d :pserver:[email protected]:/repository co smarty/docs
 echo "Checking out PEAR docs..."
 /usr/bin/cvs -d :pserver:[email protected]:/repository co peardoc
+echo "Checking out php-src..."
+/usr/bin/cvs -d :pserver:[email protected]:/repository co php-src
 
 popd
 

http://cvs.php.net/co.php/docweb/include/docweb_dao_metainfo.class.php?r=1.1&p=1
Index: docweb/include/docweb_dao_metainfo.class.php
+++ docweb/include/docweb_dao_metainfo.class.php
<?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          |
| [email protected] so we can mail you a copy immediately.               |
+----------------------------------------------------------------------+
| Author:        Sean Coates <[email protected]>                            |
+----------------------------------------------------------------------+
$Id: docweb_dao_metainfo.class.php,v 1.1 2005/02/07 00:38:20 sean Exp $
*/
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;
    }
}    
?>
http://cvs.php.net/co.php/docweb/include/lib_meta_info.inc.php?r=1.1&p=1
Index: docweb/include/lib_meta_info.inc.php
+++ docweb/include/lib_meta_info.inc.php
<?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          |
| [email protected] so we can mail you a copy immediately.               |
+----------------------------------------------------------------------+
| Authors:     Dave Barr <[email protected]>                                |
| DocWeb port: Sean Coates <[email protected]>                              |
+----------------------------------------------------------------------+
$Id: lib_meta_info.inc.php,v 1.1 2005/02/07 00:38:20 sean Exp $
*/

/**
 * 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++;
        }
    }
}
 

?>

http://cvs.php.net/co.php/docweb/scripts/gen_function_aliases.php?r=1.1&p=1
Index: docweb/scripts/gen_function_aliases.php
+++ docweb/scripts/gen_function_aliases.php
<?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          |
| [email protected] so we can mail you a copy immediately.               |
+----------------------------------------------------------------------+
| Author:        Dave Barr <[email protected]>                              |
| DocWeb Port:   Sean Coates <[email protected]>                            |
+----------------------------------------------------------------------+
$Id: gen_function_aliases.php,v 1.1 2005/02/07 00:38:20 sean Exp $
*/

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";
?>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.