Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Command line generator: quotes

Hi,

I am writing a tool on windows, which needs to use quotes for some of
its options (-I , --dlib_config). I wrote and
IManagedCommandLineGenerator implementation, and when I see a flag
that needs to be quoted, I process it and give it to the
ManagedCommandLineInfo. This is only needed for some flags which can
have directories with spaces in it on windows.

This is the function that iterates flags and quotes them, at the
beginning of generateCommandLineInfo
//Quote flags that need to be quoted
	for(int i=0;i<flags.length;i++){
			flags[i] = convertFlag(flags[i]);
	}

private String convertFlag(String flag){
		if(flag.startsWith(DLIB_CONFIG)){
			flag = flag.substring(DLIB_CONFIG.length()+1,flag.length() - 1);
			flag = DLIB_CONFIG +" \"" + flag + "\"";
			return flag;
		}else if(flag.startsWith(INCLUDE)){
				flag = flag.substring(INCLUDE.length()+1,flag.length() -1);
				return INCLUDE +" \"" + flag + "\"";
		}else{
			return flag;
		}
}

When I call return new ManagedCommandLineInfo at the end of
generateCommandLineInfo, I confirm that these flags are quoted as they
should be. When I look at the build output, I see that these flags are
still not quoted and directories with spaces give problems. Does
anyone know if this is the correctt way to quote some flags?

Regards,
Leen Toelen


Back to the top