From b5757d961ccb1710c6e7eb9e0b8be73e83b279f9 Mon Sep 17 00:00:00 2001 From: "sspitzer%netscape.com" Date: Fri, 24 Jan 2003 21:47:53 +0000 Subject: [PATCH] fix for #190215. multi-line properties in string bundles don't work on win32. this isn't a blocker, but it's bad enough to take for the respin. patch by alecf. r/sr=sspitzer, a=kyle --- .../locale/en-US/messenger.properties | 6 ++-- xpcom/ds/nsPersistentProperties.cpp | 28 +++++++++++++++---- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/mailnews/base/resources/locale/en-US/messenger.properties b/mailnews/base/resources/locale/en-US/messenger.properties index 94fd7695b63..d2b663ab990 100644 --- a/mailnews/base/resources/locale/en-US/messenger.properties +++ b/mailnews/base/resources/locale/en-US/messenger.properties @@ -224,8 +224,7 @@ mailnews.search_date_format=0 mailnews.search_date_separator= # offline msg - -nocachedbodybody =The body of this message has not been downloaded from \ +nocachedbodybody=The body of this message has not been downloaded from \ the server for reading offline. To read this message, \ you must reconnect to the network, choose Offline from \ the File menu and then select Work Online.\ @@ -241,10 +240,9 @@ mailAcctType=Mail newsAcctType=News # LOCALIZATION NOTES(nocachedbodytitle): Do not translate "" or "" in the line below -nocachedbodytitle=Go Online to View This Message\n\ +nocachedbodytitle=Go Online to View This Message\n # mailWindowOverlay.js - confirmUnsubscribeTitle=Confirm Unsubscribe confirmUnsubscribeText=Are you sure you want to unsubscribe from %S? cannotHaveTwoFilterRulesDialogs=Filter Rules Dialog diff --git a/xpcom/ds/nsPersistentProperties.cpp b/xpcom/ds/nsPersistentProperties.cpp index 55d35606d11..edd7ea6b067 100644 --- a/xpcom/ds/nsPersistentProperties.cpp +++ b/xpcom/ds/nsPersistentProperties.cpp @@ -141,7 +141,8 @@ class nsParserState { public: nsParserState(nsIPersistentProperties* aProps) : - mState(eParserState_AwaitingKey), mProps(aProps) {} + mState(eParserState_AwaitingKey), mHaveMultiLine(PR_FALSE), + mProps(aProps) {} void WaitForKey() { mState = eParserState_AwaitingKey; @@ -183,8 +184,9 @@ public: // if we see a '\' then we enter this special state PRUint32 mSpecialState; - PRUint32 mUnicodeValuesRead; // should be 4! - PRUnichar mUnicodeValue; + PRUint32 mUnicodeValuesRead; // should be 4! + PRUnichar mUnicodeValue; // currently parsed unicode value + PRBool mHaveMultiLine; // if this key is multi-line private: PRUint32 mState; @@ -263,19 +265,34 @@ ParseValueCharacter(nsParserState& aState, PRUnichar c, case eParserSpecial_None: switch (c) { case '\\': + // handle multilines - since this is the beginning of a line, + // there's no value to append + if (aState.mHaveMultiLine) + aState.mHaveMultiLine = PR_FALSE; + else + aState.mValue += Substring(tokenStart, cur); + aState.mSpecialState = eParserSpecial_Escaped; - aState.mValue += Substring(tokenStart, cur); break; case '\n': case '\r': + // ignore sequential line endings + if (aState.mHaveMultiLine) + break; + // we're done! We have a key and value aState.mValue += Substring(tokenStart, cur); aState.FinishValueState(oldValue); break; default: - // there is nothing to do with normal characters + // there is nothing to do with normal characters, + // but handle multilines correctly + if (aState.mHaveMultiLine) { + aState.mHaveMultiLine = PR_FALSE; + tokenStart = cur; + } break; } break; @@ -314,6 +331,7 @@ ParseValueCharacter(nsParserState& aState, PRUnichar c, // a \ immediately followed by a newline means we're going multiline case '\r': case '\n': + aState.mHaveMultiLine = PR_TRUE; aState.mSpecialState = eParserSpecial_None; break;