Index: configure.php
===================================================================
RCS file: /repository/phpdoc/configure.php,v
retrieving revision 1.71
diff -u -r1.71 configure.php
--- configure.php	14 Mar 2009 04:52:02 -0000	1.71
+++ configure.php	26 Mar 2009 13:43:13 -0000
@@ -18,7 +18,7 @@
   |             Hannes Magnusson <bjori@php.net>                         |
   |             Gwynne Raskind <gwynne@php.net>                          |
   +----------------------------------------------------------------------+
-  
+
   $Id: configure.php,v 1.71 2009/03/14 04:52:02 danielc Exp $
 */
 
@@ -30,7 +30,7 @@
 function usage() // {{{
 {
     global $acd;
-    
+
     echo <<<HELPCHUNK
 configure.php configures this package to adapt to many kinds of systems, and PhD
 builds too.
@@ -81,7 +81,7 @@
 function checking($for) // {{{
 {
     global $ac;
-    
+
     if ($ac['quiet'] != 'yes') {
         echo "Checking {$for}... ";
         flush( STDOUT );
@@ -91,7 +91,7 @@
 function checkerror($msg) // {{{
 {
     global $ac;
-    
+
     if ($ac['quiet'] != 'yes') {
         echo "\n";
     }
@@ -102,7 +102,7 @@
 function checkvalue($v) // {{{
 {
     global $ac;
-    
+
     if ($ac['quiet'] != 'yes') {
         echo "{$v}\n";
     }
@@ -279,7 +279,7 @@
     } else {
         continue;
     }
-    
+
     $overridden_settings[] = strtoupper($o);
     switch ($o) {
         case 'h':
@@ -351,7 +351,7 @@
         case 'howto':
             $ac['HOWTO']  =$v;
             break;
-        
+
         case 'broken-file-listing':
             $ac['USE_BROKEN_TRANSLATION_FILENAME'] = $v;
 
@@ -473,6 +473,54 @@
     echo "Saving it... ";
 
     if ($dom->save($ac['srcdir'] . '/version.xml')) {
+
+	// Extract the list of function names.
+    	$indexedFunctions = array();
+        foreach($versions->getElementsByTagName("function") as $function) {
+        	$indexedFunctions[strtoupper(substr($function->getAttribute('name'), 0, 1))][] = $function->getAttribute('name');
+        }
+
+    	// Start building the funcindex.xml
+        $indexXML =
+        	"<?xml version='1.0' encoding='iso-8859-1'?>\n" .
+		'<!-- DO NOT EDIT THIS FILE, IT WAS AUTO-GENERATED BY configure.php -->' . "\n" .
+		'<appendix xmlns="http://docbook.org/ns/docbook" xml:id="indexes">' . "\n" .
+		' <title>&FunctionIndex;</title>' . "\n" .
+		' <index xml:id="index.functions">' . "\n" .
+		'  <title>&FunctionIndex;</title>' . "\n";
+
+	// Sort so that the index is alphabetical.
+        ksort($indexedFunctions);
+        
+        // Add each letter and the entries to the index.
+        foreach($indexedFunctions as $indexLetter => $functions) {
+
+		// Sort the functions case insensitively.
+        	usort($functions, 'strcasecmp');
+
+		// Add letter header
+		$indexXML .=
+			"  <indexdiv>\n" .
+			"   <title>$indexLetter</title>\n";
+
+		// Add entries.
+		foreach($functions as $function) {
+			$indexXML .= "   <indexentry><primaryie><function>$function</function></primaryie></indexentry>\n";
+		}
+
+		// Add letter footer
+		$indexXML .= "  </indexdiv>\n";
+        }
+
+	// Finalise the XML
+	$indexXML .=
+		" </index>\n" .
+		" <para></para>\n" .
+		"</appendix>\n";
+
+	// Save the XML.
+	file_put_contents('./funcindex.xml', $indexXML);
+
         echo "OK\n";
     } else {
         echo "FAIL!\n";
@@ -572,7 +620,7 @@
     echo "done.\n";
     echo "Partial manual saved to {$filename}. To build it, run 'phd -d {$filename}'\n";
     exit(0);
-} // }}} 
+} // }}}
 
 $mxml = "{$ac['srcdir']}/.manual.xml";
 if ($dom->validate()) {
@@ -590,7 +638,7 @@
     echo "\nThe document didn't validate, ";
 
     // Allow the .manual.xml file to be created, even if it is not valid.
-    if ($ac['FORCE_DOM_SAVE'] == 'yes') { 
+    if ($ac['FORCE_DOM_SAVE'] == 'yes') {
         echo "writing .manual.xml anyway, and ";
         $dom->save($mxml);
     }

