Oops.. nested strtok in mkdeps.c, need to use strtok_r

git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5345 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2012-11-13 17:18:42 +00:00
parent b74772ee54
commit 9324847103
4 changed files with 27 additions and 10 deletions

View File

@ -1084,8 +1084,10 @@ Where <subdir> is one of the following:
b. Execute 'make menuconfig' in nuttx/ in order to start the
reconfiguration process.
2. Default toolchain:
2. Default platform/toolchain:
CONFIG_HOST_WINDOWS=y : Windows
CONFIG_WINDOWS_CYGWIN=y : Cygwin environment on Windows
CONFIG_STM32_CODESOURCERYW=y : CodeSourcery under Windows
3. By default, this project assumes that you are *NOT* using the DFU
@ -1460,6 +1462,10 @@ Where <subdir> is one of the following:
standard issue, CMD shell: ConEmu which can be downloaded from:
http://code.google.com/p/conemu-maximus5/
CONFIG_HOST_WINDOWS=y : Windows
CONFIG_WINDOWS_NATIVE=y : Native Windows environment
CONFIG_STM32_CODESOURCERYW=y : CodeSourcery under Windows
Build Tools. The build still relies on some Unix-like commands. I use
the GNUWin32 tools that can be downloaded from http://gnuwin32.sourceforge.net/.
The MSYS tools are probably also a option but are likely lower performance

View File

@ -105,16 +105,12 @@ LDSCRIPT = ld.script
ifeq ($(WINTOOL),y)
# Windows-native toolchains
DIRLINK = $(TOPDIR)/tools/winlink.sh
DIRUNLINK = $(TOPDIR)/tools/unlink.sh
MKDEP = $(TOPDIR)/tools/mknulldeps.sh
ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}"
ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}"
ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)}"
MAXOPTIMIZATION = -O2
else
# Linux/Cygwin-native toolchain
MKDEP = $(TOPDIR)/tools/mkdeps.sh
# Linux/Cygwin-native toolchain
ARCHINCLUDES = -I. -isystem $(TOPDIR)/include
ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx
ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)
@ -178,3 +174,13 @@ else
HOSTEXEEXT =
endif
ifeq ($(WINTOOL),y)
# Windows-native host tools
DIRLINK = $(TOPDIR)/tools/winlink.sh
DIRUNLINK = $(TOPDIR)/tools/unlink.sh
MKDEP = $(TOPDIR)/tools/mknulldeps.sh
else
# Linux/Cygwin-native host tools
MKDEP = $(TOPDIR)/tools/mkdeps$(HOSTEXEEXT)
endif

View File

@ -81,7 +81,6 @@ LDSCRIPT = ld.script
# Windows-native toolchains
MKDEP = $(TOPDIR)/tools/mkdeps.bat
ARCHINCLUDES = -I. -isystem $(TOPDIR)/include
ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx
ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)
@ -137,3 +136,7 @@ HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -g -pipe
HOSTLDFLAGS =
HOSTEXEEXT = .exe
# Windows-native host tools
MKDEP = $(TOPDIR)/tools/mkdeps.exe

View File

@ -288,6 +288,7 @@ static void do_dependency(const char *file, char separator)
struct stat buf;
char *altpath;
char *path;
char *lasts;
int cmdlen;
int pathlen;
int filelen;
@ -330,15 +331,15 @@ static void do_dependency(const char *file, char separator)
/* Add a space */
command[cmdlen] = ' ';
command[cmdlen+1] = '\0';
cmdlen++;
command[cmdlen] = '\0';
/* Try each path. This loop will continue until each path has been tried
* (failure) or until stat() finds the file
*/
altpath = g_altpath;
while ((path = strtok(altpath, " ")) != NULL)
while ((path = strtok_r(altpath, " ", &lasts)) != NULL)
{
/* Create a full path to the file */
@ -565,6 +566,7 @@ static void do_winpath(char *file)
int main(int argc, char **argv, char **envp)
{
char *lasts;
char *files;
char *file;
@ -575,7 +577,7 @@ int main(int argc, char **argv, char **envp)
/* Then generate dependencies for each path on the command line */
files = g_files;
while ((file = strtok(files, " ")) != NULL)
while ((file = strtok_r(files, " ", &lasts)) != NULL)
{
/* Check if we need to do path conversions for a Windows-natvie tool
* being using in a POSIX/Cygwin environment.