Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!decwrl!pa.dec.com!shlump.nac.dec.com!tkou02.enet.dec.com!jit533!diamond From: diamond@jit533.swstokyo.dec.com (Norman Diamond) Newsgroups: comp.std.c Subject: Re: stringizing Message-ID: <1991Apr26.045057.20487@tkou02.enet.dec.com> Date: 26 Apr 91 04:50:57 GMT References: <14888@darkstar.ucsc.edu> <1991Apr23.075527.19443@tkou02.enet.dec.com> <9565@cognos.UUCP> Sender: usenet@tkou02.enet.dec.com (USENET News System) Reply-To: diamond@jit533.enet@tkou02.enet.dec.com (Norman Diamond) Organization: Digital Equipment Corporation Japan , Tokyo Lines: 47 In article <9565@cognos.UUCP> jimp@cognos.UUCP (Jim Patterson) writes: >In article <1991Apr23.075527.19443@tkou02.enet.dec.com> diamond@jit345.enet@tkou02.enet.dec.com (Norman Diamond) writes: >>In article <14888@darkstar.ucsc.edu> daniel@terra.ucsc.edu (Daniel Edelson) writes: >>> #define str(x) #x >>> printf("%s\n", str( hello\t\n\vworld\n\n)); >>>Is the output from this program supposed to be: >>> hello world >> Whether each nonempty sequence of white-space characters other than newline >> is retained or replaced by one space character is implementation-defined. >> hello\t\n\vworld\n\n\n >>or >> hello \n world\n\n\n >You seem to be assuming that \t \v etc are whitespace characters. They >aren't; they are escape sequences. I guess you're right. When reading Mr. Edelson's question, I read the \t and \v and \n as the actual characters instead of the escape sequences. For some reason, I didn't make this mistake on the \n in the format string. However, this was not my only mistake. >The point at which escape characters are converted to characters is >clearly defined by the standard section 2.1.1.2 Translation Phases. >During step 4 ... the str(...) macro should be expanded. \t and \v should >still be escape sequences at this point because in step 5 Yes. >Note that \t \v etc are NOT translated except in character and string >constants. Their appearance in other contexts is not valid (though I >think the above example is valid). Yes. >My interpretation is that the entire string within the str() with >the exception of the leading white space is string-ized. That is, >the result of str( hello\t\n\vworld\n\n) is "hello\t\n\vworld\n\n". > >(Section 3.8.3.2 explains the string-ize function and it clearly >states that leading and trailing whitespace is deleted while internal >whitespace sequences are replaced by single spaces). Sorry, I hadn't read that section of the manual for a while. (In OO terminology, my mouth now "has-a" foot, though not "is-a" foot. :-) -- Norman Diamond diamond@tkov50.enet.dec.com If this were the company's opinion, I wouldn't be allowed to post it.