Closed Bug 75853 Opened 24 years ago Closed 24 years ago

CR and LF are naked ifdefs

Categories

(SeaMonkey :: Build Config, defect)

defect
Not set
blocker

Tracking

(Not tracked)

VERIFIED FIXED
mozilla0.9

People

(Reporter: mikepinkerton, Assigned: timeless)

References

Details

(Keywords: verifyme)

Attachments

(5 files)

in nsCRT.h, |CR| and |LF| are naked ifdefs. this means that no one is allowed to have members, fields, or variable names called these. Normally, this wouldn't be a problem, but there are structs in mac headers in OSX that use CR (it's a powerPC register name). As a result, this blocks OSX work. so off i go to make a nice patch to change every occurrance in the tree. just try and stop me.
Target Milestone: --- → mozilla0.9
anyone have a good perl script to do this? ;)
Target Milestone: mozilla0.9 → ---
RCS file: /cvsroot/mozilla/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc_aix.s,v retrieving revision 1.3 diff -u -0 -r1.3 xptcinvoke_asm_ppc_aix.s --- xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc_aix.s 2000/01/19 01:19:26 1.3 +++ xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc_aix.s 2001/04/13 06:09:01 @@ -39 +39 @@ -.set CR0_EQ,2 +.set NS_CR0_EQ,2 Slightly overzealous? Try flat wrong. Use a keyword grep (grep -w, \b on each side in a perl regexp, \< and \> in vi/ex, etc.). /be
Why are we using another ifdef here? Aren't we just begging to have to do this dance again when some _other_ loserly platform gets broken? Let's do nsCRT::CR and nsCRT::LF.
ok, so we want nsCRT::LF, nsCRT::CR ? that should be easy to do (i'll just modify the current patch and add the stuff to nsCRT)
Assignee: pinkerton → timeless
Isn't the problem with nsCRT::LF cases where someone has done this: const char* myTwoLineString = "line one" CR "line two" Not sure if that case exists in reality, or if it does, whether we should fix the usage rather than accomodate it.
nsCRT::CR will have to be an enum, right?
yes, waterson's comment is the unfortunate answer to shaver's question. However the lines remaining in my patch don't indicate that usage. I think that internationalization pretty much forced all real display strings out of c++ files so the only uses left should be in parsing. i have a tree that uses the class version, however, i'm having problems getting a non patched build to run so if someone else could help me test the patch, that'd be good.
Status: NEW → ASSIGNED
New patch coming up? /be
Blocks: 75653
ok. simon suggested a namespace enum, and i decided to try that approach. This patch is currently building on my system, but it did result in a few minor changes because of overloaded functions (foo(int a) foo(char a)). i'm going to attach a diff -u0 patch because my changes do not affect code flow. The enum supports more than just the two chars currently in question, but in order to do this I ellected to move all of the defines to the end of the code. the char defines should be killed by me later when I search for and convert any uses. the string defines can live either at the top or bottom, i'll let reviewers, module owners, or file owners dictate.
Attached patch namespace patchSplinter Review
This won't work: +namespace NSCRT { + enum { + TAB='\011' /* \t Horizontal Tab */, + LF /* \n Line Feed */, + VTAB /* Vertical Tab */, + FF /* Form Feed */, + CR /* \r Carriage Return */ + }; +} You have to assign each with the correct value. And why not just put the enum inside nsCRT, rather than making the ugly NSCRT?
sorry, the compilers i'm used to (borland, and aparently microsoft) have the following behavior (quoting) Syntax enum [<type_tag>] {<constant_name> [= <value>], ...} [var_list]; <value> must be an integer. If <value> is missing, it is assumed to be: <prev> + 1 where <prev> is the value of the previous integer constant in the list. For the first integer constant in the list, the default value is 0. You said namespace, perhaps i misinterpretted, i can and will move into nsCRT. are there any more Comments about my interpretation of enum?
Never mind, I missed that the order of items in the enum makes them consecutive. Even though they are, however, I'd recommend that you assign them explicitly, so we can see what the individual values are without counting. As an side, why do people always use Octal for these things? Why not hex? Who thinks in octal these days?
i would prefer the constants being explicit.
Don't use namespaces (see http://www.mozilla.org/hacking/portable-cpp.html#dont_use_namespace). Do give each enumerator an explicit value. Anything else for (small or not) enums whose enumerators are not obviously, necessarily dense, is poor style. /be
Given all the files you have to touch, why not do away with constants and use the manifest '\r', '\n', etc. fine backslash-escaped character constants? They are part of C and C++, have been forever. /be
@@ -99,0 +88,7 @@ + enum { + TAB='\t' /* Horizontal Tab */, + LF='\n' /* Line Feed */, + VTAB='\v' /* Vertical Tab */, + FF='\f' /* Form Feed */, + CR='\r' /* Carriage Return */ + }; iirc, there are sometimes compiler settings that case \r and \n to be reversed (e.g. MPW newline mode in CodeWarrior), but we need to guarantee that these enums are always the correct values. So I'd change this enum to use 0x09...0x0D.
sfraser: do we use MPW newline mode in CW? I ask because the JS engine, which has been widely ported, uses '\r' and '\n' to mean what they say. /be
No, we don't use MPW newline mode in general. However, if someone was building parts of mozilla as MPW tools (maybe xpidl, xptlink, JS?) then they would have to turn this option on. I'm not sure how much of an issue this is.
yeah as i was away from my computer i realized that just using \r \n seemed to make more sense. Pinkerton: you filed this bug, would converting everything inline to use \n form be ok w/ you? would using some numberical \ form be ok for the things which might be compiled as MPW tools? i'm told the attached patch isn't applying correctly, so i'll work on another one in an hour
ok, if anyone wants to build MPW all they'd need to do is make a new nsCRT.h file or add an ifdef to it to handle that special case. It's not really my problem, however if someone is concerned they can feel free to file a new bug on me to support that (requires detailed documentation about what it means etc). This patch is ready for review, approval and hopefully checkin.
Target Milestone: --- → mozilla0.9
prefer |char(nsCRT::LF)| over |(char)nsCRT::LF|, etc. After you fix that, sr=scc.
r=dveditz
fix checked in. someone will have to clean up the commercial side perl -p -e 's/\bCR\b/nsCRT::CR/g;s/\bLF\b/nsCRT::LF/g' <filelist> and [requires a bit more baby sitting]: perl -p -e ' s/(Append.*)nsCRT::CR/$1char(nsCRT::CR)/g s/(Append.*)nsCRT::LF/$1char(nsCRT::LF)/g ' <filelist>
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
i could care less how we fix it, just get CR out of the global namespace.
has anyone filed a bug yet to do this to the ns tree?
No one complained about problems in the NS tree. I think there might be one or two places in comm w/ their own definitions, but i don't know if they spill into global land. pinkerton: verifyme.
verified. have any Netsape engineers checked the ns tree for this yet?
Status: RESOLVED → VERIFIED
Product: Browser → Seamonkey
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: