Go Back   ZeroC Forums > Bug Reports

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 10-21-2007
kwaclaw kwaclaw is offline
Registered User
 
Name: Karl Waclawek
Organization: Toronto Star Newspapers Ltd.
Project: Proof of concept
 
Join Date: Sep 2004
Location: Oshawa, Canada
Posts: 136
slice2cs commandline parsing issue

It seems that on Windows, slice2cs has issues parsing file paths that have spaces *and* back-slashes in them. For example, this command line gives me the error "input files must end with '.ice':

"%ICE_HOME%\bin\slice2cs.exe" -I"C:\Documents and Settings\Karl\Desktop\Java Web Services\IS2ICE\" -I%ICE_HOME%\slice --output-dir "C:\Documents and Settings\Karl\Desktop\Java Web Services\IS2ICE\StateServer\generated" "C:\Documents and Settings\Karl\Desktop\Java Web Services\IS2ICE\Services.ice" "C:\Documents and Settings\Karl\Desktop\Java Web Services\IS2ICE\StorageServices.ice"

However, if I replace all back-slashes with forward-slashes, the error goes away. It looks as if with back-slashes the spaces are interpreted as command line delimiters (even though the paths are enclosed in quotes).

The issue seems limited to the -I parameter, as the error also goes away if the include directories in the command line above don't contain spaces.

This is especially a problem when I am running this as a build event under VS 2005 because the paths are build macros that are not under my control.

Karl
__________________
Karl Waclawek
The Toronto Star - http://www.thestar.com

Last edited by kwaclaw : 10-21-2007 at 12:53 AM. Reason: Added more information.
Reply With Quote
  #2 (permalink)  
Old 10-21-2007
michi's Avatar
michi michi is offline
ZeroC Staff
 
Name: Michi Henning
Organization: ZeroC
Project: Ice
 
Join Date: Feb 2003
Location: Brisbane, Australia
Posts: 909
Hi Karl,

slice2cs (and all the other command-line tools) apply the exact same quoting and escaping rules as bash. When you have something like

-I"C:\Documents and Settings\Karl\Desktop\Java Web Services\IS2ICE\"

bash quoting rules say that, within double quotes, only backslash retains its special meaning, that is, within double quotes, \" is an escaped double quote (so it doesn't close the string and you end up with a double quote), \\ is a single literal backslash, and \<newline> is an literal newline.

Bash does not specify what happens if, within double quotes, a backslash is followed by any other character. However, what every implementation of bash I tried does (and what Ice does) is to preserve both the backslash and the character following it so, for example, \D is preserved literally and results in \D in the output string.

I suspect that, in your example, the problem is caused by the quote following the include path:

-I"C:\Documents and Settings\Karl\Desktop\Java Web Services\IS2ICE\" -I%ICE_HOME%\slice --output-dir "C:\Documents and Settings\Karl\Desktop\Java Web Services\IS2ICE\StateServer\generated"

Here, we have \" at the end of the first -I option. What that will do is result in a literal double quote (without the backslash) in the output string, so the above turns into:

-IC:\Documents and Settings\Karl\Desktop\Java Web Services\IS2ICE" -I%ICE_HOME%\slice --output-dir (with a trailing space)

C:\Documents

and

Settings\Karl\Desktop\Java Web Services\IS2ICE\StateServer\generated

I have placed each string onto a separate line to show how the option parser will break up these strings into the separate elements of argv.

Of course, that explains the complaint from the compiler because any string that doesn't start with - or -- is taken not to be a command-line option, but a file argument, so the compiler ends up looking for source files such as and and C:\Documents. The compiler then complains that these file names do not end in .ice and, hence, are not legal input file names.

When you replace the backslashes with forward slashes, the problem goes away because this prevents the double quote at the end of IS2ICE\" from being taken literally, and the entire string parses and is split into command-line arguments correctly.

I'm not entirely sure what we can do to help with this. The problems with the different path separators and quoting rules in Windows and Unix are an endless source of grief, and I suspect that there is no one true way that would solve this problem completely.

One way around your problem would be to replace the double quotes with single quotes. Within single quotes, double quotes (and everything else, except for a single quote) are taken literally, so that would prevent the closing double quote from causing the problem. Is this a possible option for you?

Cheers,

Michi.
Reply With Quote
  #3 (permalink)  
Old 10-22-2007
kwaclaw kwaclaw is offline
Registered User
 
Name: Karl Waclawek
Organization: Toronto Star Newspapers Ltd.
Project: Proof of concept
 
Join Date: Sep 2004
Location: Oshawa, Canada
Posts: 136
Quote:
Originally Posted by michi View Post
Hi Karl,

One way around your problem would be to replace the double quotes with single quotes. Within single quotes, double quotes (and everything else, except for a single quote) are taken literally, so that would prevent the closing double quote from causing the problem. Is this a possible option for you?

Cheers,

Michi.
Hi Michi,

I tried the single quotes, but it seems slice2cs does not honor the include directory then. I tried this on my work PC, where i did not have spaces in my path, but it still didn't work, specifically:

The expanded (from VS macro) include path would be C:\Data\PBS\IS2ICE\, so -IC:\Data\PBS\IS2ICE\ works, but with -I'C:\Data\PBS\IS2ICE\' slice2cs does not find the included files.

However, I found an ugly looking way that seems to work: I keep using double quotes, but before the closing double quote I append another back-slash, so the expanded path would end with \\", which will turn into \" when slice2cs parses the command line. Maybe this (or another, better) solution should be added to the docs for the benefit of Windows users.

Karl
__________________
Karl Waclawek
The Toronto Star - http://www.thestar.com
Reply With Quote
  #4 (permalink)  
Old 10-22-2007
michi's Avatar
michi michi is offline
ZeroC Staff
 
Name: Michi Henning
Organization: ZeroC
Project: Ice
 
Join Date: Feb 2003
Location: Brisbane, Australia
Posts: 909
Hi Karl,

Quote:
I tried the single quotes, but it seems slice2cs does not honor the include directory then.
Hmmm... Not sure what's going on there. Thanks for letting me know, I'll have a look today.

Quote:
However, I found an ugly looking way that seems to work: I keep using double quotes, but before the closing double quote I append another back-slash, so the expanded path would end with \\", which will turn into \" when slice2cs parses the command line.
Yes, that will work. The two backslashes turn into a single literal backslash, and the double quote the retains its meaning as a string delimiter.

Quote:
Maybe this (or another, better) solution should be added to the docs for the benefit of Windows users.
Thanks, I'll have a look at what we can do to improve things there.

Cheers,

Michi.

Last edited by michi : 10-23-2007 at 01:37 AM.
Reply With Quote
  #5 (permalink)  
Old 10-23-2007
michi's Avatar
michi michi is offline
ZeroC Staff
 
Name: Michi Henning
Organization: ZeroC
Project: Ice
 
Join Date: Feb 2003
Location: Brisbane, Australia
Posts: 909
Quote:
Originally Posted by kwaclaw View Post
The expanded (from VS macro) include path would be C:\Data\PBS\IS2ICE\, so -IC:\Data\PBS\IS2ICE\ works, but with -I'C:\Data\PBS\IS2ICE\' slice2cs does not find the included files.
Ah, sorry, this suffers essentially the same problem:

-I'C:\Data\PBS\IS2ICE\'

The problem here is the \' at the end, which escapes the single quote and produces a literal single quote in the output string.

Basically, to make things work, you have to either avoid a backslash immediately preceding a single or double quote, or replace the backslash preceding a single or double quote with a double backslash, as you mentioned in your earlier post.

Cheers,

Michi.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Python Ice Parsing: Bug or User Error? jae Help Center 3 04-02-2007 10:36 PM
slice2cs - no output kwaclaw Help Center 8 06-24-2005 07:52 PM
Possible bug in slice2cs version 1.5 wodi Bug Reports 3 07-27-2004 11:06 PM
Patch for slice2cs, release 1.5.0 michi Patches 0 07-27-2004 11:03 PM
error in doc for parsing of --Command.Line properties (14.8.3) shaver Bug Reports 1 11-30-2003 01:02 PM


All times are GMT -4. The time now is 07:39 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.