# Tiny pathinfo() patch

- Thread: https://externals.io/message/24380
- Original archive: https://news-web.php.net/php.internals/24380
- Started by Tobias Schlitt on 2006-07-14T19:30:48+00:00
- Messages: 8
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #24380 — Tobias Schlitt — 2006-07-14T19:30:48+00:00

URL: https://externals.io/message/24380#24380

Hi all!

It occured several times in the past weeks, where I needed the filename
without extension as well as the file extension extracted from a
pathname. Since first calling `pathinfo()` and then `basename()` again, or
using string manipulation, I now patched `pathinfo()` to provide the
filename without extension per default with key "filename".

Find the patch here: http://schlitt.info/misc/pathinfo.patch

The patch is against 5_2.

Maybe someone considers that useful as well?

Regards,
Toby
-- 
Tobias Schlitt - Zend Certified Engineer         GPG Key: 0xC462BC14
a passion for php                            http://www.schlitt.info
Like to say "thank you"?    -  http://pear.php.net/wishlist.php/toby

---

## #24381 — Christian Schneider — 2006-07-14T20:09:28+00:00

URL: https://externals.io/message/24380#24381 · In reply to: #24380

Tobias Schlitt wrote:
> using string manipulation, I now patched `pathinfo()` to provide the
> filename without extension per default with key "filename".
> 
> Find the patch here: http://schlitt.info/misc/pathinfo.patch

If the patch is considered then I would propose to also return the key 
"filename" if the filename does not have a suffix. The current code 
seems to only return it if it can find a '.' in the filename.

I.e. change
	if (p) {
		idx = p - ret;
		add_assoc_stringl(tmp, "filename", ret, idx, 1);
	}

to
	idx = p ? (p - ret) : ret_len;
	add_assoc_stringl(tmp, "filename", ret, idx, 1);
or something like that.

- Chris

---

## #24382 — Tobias Schlitt — 2006-07-14T20:20:27+00:00

URL: https://externals.io/message/24380#24382 · In reply to: #24381

On 07/14/2006 10:09 PM Christian Schneider wrote:
> Tobias Schlitt wrote:

> > […]

> If the patch is considered then I would propose to also return the key
> "filename" if the filename does not have a suffix. The current code
> seems to only return it if it can find a '.' in the filename.
> 
> I.e. change
>     if (p) {
>         idx = p - ret;
>         add_assoc_stringl(tmp, "filename", ret, idx, 1);
>     }
> 
> to
>     idx = p ? (p - ret) : ret_len;
>     add_assoc_stringl(tmp, "filename", ret, idx, 1);
> or something like that.

Valid point. I updated the patch.

Have a nice weekend!
Toby
-- 
Tobias Schlitt - Zend Certified Engineer         GPG Key: 0xC462BC14
a passion for php                            http://www.schlitt.info
Like to say "thank you"?    -  http://pear.php.net/wishlist.php/toby

---

## #24388 — Marcus Boerger — 2006-07-15T10:35:35+00:00

URL: https://externals.io/message/24380#24388 · In reply to: #24380

Hello Tobias,

  looks good after the update. Can you provide a patch for HEAD too?

  also please provide patches with "cvs di -upd".

best regards
marcus

Friday, July 14, 2006, 9:30:48 PM, you wrote:

> Hi all!

> It occured several times in the past weeks, where I needed the filename
> without extension as well as the file extension extracted from a
> pathname. Since first calling `pathinfo()` and then `basename()` again, or
> using string manipulation, I now patched `pathinfo()` to provide the
> filename without extension per default with key "filename".

> Find the patch here: http://schlitt.info/misc/pathinfo.patch

> The patch is against 5_2.

> Maybe someone considers that useful as well?

> Regards,
> Toby
> -- 
> Tobias Schlitt - Zend Certified Engineer         GPG Key: 0xC462BC14
> a passion for php                            http://www.schlitt.info
> Like to say "thank you"?    -  http://pear.php.net/wishlist.php/toby




Best regards,
 Marcus

---

## #24392 — Richard Quadling — 2006-07-15T12:15:15+00:00

URL: https://externals.io/message/24380#24392 · In reply to: #24388

I'm annoyed! Quite annoyed!!

Ok. I know none of you know me and I've not met any of you.

But, a while ago I submitted a relatively minor patch to extend PHP's
php.ini filename to include the major version. This was an extension
to the existing searching rules. As a windows user, I'm not in a
position to build my own executables. I wish I was!!!!

The patch would allow different versions of PHP to use the same SAPI
but with different php.ini files. e.g. originally just php.ini, then
php-cli.ini, php-cgi.ini, php-isapi.ini, etc.

My patch would extend this to _ALSO_ allow php4-cli.ini, php5-cgi.ini,
php6-ispai.ini (just examples - all combinations allowed). And the
patch, whilst untested by me, would allow upto php V99. (I've been
with PHP since just into V4, and soon V6 will be here, so PHP V9
seemed too short sighted).

As this patch has REAL advantages for me and others wishing to use
PHP4 / 5 and 6 on the same machine, with the same webserver (Either
ISAPI OR CGI), I was surprised when it wasn't committed.

Now the patch provided by Tobias, for what is, from his own words,
completely possible in userland without any extension or enhancement
to php core, seems totally redundant.

Whilst I understand that you cannot have every patch supplied
incorporated into the source, would you please comment as to why my
patch was rejected?

Are there some more hoops I'm expected to jump through?

I know that there is a major focus on Unicode at the moment and this
is taking a lot of time. This is why I though actually supplying a
patch would be better received than simply a WIBNI approach.

My intention here is NOT to upset anyone, especially Tobias. He had a
problem and he fixed it and with the support of the core devlopers,
his solution has been incorporated into the core.

I have a different problem. I did the research and supplied a patch.
The patch has been rejected. I do not know why.

If there is more that I need to do to get this functioning, then a few
pointers would be nice.

Regards and true appreciation of the skills, hard work and dedication
of the efforts of the core php developers. I make my living standing
on your shoulders.

Richard Quadling.

P.S. I REALLY don't want to annoy anyone. Really.



> Hello Tobias,
>
>   looks good after the update. Can you provide a patch for HEAD too?
>
>   also please provide patches with "cvs di -upd".
>
> best regards
> marcus
>
> Friday, July 14, 2006, 9:30:48 PM, you wrote:
>
> > […]
>
> > […]
>
> > […]
>
> > […]
>
> > […]
>
> > […]

-- 
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&amp;r=213474731

---

## #24393 — Marcus Boerger — 2006-07-15T12:24:52+00:00

URL: https://externals.io/message/24380#24393 · In reply to: #24392

Hello Richard,

Saturday, July 15, 2006, 2:15:15 PM, you wrote:

> I'm annoyed! Quite annoyed!!

> Ok. I know none of you know me and I've not met any of you.

> But, a while ago I submitted a relatively minor patch to extend PHP's
> php.ini filename to include the major version. This was an extension
> to the existing searching rules. As a windows user, I'm not in a
> position to build my own executables. I wish I was!!!!

Why not simply provide it again? Sometimes patches get lost just because
nobody felt responsible or saw a need for himself. In this particularcase
i am interested myslef, quite selfish, isn't it? And btw what does your
patch offer besides the configure options related to ini searching we
have already? And please do this in a new seperate thread.

Best regards,
 Marcus

---

## #24397 — Pierre — 2006-07-15T12:48:40+00:00

URL: https://externals.io/message/24380#24397 · In reply to: #24393

> Hello Richard,
>
> Saturday, July 15, 2006, 2:15:15 PM, you wrote:
>
> > […]
>
> > […]
>
> > […]
>
> Why not simply provide it again? Sometimes patches get lost just because
> nobody felt responsible or saw a need for himself. In this particularcase
> i am interested myslef, quite selfish, isn't it? And btw what does your
> patch offer besides the configure options related to ini searching we
> have already? And please do this in a new seperate thread.

The best way to do not lost a patch is to open a bug and leave a link to it.

--Pierre

---

## #24398 — Tobias Schlitt — 2006-07-15T13:48:34+00:00

URL: https://externals.io/message/24380#24398 · In reply to: #24388

On 07/15/2006 12:35 PM Marcus Boerger wrote:
> Hello Tobias,

>   looks good after the update. Can you provide a patch for HEAD too?
>   also please provide patches with "cvs di -upd".

Done.

Find the patches here:

http://schlitt.info/misc/pathinfo-HEAD.patch
http://schlitt.info/misc/pathinfo-5_2.patch

Regards,
Toby
-- 
Tobias Schlitt - Zend Certified Engineer         GPG Key: 0xC462BC14
a passion for php                            http://www.schlitt.info
Like to say "thank you"?    -  http://pear.php.net/wishlist.php/toby
