File: generate_changelog.php

package info (click to toggle)
php-doc 20061001-1
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 45,764 kB
  • ctags: 1,611
  • sloc: xml: 502,485; php: 7,645; cpp: 500; makefile: 297; perl: 161; sh: 141; awk: 28
file content (140 lines) | stat: -rwxr-xr-x 3,749 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
/*
  +----------------------------------------------------------------------+
  | ini doc settings updater                                             |
  +----------------------------------------------------------------------+
  | Copyright (c) 1997-2005 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:    Nuno Lopes <nlopess@php.net>                             |
  +----------------------------------------------------------------------+
*/

require_once './cvs-versions.php';

/** converts a tag like php_5_0_0 into a version like 5.0.0 */
function tag2version($tag) {
    global $cvs_versions;

    if (isset($cvs_versions[$tag]))
        return $cvs_versions[$tag];

    return strtr(substr($tag, 4), '_', '.');
}


/** checks if an ini setting has changed its value in PHP 5  */
function check_php4($array) {

    foreach($array as $key => $val) {
        if (substr($key, 0, 5) != 'php_4') {
            continue;
        }

        if ($val) {
            if (isset($old)) {
                if ($val != $old) {
                    return '';
                }
            } else {
                $old = $val;
            }
        }
    }

    if (isset($old) && $old != $array['php_5_0_0'] && $array['php_5_0_0']) {
        return "$old in PHP 4.";
    }
}


/** return when the option become available */
function available_since($array) {

    if ($array['php_4_0_0']) {
        return '';
    }

    foreach($array as $key => $val) {
        if ($val) {
            return 'Available since PHP ' . tag2version($key) . '.';
        }
    }

}


/** check for changes between versions */
function last_version($array) {

    $php4 = check_php4($array);
    $str  = '';

    foreach($array as $key => $val) {
        if ($php4 && substr($key, 0, 5) == 'php_4') {
            continue;
        }

        if ($val) {
            if (isset($old)) {
                if ($val != $old) {
                    if ($old_tag == 'php_4_cvs') {
                        $str .= " $old in PHP &lt; 5.";
                    } else {
                        $str .= " $old in PHP &lt;= " . tag2version($old_tag) . '.';
                    }
                }
            }

            $old     = $val;
            $old_tag = $key;
        }
    }

    return $php4 . $str;
}


/** generate the changelog column */
function generate_changelog($array) {

    array_shift($array);
    return trim(last_version($array) . ' ' . available_since($array));
}



if (!$idx = sqlite_open('ini_changelog.sqlite', 0666, $error)) {
    die("Couldn't open the DB: $error");
}

$q = sqlite_unbuffered_query($idx, 'SELECT * FROM changelog');

/* This hack is needed because sqlite 2 sort case-sensitive */
while($row = sqlite_fetch_array($q, SQLITE_ASSOC)) {
    uksort($row, 'strnatcmp');
    $info[$row['name']] = $row;
}

uksort($info, 'strnatcasecmp');

foreach ($info as $row) {
    $changelog[$row['name']] = generate_changelog($row);
}

if (!isset($included)) {
    foreach ($changelog as $key => $val) {
        echo "$key : $val\n";
    }
}

sqlite_close($idx);

?>