# Possible tweak for tm2unixtime.c

- Thread: https://externals.io/message/73055
- Original archive: https://news-web.php.net/php.internals/73055
- Started by tigger.on@gmail.com on 2014-03-11T06:14:40+00:00
- Messages: 5
- 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

---

## #73055 — tigger.on@gmail.com — 2014-03-11T06:14:40+00:00

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

Hello. I'm not sure, but I believe the following `do {} while` code is
pointless in /ext/date/lib/tm2unixtime.c (located here:
https://github.com/php/php-src/blob/af6c11c5f060870d052a2b765dc634d9e47d0f18/ext/date/lib/tm2unixtime.c)

The code in question (appears a lot):

do {} while (do_range_limit(0, 60, 60, &rt->s, &rt->i));

The method `do_range_limit()` will always return 0, so why not just
call it like so:

do_range_limit(0, 60, 60, &rt->s, &rt->i);

And remove the `do {} while` loop.

There may be a reason why that loop code is there, but I'm not seeing
why. More than happy to be wrong.

-Tig

---

## #73056 — Tjerk Meesters — 2014-03-11T09:11:26+00:00

URL: https://externals.io/message/73055#73056 · In reply to: #73055

> Hello. I'm not sure, but I believe the following `do {} while` code is
> pointless in /ext/date/lib/tm2unixtime.c (located here:
>
> https://github.com/php/php-src/blob/af6c11c5f060870d052a2b765dc634d9e47d0f18/ext/date/lib/tm2unixtime.c
> )
>
> The code in question (appears a lot):
>
> do {} while (do_range_limit(0, 60, 60, &rt->s, &rt->i));
>
> The method `do_range_limit()` will always return 0, so why not just
> call it like so:
>
> do_range_limit(0, 60, 60, &rt->s, &rt->i);
>
> And remove the `do {} while` loop.
>

I can only tell you that removing them will cause 14 test cases to fail.
Unfortunately I can't tell you why that happens.


>
> There may be a reason why that loop code is there, but I'm not seeing
> why. More than happy to be wrong.
>
> -Tig
>
> --
> 
> 
>
>


-- 
--
Tjerk

---

## #73057 — Kris Craig — 2014-03-11T09:42:49+00:00

URL: https://externals.io/message/73055#73057 · In reply to: #73056

On Tue, Mar 11, 2014 at 2:11 AM, Tjerk Meesters <tjerk.meesters@gmail.com>wrote:

> 
>
> > […]
> https://github.com/php/php-src/blob/af6c11c5f060870d052a2b765dc634d9e47d0f18/ext/date/lib/tm2unixtime.c
> > […]
>
> I can only tell you that removing them will cause 14 test cases to fail.
> Unfortunately I can't tell you why that happens.
>
>
> > […]
>
>
> --
> --
> Tjerk
>

Do you recall which tests are those affected?

--Kris

---

## #73058 — Tjerk Meesters — 2014-03-11T09:53:52+00:00

URL: https://externals.io/message/73055#73058 · In reply to: #73057

Hi




>
>
>
> On Tue, Mar 11, 2014 at 2:11 AM, Tjerk Meesters <tjerk.meesters@gmail.com>wrote:
>
> > […]
>
> Do you recall which tests are those affected?
>

Never mind, I'm an idiot :)

The following will work just peachy:

https://github.com/datibbaw/php-src/compare/master...date-empty-loops



>
> --Kris
>
>


-- 
--
Tjerk

---

## #73061 — Derick Rethans — 2014-03-11T10:45:00+00:00

URL: https://externals.io/message/73055#73061 · In reply to: #73058

> 
> 
> > […]
> 
> Never mind, I'm an idiot :)
> 
> The following will work just peachy:
> 
> https://github.com/datibbaw/php-src/compare/master...date-empty-loops

That looks fine. In earlier versions of the code, the do_range_limit 
function did not in one go change the values and you had to call it in a 
loop. The loop in general wouldn't be run more than once though.

cheers,
Derick

-- 
http://derickrethans.nl | http://xdebug.org
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
twitter: @derickr and @xdebug
Posted with an email client that doesn't mangle email: alpine
