From 1d843feacfb882608367f63e64e6b3237e1237d9 Mon Sep 17 00:00:00 2001 From: "dbaron@fas.harvard.edu" Date: Wed, 7 Nov 2001 06:24:10 +0000 Subject: [PATCH] Ensure that string literals are used as |const char*| rather than |char*|. r=jag sr=brendan b=107052 --- caps/src/nsScriptSecurityManager.cpp | 2 +- content/base/src/nsCommentNode.cpp | 8 ++--- content/build/nsContentDLF.cpp | 12 +++---- content/events/src/nsDOMEvent.cpp | 2 +- .../html/document/src/nsHTMLContentSink.cpp | 4 +-- .../src/nsHTMLFragmentContentSink.cpp | 2 +- content/xbl/src/nsXBLWindowHandler.cpp | 12 +++---- dom/public/base/nsIFocusController.h | 2 +- dom/src/base/nsFocusController.cpp | 2 +- dom/src/base/nsFocusController.h | 2 +- editor/libeditor/html/nsHTMLDataTransfer.cpp | 10 +++--- .../text/nsPlaintextDataTransfer.cpp | 4 +-- embedding/base/nsEmbedAPI.cpp | 2 +- embedding/browser/gtk/src/EmbedPrivate.cpp | 2 +- embedding/browser/gtk/tests/TestGtkEmbed.cpp | 8 ++--- .../webBrowser/nsDocShellTreeOwner.cpp | 2 +- .../src/nsWebBrowserPersist.cpp | 5 +-- .../src/nsWebBrowserPersist.h | 5 +-- extensions/cookie/tests/TestCookie.cpp | 2 +- .../xslt/functions/GenerateIdFunctionCall.cpp | 4 +-- .../source/xslt/functions/XSLTFunctions.h | 2 +- gfx/src/gtk/nsFontMetricsGTK.cpp | 12 ++++--- gfx/src/ps/isotab.c | 2 +- gfx/src/ps/nsAFMObject.h | 20 +++++------ gfx/src/ps/nsPostScriptObj.cpp | 19 +++++----- gfx/src/ps/nsPostScriptObj.h | 18 +++++----- htmlparser/src/COtherDTD.cpp | 2 +- htmlparser/src/nsViewSourceHTML.cpp | 10 +++--- intl/uconv/src/nsCharsetConverterManager.cpp | 20 +++++------ js/src/xpconnect/tests/TestXPC.cpp | 2 +- layout/build/nsContentDLF.cpp | 12 +++---- layout/forms/nsHTMLButtonControlFrame.cpp | 2 +- .../forms/src/nsHTMLButtonControlFrame.cpp | 2 +- modules/oji/src/nsCNullSecurityContext.cpp | 5 ++- modules/plugin/base/src/nsPluginsDirUnix.cpp | 3 +- netwerk/base/src/nsSocketTransportService.cpp | 2 +- netwerk/build/nsNetModule.cpp | 2 +- .../ftp/src/nsFtpConnectionThread.cpp | 2 +- netwerk/protocol/http/src/nsHttpChannel.cpp | 2 +- netwerk/streamconv/test/TestStreamConv.cpp | 2 +- netwerk/test/TestCallbacks.cpp | 4 +-- netwerk/test/TestSocketTransport.cpp | 2 +- parser/htmlparser/src/COtherDTD.cpp | 2 +- parser/htmlparser/src/nsViewSourceHTML.cpp | 10 +++--- profile/pref-migrator/src/nsPrefMigration.cpp | 2 +- profile/pref-migrator/src/nsPrefMigration.h | 2 +- security/manager/ssl/src/nsNSSComponent.cpp | 2 +- webshell/tests/viewer/nsViewerApp.cpp | 4 +-- widget/src/gtk/nsDragService.cpp | 8 ++--- widget/src/gtk/nsGtkIMEHelper.cpp | 2 +- widget/src/gtk/nsGtkIMEHelper.h | 2 +- widget/src/gtk/nsGtkMozRemoteHelper.cpp | 2 +- widget/src/xpwidgets/nsXPLookAndFeel.h | 4 +-- xpcom/ds/nsPersistentProperties.cpp | 2 +- xpcom/io/nsEscape.cpp | 4 +-- xpcom/io/nsFileSpecUnix.cpp | 4 +-- xpcom/io/nsLinebreakConverter.cpp | 2 +- xpcom/reflect/xptinfo/src/xptiMisc.cpp | 2 +- xpcom/tests/TestID.cpp | 4 +-- xpcom/tests/nsIFileTest.cpp | 10 +++--- xpcom/threads/nsEventQueue.cpp | 4 +-- xpfe/bootstrap/nsAppRunner.cpp | 14 ++++---- xpfe/bootstrap/showOSAlert.cpp | 10 +++--- xpfe/components/find/src/nsFindComponent.cpp | 4 +-- xpfe/components/intl/nsCharsetMenu.cpp | 35 ++++++++++--------- .../search/src/nsInternetSearchService.cpp | 4 +-- .../search/src/nsLocalSearchService.h | 2 +- .../urlbarhistory/src/nsUrlbarHistory.cpp | 2 +- .../components/xremote/src/XRemoteService.cpp | 10 +++--- xpinstall/src/nsInstallFolder.cpp | 2 +- 70 files changed, 200 insertions(+), 194 deletions(-) diff --git a/caps/src/nsScriptSecurityManager.cpp b/caps/src/nsScriptSecurityManager.cpp index 4bea5798a6bb..426b38f56245 100644 --- a/caps/src/nsScriptSecurityManager.cpp +++ b/caps/src/nsScriptSecurityManager.cpp @@ -1531,7 +1531,7 @@ nsScriptSecurityManager::IsCapabilityEnabled(const char *capability, #define PROPERTIES_URL "chrome://communicator/locale/security/security.properties" nsresult -Localize(char *genericString, nsString &result) +Localize(const char *genericString, nsString &result) { nsresult ret; diff --git a/content/base/src/nsCommentNode.cpp b/content/base/src/nsCommentNode.cpp index da2d20949db2..045f0ce12a95 100644 --- a/content/base/src/nsCommentNode.cpp +++ b/content/base/src/nsCommentNode.cpp @@ -394,10 +394,10 @@ static void StripCommentDelimiters(nsString& aCommentString) { PRInt32 offset; - static char* kCommentStart = ""; - static char* kCommentAlternateEnd = "--!>"; - static char kMinus = '-'; + static const char kCommentStart[] = ""; + static const char kCommentAlternateEnd[] = "--!>"; + static const char kMinus = '-'; offset = aCommentString.Find(kCommentStart); if (-1 != offset) { diff --git a/content/build/nsContentDLF.cpp b/content/build/nsContentDLF.cpp index 83ce20e0691c..ef7853181b0c 100644 --- a/content/build/nsContentDLF.cpp +++ b/content/build/nsContentDLF.cpp @@ -75,7 +75,7 @@ static NS_DEFINE_IID(kXULDocumentCID, NS_XULDOCUMENT_CID); extern nsresult NS_NewDocumentViewer(nsIDocumentViewer** aResult); -static char* gHTMLTypes[] = { +static const char* const gHTMLTypes[] = { "text/html", "text/plain", "text/css", @@ -89,7 +89,7 @@ static char* gHTMLTypes[] = { 0 }; -static char* gXMLTypes[] = { +static const char* const gXMLTypes[] = { "text/xml", "application/xml", "application/xhtml+xml", @@ -100,7 +100,7 @@ static char* gXMLTypes[] = { }; -static char* gRDFTypes[] = { +static const char* const gRDFTypes[] = { "text/rdf", "application/vnd.mozilla.xul+xml", "mozilla.application/cached-xul", @@ -109,7 +109,7 @@ static char* gRDFTypes[] = { 0 }; -static char* gImageTypes[] = { +static const char* const gImageTypes[] = { "image/gif", "image/jpeg", "image/jpg", @@ -538,12 +538,12 @@ RegisterTypes(nsIComponentManager* aCompMgr, nsIFile* aPath, const char *aLocation, const char *aType, - char** aTypes) + const char* const* aTypes) { nsresult rv = NS_OK; while (*aTypes) { char contractid[500]; - char* contentType = *aTypes++; + const char* contentType = *aTypes++; PR_snprintf(contractid, sizeof(contractid), NS_DOCUMENT_LOADER_FACTORY_CONTRACTID_PREFIX "%s;1?type=%s", aCommand, contentType); diff --git a/content/events/src/nsDOMEvent.cpp b/content/events/src/nsDOMEvent.cpp index 33c762677423..793fac21ed6c 100644 --- a/content/events/src/nsDOMEvent.cpp +++ b/content/events/src/nsDOMEvent.cpp @@ -63,7 +63,7 @@ #include "nsIDOMKeyEvent.h" #include "nsIDOMMutationEvent.h" -static char* mEventNames[] = { +static const char* const mEventNames[] = { "mousedown", "mouseup", "click", "dblclick", "mouseover", "mouseout", "mousemove", "contextmenu", "keydown", "keyup", "keypress", "focus", "blur", "load", "unload", "abort", "error", diff --git a/content/html/document/src/nsHTMLContentSink.cpp b/content/html/document/src/nsHTMLContentSink.cpp index 7daf9e4d9d32..19e954f02123 100644 --- a/content/html/document/src/nsHTMLContentSink.cpp +++ b/content/html/document/src/nsHTMLContentSink.cpp @@ -4658,8 +4658,8 @@ HTMLContentSink::ProcessHTTPHeaders(nsIChannel* aChannel) { if(aChannel) { nsCOMPtr httpchannel(do_QueryInterface(aChannel)); if (httpchannel) { - char* headers[]={"link","default-style","content-base",0}; // add more http headers if you need - char** name=headers; + const char *const headers[]={"link","default-style","content-base",0}; // add more http headers if you need + const char *const *name=headers; nsXPIDLCString tmp; while(*name) { diff --git a/content/html/document/src/nsHTMLFragmentContentSink.cpp b/content/html/document/src/nsHTMLFragmentContentSink.cpp index f64c70f73b70..c979eef832f8 100644 --- a/content/html/document/src/nsHTMLFragmentContentSink.cpp +++ b/content/html/document/src/nsHTMLFragmentContentSink.cpp @@ -481,7 +481,7 @@ nsHTMLFragmentContentSink::AddBaseTagInfo(nsIHTMLContent* aContent) } } -static char* kSentinelStr = "endnote"; +static const char kSentinelStr[] = "endnote"; NS_IMETHODIMP nsHTMLFragmentContentSink::OpenContainer(const nsIParserNode& aNode) diff --git a/content/xbl/src/nsXBLWindowHandler.cpp b/content/xbl/src/nsXBLWindowHandler.cpp index a6aeb8b87aee..dd30adc783b2 100644 --- a/content/xbl/src/nsXBLWindowHandler.cpp +++ b/content/xbl/src/nsXBLWindowHandler.cpp @@ -78,9 +78,9 @@ public: nsCString mPlatformHTMLBindingStr; nsCString mUserHTMLBindingStr; - static char* sHTMLBindingStr; - static char* sPlatformHTMLBindingStr; - static char* sUserHTMLBindingStr; + static const char sHTMLBindingStr[]; + static const char sPlatformHTMLBindingStr[]; + static const char sUserHTMLBindingStr[]; PRBool mInitialized; @@ -97,11 +97,11 @@ public: nsXBLSpecialDocInfo() : mInitialized(PR_FALSE) {}; }; -char* nsXBLSpecialDocInfo::sHTMLBindingStr = "resource:///res/builtin/htmlBindings.xml"; -char* nsXBLSpecialDocInfo::sPlatformHTMLBindingStr = "resource:///res/builtin/platformHTMLBindings.xml"; +const char nsXBLSpecialDocInfo::sHTMLBindingStr[] = "resource:///res/builtin/htmlBindings.xml"; +const char nsXBLSpecialDocInfo::sPlatformHTMLBindingStr[] = "resource:///res/builtin/platformHTMLBindings.xml"; // Allow for a userHTMLBindings.xml. // XXX Should be in the user profile directory, when we have a urlspec for that -char* nsXBLSpecialDocInfo::sUserHTMLBindingStr = "resource:///res/builtin/userHTMLBindings.xml"; +const char nsXBLSpecialDocInfo::sUserHTMLBindingStr[] = "resource:///res/builtin/userHTMLBindings.xml"; void nsXBLSpecialDocInfo::LoadDocInfo() { diff --git a/dom/public/base/nsIFocusController.h b/dom/public/base/nsIFocusController.h index d024c737a69c..847c77179857 100644 --- a/dom/public/base/nsIFocusController.h +++ b/dom/public/base/nsIFocusController.h @@ -47,7 +47,7 @@ public: NS_IMETHOD SetFocusedWindow(nsIDOMWindowInternal* aResult)=0; NS_IMETHOD GetSuppressFocus(PRBool* aSuppressFlag)=0; - NS_IMETHOD SetSuppressFocus(PRBool aSuppressFlag, char* aReason)=0; + NS_IMETHOD SetSuppressFocus(PRBool aSuppressFlag, const char* aReason)=0; NS_IMETHOD GetSuppressFocusScroll(PRBool* aSuppressFlag)=0; NS_IMETHOD SetSuppressFocusScroll(PRBool aSuppressFlag)=0; diff --git a/dom/src/base/nsFocusController.cpp b/dom/src/base/nsFocusController.cpp index 99f5b22710eb..e9c7290aa0b5 100644 --- a/dom/src/base/nsFocusController.cpp +++ b/dom/src/base/nsFocusController.cpp @@ -410,7 +410,7 @@ nsFocusController::GetSuppressFocus(PRBool* aSuppressFocus) } NS_IMETHODIMP -nsFocusController::SetSuppressFocus(PRBool aSuppressFocus, char* aReason) +nsFocusController::SetSuppressFocus(PRBool aSuppressFocus, const char* aReason) { if(aSuppressFocus) { ++mSuppressFocus; diff --git a/dom/src/base/nsFocusController.h b/dom/src/base/nsFocusController.h index 9d607ffa72b7..de76e93ae7de 100644 --- a/dom/src/base/nsFocusController.h +++ b/dom/src/base/nsFocusController.h @@ -57,7 +57,7 @@ public: NS_IMETHOD SetFocusedWindow(nsIDOMWindowInternal* aResult); NS_IMETHOD GetSuppressFocus(PRBool* aSuppressFlag); - NS_IMETHOD SetSuppressFocus(PRBool aSuppressFlag, char* aReason); + NS_IMETHOD SetSuppressFocus(PRBool aSuppressFlag, const char* aReason); NS_IMETHOD GetSuppressFocusScroll(PRBool* aSuppressFlag); NS_IMETHOD SetSuppressFocusScroll(PRBool aSuppressFlag); diff --git a/editor/libeditor/html/nsHTMLDataTransfer.cpp b/editor/libeditor/html/nsHTMLDataTransfer.cpp index ebb19475cdf0..7a83903d2a38 100644 --- a/editor/libeditor/html/nsHTMLDataTransfer.cpp +++ b/editor/libeditor/html/nsHTMLDataTransfer.cpp @@ -1303,8 +1303,8 @@ NS_IMETHODIMP nsHTMLEditor::CanPaste(PRInt32 aSelectionType, PRBool *aCanPaste) if (NS_FAILED(rv)) return rv; // the flavors that we can deal with - char* textEditorFlavors[] = { kUnicodeMime, nsnull }; - char* htmlEditorFlavors[] = { kJPEGImageMime, kHTMLMime, nsnull }; + const char* const textEditorFlavors[] = { kUnicodeMime, nsnull }; + const char* const htmlEditorFlavors[] = { kJPEGImageMime, kHTMLMime, nsnull }; nsCOMPtr flavorsList; rv = nsComponentManager::CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, nsnull, @@ -1315,7 +1315,7 @@ NS_IMETHODIMP nsHTMLEditor::CanPaste(PRInt32 aSelectionType, PRBool *aCanPaste) GetFlags(&editorFlags); // add the flavors for all editors - for (char** flavor = textEditorFlavors; *flavor; flavor++) + for (const char* const* flavor = textEditorFlavors; *flavor; flavor++) { nsCOMPtr flavorString; nsComponentManager::CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, nsnull, @@ -1330,7 +1330,9 @@ NS_IMETHODIMP nsHTMLEditor::CanPaste(PRInt32 aSelectionType, PRBool *aCanPaste) // add the HTML-editor only flavors if ((editorFlags & eEditorPlaintextMask) == 0) { - for (char** htmlFlavor = htmlEditorFlavors; *htmlFlavor; htmlFlavor++) + for (const char* const* htmlFlavor = htmlEditorFlavors; + *htmlFlavor; + htmlFlavor++) { nsCOMPtr flavorString; nsComponentManager::CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, nsnull, diff --git a/editor/libeditor/text/nsPlaintextDataTransfer.cpp b/editor/libeditor/text/nsPlaintextDataTransfer.cpp index 0df4d52c19ad..5b285362e2ea 100644 --- a/editor/libeditor/text/nsPlaintextDataTransfer.cpp +++ b/editor/libeditor/text/nsPlaintextDataTransfer.cpp @@ -584,7 +584,7 @@ NS_IMETHODIMP nsPlaintextEditor::CanPaste(PRInt32 aSelectionType, PRBool *aCanPa if (NS_FAILED(rv)) return rv; // the flavors that we can deal with - char* textEditorFlavors[] = { kUnicodeMime, nsnull }; + const char* const textEditorFlavors[] = { kUnicodeMime, nsnull }; nsCOMPtr flavorsList; rv = nsComponentManager::CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, nsnull, @@ -595,7 +595,7 @@ NS_IMETHODIMP nsPlaintextEditor::CanPaste(PRInt32 aSelectionType, PRBool *aCanPa GetFlags(&editorFlags); // add the flavors for text editors - for (char** flavor = textEditorFlavors; *flavor; flavor++) + for (const char* const* flavor = textEditorFlavors; *flavor; flavor++) { nsCOMPtr flavorString; nsComponentManager::CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, nsnull, diff --git a/embedding/base/nsEmbedAPI.cpp b/embedding/base/nsEmbedAPI.cpp index 23065fc5c8f6..df1fcafd0c54 100644 --- a/embedding/base/nsEmbedAPI.cpp +++ b/embedding/base/nsEmbedAPI.cpp @@ -134,7 +134,7 @@ nsresult NS_InitEmbedding(nsILocalFile *mozBinDirectory, if (NS_SUCCEEDED(rv)) { nsCOMPtr stringBundle; - char* propertyURL = "chrome://necko/locale/necko.properties"; + const char propertyURL[] = "chrome://necko/locale/necko.properties"; rv = sBundleService->CreateBundle(propertyURL, getter_AddRefs(stringBundle)); } diff --git a/embedding/browser/gtk/src/EmbedPrivate.cpp b/embedding/browser/gtk/src/EmbedPrivate.cpp index 952e893b5d22..f60ea0e4d18a 100644 --- a/embedding/browser/gtk/src/EmbedPrivate.cpp +++ b/embedding/browser/gtk/src/EmbedPrivate.cpp @@ -61,7 +61,7 @@ static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID); -static char *sWatcherContractID = "@mozilla.org/embedcomp/window-watcher;1"; +static const char sWatcherContractID[] = "@mozilla.org/embedcomp/window-watcher;1"; PRUint32 EmbedPrivate::sWidgetCount = 0; char *EmbedPrivate::sCompPath = nsnull; diff --git a/embedding/browser/gtk/tests/TestGtkEmbed.cpp b/embedding/browser/gtk/tests/TestGtkEmbed.cpp index fbf4bec2b66c..74d3f0bad4eb 100644 --- a/embedding/browser/gtk/tests/TestGtkEmbed.cpp +++ b/embedding/browser/gtk/tests/TestGtkEmbed.cpp @@ -550,8 +550,8 @@ reload_clicked_cb (GtkButton *button, TestGtkBrowser *browser) void stream_clicked_cb (GtkButton *button, TestGtkBrowser *browser) { - char *data; - char *data2; + const char *data; + const char *data2; data = "Hi"; data2 = " there\n"; g_print("stream_clicked_cb\n"); @@ -587,8 +587,8 @@ void menu_stream_cb (GtkMenuItem *menuitem, TestGtkBrowser *browser) { g_print("menu_stream_cb\n"); - char *data; - char *data2; + const char *data; + const char *data2; data = "Hi"; data2 = " there\n"; g_print("stream_clicked_cb\n"); diff --git a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp index 7c18d7d2a3e7..715ac98179f4 100644 --- a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp +++ b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp @@ -64,7 +64,7 @@ #include "nsRect.h" #include "nsIWebBrowserChromeFocus.h" -static char *sWindowWatcherContractID = "@mozilla.org/embedcomp/window-watcher;1"; +static const char sWindowWatcherContractID[] = "@mozilla.org/embedcomp/window-watcher;1"; diff --git a/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp b/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp index 238370fd612b..d60a9739c766 100644 --- a/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp +++ b/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp @@ -1200,7 +1200,7 @@ nsWebBrowserPersist::CloneNodeWithFixedUpURIAttributes( nsresult nsWebBrowserPersist::StoreURIAttribute( - nsIDOMNode *aNode, char *aAttribute, PRBool aNeedsPersisting, + nsIDOMNode *aNode, const char *aAttribute, PRBool aNeedsPersisting, URIData **aData) { NS_ENSURE_ARG_POINTER(aNode); @@ -1235,7 +1235,8 @@ nsWebBrowserPersist::StoreURIAttribute( } nsresult -nsWebBrowserPersist::FixupNodeAttribute(nsIDOMNode *aNode, char *aAttribute) +nsWebBrowserPersist::FixupNodeAttribute(nsIDOMNode *aNode, + const char *aAttribute) { NS_ENSURE_ARG_POINTER(aNode); NS_ENSURE_ARG_POINTER(aAttribute); diff --git a/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.h b/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.h index ccfccf0db1ff..3eaf00b74bfb 100644 --- a/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.h +++ b/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.h @@ -91,9 +91,10 @@ private: nsresult MakeFilenameFromURI( nsIURI *aURI, nsString &aFilename); nsresult StoreURIAttribute( - nsIDOMNode *aNode, char *aAttribute, PRBool aNeedsPersisting = PR_TRUE, + nsIDOMNode *aNode, const char *aAttribute, + PRBool aNeedsPersisting = PR_TRUE, URIData **aData = nsnull); - nsresult FixupNodeAttribute(nsIDOMNode *aNode, char *aAttribute); + nsresult FixupNodeAttribute(nsIDOMNode *aNode, const char *aAttribute); nsresult FixupAnchor(nsIDOMNode *aNode); nsresult StoreAndFixupStyleSheet(nsIStyleSheet *aStyleSheet); nsresult SaveDocumentToFileWithFixup( diff --git a/extensions/cookie/tests/TestCookie.cpp b/extensions/cookie/tests/TestCookie.cpp index 4475d6a66c21..75d08b766e4c 100644 --- a/extensions/cookie/tests/TestCookie.cpp +++ b/extensions/cookie/tests/TestCookie.cpp @@ -107,7 +107,7 @@ int main(PRInt32 argc, char *argv[]) if (NS_SUCCEEDED(rv)) { nsCOMPtr stringBundle; - char* propertyURL = "chrome://necko/locale/necko.properties"; + const char propertyURL[] = "chrome://necko/locale/necko.properties"; rv = bundleService->CreateBundle(propertyURL, getter_AddRefs(stringBundle)); } diff --git a/extensions/transformiix/source/xslt/functions/GenerateIdFunctionCall.cpp b/extensions/transformiix/source/xslt/functions/GenerateIdFunctionCall.cpp index 8482458f2850..4b8b5545a589 100644 --- a/extensions/transformiix/source/xslt/functions/GenerateIdFunctionCall.cpp +++ b/extensions/transformiix/source/xslt/functions/GenerateIdFunctionCall.cpp @@ -35,9 +35,9 @@ */ #ifndef HAVE_64BIT_OS -char* GenerateIdFunctionCall::printfFmt = "id0x%08p"; +const char GenerateIdFunctionCall::printfFmt[] = "id0x%08p"; #else -char* GenerateIdFunctionCall::printfFmt = "id0x%016p"; +const char GenerateIdFunctionCall::printfFmt[] = "id0x%016p"; #endif /** diff --git a/extensions/transformiix/source/xslt/functions/XSLTFunctions.h b/extensions/transformiix/source/xslt/functions/XSLTFunctions.h index 472a62e9c9ce..a87a63688cd6 100644 --- a/extensions/transformiix/source/xslt/functions/XSLTFunctions.h +++ b/extensions/transformiix/source/xslt/functions/XSLTFunctions.h @@ -316,7 +316,7 @@ public: virtual ExprResult* evaluate(Node* context, ContextState* cs); private: - static char* printfFmt; + static const char printfFmt[]; }; /** diff --git a/gfx/src/gtk/nsFontMetricsGTK.cpp b/gfx/src/gtk/nsFontMetricsGTK.cpp index 64bff8958c91..88488b0b0337 100644 --- a/gfx/src/gtk/nsFontMetricsGTK.cpp +++ b/gfx/src/gtk/nsFontMetricsGTK.cpp @@ -140,7 +140,7 @@ struct nsFontCharSetInfo struct nsFontCharSetMap { - char* mName; + const char* mName; nsFontLangGroup* mFontLangGroup; nsFontCharSetInfo* mInfo; }; @@ -173,8 +173,8 @@ struct nsFontNode struct nsFontPropertyName { - char* mName; - int mValue; + const char* mName; + int mValue; }; struct nsFontStretch @@ -3396,7 +3396,8 @@ FFREToXLFDPattern(nsAWritableCString &aFFREName, nsAWritableCString &oPattern) // substitute the charset in a FFRE (Foundry-Family-Registry-Encoding) // static void -FFRESubstituteCharset(nsAWritableCString &aFFREName, char *aReplacementCharset) +FFRESubstituteCharset(nsAWritableCString &aFFREName, + const char *aReplacementCharset) { PRInt32 charsetHyphen = aFFREName.FindChar('-'); charsetHyphen = aFFREName.FindChar('-', charsetHyphen + 1); @@ -3408,7 +3409,8 @@ FFRESubstituteCharset(nsAWritableCString &aFFREName, char *aReplacementCharset) // substitute the encoding in a FFRE (Foundry-Family-Registry-Encoding) // static void -FFRESubstituteEncoding(nsAWritableCString &aFFREName, char *aReplacementEncoding) +FFRESubstituteEncoding(nsAWritableCString &aFFREName, + const char *aReplacementEncoding) { PRInt32 encodingHyphen = aFFREName.FindChar('-'); encodingHyphen = aFFREName.FindChar('-', encodingHyphen + 1); diff --git a/gfx/src/ps/isotab.c b/gfx/src/ps/isotab.c index 96879480a768..992757f13deb 100644 --- a/gfx/src/ps/isotab.c +++ b/gfx/src/ps/isotab.c @@ -39,7 +39,7 @@ ** The names of the characters in the ISO Latin1 set. ** Index into this array is the encoding for that character */ -char *isotab[256] = { +const char *const isotab[256] = { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", diff --git a/gfx/src/ps/nsAFMObject.h b/gfx/src/ps/nsAFMObject.h index 244bd31cb5b3..31bf867c1111 100644 --- a/gfx/src/ps/nsAFMObject.h +++ b/gfx/src/ps/nsAFMObject.h @@ -192,20 +192,20 @@ typedef struct AFM_Single_Char_Metrics AFMscm; struct fontInformation { double mFontVersion; - char *mFontName; - char *mFullName; - char *mFamilyName; - char *mWeight; + const char *mFontName; + const char *mFullName; + const char *mFamilyName; + const char *mWeight; double mFontBBox_llx; double mFontBBox_lly; double mFontBBox_urx; double mFontBBox_ury; - char *mVersion; - char *mNotice; - char *mEncodingScheme; + const char *mVersion; + const char *mNotice; + const char *mEncodingScheme; PRInt32 mMappingScheme; PRInt32 mEscChar; - char *mCharacterSet; + const char *mCharacterSet; PRInt32 mCharacters; PRBool mIsBaseFont; double mVVector_0; @@ -422,8 +422,8 @@ protected: */ struct AFM_SubstituteFonts { -char* mPSName; -char* mFamily; +const char* mPSName; +const char* mFamily; PRUint16 mWeight; PRUint8 mStyle; AFMFontInformation* mFontInfo; diff --git a/gfx/src/ps/nsPostScriptObj.cpp b/gfx/src/ps/nsPostScriptObj.cpp index a95534552c4d..a3082a2065ad 100644 --- a/gfx/src/ps/nsPostScriptObj.cpp +++ b/gfx/src/ps/nsPostScriptObj.cpp @@ -73,7 +73,7 @@ static NS_DEFINE_IID(kICharsetConverterManagerIID, NS_ICHARSETCONVERTERMANAGER_I /* * Paper Names */ -char* paper_string[]={ "Letter", "Legal", "Executive", "A4", "A3" }; +const char*const paper_string[]={ "Letter", "Legal", "Executive", "A4", "A3" }; /* * global @@ -886,7 +886,8 @@ nsPostScriptObj::end_document() * @update 2/1/99 dwc */ void -nsPostScriptObj::annotate_page(char *aTemplate, int y, int delta_dir, int pn) +nsPostScriptObj::annotate_page(const char *aTemplate, + int y, int delta_dir, int pn) { } @@ -896,7 +897,7 @@ nsPostScriptObj::annotate_page(char *aTemplate, int y, int delta_dir, int pn) * @update 2/1/99 dwc. Updated 3/22/2000 to deal with only non-Unicode chars. yueheng.xu@intel.com */ void -nsPostScriptObj::show(const char* txt, int len, char *align) +nsPostScriptObj::show(const char* txt, int len, const char *align) { FILE *f; @@ -979,7 +980,7 @@ nsPostScriptObj::preshow(const PRUnichar* txt, int len) * @update 3/22/2000 to deal with only unicode chars. yueheng.xu@intel.com */ void -nsPostScriptObj::show(const PRUnichar* txt, int len, char *align) +nsPostScriptObj::show(const PRUnichar* txt, int len, const char *align) { FILE *f = mPrintContext->prSetup->out; unsigned char highbyte, lowbyte; @@ -1554,7 +1555,7 @@ int postscriptFont = 0; * @update 2/1/98 dwc */ void -nsPostScriptObj::comment(char *aTheComment) +nsPostScriptObj::comment(const char *aTheComment) { fprintf(mPrintContext->prSetup->out,"%%%s\n", aTheComment); @@ -1635,11 +1636,11 @@ nsPostScriptObj::GetUnixPrinterSetting(const nsCAutoString& aKey, char** aVal) typedef struct _unixPrinterFallbacks_t { - char *key; - char *val; + const char *key; + const char *val; } unixPrinterFallbacks_t; -static unixPrinterFallbacks_t unixPrinterFallbacks[] = { +static const unixPrinterFallbacks_t unixPrinterFallbacks[] = { {"print.psnativefont.ja", "Ryumin-Light-EUC-H"}, {"print.psnativecode.ja", "euc-jp"}, {nsnull, nsnull} @@ -1648,7 +1649,7 @@ static unixPrinterFallbacks_t unixPrinterFallbacks[] = { PRBool GetUnixPrinterFallbackSetting(const nsCAutoString& aKey, char** aVal) { - unixPrinterFallbacks_t *p; + const unixPrinterFallbacks_t *p; const char* key = aKey.get(); for (p=unixPrinterFallbacks; p->key; p++) { if (strcmp(key, p->key) == 0) { diff --git a/gfx/src/ps/nsPostScriptObj.h b/gfx/src/ps/nsPostScriptObj.h index de4d47e0fe70..0ae1023634f2 100644 --- a/gfx/src/ps/nsPostScriptObj.h +++ b/gfx/src/ps/nsPostScriptObj.h @@ -159,8 +159,8 @@ struct PrintSetup_ { int width; /* Paper size, # of cols for text xlate */ int height; - char* header; - char* footer; + const char* header; + const char* footer; int *sizes; XP_Bool reverse; /* Output order */ @@ -176,9 +176,9 @@ struct PrintSetup_ { int bigger; /* Used to init sizes if sizesin NULL */ int paper_size; /* Paper Size(letter,legal,exec,a4,a3) */ - char* prefix; /* For text xlate, prepended to each line */ - char* eol; /* For text translation, line terminator */ - char* bullet; /* What char to use for bullets */ + const char* prefix; /* For text xlate, prepended to each line */ + const char* eol; /* For text translation, line terminator */ + const char* bullet; /* What char to use for bullets */ struct URL_Struct_ *url; /* url of doc being translated */ FILE *out; /* Where to send the output */ @@ -347,7 +347,7 @@ public: * ??? * @update 2/1/99 dwc */ - void annotate_page( char*, int, int, int); + void annotate_page( const char*, int, int, int); /** --------------------------------------------------- * translate the current coordinate system * @update 2/1/99 dwc @@ -357,12 +357,12 @@ public: * Issue a PS show command, which causes image to be rastered * @update 2/1/99 dwc */ - void show(const char* aText, int aLen, char *aAlign); + void show(const char* aText, int aLen, const char *aAlign); /** --------------------------------------------------- * This version takes an Unicode string. * @update 3/22/2000 yueheng.xu@intel.com */ - void show(const PRUnichar* aText, int aLen, char *aAlign); + void show(const PRUnichar* aText, int aLen, const char *aAlign); /** --------------------------------------------------- * set the clipping path to the current path using the winding rule * @update 2/1/99 dwc @@ -402,7 +402,7 @@ public: * output a postscript comment * @update 2/1/99 dwc */ - void comment(char *aTheComment); + void comment(const char *aTheComment); /** --------------------------------------------------- * setup language group * @update 5/30/00 katakai diff --git a/htmlparser/src/COtherDTD.cpp b/htmlparser/src/COtherDTD.cpp index 017077d8251e..3a6825095092 100644 --- a/htmlparser/src/COtherDTD.cpp +++ b/htmlparser/src/COtherDTD.cpp @@ -70,7 +70,7 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kIDTDIID, NS_IDTD_IID); static NS_DEFINE_IID(kClassIID, NS_IOTHERHTML_DTD_IID); static NS_DEFINE_IID(kParserServiceCID, NS_PARSERSERVICE_CID); -static char* kVerificationDir = "c:/temp"; +static const char kVerificationDir[] = "c:/temp"; #ifdef ENABLE_CRC diff --git a/htmlparser/src/nsViewSourceHTML.cpp b/htmlparser/src/nsViewSourceHTML.cpp index 1072e747770c..d0ebad2b2cb3 100644 --- a/htmlparser/src/nsViewSourceHTML.cpp +++ b/htmlparser/src/nsViewSourceHTML.cpp @@ -232,7 +232,7 @@ enum { VIEW_SOURCE_MARKUPDECLARATION = 12 }; -static char* kElementClasses[] = { +static const char* const kElementClasses[] = { "start-tag", "end-tag", "comment", @@ -248,7 +248,7 @@ static char* kElementClasses[] = { "markupdeclaration" }; -static char* kBeforeText[] = { +static const char* const kBeforeText[] = { "<", "", ">", "", @@ -281,7 +281,7 @@ static char* kAfterText[] = { }; #ifdef DUMP_TO_FILE -static char* kDumpFileBeforeText[] = { +static const char* const kDumpFileBeforeText[] = { "<", "</", "", @@ -297,7 +297,7 @@ static char* kDumpFileBeforeText[] = { "" }; -static char* kDumpFileAfterText[] = { +static const char* const kDumpFileAfterText[] = { ">", ">", "", diff --git a/intl/uconv/src/nsCharsetConverterManager.cpp b/intl/uconv/src/nsCharsetConverterManager.cpp index 2222be545245..04f16bb6c6ac 100644 --- a/intl/uconv/src/nsCharsetConverterManager.cpp +++ b/intl/uconv/src/nsCharsetConverterManager.cpp @@ -93,10 +93,10 @@ private: nsIStringBundle ** aResult); static nsresult RegisterConverterTitles(nsIRegistry * aRegistry, - char * aRegistryPath); + const char * aRegistryPath); static nsresult RegisterConverterData(nsIRegistry * aRegistry, - char * aRegistryPath); + const char * aRegistryPath); nsresult GetBundleValue(nsIStringBundle * aBundle, const nsIAtom * aName, nsString * aProp, PRUnichar ** aResult); @@ -104,10 +104,10 @@ private: nsresult GetBundleValue(nsIStringBundle * aBundle, const nsIAtom * aName, nsString * aProp, nsIAtom ** aResult); - nsresult GetRegistryEnumeration(char * aRegistryKey, char * aAddPrefix, - nsISupportsArray ** aArray); + nsresult GetRegistryEnumeration(const char * aRegistryKey, + const char * aAddPrefix, nsISupportsArray ** aArray); - nsresult GetRegistryEnumeration2(char * aRegistryKey, PRBool aDecoder, + nsresult GetRegistryEnumeration2(const char * aRegistryKey, PRBool aDecoder, nsISupportsArray ** aArray); public: @@ -239,7 +239,7 @@ nsresult nsCharsetConverterManager::RegisterConverterManagerData() nsresult nsCharsetConverterManager::RegisterConverterTitles( nsIRegistry * aRegistry, - char * aRegistryPath) + const char * aRegistryPath) { nsresult res; nsRegistryKey key; @@ -259,7 +259,7 @@ nsresult nsCharsetConverterManager::RegisterConverterTitles( nsresult nsCharsetConverterManager::RegisterConverterData( nsIRegistry * aRegistry, - char * aRegistryPath) + const char * aRegistryPath) { nsresult res; nsRegistryKey key; @@ -329,8 +329,8 @@ nsresult nsCharsetConverterManager::GetBundleValue(nsIStringBundle * aBundle, } nsresult nsCharsetConverterManager::GetRegistryEnumeration( - char * aRegistryKey, - char * aAddPrefix, + const char * aRegistryKey, + const char * aAddPrefix, nsISupportsArray ** aArray) { nsresult res = NS_OK; @@ -401,7 +401,7 @@ next: // .../uconv/decoder/name // .../uconv/encoder/name nsresult nsCharsetConverterManager::GetRegistryEnumeration2( - char * aRegistryKey, + const char * aRegistryKey, PRBool aDecoder, nsISupportsArray ** aArray) { diff --git a/js/src/xpconnect/tests/TestXPC.cpp b/js/src/xpconnect/tests/TestXPC.cpp index 1e4f005c6256..d72eb078c0c2 100644 --- a/js/src/xpconnect/tests/TestXPC.cpp +++ b/js/src/xpconnect/tests/TestXPC.cpp @@ -306,7 +306,7 @@ MySecMan::CanAccess(PRUint32 aAction, nsIXPCNativeCallContext *aCallContext, JSC static void TestSecurityManager(JSContext* jscontext, JSObject* glob, nsIXPConnect* xpc) { - char* t; + const char* t; jsval rval; JSBool success = JS_TRUE; MySecMan* sm = new MySecMan(); diff --git a/layout/build/nsContentDLF.cpp b/layout/build/nsContentDLF.cpp index 83ce20e0691c..ef7853181b0c 100644 --- a/layout/build/nsContentDLF.cpp +++ b/layout/build/nsContentDLF.cpp @@ -75,7 +75,7 @@ static NS_DEFINE_IID(kXULDocumentCID, NS_XULDOCUMENT_CID); extern nsresult NS_NewDocumentViewer(nsIDocumentViewer** aResult); -static char* gHTMLTypes[] = { +static const char* const gHTMLTypes[] = { "text/html", "text/plain", "text/css", @@ -89,7 +89,7 @@ static char* gHTMLTypes[] = { 0 }; -static char* gXMLTypes[] = { +static const char* const gXMLTypes[] = { "text/xml", "application/xml", "application/xhtml+xml", @@ -100,7 +100,7 @@ static char* gXMLTypes[] = { }; -static char* gRDFTypes[] = { +static const char* const gRDFTypes[] = { "text/rdf", "application/vnd.mozilla.xul+xml", "mozilla.application/cached-xul", @@ -109,7 +109,7 @@ static char* gRDFTypes[] = { 0 }; -static char* gImageTypes[] = { +static const char* const gImageTypes[] = { "image/gif", "image/jpeg", "image/jpg", @@ -538,12 +538,12 @@ RegisterTypes(nsIComponentManager* aCompMgr, nsIFile* aPath, const char *aLocation, const char *aType, - char** aTypes) + const char* const* aTypes) { nsresult rv = NS_OK; while (*aTypes) { char contractid[500]; - char* contentType = *aTypes++; + const char* contentType = *aTypes++; PR_snprintf(contractid, sizeof(contractid), NS_DOCUMENT_LOADER_FACTORY_CONTRACTID_PREFIX "%s;1?type=%s", aCommand, contentType); diff --git a/layout/forms/nsHTMLButtonControlFrame.cpp b/layout/forms/nsHTMLButtonControlFrame.cpp index 37bc2f01330c..939b0174d062 100644 --- a/layout/forms/nsHTMLButtonControlFrame.cpp +++ b/layout/forms/nsHTMLButtonControlFrame.cpp @@ -468,7 +468,7 @@ nsHTMLButtonControlFrame::Paint(nsIPresContext* aPresContext, // XXX a hack until the reflow state does this correctly // XXX when it gets fixed, leave in the printf statements or add an assertion static -void ButtonHack(nsHTMLReflowState& aReflowState, char* aMessage) +void ButtonHack(nsHTMLReflowState& aReflowState, const char* aMessage) { if (aReflowState.mComputedWidth == 0) { aReflowState.mComputedWidth = aReflowState.availableWidth; diff --git a/layout/html/forms/src/nsHTMLButtonControlFrame.cpp b/layout/html/forms/src/nsHTMLButtonControlFrame.cpp index 37bc2f01330c..939b0174d062 100644 --- a/layout/html/forms/src/nsHTMLButtonControlFrame.cpp +++ b/layout/html/forms/src/nsHTMLButtonControlFrame.cpp @@ -468,7 +468,7 @@ nsHTMLButtonControlFrame::Paint(nsIPresContext* aPresContext, // XXX a hack until the reflow state does this correctly // XXX when it gets fixed, leave in the printf statements or add an assertion static -void ButtonHack(nsHTMLReflowState& aReflowState, char* aMessage) +void ButtonHack(nsHTMLReflowState& aReflowState, const char* aMessage) { if (aReflowState.mComputedWidth == 0) { aReflowState.mComputedWidth = aReflowState.availableWidth; diff --git a/modules/oji/src/nsCNullSecurityContext.cpp b/modules/oji/src/nsCNullSecurityContext.cpp index 0aa4c528eafa..1031ab0c0be0 100644 --- a/modules/oji/src/nsCNullSecurityContext.cpp +++ b/modules/oji/src/nsCNullSecurityContext.cpp @@ -49,10 +49,9 @@ NS_IMETHODIMP nsCNullSecurityContext::GetOrigin(char* buf, int len) if (buf == NULL) return NS_ERROR_NULL_POINTER; - char* origin = "file:///"; - PRInt32 originLen = (PRInt32) nsCRT::strlen(origin); + const char origin[] = "file:///"; + PRInt32 originLen = (PRInt32) (sizeof(origin) - 1); if (len <= originLen) { - nsCRT::free(origin); return NS_ERROR_NULL_POINTER; } // Copy origin diff --git a/modules/plugin/base/src/nsPluginsDirUnix.cpp b/modules/plugin/base/src/nsPluginsDirUnix.cpp index d30486438faf..07d750894b3a 100644 --- a/modules/plugin/base/src/nsPluginsDirUnix.cpp +++ b/modules/plugin/base/src/nsPluginsDirUnix.cpp @@ -221,8 +221,7 @@ static void LoadExtraSharedLibs() if (!sonameList) { // pref is not set, lets use hardcoded list prefSonameListIsSet = PR_FALSE; - sonameList = DEFAULT_EXTRA_LIBS_LIST; - sonameList = PL_strdup(sonameList); + sonameList = PL_strdup(DEFAULT_EXTRA_LIBS_LIST); } if (sonameList) { char *arrayOfLibs[PLUGIN_MAX_NUMBER_OF_EXTRA_LIBS] = {0}; diff --git a/netwerk/base/src/nsSocketTransportService.cpp b/netwerk/base/src/nsSocketTransportService.cpp index 96476f2312a7..7e4761db3b1c 100644 --- a/netwerk/base/src/nsSocketTransportService.cpp +++ b/netwerk/base/src/nsSocketTransportService.cpp @@ -781,7 +781,7 @@ nsSocketTransportService::GetNeckoStringByName (const char *aName, PRUnichar **a nsAutoString resultString; resultString.AssignWithConversion(aName); if (!m_stringBundle) { - char* propertyURL = NECKO_MSGS_URL; + const char propertyURL[] = NECKO_MSGS_URL; // make sure that we get this service on the UI thread. NS_WITH_PROXIED_SERVICE(nsIStringBundleService, sBundleService, kStringBundleServiceCID, NS_UI_THREAD_EVENTQ, &res); diff --git a/netwerk/build/nsNetModule.cpp b/netwerk/build/nsNetModule.cpp index 2a00c66a3794..05d3774b7d7e 100644 --- a/netwerk/build/nsNetModule.cpp +++ b/netwerk/build/nsNetModule.cpp @@ -255,7 +255,7 @@ static PRUint32 g_StreamConverterCount = 16; static PRUint32 g_StreamConverterCount = 15; #endif -static char *g_StreamConverterArray[] = { +static const char *const g_StreamConverterArray[] = { FTP_UNIX_TO_INDEX, FTP_NT_TO_INDEX, FTP_OS2_TO_INDEX, diff --git a/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp b/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp index e85907a88e06..a33b40e07402 100644 --- a/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp +++ b/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp @@ -1475,7 +1475,7 @@ nsFtpState::S_pasv() { } - char * string; + const char * string; if (mIPv6ServerAddress) string = "EPSV" CRLF; else diff --git a/netwerk/protocol/http/src/nsHttpChannel.cpp b/netwerk/protocol/http/src/nsHttpChannel.cpp index 67dd2fa24be5..bad2e5c26c5f 100644 --- a/netwerk/protocol/http/src/nsHttpChannel.cpp +++ b/netwerk/protocol/http/src/nsHttpChannel.cpp @@ -1996,7 +1996,7 @@ nsHttpChannel::GetReferrer(nsIURI **referrer) #define numInvalidReferrerSchemes 8 -static char * invalidReferrerSchemes [numInvalidReferrerSchemes] = +static const char *const invalidReferrerSchemes [numInvalidReferrerSchemes] = { "chrome", "resource", diff --git a/netwerk/streamconv/test/TestStreamConv.cpp b/netwerk/streamconv/test/TestStreamConv.cpp index 156c9ada4c15..d94fc91d8dd9 100644 --- a/netwerk/streamconv/test/TestStreamConv.cpp +++ b/netwerk/streamconv/test/TestStreamConv.cpp @@ -169,7 +169,7 @@ main(int argc, char* argv[]) // in other modules (necko converters for example). PRUint32 converterListSize = 7; - char *converterList[] = { + const char *const converterList[] = { "?from=a/foo&to=b/foo", "?from=b/foo&to=c/foo", "?from=b/foo&to=d/foo", diff --git a/netwerk/test/TestCallbacks.cpp b/netwerk/test/TestCallbacks.cpp index 542a9308466a..9789b250bb18 100644 --- a/netwerk/test/TestCallbacks.cpp +++ b/netwerk/test/TestCallbacks.cpp @@ -238,7 +238,7 @@ Consumer::Validate(nsIRequest* request, nsISupports *aContext) { return rv; } -nsresult StartLoad(char *); +nsresult StartLoad(const char *); int main(int argc, char *argv[]) { nsresult rv = NS_OK; @@ -299,7 +299,7 @@ int main(int argc, char *argv[]) { return rv; } -nsresult StartLoad(char *aURISpec) { +nsresult StartLoad(const char *aURISpec) { nsresult rv = NS_OK; // create a context diff --git a/netwerk/test/TestSocketTransport.cpp b/netwerk/test/TestSocketTransport.cpp index b85aaff6ba92..6ef8207832bb 100644 --- a/netwerk/test/TestSocketTransport.cpp +++ b/netwerk/test/TestSocketTransport.cpp @@ -602,7 +602,7 @@ main(int argc, char* argv[]) /// } PRBool bIsAsync = PR_TRUE; - char* hostName = nsnull; + const char* hostName = nsnull; int i; diff --git a/parser/htmlparser/src/COtherDTD.cpp b/parser/htmlparser/src/COtherDTD.cpp index 017077d8251e..3a6825095092 100644 --- a/parser/htmlparser/src/COtherDTD.cpp +++ b/parser/htmlparser/src/COtherDTD.cpp @@ -70,7 +70,7 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kIDTDIID, NS_IDTD_IID); static NS_DEFINE_IID(kClassIID, NS_IOTHERHTML_DTD_IID); static NS_DEFINE_IID(kParserServiceCID, NS_PARSERSERVICE_CID); -static char* kVerificationDir = "c:/temp"; +static const char kVerificationDir[] = "c:/temp"; #ifdef ENABLE_CRC diff --git a/parser/htmlparser/src/nsViewSourceHTML.cpp b/parser/htmlparser/src/nsViewSourceHTML.cpp index 1072e747770c..d0ebad2b2cb3 100644 --- a/parser/htmlparser/src/nsViewSourceHTML.cpp +++ b/parser/htmlparser/src/nsViewSourceHTML.cpp @@ -232,7 +232,7 @@ enum { VIEW_SOURCE_MARKUPDECLARATION = 12 }; -static char* kElementClasses[] = { +static const char* const kElementClasses[] = { "start-tag", "end-tag", "comment", @@ -248,7 +248,7 @@ static char* kElementClasses[] = { "markupdeclaration" }; -static char* kBeforeText[] = { +static const char* const kBeforeText[] = { "<", "", ">", "", @@ -281,7 +281,7 @@ static char* kAfterText[] = { }; #ifdef DUMP_TO_FILE -static char* kDumpFileBeforeText[] = { +static const char* const kDumpFileBeforeText[] = { "<", "</", "", @@ -297,7 +297,7 @@ static char* kDumpFileBeforeText[] = { "" }; -static char* kDumpFileAfterText[] = { +static const char* const kDumpFileAfterText[] = { ">", ">", "", diff --git a/profile/pref-migrator/src/nsPrefMigration.cpp b/profile/pref-migrator/src/nsPrefMigration.cpp index 69f82eb62856..c5e23ce58d49 100644 --- a/profile/pref-migrator/src/nsPrefMigration.cpp +++ b/profile/pref-migrator/src/nsPrefMigration.cpp @@ -1237,7 +1237,7 @@ nsPrefMigration::CreateNewUser5Tree(nsIFileSpec * oldProfilePath, nsIFileSpec * * *--------------------------------------------------------------------------------*/ nsresult -nsPrefMigration::GetDirFromPref(nsIFileSpec * oldProfilePath, nsIFileSpec * newProfilePath, const char *newDirName, char* pref, nsIFileSpec* newPath, nsIFileSpec* oldPath) +nsPrefMigration::GetDirFromPref(nsIFileSpec * oldProfilePath, nsIFileSpec * newProfilePath, const char *newDirName, const char* pref, nsIFileSpec* newPath, nsIFileSpec* oldPath) { nsresult rv; diff --git a/profile/pref-migrator/src/nsPrefMigration.h b/profile/pref-migrator/src/nsPrefMigration.h index e563e3007fbc..16a19da0860d 100644 --- a/profile/pref-migrator/src/nsPrefMigration.h +++ b/profile/pref-migrator/src/nsPrefMigration.h @@ -119,7 +119,7 @@ class nsPrefMigration: public nsIPrefMigration nsresult GetDirFromPref(nsIFileSpec* oldProfilePath, nsIFileSpec* newProfilePath, const char* newDirName, - char* pref, + const char* pref, nsIFileSpec* newPath, nsIFileSpec* oldPath); diff --git a/security/manager/ssl/src/nsNSSComponent.cpp b/security/manager/ssl/src/nsNSSComponent.cpp index a6fdbcf1f4c0..d2dc401cdf56 100644 --- a/security/manager/ssl/src/nsNSSComponent.cpp +++ b/security/manager/ssl/src/nsNSSComponent.cpp @@ -446,7 +446,7 @@ nsNSSComponent::RegisterPSMContentListener() /* Table of pref names and SSL cipher ID */ typedef struct { - char* pref; + const char* pref; long id; } CipherPref; diff --git a/webshell/tests/viewer/nsViewerApp.cpp b/webshell/tests/viewer/nsViewerApp.cpp index 0878cc53aeeb..4567ddf1d480 100644 --- a/webshell/tests/viewer/nsViewerApp.cpp +++ b/webshell/tests/viewer/nsViewerApp.cpp @@ -1156,7 +1156,7 @@ nsViewerApp::CreateRobot(nsBrowserWindow* aWindow) static nsBrowserWindow* gWinData; static int gTop100Pointer = 0; static int gTop100LastPointer = 0; -static char * gTop100List[] = { +static const char *const gTop100List[] = { "http://www.yahoo.com", "http://www.netscape.com", "http://www.mozilla.org", @@ -1386,7 +1386,7 @@ PRBool CreateSiteDialog(nsIWidget * aParent) { // Dynamically find the index of the last pointer gTop100LastPointer = 0; - char * p; + const char * p; do { p = gTop100List[gTop100LastPointer++]; } while (p); diff --git a/widget/src/gtk/nsDragService.cpp b/widget/src/gtk/nsDragService.cpp index dcdbb48f896c..30b2a749542e 100644 --- a/widget/src/gtk/nsDragService.cpp +++ b/widget/src/gtk/nsDragService.cpp @@ -36,9 +36,9 @@ static NS_DEFINE_IID(kCDragServiceCID, NS_DRAGSERVICE_CID); static PRLogModuleInfo *sDragLm = NULL; -static char *gMimeListType = "application/x-moz-internal-item-list"; -static char *gMozUrlType = "_NETSCAPE_URL"; -static char *gTextUriListType = "text/uri-list"; +static const char gMimeListType[] = "application/x-moz-internal-item-list"; +static const char gMozUrlType[] = "_NETSCAPE_URL"; +static const char gTextUriListType[] = "text/uri-list"; NS_IMPL_ADDREF_INHERITED(nsDragService, nsBaseDragService) NS_IMPL_RELEASE_INHERITED(nsDragService, nsBaseDragService) @@ -776,7 +776,7 @@ nsDragService::GetSourceList(void) GtkTargetList *multiTargetList = 0; GdkAtom listAtom = gdk_atom_intern(gMimeListType, FALSE); GtkTargetEntry target; - target.target = gMimeListType; + target.target = (gchar*)gMimeListType; target.flags = 0; target.info = listAtom; multiTargetList = gtk_target_list_new(&target, 1); diff --git a/widget/src/gtk/nsGtkIMEHelper.cpp b/widget/src/gtk/nsGtkIMEHelper.cpp index c06bb974c2d0..aef4d3ccc84c 100644 --- a/widget/src/gtk/nsGtkIMEHelper.cpp +++ b/widget/src/gtk/nsGtkIMEHelper.cpp @@ -1362,7 +1362,7 @@ nsIMEGtkIC::SetPreeditFont(GdkFont *aFontset) { } void -nsIMEGtkIC::SetStatusText(char *aText) { +nsIMEGtkIC::SetStatusText(const char *aText) { if (!aText) { return; } diff --git a/widget/src/gtk/nsGtkIMEHelper.h b/widget/src/gtk/nsGtkIMEHelper.h index c449efabe10e..5943b42e458a 100644 --- a/widget/src/gtk/nsGtkIMEHelper.h +++ b/widget/src/gtk/nsGtkIMEHelper.h @@ -158,7 +158,7 @@ class nsIMEGtkIC { GdkIMStyle mInputStyle; GdkFont *GetPreeditFont(); char *mStatusText; - void SetStatusText(char*); + void SetStatusText(const char*); void SetPreeditFont(GdkFont*); void SetStatusFont(GdkFont*); void SetPreeditSpotLocation(unsigned long, unsigned long); diff --git a/widget/src/gtk/nsGtkMozRemoteHelper.cpp b/widget/src/gtk/nsGtkMozRemoteHelper.cpp index 7d07dba08b97..8b002e728de1 100644 --- a/widget/src/gtk/nsGtkMozRemoteHelper.cpp +++ b/widget/src/gtk/nsGtkMozRemoteHelper.cpp @@ -42,7 +42,7 @@ Atom nsGtkMozRemoteHelper::sMozResponseAtom = 0; Atom nsGtkMozRemoteHelper::sMozUserAtom = 0; // XXX get this dynamically -static char *sRemoteVersion = "5.0"; +static const char sRemoteVersion[] = "5.0"; void nsGtkMozRemoteHelper::SetupVersion(GdkWindow *aWindow) diff --git a/widget/src/xpwidgets/nsXPLookAndFeel.h b/widget/src/xpwidgets/nsXPLookAndFeel.h index 632f2a74209f..6ff3c3d8d8cd 100644 --- a/widget/src/xpwidgets/nsXPLookAndFeel.h +++ b/widget/src/xpwidgets/nsXPLookAndFeel.h @@ -55,7 +55,7 @@ typedef enum { struct nsLookAndFeelIntPref { - char* name; + const char* name; nsILookAndFeel::nsMetricID id; PRPackedBool isSet; nsLookAndFeelType type; @@ -64,7 +64,7 @@ struct nsLookAndFeelIntPref struct nsLookAndFeelFloatPref { - char* name; + const char* name; nsILookAndFeel::nsMetricFloatID id; PRPackedBool isSet; nsLookAndFeelType type; diff --git a/xpcom/ds/nsPersistentProperties.cpp b/xpcom/ds/nsPersistentProperties.cpp index a3beda5dcc40..c8e3649b3263 100644 --- a/xpcom/ds/nsPersistentProperties.cpp +++ b/xpcom/ds/nsPersistentProperties.cpp @@ -144,7 +144,7 @@ nsPersistentProperties::Load(nsIInputStream *aIn) if (c < 0) { break; } - char *trimThese = " \t"; + static const char trimThese[] = " \t"; key.Trim(trimThese, PR_FALSE, PR_TRUE); c = Read(); nsAutoString value; diff --git a/xpcom/io/nsEscape.cpp b/xpcom/io/nsEscape.cpp index d57a505c1e68..c3ccdb0cca91 100644 --- a/xpcom/io/nsEscape.cpp +++ b/xpcom/io/nsEscape.cpp @@ -92,7 +92,7 @@ NS_COM char* nsEscapeCount( return 0; int i, extra = 0; - char* hexChars = "0123456789ABCDEF"; + static const char hexChars[] = "0123456789ABCDEF"; register const unsigned char* src = (const unsigned char *) str; for (i = 0; i < len; i++) @@ -339,7 +339,7 @@ NS_COM nsresult nsStdEscape(const char* str, PRInt16 mask, nsCString &result) return NS_OK; int i = 0; - char* hexChars = "0123456789ABCDEF"; + static const char hexChars[] = "0123456789ABCDEF"; int len = PL_strlen(str); PRBool forced = PR_FALSE; diff --git a/xpcom/io/nsFileSpecUnix.cpp b/xpcom/io/nsFileSpecUnix.cpp index 41917d06c5e6..252b0847d763 100644 --- a/xpcom/io/nsFileSpecUnix.cpp +++ b/xpcom/io/nsFileSpecUnix.cpp @@ -595,8 +595,8 @@ nsDirectoryIterator& nsDirectoryIterator::operator ++ () mExists = PR_FALSE; if (!mDir) return *this; - char* dot = "."; - char* dotdot = ".."; + const char dot[] = "."; + const char dotdot[] = ".."; struct dirent* entry = readdir(mDir); if (entry && strcmp(entry->d_name, dot) == 0) entry = readdir(mDir); diff --git a/xpcom/io/nsLinebreakConverter.cpp b/xpcom/io/nsLinebreakConverter.cpp index f5d30721f42b..50bcaff991db 100644 --- a/xpcom/io/nsLinebreakConverter.cpp +++ b/xpcom/io/nsLinebreakConverter.cpp @@ -56,7 +56,7 @@ ----------------------------------------------------------------------------*/ static const char* GetLinebreakString(nsLinebreakConverter::ELinebreakType aBreakType) { - static char* sLinebreaks[] = { + static const char* const sLinebreaks[] = { "", // any NS_LINEBREAK, // platform LFSTR, // content diff --git a/xpcom/reflect/xptinfo/src/xptiMisc.cpp b/xpcom/reflect/xptinfo/src/xptiMisc.cpp index 9d2a547d2131..1a7830e1a51a 100644 --- a/xpcom/reflect/xptinfo/src/xptiMisc.cpp +++ b/xpcom/reflect/xptinfo/src/xptiMisc.cpp @@ -41,7 +41,7 @@ struct xptiFileTypeEntry { - char* name; + const char* name; int len; xptiFileType::Type type; }; diff --git a/xpcom/tests/TestID.cpp b/xpcom/tests/TestID.cpp index 93028ac4ac5f..bd89ea8b11ba 100644 --- a/xpcom/tests/TestID.cpp +++ b/xpcom/tests/TestID.cpp @@ -38,7 +38,7 @@ #include "plstr.h" #include "nsID.h" -static char* ids[] = { +static const char* const ids[] = { "5C347B10-D55C-11D1-89B7-006008911B81", "{5C347B10-D55C-11D1-89B7-006008911B81}", "5c347b10-d55c-11d1-89b7-006008911b81", @@ -55,7 +55,7 @@ int main(int argc, char** argv) { nsID id; for (int i = 0; i < NUM_IDS; i++) { - char* idstr = ids[i]; + const char* idstr = ids[i]; if (!id.Parse(idstr)) { fprintf(stderr, "TestID: Parse failed on test #%d\n", i); return -1; diff --git a/xpcom/tests/nsIFileTest.cpp b/xpcom/tests/nsIFileTest.cpp index 4bbc3b600b35..15950d2af816 100644 --- a/xpcom/tests/nsIFileTest.cpp +++ b/xpcom/tests/nsIFileTest.cpp @@ -69,7 +69,7 @@ NS_SetupRegistry() nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, NULL); } -void InitTest(char* creationPath, char* appendPath) +void InitTest(const char* creationPath, const char* appendPath) { nsILocalFile* file = nsnull; nsresult rv = nsComponentManager::CreateInstance(NS_LOCAL_FILE_CONTRACTID, @@ -120,7 +120,7 @@ void InitTest(char* creationPath, char* appendPath) } -void CreationTest(char* creationPath, char* appendPath, +void CreationTest(const char* creationPath, const char* appendPath, PRInt32 whatToCreate, PRInt32 perm) { nsCOMPtr file; @@ -172,7 +172,7 @@ void CreationTest(char* creationPath, char* appendPath, } -void CreateUniqueTest(char* creationPath, char* appendPath, +void CreateUniqueTest(const char* creationPath, const char* appendPath, PRInt32 whatToCreate, PRInt32 perm) { nsCOMPtr file; @@ -226,7 +226,7 @@ void CreateUniqueTest(char* creationPath, char* appendPath, void -CopyTest(char *testFile, char *targetDir) +CopyTest(const char *testFile, const char *targetDir) { nsCOMPtr file; nsCOMPtr dir; @@ -267,7 +267,7 @@ CopyTest(char *testFile, char *targetDir) } void -DeletionTest(char* creationPath, char* appendPath, PRBool recursive) +DeletionTest(const char* creationPath, const char* appendPath, PRBool recursive) { nsCOMPtr file; nsresult rv = diff --git a/xpcom/threads/nsEventQueue.cpp b/xpcom/threads/nsEventQueue.cpp index e2b343cbf983..84751c792cfb 100644 --- a/xpcom/threads/nsEventQueue.cpp +++ b/xpcom/threads/nsEventQueue.cpp @@ -59,8 +59,8 @@ static PRThread *gEventQueueLogThread = 0; #endif // in a real system, these would be members in a header class... -static char *gActivatedNotification = "nsIEventQueueActivated"; -static char *gDestroyedNotification = "nsIEventQueueDestroyed"; +static const char gActivatedNotification[] = "nsIEventQueueActivated"; +static const char gDestroyedNotification[] = "nsIEventQueueDestroyed"; nsEventQueueImpl::nsEventQueueImpl() { diff --git a/xpfe/bootstrap/nsAppRunner.cpp b/xpfe/bootstrap/nsAppRunner.cpp index 8e7d496d4fa9..186e755c96be 100644 --- a/xpfe/bootstrap/nsAppRunner.cpp +++ b/xpfe/bootstrap/nsAppRunner.cpp @@ -111,7 +111,7 @@ static NS_DEFINE_CID(kChromeRegistryCID, NS_CHROMEREGISTRY_CID); #define UILOCALE_CMD_LINE_ARG "-UILocale" #define CONTENTLOCALE_CMD_LINE_ARG "-contentLocale" -extern "C" void ShowOSAlert(char* aMessage); +extern "C" void ShowOSAlert(const char* aMessage); #define HELP_SPACER_1 "\t" #define HELP_SPACER_2 "\t\t" @@ -271,7 +271,7 @@ static void InitializeMacOSXApp(int argc, char* argv[]) /* Define Class IDs */ static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID); static NS_DEFINE_CID(kCmdLineServiceCID, NS_COMMANDLINE_SERVICE_CID); -static char *sWatcherServiceContractID = "@mozilla.org/embedcomp/window-watcher;1"; +static const char sWatcherServiceContractID[] = "@mozilla.org/embedcomp/window-watcher;1"; #include "nsNativeAppSupport.h" @@ -942,11 +942,11 @@ static nsresult InitializeWindowCreator() // Maximum allowed / used length of alert message is 255 chars, due to restrictions on Mac. // Please make sure that file contents and fallback_alert_text are at most 255 chars. // Fallback_alert_text must be non-const, because of inplace conversion on Mac. -static void ShowOSAlertFromFile(int argc, char **argv, const char *alert_filename, char* fallback_alert_text) +static void ShowOSAlertFromFile(int argc, char **argv, const char *alert_filename, const char* fallback_alert_text) { char message[256] = { 0 }; PRInt32 numRead = 0; - char *messageToShow = fallback_alert_text; + const char *messageToShow = fallback_alert_text; nsresult rv; nsCOMPtr fileName; nsCOMPtr directoryService; @@ -1002,7 +1002,7 @@ static nsresult VerifyInstallation(int argc, char **argv) if (exists) { nsCOMPtr binPath; - char* lastResortMessage = "A previous install did not complete correctly. Finishing install."; + const char lastResortMessage[] = "A previous install did not complete correctly. Finishing install."; ShowOSAlertFromFile(argc, argv, CLEANUP_MESSAGE_FILENAME, lastResortMessage); @@ -1033,13 +1033,13 @@ static nsresult VerifyPsmAbsentOrSane(int argc, char **argv) // In case the security component can not do its internal initialization, // we must warn the user and exit. - char *panicMsg = "Could not initialize the browser's security component. " + const char panicMsg[] = "Could not initialize the browser's security component. " "The most likely cause is problems with files in your " "browser's profile directory. Please check that this " "directory has no read/write restrictions and your " "hard disk is not full or close to full."; - char *panicMessageFilename = "nssifail.txt"; + const char panicMessageFilename[] = "nssifail.txt"; ShowOSAlertFromFile(argc, argv, panicMessageFilename, panicMsg); diff --git a/xpfe/bootstrap/showOSAlert.cpp b/xpfe/bootstrap/showOSAlert.cpp index a96f7631f539..a259740609d3 100644 --- a/xpfe/bootstrap/showOSAlert.cpp +++ b/xpfe/bootstrap/showOSAlert.cpp @@ -52,7 +52,7 @@ #include #endif -extern "C" void ShowOSAlert(char* aMessage); +extern "C" void ShowOSAlert(const char* aMessage); #if defined (MOZ_WIDGET_GTK) @@ -96,7 +96,7 @@ ns_gtk_alert_OK_callback(GtkWidget *aWidget, gpointer aData) * returns -2 for widget creation error */ int -NS_gtk_alert(char *aMessage, char *aTitle, char *aOKBtnText) +NS_gtk_alert(const char *aMessage, const char *aTitle, const char *aOKBtnText) { #ifdef DEBUG_dbragg printf ("\n*** Now inside NS_gtk_alert *** \n"); @@ -107,8 +107,8 @@ NS_gtk_alert(char *aMessage, char *aTitle, char *aOKBtnText) GtkWidget *msgLabel = NULL; GtkWidget *packerLbl = NULL; GtkWidget *packerBtn = NULL; - char *okBtnText = aOKBtnText; - char *title = aTitle; + const char *okBtnText = aOKBtnText; + const char *title = aTitle; if (!aMessage) return -1; @@ -178,7 +178,7 @@ NS_gtk_alert(char *aMessage, char *aTitle, char *aOKBtnText) // The maximum allowed length of aMessage is 255 characters! -void ShowOSAlert(char* aMessage) +void ShowOSAlert(const char* aMessage) { #ifdef DEBUG_dbragg printf("\n****Inside ShowOSAlert ***\n"); diff --git a/xpfe/components/find/src/nsFindComponent.cpp b/xpfe/components/find/src/nsFindComponent.cpp index 1736d60ae323..aacdcb3edc92 100644 --- a/xpfe/components/find/src/nsFindComponent.cpp +++ b/xpfe/components/find/src/nsFindComponent.cpp @@ -571,7 +571,7 @@ nsFindComponent::Find(nsISupports *aContext, PRBool *aDidFind) return rv; // Open Find dialog and prompt for search parameters. - char * urlStr = "chrome://global/content/finddialog.xul"; + const char urlStr[] = "chrome://global/content/finddialog.xul"; // We need the parent's nsIDOMWindowInternal... // 1. Get topLevelWindow nsIWebShellContainer (chrome included). @@ -659,7 +659,7 @@ nsFindComponent::Replace( nsISupports *aContext ) return rv; // Open Replace dialog and prompt for search parameters. - char * urlStr = "chrome://global/content/replacedialog.xul"; + const char urlStr[] = "chrome://global/content/replacedialog.xul"; // We need the parent's nsIDOMWindowInternal... // 1. Get topLevelWindow nsIWebShellContainer (chrome included). diff --git a/xpfe/components/intl/nsCharsetMenu.cpp b/xpfe/components/intl/nsCharsetMenu.cpp index 2ebe57305d22..4b535afa962b 100644 --- a/xpfe/components/intl/nsCharsetMenu.cpp +++ b/xpfe/components/intl/nsCharsetMenu.cpp @@ -209,7 +209,7 @@ private: nsresult InitCacheMenu(nsISupportsArray * aDecs, nsIRDFResource * aResource, const char * aKey, nsVoidArray * aArray); nsresult InitMoreMenu(nsISupportsArray * aDecs, nsIRDFResource * aResource, - char * aFlag); + const char * aFlag); nsresult InitMoreSubmenus(nsISupportsArray * aDecs); nsresult AddCharsetToItemArray(nsVoidArray * aArray, nsIAtom * aCharset, @@ -217,22 +217,23 @@ private: nsresult AddCharsetArrayToItemArray(nsVoidArray * aArray, nsISupportsArray * aCharsets); nsresult AddMenuItemToContainer(nsIRDFContainer * aContainer, - nsMenuEntry * aItem, nsIRDFResource * aType, char * aIDPrefix, + nsMenuEntry * aItem, nsIRDFResource * aType, const char * aIDPrefix, PRInt32 aPlace); nsresult AddMenuItemArrayToContainer(nsIRDFContainer * aContainer, nsVoidArray * aArray, nsIRDFResource * aType); nsresult AddCharsetToContainer(nsVoidArray * aArray, - nsIRDFContainer * aContainer, nsIAtom * aCharset, char * aIDPrefix, + nsIRDFContainer * aContainer, nsIAtom * aCharset, const char * aIDPrefix, PRInt32 aPlace, PRInt32 aRDFPlace); nsresult AddFromPrefsToMenu(nsVoidArray * aArray, nsIRDFContainer * aContainer, const char * aKey, nsISupportsArray * aDecs, - char * aIDPrefix); + const char * aIDPrefix); nsresult AddFromNolocPrefsToMenu(nsVoidArray * aArray, nsIRDFContainer * aContainer, const char * aKey, nsISupportsArray * aDecs, - char * aIDPrefix); + const char * aIDPrefix); nsresult AddFromStringToMenu(char * aCharsetList, nsVoidArray * aArray, - nsIRDFContainer * aContainer, nsISupportsArray * aDecs, char * aIDPrefix); + nsIRDFContainer * aContainer, nsISupportsArray * aDecs, + const char * aIDPrefix); nsresult AddSeparatorToContainer(nsIRDFContainer * aContainer); nsresult AddCharsetToCache(nsIAtom * aCharset, nsVoidArray * aArray, @@ -1091,7 +1092,7 @@ nsresult nsCharsetMenu::InitAutodetMenu() nsresult nsCharsetMenu::InitMoreMenu( nsISupportsArray * aDecs, nsIRDFResource * aResource, - char * aFlag) + const char * aFlag) { NS_TIMELINE_START_TIMER("nsCharsetMenu::InitMoreMenu"); @@ -1139,11 +1140,11 @@ nsresult nsCharsetMenu::InitMoreSubmenus(nsISupportsArray * aDecs) nsCOMPtr container3; nsCOMPtr container4; nsCOMPtr container5; - char * key1 = "intl.charsetmenu.browser.more1"; - char * key2 = "intl.charsetmenu.browser.more2"; - char * key3 = "intl.charsetmenu.browser.more3"; - char * key4 = "intl.charsetmenu.browser.more4"; - char * key5 = "intl.charsetmenu.browser.more5"; + const char key1[] = "intl.charsetmenu.browser.more1"; + const char key2[] = "intl.charsetmenu.browser.more2"; + const char key3[] = "intl.charsetmenu.browser.more3"; + const char key4[] = "intl.charsetmenu.browser.more4"; + const char key5[] = "intl.charsetmenu.browser.more5"; res = NewRDFContainer(mInner, kNC_BrowserMore1CharsetMenuRoot, getter_AddRefs(container1)); @@ -1248,7 +1249,7 @@ nsresult nsCharsetMenu::AddMenuItemToContainer( nsIRDFContainer * aContainer, nsMenuEntry * aItem, nsIRDFResource * aType, - char * aIDPrefix, + const char * aIDPrefix, PRInt32 aPlace) { nsresult res = NS_OK; @@ -1331,7 +1332,7 @@ nsresult nsCharsetMenu::AddCharsetToContainer( nsVoidArray * aArray, nsIRDFContainer * aContainer, nsIAtom * aCharset, - char * aIDPrefix, + const char * aIDPrefix, PRInt32 aPlace, PRInt32 aRDFPlace) { @@ -1359,7 +1360,7 @@ nsresult nsCharsetMenu::AddFromPrefsToMenu( nsIRDFContainer * aContainer, const char * aKey, nsISupportsArray * aDecs, - char * aIDPrefix) + const char * aIDPrefix) { nsresult res = NS_OK; @@ -1383,7 +1384,7 @@ nsresult nsCharsetMenu::AddFromNolocPrefsToMenu( nsIRDFContainer * aContainer, const char * aKey, nsISupportsArray * aDecs, - char * aIDPrefix) + const char * aIDPrefix) { nsresult res = NS_OK; @@ -1404,7 +1405,7 @@ nsresult nsCharsetMenu::AddFromStringToMenu( nsVoidArray * aArray, nsIRDFContainer * aContainer, nsISupportsArray * aDecs, - char * aIDPrefix) + const char * aIDPrefix) { nsresult res = NS_OK; char * p = aCharsetList; diff --git a/xpfe/components/search/src/nsInternetSearchService.cpp b/xpfe/components/search/src/nsInternetSearchService.cpp index 39ff8782e346..5bca63d33e15 100755 --- a/xpfe/components/search/src/nsInternetSearchService.cpp +++ b/xpfe/components/search/src/nsInternetSearchService.cpp @@ -3308,8 +3308,8 @@ InternetSearchDataSource::updateAtom(nsIRDFDataSource *db, nsIRDFResource *src, struct encodings { - char *numericEncoding; - char *stringEncoding; + const char *numericEncoding; + const char *stringEncoding; }; diff --git a/xpfe/components/search/src/nsLocalSearchService.h b/xpfe/components/search/src/nsLocalSearchService.h index 1d264b48a130..3f8f0be151b3 100644 --- a/xpfe/components/search/src/nsLocalSearchService.h +++ b/xpfe/components/search/src/nsLocalSearchService.h @@ -48,7 +48,7 @@ typedef struct _findTokenStruct { - char *token; + const char *token; nsString value; } findTokenStruct, *findTokenPtr; diff --git a/xpfe/components/urlbarhistory/src/nsUrlbarHistory.cpp b/xpfe/components/urlbarhistory/src/nsUrlbarHistory.cpp index 3ce28c1c7b8a..828061499e44 100644 --- a/xpfe/components/urlbarhistory/src/nsUrlbarHistory.cpp +++ b/xpfe/components/urlbarhistory/src/nsUrlbarHistory.cpp @@ -46,7 +46,7 @@ static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID); static NS_DEFINE_CID(kRDFCUtilsCID, NS_RDFCONTAINERUTILS_CID); -static char * ignoreArray[] = { +static const char * const ignoreArray[] = { "http://", "ftp://", "gopher://", diff --git a/xpfe/components/xremote/src/XRemoteService.cpp b/xpfe/components/xremote/src/XRemoteService.cpp index 5e51c4598492..eec24cd860e2 100644 --- a/xpfe/components/xremote/src/XRemoteService.cpp +++ b/xpfe/components/xremote/src/XRemoteService.cpp @@ -49,12 +49,12 @@ NS_DEFINE_CID(kWindowCID, NS_WINDOW_CID); // protocol strings -static char *s200ExecutedCommand = "200 executed command:"; -static char *s500ParseCommand = "500 command not parsable:"; -static char *s501UnrecognizedCommand = "501 unrecognized command:"; +static const char s200ExecutedCommand[] = "200 executed command:"; +static const char s500ParseCommand[] = "500 command not parsable:"; +static const char s501UnrecognizedCommand[] = "501 unrecognized command:"; // not used -//static char *s502NoWindow = "502 no appropriate window for:"; -static char *s509InternalError = "509 internal error"; +//static const char s502NoWindow[] = "502 no appropriate window for:"; +static const char s509InternalError[] = "509 internal error"; XRemoteService::XRemoteService() { diff --git a/xpinstall/src/nsInstallFolder.cpp b/xpinstall/src/nsInstallFolder.cpp index da9e0a6c2607..80bd96f70dbd 100644 --- a/xpinstall/src/nsInstallFolder.cpp +++ b/xpinstall/src/nsInstallFolder.cpp @@ -44,7 +44,7 @@ struct DirectoryTable { - char * directoryName; /* The formal directory name */ + const char * directoryName; /* The formal directory name */ PRInt32 folderEnum; /* Directory ID */ };