php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch 0002-rename-arg-nb-to-levels-frenchism.patch for Unknown/Other Function Bug #70112

Patch version 2015-07-22 12:39 UTC

Return to Bug #70112 | Download this patch
This patch is obsolete

Obsoleted by patches:

Patch Revisions:

Developer: remi@php.net

From 70cce400151dc909515f3d7aa2511bcc8df5cc4d Mon Sep 17 00:00:00 2001
From: Remi Collet <fedora@famillecollet.com>
Date: Wed, 22 Jul 2015 14:38:09 +0200
Subject: [PATCH 2/2] rename arg nb to levels (frenchism)

---
 ext/standard/basic_functions.c                |  2 +-
 ext/standard/string.c                         | 12 ++++++------
 ext/standard/tests/strings/dirname_error.phpt |  2 +-
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index 2c65aff..3f03275 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -2215,7 +2215,7 @@ ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_dirname, 0, 0, 1)
 	ZEND_ARG_INFO(0, path)
-	ZEND_ARG_INFO(0, nb)
+	ZEND_ARG_INFO(0, levels)
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_pathinfo, 0, 0, 1)
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 82a1e8e..d921ad0 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -1648,26 +1648,26 @@ PHPAPI size_t php_dirname(char *path, size_t len)
 }
 /* }}} */
 
-/* {{{ proto string dirname(string path[, int nb])
+/* {{{ proto string dirname(string path[, int levels])
    Returns the directory name component of the path */
 PHP_FUNCTION(dirname)
 {
 	char *str;
 	zend_string *ret;
 	size_t str_len;
-	zend_long nb = 1;
+	zend_long levels = 1;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &str, &str_len, &nb) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &str, &str_len, &levels) == FAILURE) {
 		return;
 	}
-	if (nb < 1) {
-		php_error_docref(NULL, E_WARNING, "Invalid argument, nb must be >= 1");
+	if (levels < 1) {
+		php_error_docref(NULL, E_WARNING, "Invalid argument, levels must be >= 1");
 		return;
 	}
 	ret = zend_string_init(str, str_len, 0);
 	do {
 		ZSTR_LEN(ret) = zend_dirname(ZSTR_VAL(ret), ZSTR_LEN(ret));
-	} while (ZSTR_LEN(ret) && --nb>0);
+	} while (ZSTR_LEN(ret) && --levels>0);
 
 	RETURN_NEW_STR(ret);
 }
diff --git a/ext/standard/tests/strings/dirname_error.phpt b/ext/standard/tests/strings/dirname_error.phpt
index e5802dc..303a59b 100644
--- a/ext/standard/tests/strings/dirname_error.phpt
+++ b/ext/standard/tests/strings/dirname_error.phpt
@@ -23,7 +23,7 @@ echo "Done\n";
 Warning: dirname() expects at least 1 parameter, 0 given in %s on line %d
 NULL
 
-Warning: dirname(): Invalid argument, nb must be >= 1 in %s on line %d
+Warning: dirname(): Invalid argument, levels must be >= 1 in %s on line %d
 NULL
 
 Warning: dirname() expects at most 2 parameters, 3 given in %s on line %d
-- 
2.1.0

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 12 09:01:27 2024 UTC