From a563d786800a2633309e22364bd26bf56efdfcd0 Mon Sep 17 00:00:00 2001 From: "norris%netscape.com" Date: Thu, 23 Mar 2000 23:42:46 +0000 Subject: [PATCH] Fix bug 32904 Asserts at startup in nsScriptSecurityManager.cpp r=mstoltz git-svn-id: svn://10.0.0.236/trunk@63928 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/caps/src/nsScriptSecurityManager.cpp | 8 +++ mozilla/dom/public/genPropNames.pl | 17 +++++- mozilla/dom/public/nsDOMPropEnums.h | 58 ++++++++++---------- mozilla/dom/public/nsDOMPropNames.h | 58 ++++++++++---------- 4 files changed, 81 insertions(+), 60 deletions(-) diff --git a/mozilla/caps/src/nsScriptSecurityManager.cpp b/mozilla/caps/src/nsScriptSecurityManager.cpp index 5665a57b683..fece22707cb 100644 --- a/mozilla/caps/src/nsScriptSecurityManager.cpp +++ b/mozilla/caps/src/nsScriptSecurityManager.cpp @@ -1595,6 +1595,14 @@ nsScriptSecurityManager::InitFromPrefs() NS_ASSERTION(NS_DOM_PROP_MAX == sizeof(domPropNames)/sizeof(domPropNames[0]), "mismatch in property name count"); + // The DOM property names had better be sorted for binary search to work +#ifdef DEBUG + for (unsigned i=1; i < sizeof(domPropNames)/sizeof(domPropNames[0]); i++) { + NS_ASSERTION(strcmp(domPropNames[i-1], domPropNames[i]) < 0, + "DOM properties are not properly sorted"); + } +#endif + nsresult rv; NS_WITH_SERVICE(nsIPref, prefs, kPrefServiceCID, &rv); if (NS_FAILED(rv)) diff --git a/mozilla/dom/public/genPropNames.pl b/mozilla/dom/public/genPropNames.pl index 3e49484ed5e..67eb85dd6b3 100644 --- a/mozilla/dom/public/genPropNames.pl +++ b/mozilla/dom/public/genPropNames.pl @@ -68,14 +68,27 @@ print OUT <<'EOF'; #define NS_DOM_PROP_NAMES \ EOF +$last = ""; + while () { if (/NS_DOM_PROP_MAX/) { last; } + $save = $_; + s/,.*/", \\/; s/NS_DOM_PROP_/"/; s/_/./; - s/,.*/", \\/; - print OUT lc($_); + $_ = lc($_); + print OUT $_; + # Check order of names and make sure they are sorted. + # It's important we check after the subsitution of '.' for '_' + # since it's the sort order of the names we care about and '.' + # and '_' sort differently with respect to letters. + if ($last ne "" && ($last gt $_)) { + die "Name $lastsave and $save are out of order in nsDOMPropEnums.h.\n"; + } + $last = $_; + $lastsave = $save; } print OUT <