Closed Bug 103495 Opened 24 years ago Closed 14 years ago

xpidl does not allow a space beteen # and include in XPCOM IDL

Categories

(Core :: XPCOM, defect, P5)

Sun
Solaris
defect

Tracking

()

RESOLVED INCOMPLETE
mozilla1.7alpha

People

(Reporter: mike72, Assigned: dbradley)

Details

Attachments

(2 files, 2 obsolete files)

IDL below not compile with diagnostics: bug.idl:1: `nsISupports' undeclared identifier # include "nsISupports.idl" [uuid(BA419180-388C-11d3-A5B3-00C04F8EEB79)] interface nsIFoo : nsISupports {}; If I remove the space between # and include, it works fine.
FWIW... if it were up to me I'd mark this as WONTFIX and suggest to people that they might not want to leave any spaces between the '#' and the 'include'.
mike72: Is the tool's intolerance of those spaces a hardship for you? or just a surprise?
It does not create hardship, that's why I filed it as "minor". But it does not let me write how I usually write, and it's surprising to see a construct that looks so similar to familiar C preprocessor but still has a subtle difference in syntax (I know there is no preprocessor in XPCOM IDL). I am not writing part of Mozilla code so I don't think I should be forced to follow Mozilla-specific cosmetic guidelines. Also the diagnostics is confusing: it complains well past the place that made it not well formed XPCOM IDL, i.e. the space after #. One has to look carefully at the diagnostics to realize that the line number pertains to #include and not to the inheritance spec of one of the interfaces. I spent some time carefully checking the spelling of nsISupports and whether my interface declaration syntax was correct. It's ok if it's not fixed -- it's only a nuisance once you hit it the first time. I just thought it would be easy to fix -- just consider # and include as separate tokens.
Fair enough. I'll certainly leave it up to dbradley to determine where this fits in his view of priorities. Of course, the presence of a debugged patch would likely have an impact on priorities :) This does look easier to fix than I imagined at first since it looks like fixing this would only impact xpidl_idl.c and would apparently not require hacking libIDL (which is outside our codebase). Still, this is somewhat brittle code and there are plenty of other ways that it is unfreindly to 'incorrect' input. Given the plethora of other things worth fixing I'd leave it pretty low on the list if it were up to me. I *do* appreciate that you went to the trouble to report it. Sorry if I came off otherwise.
Confirming for condideration -
Status: UNCONFIRMED → NEW
Ever confirmed: true
Um, "consideration" !
Interesting, I would have bet money this was handled by at least the lexer. The code as it stands today appears to be quite brittle. I suspect adding more than one space between #include and the quote will cause this to wig out as well. This would have been automatically handled had it been parsed within the lexer. I went ahead and cooked up patch. I'll attach it in a bit, once I've confirmed it works under Linux.
Status: NEW → ASSIGNED
Comment on attachment 52557 [details] [diff] [review] Allows spaces between #, include, and the first quote mark Forgot to account for spaces before #
Attachment #52557 - Attachment is obsolete: true
Check the edge cases. I missed about handling spaces before #. I don't think there are any others. Also this allows for #include"file.h", which I think should be allowed as well, but wasn't. Basically this adds logic that would normally have been handled by the lexer, probably not as robust, but good enough.
FWIW, space before the '#' is not supported by some C preprocessors for platforms we support - or used to support - (please don't ask which ones).
I thought I had encountered that long ago in some compiler. I had checked the generated header and the include's are reformatted. The only issue would be if we ever plan on using a C preprocessor to preprocess the IDL files. I know the author of libIDL originally wanted to do this. But access to a C preprocessor wasn't universal across platforms, IIRC. I think Mac is one such platform.
FWIW. I only mentioned that about C preprocessors as a data point to suggest that fixing leading spaces is of lesser importance - since bahavior more like C preprocessors was the stated goal. Looking for a '#' in column zero wouuld be acceptable in my book.
Priority: -- → P4
Target Milestone: --- → mozilla0.9.6
If SkipWhiteSpace() needs to worry about '\n', should it then not also worry about '\r'? Or do we need to care about newlines at all here?
I may have erroneously assumed that the xpidl file was opened as a text file and thus any \r\n would get translated to \n. Other than completeness I don't think there is any reason to check for line endings. And isspace would seem more appropriate. Don't know why I didn't use that in the first place.
Attachment #52567 - Attachment is obsolete: true
Comment on attachment 55906 [details] [diff] [review] Patch with isspace r=jst
Attachment #55906 - Flags: review+
Moving out
Target Milestone: mozilla0.9.6 → mozilla0.9.7
Priority: P4 → P5
Target Milestone: mozilla0.9.7 → mozilla1.1
After further discussion it was decided 1.0.1 makes more sense as a post 1.0 milestone.
Target Milestone: mozilla1.1 → mozilla1.0.1
Retargetting to the proper post 1.0 milestone
Target Milestone: mozilla1.0.1 → mozilla1.2
Moving out to 1.3. If this needs to be in before 1.3 please comment.
Target Milestone: mozilla1.2alpha → mozilla1.3alpha
Moving to 1.4 Alpha
Target Milestone: mozilla1.3alpha → mozilla1.4alpha
Moving out
Target Milestone: mozilla1.4alpha → mozilla1.5alpha
Moving out
Target Milestone: mozilla1.5alpha → mozilla1.6alpha
Moving out
Target Milestone: mozilla1.6alpha → mozilla1.7alpha
Component: xpidl → XPCOM
QA Contact: pschwartau → xpcom
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: