Skip to content

Commit f83413d

Browse files
author
Dan
committed
Follow the PHP coding standards.
1 parent 2473f5a commit f83413d

11 files changed

+693
-748
lines changed

config.m4

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl +----------------------------------------------------------------------+
2-
dnl | XZ Extension |
2+
dnl | PHP Version 5 |
33
dnl +----------------------------------------------------------------------+
44
dnl | Copyright (c) 1997-2015 The PHP Group |
55
dnl +----------------------------------------------------------------------+

php_xz.h

+35-60
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
/*
2-
+----------------------------------------------------------------------+
3-
| XZ Extension |
4-
+----------------------------------------------------------------------+
5-
| Copyright (c) 1997-2015 The PHP Group |
6-
+----------------------------------------------------------------------+
7-
| This source file is subject to version 3.01 of the PHP license, |
8-
| that is bundled with this package in the file LICENSE, and is |
9-
| available through the world-wide-web at the following url: |
10-
| http://www.php.net/license/3_01.txt |
11-
| If you did not receive a copy of the PHP license and are unable to |
12-
| obtain it through the world-wide-web, please send a note to |
13-
| license@php.net so we can mail you a copy immediately. |
14-
+----------------------------------------------------------------------+
15-
| Authors: Payden Sutherland <payden@paydensutherland.com> |
16-
| Dan Ungureanu <udan1107@gmail.com> |
17-
| authors of the `zlib` extension (for guidance) |
18-
+----------------------------------------------------------------------+
2+
+----------------------------------------------------------------------+
3+
| PHP Version 5 |
4+
+----------------------------------------------------------------------+
5+
| Copyright (c) 1997-2015 The PHP Group |
6+
+----------------------------------------------------------------------+
7+
| This source file is subject to version 3.01 of the PHP license, |
8+
| that is bundled with this package in the file LICENSE, and is |
9+
| available through the world-wide-web at the following url: |
10+
| http://www.php.net/license/3_01.txt |
11+
| If you did not receive a copy of the PHP license and are unable to |
12+
| obtain it through the world-wide-web, please send a note to |
13+
| license@php.net so we can mail you a copy immediately. |
14+
+----------------------------------------------------------------------+
15+
| Authors: Payden Sutherland <payden@paydensutherland.com> |
16+
| Dan Ungureanu <udan1107@gmail.com> |
17+
| authors of the `zlib` extension (for guidance) |
18+
+----------------------------------------------------------------------+
1919
*/
2020

2121
#ifndef PHP_XZ_H
@@ -26,72 +26,47 @@ extern php_stream_wrapper php_stream_xz_wrapper;
2626

2727
#define phpext_xz_ptr &xz_module_entry
2828

29-
/**
30-
* The default size of the buffer used for compression and decompression.
31-
*/
29+
/* The default size of the buffer used for compression and decompression. */
3230
#define XZ_BUFFER_SIZE 4096
3331

3432
#ifdef PHP_WIN32
35-
#define PHP_XZ_API __declspec(dllexport)
33+
# define PHP_XZ_API __declspec(dllexport)
3634
#elif defined(__GNUC__) && (__GNUC__ >= 4)
37-
#define PHP_XZ_API __attribute__ ((visibility("default")))
35+
# define PHP_XZ_API __attribute__ ((visibility("default")))
3836
#else
39-
#define PHP_XZ_API
37+
# define PHP_XZ_API
4038
#endif
4139

4240
#ifdef ZTS
43-
#include "TSRM.h"
41+
# include "TSRM.h"
4442
#endif
4543

46-
/**
47-
* Function called when module initializes.
48-
*/
4944
PHP_MINIT_FUNCTION(xz);
50-
51-
/**
52-
* Function called when module shuts down.
53-
*/
5445
PHP_MSHUTDOWN_FUNCTION(xz);
5546

56-
/**
57-
* Function called to retrieve module's information.
58-
*/
5947
PHP_MINFO_FUNCTION(xz);
6048

61-
/**
62-
* Opens a XZ stream.
63-
*/
6449
PHP_FUNCTION(xzopen);
65-
66-
/**
67-
* Encodes a given string.
68-
*/
6950
PHP_FUNCTION(xzencode);
70-
71-
/**
72-
* Decodes a given string.
73-
*/
7451
PHP_FUNCTION(xzdecode);
7552

76-
/**
77-
* Function that opens a stream. It is internally used for `xzopen`.
78-
*
79-
* @param wrapper
80-
* @param path
81-
* @param mode_pass
82-
* @param options
83-
* @param opened_path
84-
*
85-
* @return
86-
*/
8753
php_stream *php_stream_xzopen(php_stream_wrapper *wrapper, const char *path,
88-
const char *mode_pass, int options, char **opened_path,
89-
php_stream_context *context STREAMS_DC TSRMLS_DC);
54+
const char *mode_pass, int options, char **opened_path,
55+
php_stream_context *context STREAMS_DC TSRMLS_DC);
9056

9157
#ifdef ZTS
92-
#define XZ_G(v) TSRMG(xz_globals_id, zend_xz_globals *, v)
58+
# define XZ_G(v) TSRMG(xz_globals_id, zend_xz_globals *, v)
9359
#else
94-
#define XZ_G(v) (xz_globals.v)
60+
# define XZ_G(v) (xz_globals.v)
9561
#endif
9662

9763
#endif
64+
65+
/*
66+
* Local variables:
67+
* tab-width: 4
68+
* c-basic-offset: 4
69+
* End:
70+
* vim600: sw=4 ts=4 fdm=marker
71+
* vim<600: sw=4 ts=4
72+
*/

tests/xzcode_advanced.phpt

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Test `xzencode` and `xzdecode`: big inputs.
33
--SKIPIF--
44
<?php
55
if (!extension_loaded("xz")) {
6-
print("XZ extension is not loaded!");
6+
print("XZ extension is not loaded!");
77
}
88
?>
99
--FILE--
@@ -29,7 +29,7 @@ $chunk = '';
2929

3030
// Generating a random chunk.
3131
for ($i = 0; $i < $chunkSize; ++$i) {
32-
$chunk .= chr(rand(0, 255)); // adds one random byte
32+
$chunk .= chr(rand(0, 255)); // adds one random byte
3333
}
3434

3535
/**
@@ -40,7 +40,7 @@ $str = '';
4040

4141
// Generating a random string.
4242
for ($i = 0; $i < $chunkNumber; ++$i) {
43-
$str .= $chunk;
43+
$str .= $chunk;
4444
}
4545

4646
var_dump($chunkSize * $chunkNumber == strlen($str));

tests/xzcode_basic.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Test `xzencode` and `xzdecode`: basic functionality.
33
--SKIPIF--
44
<?php
55
if (!extension_loaded("xz")) {
6-
print("XZ extension is not loaded!");
6+
print("XZ extension is not loaded!");
77
}
88
?>
99
--FILE--

tests/xzopen_basic.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Test `xzopen`: basic functionality.
33
--SKIPIF--
44
<?php
55
if (!extension_loaded("xz")) {
6-
print("XZ extension is not loaded!");
6+
print("XZ extension is not loaded!");
77
}
88
?>
99
--FILE--

tests/xzopen_error.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Test `xzopen`: error conditions.
33
--SKIPIF--
44
<?php
55
if (!extension_loaded("xz")) {
6-
print("XZ extension is not loaded!");
6+
print("XZ extension is not loaded!");
77
}
88
?>
99
--FILE--

tests/xzwrite_basic.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Test function xzwrite() by calling it with its expected arguments
33
--SKIPIF--
44
<?php
55
if (!extension_loaded("xz")) {
6-
print("XZ extension is not loaded!");
6+
print("XZ extension is not loaded!");
77
}
88
?>
99
--FILE--

utils.c

+37-27
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,44 @@
11
/*
2-
+----------------------------------------------------------------------+
3-
| XZ Extension |
4-
+----------------------------------------------------------------------+
5-
| Copyright (c) 1997-2015 The PHP Group |
6-
+----------------------------------------------------------------------+
7-
| This source file is subject to version 3.01 of the PHP license, |
8-
| that is bundled with this package in the file LICENSE, and is |
9-
| available through the world-wide-web at the following url: |
10-
| http://www.php.net/license/3_01.txt |
11-
| If you did not receive a copy of the PHP license and are unable to |
12-
| obtain it through the world-wide-web, please send a note to |
13-
| license@php.net so we can mail you a copy immediately. |
14-
+----------------------------------------------------------------------+
15-
| Authors: Payden Sutherland <payden@paydensutherland.com> |
16-
| Dan Ungureanu <udan1107@gmail.com> |
17-
| authors of the `zlib` extension (for guidance) |
18-
+----------------------------------------------------------------------+
2+
+----------------------------------------------------------------------+
3+
| PHP Version 5 |
4+
+----------------------------------------------------------------------+
5+
| Copyright (c) 1997-2015 The PHP Group |
6+
+----------------------------------------------------------------------+
7+
| This source file is subject to version 3.01 of the PHP license, |
8+
| that is bundled with this package in the file LICENSE, and is |
9+
| available through the world-wide-web at the following url: |
10+
| http://www.php.net/license/3_01.txt |
11+
| If you did not receive a copy of the PHP license and are unable to |
12+
| obtain it through the world-wide-web, please send a note to |
13+
| license@php.net so we can mail you a copy immediately. |
14+
+----------------------------------------------------------------------+
15+
| Authors: Payden Sutherland <payden@paydensutherland.com> |
16+
| Dan Ungureanu <udan1107@gmail.com> |
17+
| authors of the `zlib` extension (for guidance) |
18+
+----------------------------------------------------------------------+
1919
*/
2020

2121
#include "php.h"
2222

23-
void *memmerge(void *ptr1, void *ptr2, size_t len1, size_t len2)
23+
void *memmerge(void *ptr1, void *ptr2, size_t len1, size_t len2) /* {{{ */
2424
{
25-
if ((ptr2 == NULL) || (len2 < 1)) {
26-
return ptr1;
27-
}
28-
ptr1 = erealloc(ptr1, len1 + len2);
29-
if (ptr1 == NULL) {
30-
return NULL;
31-
}
32-
memcpy(ptr1 + len1, ptr2, len2);
33-
return ptr1;
25+
if ((ptr2 == NULL) || (len2 < 1)) {
26+
return ptr1;
27+
}
28+
ptr1 = erealloc(ptr1, len1 + len2);
29+
if (ptr1 == NULL) {
30+
return NULL;
31+
}
32+
memcpy(ptr1 + len1, ptr2, len2);
33+
return ptr1;
3434
}
35+
/* }}} */
36+
37+
/*
38+
* Local variables:
39+
* tab-width: 4
40+
* c-basic-offset: 4
41+
* End:
42+
* vim600: sw=4 ts=4 fdm=marker
43+
* vim<600: sw=4 ts=4
44+
*/

utils.h

+29-28
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,38 @@
11
/*
2-
+----------------------------------------------------------------------+
3-
| XZ Extension |
4-
+----------------------------------------------------------------------+
5-
| Copyright (c) 1997-2015 The PHP Group |
6-
+----------------------------------------------------------------------+
7-
| This source file is subject to version 3.01 of the PHP license, |
8-
| that is bundled with this package in the file LICENSE, and is |
9-
| available through the world-wide-web at the following url: |
10-
| http://www.php.net/license/3_01.txt |
11-
| If you did not receive a copy of the PHP license and are unable to |
12-
| obtain it through the world-wide-web, please send a note to |
13-
| license@php.net so we can mail you a copy immediately. |
14-
+----------------------------------------------------------------------+
15-
| Authors: Payden Sutherland <payden@paydensutherland.com> |
16-
| Dan Ungureanu <udan1107@gmail.com> |
17-
| authors of the `zlib` extension (for guidance) |
18-
+----------------------------------------------------------------------+
2+
+----------------------------------------------------------------------+
3+
| PHP Version 5 |
4+
+----------------------------------------------------------------------+
5+
| Copyright (c) 1997-2015 The PHP Group |
6+
+----------------------------------------------------------------------+
7+
| This source file is subject to version 3.01 of the PHP license, |
8+
| that is bundled with this package in the file LICENSE, and is |
9+
| available through the world-wide-web at the following url: |
10+
| http://www.php.net/license/3_01.txt |
11+
| If you did not receive a copy of the PHP license and are unable to |
12+
| obtain it through the world-wide-web, please send a note to |
13+
| license@php.net so we can mail you a copy immediately. |
14+
+----------------------------------------------------------------------+
15+
| Authors: Payden Sutherland <payden@paydensutherland.com> |
16+
| Dan Ungureanu <udan1107@gmail.com> |
17+
| authors of the `zlib` extension (for guidance) |
18+
+----------------------------------------------------------------------+
1919
*/
2020

2121
#ifndef __UTILS_H__
2222
#define __UTILS_H__
2323

24-
/**
25-
* Merges two memory fragments by reallocating the first one.
26-
*
27-
* @param ptr1 The first memory segment which is going to be resized.
28-
* @param ptr2 The second memory segment that is going to be copied.
29-
* @param len1 The length of the first memory segment.
30-
* @param len2 The length of the second memory segment.
31-
*
32-
* @return Pointer to the first memory segment or if reallocated to the
33-
* new address.
34-
*/
24+
/* Merges two memory fragments by reallocating the first one.
25+
Returns a pointer to the first memory segment or, if reallocated, to the new
26+
address. */
3527
void *memmerge(void *ptr1, void *ptr2, size_t len1, size_t len2);
3628

3729
#endif
30+
31+
/*
32+
* Local variables:
33+
* tab-width: 4
34+
* c-basic-offset: 4
35+
* End:
36+
* vim600: sw=4 ts=4 fdm=marker
37+
* vim<600: sw=4 ts=4
38+
*/

0 commit comments

Comments
 (0)