Skip to content

Commit

Permalink
ecere, ide; Instance_COM_Initialize, Tokenize, _DualPipeOpen; multipl…
Browse files Browse the repository at this point in the history
…e fixes. finally closes #778, #777 and #863.

 - affects all command line tools.
 - fixed windows arguments parsing to respect spaces and double quotes that are escaped.
 - adjusted toolchaing debugging tools to not alter the way args are passed to the debugging ide now that win args parsing is fixed.
 - fixed preprocessor definitions when defining MY_STR_DEF="string" on windows by escaping quotes.
  • Loading branch information
redj committed Jun 13, 2013
1 parent 8c72bc7 commit 5a5cf3b
Show file tree
Hide file tree
Showing 18 changed files with 298 additions and 281 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -126,7 +126,7 @@ else
endif

export CPPFLAGS
CPPFLAGS += -DDEB_HOST_MULTIARCH=\"$(PREFIXLIBDIR)\"
CPPFLAGS += -DDEB_HOST_MULTIARCH=\"$(call escspace,$(PREFIXLIBDIR))\"

DESTLIBDIR := $(DESTDIR)$(PREFIXLIBDIR)
ifdef SLIBDIR
Expand Down
4 changes: 2 additions & 2 deletions compiler/Makefile
Expand Up @@ -54,15 +54,15 @@ clean:
realclean:
cd bootstrap && $(MAKE) realclean
cd libec && $(MAKE) realclean
cd libec && $(MAKE) fixprecompile
cd libec && $(MAKE) silentfixprecompile
cd ecp && $(MAKE) realclean
cd ecc && $(MAKE) realclean
cd ecs && $(MAKE) realclean

distclean:
cd bootstrap && $(MAKE) distclean
cd libec && $(MAKE) distclean
cd libec && $(MAKE) fixprecompile
cd libec && $(MAKE) silentfixprecompile
cd ecp && $(MAKE) distclean
cd ecc && $(MAKE) distclean
cd ecs && $(MAKE) distclean
70 changes: 28 additions & 42 deletions compiler/ecc/ecc.ec
Expand Up @@ -296,42 +296,31 @@ class CompilerApp : Application
{
if(!strcmp(arg + 1, "m32") || !strcmp(arg + 1, "m64"))
{
int argLen = strlen(arg);
int newLen = cppOptionsLen + 1 + argLen;
int newLen = cppOptionsLen + 1 + strlen(arg);
cppOptions = renew cppOptions char[newLen + 1];
cppOptions[cppOptionsLen] = ' ';
strcpy(cppOptions + cppOptionsLen + 1, arg);
cppOptionsLen = newLen;
targetBits = !strcmp(arg + 1, "m32") ? 32 : 64;
}
else if(arg[1] == 'D')
else if(arg[1] == 'D' || arg[1] == 'I')
{
int argLen = strlen(arg);
int newLen = cppOptionsLen + 1 + argLen;
cppOptions = renew cppOptions char[newLen + 1];
cppOptions[cppOptionsLen] = ' ';
strcpy(cppOptions + cppOptionsLen + 1, arg);
cppOptionsLen = newLen;
if(!strcmp(arg, "-DBUILDING_ECERE_COM"))
SetBuildingEcereCom(true);
else if(!strcmp(arg, "-DECERE_COM_MODULE"))
SetBuildingEcereComModule(true);
else if(!strcmp(arg, "-DECERE_BOOTSTRAP"))
buildingBootStrap = true;
}
else if(arg[1] == 'I')
{
int argLen = strlen(arg);
int newLen = cppOptionsLen + argLen + 3;
cppOptions = renew cppOptions char[newLen + 1];
cppOptions[cppOptionsLen] = ' ';
cppOptions[cppOptionsLen+1] = '-';
cppOptions[cppOptionsLen+2] = 'I';
cppOptions[cppOptionsLen+3] = '"';
strcpy(cppOptions + cppOptionsLen + 4, arg+2);
cppOptions[newLen-1] = '\"';
cppOptions[newLen] = '\0';
cppOptionsLen = newLen;
char * buf;
int size = cppOptionsLen + 1 + strlen(arg) * 2 + 1;
cppOptions = renew cppOptions char[size];
buf = cppOptions + cppOptionsLen;
*buf++ = ' ';
PassArg(buf, arg);
cppOptionsLen = cppOptionsLen + 1 + strlen(buf);
if(arg[1] == 'D')
{
if(!strcmp(arg, "-DBUILDING_ECERE_COM"))
SetBuildingEcereCom(true);
else if(!strcmp(arg, "-DECERE_COM_MODULE"))
SetBuildingEcereComModule(true);
else if(!strcmp(arg, "-DECERE_BOOTSTRAP"))
buildingBootStrap = true;
}
}
else if(!strcmp(arg+1, "t"))
{
Expand Down Expand Up @@ -371,19 +360,16 @@ class CompilerApp : Application
{
if(c + 1 < argc)
{
int argLen = strlen(arg);
int arg1Len = strlen(argv[c+1]);
int newLen = cppOptionsLen + argLen + arg1Len + 4;
cppOptions = renew cppOptions char[newLen + 1];
cppOptions[cppOptionsLen] = ' ';
strcpy(cppOptions + cppOptionsLen + 1, arg);
cppOptions[cppOptionsLen+argLen+1] = ' ';
cppOptions[cppOptionsLen+argLen+2] = '"';
arg = argv[++c];
strcpy(cppOptions + cppOptionsLen + argLen + 3, arg);
cppOptions[newLen-1] = '\"';
cppOptions[newLen] = '\0';
cppOptionsLen = newLen;
char * buf;
char * arg1 = argv[++c];
int size = cppOptionsLen + 1 + strlen(arg) * 2 + strlen(arg1) * 2 + 1;
cppOptions = renew cppOptions char[size];
buf = cppOptions + cppOptionsLen;
*buf++ = ' ';
buf = PassArg(buf, arg);
*buf++ = ' ';
buf = PassArg(buf, arg1);
cppOptionsLen = buf - cppOptions;
}
else
valid = false;
Expand Down
55 changes: 19 additions & 36 deletions compiler/ecp/ecp.ec
Expand Up @@ -1337,36 +1337,22 @@ class PrecompApp : Application
{
if(!strcmp(arg + 1, "m32") || !strcmp(arg + 1, "m64"))
{
int argLen = strlen(arg);
int newLen = cppOptionsLen + 1 + argLen;
int newLen = cppOptionsLen + 1 + strlen(arg);
cppOptions = renew cppOptions char[newLen + 1];
cppOptions[cppOptionsLen] = ' ';
strcpy(cppOptions + cppOptionsLen + 1, arg);
cppOptionsLen = newLen;
targetBits = !strcmp(arg + 1, "m32") ? 32 : 64;
}
else if(arg[1] == 'D')
else if(arg[1] == 'D' || arg[1] == 'I')
{
int argLen = strlen(arg);
int newLen = cppOptionsLen + 1 + argLen;
cppOptions = renew cppOptions char[newLen + 1];
cppOptions[cppOptionsLen] = ' ';
strcpy(cppOptions + cppOptionsLen + 1, arg);
cppOptionsLen = newLen;
}
else if(arg[1] == 'I')
{
int argLen = strlen(arg);
int newLen = cppOptionsLen + argLen + 3;
cppOptions = renew cppOptions char[newLen + 1];
cppOptions[cppOptionsLen] = ' ';
cppOptions[cppOptionsLen+1] = '-';
cppOptions[cppOptionsLen+2] = 'I';
cppOptions[cppOptionsLen+3] = '"';
strcpy(cppOptions + cppOptionsLen + 4, arg+2);
cppOptions[newLen-1] = '\"';
cppOptions[newLen] = '\0';
cppOptionsLen = newLen;
char * buf;
int size = cppOptionsLen + 1 + strlen(arg) * 2 + 1;
cppOptions = renew cppOptions char[size];
buf = cppOptions + cppOptionsLen;
*buf++ = ' ';
PassArg(buf, arg);
cppOptionsLen = cppOptionsLen + 1 + strlen(buf);
}
else if(!strcmp(arg+1, "t"))
{
Expand Down Expand Up @@ -1406,19 +1392,16 @@ class PrecompApp : Application
{
if(c + 1 < argc)
{
int argLen = strlen(arg);
int arg1Len = strlen(argv[c+1]);
int newLen = cppOptionsLen + argLen + arg1Len + 4;
cppOptions = renew cppOptions char[newLen + 1];
cppOptions[cppOptionsLen] = ' ';
strcpy(cppOptions + cppOptionsLen + 1, arg);
cppOptions[cppOptionsLen+argLen+1] = ' ';
cppOptions[cppOptionsLen+argLen+2] = '"';
arg = argv[++c];
strcpy(cppOptions + cppOptionsLen + argLen + 3, arg);
cppOptions[newLen-1] = '\"';
cppOptions[newLen] = '\0';
cppOptionsLen = newLen;
char * buf;
char * arg1 = argv[++c];
int size = cppOptionsLen + 1 + strlen(arg) * 2 + strlen(arg1) * 2 + 1;
cppOptions = renew cppOptions char[size];
buf = cppOptions + cppOptionsLen;
*buf++ = ' ';
buf = PassArg(buf, arg);
*buf++ = ' ';
buf = PassArg(buf, arg1);
cppOptionsLen = buf - cppOptions;
}
else
valid = false;
Expand Down
39 changes: 39 additions & 0 deletions compiler/libec/src/ecdefs.ec
Expand Up @@ -101,6 +101,45 @@ public void FixModuleName(char *moduleName)
ChangeCh(moduleName, '&', '_');
}

// todo support %var% variables for windows and $var for linux?
public char * PassArg(char * output, const char * input)
{
#ifdef __WIN32__
//define windowsFileNameCharsNeedEscaping = " !%&'()+,;=[]^`{}~"; // "#$-.@_" are ok
const char * escChars = " !\"%&'()+,;=[]^`{}~"; // windowsFileNameCharsNeedEscaping;
const char * escCharsQuoted = "\"";
#else
//define linuxFileNameCharsNeedEscaping = " !\"$&'()*:;<=>?[\\`{|"; // "#%+,-.@]^_}~" are ok
const char * escChars = " !\"$&'()*:;<=>?[\\`{|"; // linuxFileNameCharsNeedEscaping;
const char * escCharsQuoted = "\"()$";
#endif
bool quoting = false;
char *o = output, *i = input, *l = input;
#ifdef __WIN32__
while(*l && !strchr(escChars, *l)) l++;
if(*l) quoting = true;
#else
if(*i == '-')
{
l++;
while(*l && !strchr(escChars, *l)) l++;
if(*l) quoting = true;
*o++ = *i++;
}
#endif
if(quoting)
*o++ = '\"';
while(*i)
{
if(strchr(quoting ? escCharsQuoted : escChars, *i))
*o++ = '\\';
*o++ = *i++;
}
if(quoting)
*o++ = '\"';
*o = '\0';
return o;
}
/*public Module GetPrivateModule()
{
return privateModule;
Expand Down
38 changes: 22 additions & 16 deletions crossplatform.mk
Expand Up @@ -150,11 +150,15 @@ endif

# MISC STRING TOOLS
empty :=
esc := $(empty)$(empty)
space := $(empty) $(empty)
comma := ,
escspace = $(subst $(space),\$(space),$(subst \$(space),$(space),$1))
hidspace = $(subst $(space),,$(subst \$(space),,$1))
shwspace = $(subst ,\$(space),$1)
slash := $(empty)/$(empty)
backslash := $(empty)\$(empty)
escspace = $(subst $(space),$(backslash)$(space),$(subst $(backslash)$(space),$(space),$(1)))
hidspace = $(subst $(space),$(esc),$(subst $(backslash)$(space),$(esc),$(1)))
shwspace = $(subst $(esc),$(backslash)$(space),$(1))
unescp_all = $(subst $(esc),$(backslash),$(subst $(backslash),,$(subst $(backslash)$(backslash),$(esc),$(1))))

# PATH SEPARATOR STRING TOOLS
ifdef WINDOWS_HOST
Expand All @@ -163,13 +167,15 @@ ifndef MSYSCON
endif
endif
ifdef WIN_PS_TOOLS
fixps = $(subst \,/,$(1))
psep = $(subst \\,/,$(subst /,\,$(1)))
PS := $(strip \)
psep := $(backslash)
slash_path = $(subst $(backslash),$(slash),$(1))
sys_path = $(subst $(backslash)$(backslash),$(slash),$(subst $(slash),$(backslash),$(1)))
quote_path = "$(call sys_path,$(call unescp_all,$(1)))"
else
fixps = $(1)
PS := $(strip /)
psep = $(1)
psep := $(slash)
slash_path = $(1)
sys_path = $(1)
quote_path = $(1)
endif

# PREFIXES AND EXTENSIONS
Expand Down Expand Up @@ -215,12 +221,12 @@ endif
endif
ifdef WIN_SHELL_COMMANDS
echo = $(if $(1),echo $(1))
touch = $(if $(1),@cmd /c "for %%a in ($(call psep,$(1))) do @(cd %%~pa && type nul >> %%~nxa && copy /by %%~nxa+,, >nul 2>&1 && cd %%cd%%)")
cpq = $(if $(1),@cmd /c "for %%a in ($(call psep,$(1))) do copy /by %%a $(call psep,$(2))" >nul 2>&1)
rmq = $(if $(1),-del /f /q $(call psep,$(1)) > nul 2>&1)
rmrq = $(if $(1),-rmdir /q /s $(call psep,$(1)) > nul 2>&1)
mkdirq = $(if $(1),-mkdir $(call psep,$(1)) > nul 2>&1)
rmdirq = $(if $(1),-rmdir /q $(call psep,$(1)) > nul 2>&1)
touch = $(if $(1),@cmd /c "for %%I in ($(call sys_path,$(1))) do @(cd %%~pI && type nul >> %%~nxI && copy /by %%~nxI+,, > nul 2>&1 && cd %%cd%%)")
cpq = $(if $(1),@cmd /c "for %%I in ($(call sys_path,$(1))) do copy /by %%I $(call sys_path,$(2))" > nul 2>&1)
rmq = $(if $(1),-del /f /q $(call sys_path,$(1)) > nul 2>&1)
rmrq = $(if $(1),-rmdir /q /s $(call sys_path,$(1)) > nul 2>&1)
mkdirq = $(if $(1),-mkdir $(call sys_path,$(1)) > nul 2>&1)
rmdirq = $(if $(1),-rmdir /q $(call sys_path,$(1)) > nul 2>&1)
else
echo = $(if $(1),echo "$(1)")
touch = $(if $(1),touch $(1))
Expand Down Expand Up @@ -260,7 +266,7 @@ endif
# COMMON LIBRARIES DETECTION
ifdef WINDOWS_TARGET
ifdef OPENSSL_CONF
_OPENSSL_CONF = $(call hidspace,$(call fixps,$(OPENSSL_CONF)))
_OPENSSL_CONF = $(call hidspace,$(call slash_path,$(OPENSSL_CONF)))
OPENSSL_INCLUDE_DIR = $(call shwspace,$(subst /bin/openssl.cfg,/include,$(_OPENSSL_CONF)))
OPENSSL_LIB_DIR = $(call shwspace,$(subst /bin/openssl.cfg,/lib,$(_OPENSSL_CONF)))
OPENSSL_BIN_DIR = $(call shwspace,$(subst /bin/openssl.cfg,/bin,$(_OPENSSL_CONF)))
Expand Down
8 changes: 4 additions & 4 deletions default.cf
Expand Up @@ -14,10 +14,10 @@ export AS = $(GCC_PREFIX)as
export LD = $(GCC_PREFIX)ld
export AR = $(GCC_PREFIX)ar
export STRIP = $(GCC_PREFIX)strip
export ECP := $(call psep,$(EC_BINS)ecp$(HOST_E))
export ECC := $(call psep,$(EC_BINS)ecc$(HOST_E))$(if $(CROSS_TARGET), -t $(TARGET_PLATFORM),)
export ECS := $(call psep,$(EC_BINS)ecs$(HOST_E))$(if $(CROSS_TARGET), -t $(TARGET_PLATFORM),)$(if $(OUTPUT_POT), -outputpot,)
export EAR := $(call psep,$(_CF_DIR)obj/$(HOST_PLATFORM)$(COMPILER_SUFFIX)$(DEBUG_SUFFIX)/bin/ear$(HOST_E))
export ECP := $(call sys_path,$(EC_BINS)ecp$(HOST_E))
export ECC := $(call sys_path,$(EC_BINS)ecc$(HOST_E))$(if $(CROSS_TARGET), -t $(TARGET_PLATFORM),)
export ECS := $(call sys_path,$(EC_BINS)ecs$(HOST_E))$(if $(CROSS_TARGET), -t $(TARGET_PLATFORM),)$(if $(OUTPUT_POT), -outputpot,)
export EAR := $(call sys_path,$(_CF_DIR)obj/$(HOST_PLATFORM)$(COMPILER_SUFFIX)$(DEBUG_SUFFIX)/bin/ear$(HOST_E))
ifdef WINDOWS_TARGET
WINDRES := $(GCC_PREFIX)windres
ifdef ARCH
Expand Down
4 changes: 2 additions & 2 deletions ear/extract/Makefile
Expand Up @@ -198,10 +198,10 @@ ifndef NOSTRIP
endif
ifndef WINDOWS_TARGET
ifdef EXECUTABLE_TARGET
@-$(call psep,$(UPX) $(UPXFLAGS) $(TARGET)) || $(call echo,upx not installed; not compressing.)
@-$(call sys_path,$(UPX) $(UPXFLAGS) $(TARGET)) || $(call echo,upx not installed; not compressing.)
endif
else
@-$(call psep,$(UPX) $(UPXFLAGS) $(TARGET)) || $(call echo,upx not installed; not compressing.)
@-$(call sys_path,$(UPX) $(UPXFLAGS) $(TARGET)) || $(call echo,upx not installed; not compressing.)
endif
$(EAR) aw$(EARFLAGS) $(TARGET) ../../ecere/res/vanilla/ecere/actions/folderNew.png ../../ecere/res/vanilla/ecere/actions/goUp.png "ecere/actions"
$(EAR) aw$(EARFLAGS) $(TARGET) ../../ecere/res/vanilla/ecere/devices/computer.png ../../ecere/res/vanilla/ecere/devices/driveHardDisk.png ../../ecere/res/vanilla/ecere/devices/driveRemovableMedia.png ../../ecere/res/vanilla/ecere/devices/mediaFloppy.png ../../ecere/res/vanilla/ecere/devices/mediaOptical.png "ecere/devices"
Expand Down
2 changes: 1 addition & 1 deletion ecere/Makefile
Expand Up @@ -38,7 +38,7 @@ include $(_CF_DIR)crossplatform.mk
include $(_CF_DIR)default.cf

ifdef PREFIXLIBDIR
CFLAGS += -DDEB_HOST_MULTIARCH=\"$(PREFIXLIBDIR)\"
CFLAGS += -DDEB_HOST_MULTIARCH=\"$(call escspace,$(PREFIXLIBDIR))\"
endif

# POST-INCLUDES VARIABLES
Expand Down
2 changes: 1 addition & 1 deletion ecere/Makefile.ecereCOM
Expand Up @@ -38,7 +38,7 @@ include $(_CF_DIR)crossplatform.mk
include $(_CF_DIR)default.cf

ifdef PREFIXLIBDIR
CFLAGS += -DDEB_HOST_MULTIARCH=\"$(PREFIXLIBDIR)\"
CFLAGS += -DDEB_HOST_MULTIARCH=\"$(call escspace,$(PREFIXLIBDIR))\"
endif

# POST-INCLUDES VARIABLES
Expand Down
2 changes: 1 addition & 1 deletion ecere/Makefile.vanilla
Expand Up @@ -38,7 +38,7 @@ include $(_CF_DIR)crossplatform.mk
include $(_CF_DIR)default.cf

ifdef PREFIXLIBDIR
CFLAGS += -DDEB_HOST_MULTIARCH=\"$(PREFIXLIBDIR)\"
CFLAGS += -DDEB_HOST_MULTIARCH=\"$(call escspace,$(PREFIXLIBDIR))\"
endif

# POST-INCLUDES VARIABLES
Expand Down

0 comments on commit 5a5cf3b

Please sign in to comment.