pgsql: Windows doesn't have strtok_r, so let's use strtok_s instead.

Started by Michael Meskesover 14 years ago9 messagescomitters
Jump to latest
#1Michael Meskes
meskes@postgresql.org

Windows doesn't have strtok_r, so let's use strtok_s instead.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/e3155c97b0fa6d73aa9128cf0e56e8a776f5d355

Modified Files
--------------
src/interfaces/ecpg/ecpglib/connect.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)

#2Andrew Dunstan
andrew@dunslane.net
In reply to: Michael Meskes (#1)
Re: pgsql: Windows doesn't have strtok_r, so let's use strtok_s instead.

On 02/18/2012 09:56 AM, Michael Meskes wrote:

Windows doesn't have strtok_r, so let's use strtok_s instead.

This broke mingw builds.

I think you need a test like:

#if defined(WIN32) && ! defined(__GNUC__)

cheers

andrew

#3Michael Meskes
meskes@postgresql.org
In reply to: Andrew Dunstan (#2)
Re: pgsql: Windows doesn't have strtok_r, so let's use strtok_s instead.

On Sat, Feb 18, 2012 at 11:26:30AM -0500, Andrew Dunstan wrote:

I think you need a test like:

#if defined(WIN32) && ! defined(__GNUC__)

I found WIN32_ONLY_COMPILER used elsewhere and tried that. So far I've seen no
new red on the buildfarm.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
Jabber: michael.meskes at googlemail dot com
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL

#4Andrew Dunstan
andrew@dunslane.net
In reply to: Michael Meskes (#3)
Re: pgsql: Windows doesn't have strtok_r, so let's use strtok_s instead.

On 02/18/2012 11:50 AM, Michael Meskes wrote:

On Sat, Feb 18, 2012 at 11:26:30AM -0500, Andrew Dunstan wrote:

I think you need a test like:

#if defined(WIN32)&& ! defined(__GNUC__)

I found WIN32_ONLY_COMPILER used elsewhere and tried that. So far I've seen no
new red on the buildfarm.

Yeah, that should work too.

cheers

andrew

#5Michael Meskes
meskes@postgresql.org
In reply to: Andrew Dunstan (#2)
Re: pgsql: Windows doesn't have strtok_r, so let's use strtok_s instead.

On Sat, Feb 18, 2012 at 11:26:30AM -0500, Andrew Dunstan wrote:

This broke mingw builds.

Which one of these functions is available on MinGW?

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
Jabber: michael.meskes at googlemail dot com
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL

#6Andrew Dunstan
andrew@dunslane.net
In reply to: Michael Meskes (#5)
Re: pgsql: Windows doesn't have strtok_r, so let's use strtok_s instead.

On 02/18/2012 12:26 PM, Michael Meskes wrote:

On Sat, Feb 18, 2012 at 11:26:30AM -0500, Andrew Dunstan wrote:

This broke mingw builds.

Which one of these functions is available on MinGW?

strtok_r

cheers

andrew

#7Michael Meskes
meskes@postgresql.org
In reply to: Andrew Dunstan (#6)
Re: pgsql: Windows doesn't have strtok_r, so let's use strtok_s instead.

On Sat, Feb 18, 2012 at 12:40:43PM -0500, Andrew Dunstan wrote:

Which one of these functions is available on MinGW?

So what is the system on pitta? It says gcc, but doesn't seem to know strtok_r.

I'm tempted to remove strtok and program the bits and pieces I need myself.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
Jabber: michael.meskes at googlemail dot com
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL

#8Andrew Dunstan
andrew@dunslane.net
In reply to: Michael Meskes (#7)
Re: pgsql: Windows doesn't have strtok_r, so let's use strtok_s instead.

On 02/18/2012 02:38 PM, Michael Meskes wrote:

On Sat, Feb 18, 2012 at 12:40:43PM -0500, Andrew Dunstan wrote:

Which one of these functions is available on MinGW?

So what is the system on pitta? It says gcc, but doesn't seem to know strtok_r.

I'm tempted to remove strtok and program the bits and pieces I need myself.

Sorry, it looks like I was mistaken, and neither of these is available
on mingw. Could you just use plain strtok(), possibly on a copy of the
string?

cheers

andrew

#9Michael Meskes
meskes@postgresql.org
In reply to: Andrew Dunstan (#8)
Re: pgsql: Windows doesn't have strtok_r, so let's use strtok_s instead.

On Sat, Feb 18, 2012 at 03:12:21PM -0500, Andrew Dunstan wrote:

Sorry, it looks like I was mistaken, and neither of these is
available on mingw. Could you just use plain strtok(), possibly on a
copy of the string?

I got tired of worrying about these differences and simply wrote the code
needed directly in ecpglib. Hopefully this will put this problem to rest.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
Jabber: michael.meskes at googlemail dot com
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL