mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
add XP_ASSERT IsUTF8String for more data source. reviewed by rjc
This commit is contained in:
parent
773132fb8a
commit
748ef02062
@ -26,6 +26,7 @@
|
||||
#include "fs2rdf.h"
|
||||
#include "glue.h"
|
||||
#include "mcf.h"
|
||||
#include "utils.h"
|
||||
|
||||
/* external string references in allxpstr */
|
||||
extern int RDF_UNABLETODELETEFILE, RDF_UNABLETODELETEFOLDER;
|
||||
@ -886,6 +887,7 @@ fsGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PR
|
||||
}
|
||||
}
|
||||
}
|
||||
XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char*) retVal)));
|
||||
return(retVal);
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include "hist2rdf.h"
|
||||
#include "remstore.h"
|
||||
#include "utils.h"
|
||||
|
||||
static PRBool histInFlatFilep = 0;
|
||||
|
||||
@ -116,6 +117,9 @@ collateOneHist (RDFT r, RDF_Resource u, char* url, char* title, time_t lastAcces
|
||||
if (startsWith("404", title)) return;
|
||||
urlUnit = HistCreate(url, 1);
|
||||
existingName = nlocalStoreGetSlotValue(gLocalStore, urlUnit, gCoreVocab->RDF_name, RDF_STRING_TYPE, 0, 1);
|
||||
|
||||
XP_ASSERT( IsUTF8String((const char* )existingName));
|
||||
|
||||
if (existingName == NULL) {
|
||||
if (title[0] != '\0') remoteAddName(urlUnit, title);
|
||||
} else freeMem(existingName);
|
||||
@ -140,6 +144,7 @@ collateOneHist (RDFT r, RDF_Resource u, char* url, char* title, time_t lastAcces
|
||||
#else
|
||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_WINDATE),time);
|
||||
#endif
|
||||
XP_ASSERT( IsUTF8String((const char* )buffer));
|
||||
remoteStoreAdd(gRemoteStore, urlUnit, gWebData->RDF_lastVisitDate,
|
||||
(void *)copyString(buffer), RDF_STRING_TYPE, 1);
|
||||
}
|
||||
@ -153,6 +158,7 @@ collateOneHist (RDFT r, RDF_Resource u, char* url, char* title, time_t lastAcces
|
||||
#else
|
||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_WINDATE),time);
|
||||
#endif
|
||||
XP_ASSERT( IsUTF8String((const char* )buffer));
|
||||
remoteStoreAdd(gRemoteStore, urlUnit, gWebData->RDF_firstVisitDate,
|
||||
(void *)copyString(buffer), RDF_STRING_TYPE, 1);
|
||||
}
|
||||
@ -329,6 +335,7 @@ hostUnitOfDate (RDFT r, RDF_Resource u, time_t lastAccessDate)
|
||||
setResourceType(node, HISTORY_RT);
|
||||
remoteStoreAdd(gHistoryStore, node, gCoreVocab->RDF_parent,
|
||||
parentNode, RDF_RESOURCE_TYPE, 1);
|
||||
XP_ASSERT( IsUTF8String((const char* )weekBuffer));
|
||||
remoteStoreAdd(gHistoryStore, node, gCoreVocab->RDF_name,
|
||||
copyString(weekBuffer), RDF_STRING_TYPE, 1);
|
||||
parentNode = node;
|
||||
@ -347,6 +354,7 @@ hostUnitOfDate (RDFT r, RDF_Resource u, time_t lastAccessDate)
|
||||
setResourceType(node, HISTORY_RT);
|
||||
histAddParent(node, parentNode);
|
||||
sprintf(bigBuffer,"%s - %s",weekBuffer,dayBuffer);
|
||||
XP_ASSERT( IsUTF8String((const char* )dayBuffer));
|
||||
remoteStoreAdd(gHistoryStore, node, gCoreVocab->RDF_name,
|
||||
copyString(dayBuffer), RDF_STRING_TYPE, 1);
|
||||
parentNode = node;
|
||||
@ -363,6 +371,7 @@ hostUnitOfDate (RDFT r, RDF_Resource u, time_t lastAccessDate)
|
||||
setResourceType(node, HISTORY_RT);
|
||||
remoteStoreAdd(gHistoryStore, node, gCoreVocab->RDF_parent,
|
||||
parentNode, RDF_RESOURCE_TYPE, 1);
|
||||
XP_ASSERT( IsUTF8String((const char* )hourBuffer));
|
||||
remoteStoreAdd(gHistoryStore, node, gCoreVocab->RDF_name,
|
||||
copyString(hourBuffer), RDF_STRING_TYPE, 1);
|
||||
parentNode = node;
|
||||
@ -549,6 +558,8 @@ PRBool
|
||||
historyUnassert (RDFT hst, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type)
|
||||
{
|
||||
|
||||
XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
if ((type == RDF_RESOURCE_TYPE) && (resourceType((RDF_Resource)v) == HISTORY_RT) &&
|
||||
(s == gCoreVocab->RDF_parent)) {
|
||||
RDF_Resource parents[5];
|
||||
|
@ -121,6 +121,7 @@ PRBool
|
||||
ldapAssert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v));
|
||||
if (!ldap2rdfInitedp) ldap2rdfInit(rdf);
|
||||
if ((s == gCoreVocab->RDF_parent) && (type == RDF_RESOURCE_TYPE) &&
|
||||
(tv) && (ldapContainerp(v))) {
|
||||
@ -136,6 +137,8 @@ PRBool
|
||||
ldapUnassert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type)
|
||||
{
|
||||
|
||||
XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
if (!ldap2rdfInitedp) ldap2rdfInit(rdf);
|
||||
if ((s == gCoreVocab->RDF_parent) && (type == RDF_RESOURCE_TYPE) &&
|
||||
(ldapContainerp(v))) {
|
||||
@ -151,6 +154,7 @@ PRBool
|
||||
ldapDBAdd (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type)
|
||||
{
|
||||
Assertion nextAs, prevAs, newAs;
|
||||
XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
if ((s == gCoreVocab->RDF_instanceOf) && (v == gWebData->RDF_Container)) {
|
||||
setContainerp(u, true);
|
||||
return 1;
|
||||
@ -191,6 +195,7 @@ ldapDBRemove (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType t
|
||||
{
|
||||
Assertion nextAs, prevAs, ans;
|
||||
PRBool found = false;
|
||||
XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
nextAs = prevAs = ldaparg1(u);
|
||||
while (nextAs != null) {
|
||||
if (asEqual(nextAs, u, s, v, type)) {
|
||||
@ -231,6 +236,7 @@ PRBool
|
||||
ldapHasAssertion (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
Assertion nextAs;
|
||||
XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
if (!ldap2rdfInitedp) ldap2rdfInit(rdf);
|
||||
|
||||
nextAs = ldaparg1(u);
|
||||
@ -260,7 +266,9 @@ ldapGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type,
|
||||
nextAs = (inversep ? ldaparg2(u) : ldaparg1(u));
|
||||
while (nextAs != null) {
|
||||
if ((nextAs->s == s) && (nextAs->tv == tv) && (nextAs->type == type)) {
|
||||
return (inversep ? nextAs->u : nextAs->value);
|
||||
void * retVal = (inversep ? nextAs->u : nextAs->value);
|
||||
XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )retVal)));
|
||||
return retVal
|
||||
}
|
||||
nextAs = (inversep ? nextAs->invNext : nextAs->next);
|
||||
}
|
||||
@ -270,7 +278,9 @@ ldapGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type,
|
||||
nextAs = (inversep ? ldaparg2(u) : ldaparg1(u));
|
||||
while (nextAs != null) {
|
||||
if ((nextAs->s == s) && (nextAs->tv == tv) && (nextAs->type == type)) {
|
||||
return (inversep ? nextAs->u : nextAs->value);
|
||||
void * retVal = (inversep ? nextAs->u : nextAs->value);
|
||||
XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )retVal)));
|
||||
return retVal
|
||||
}
|
||||
nextAs = (inversep ? nextAs->invNext : nextAs->next);
|
||||
}
|
||||
@ -397,6 +407,7 @@ ldapModifyEntry (RDFT rdf, RDF_Resource parent, RDF_Resource child, PRBool addFl
|
||||
{
|
||||
if ((errStr = ldap_err2string(err)) != NULL)
|
||||
{
|
||||
/* We need to change XP_MakeHTMLAlert to use UTF8 */
|
||||
XP_MakeHTMLAlert(NULL, errStr);
|
||||
}
|
||||
|
||||
@ -420,6 +431,7 @@ ldapModifyEntry (RDFT rdf, RDF_Resource parent, RDF_Resource child, PRBool addFl
|
||||
{
|
||||
if ((errStr = ldap_err2string(err)) != NULL)
|
||||
{
|
||||
/* We need to change XP_MakeHTMLAlert to use UTF8 */
|
||||
XP_MakeHTMLAlert(NULL, errStr);
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "mcff2mcf.h"
|
||||
#include "utils.h"
|
||||
|
||||
|
||||
|
||||
@ -229,6 +230,7 @@ void
|
||||
addSlotValue (RDFFile f, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
if (f == NULL || u == NULL || s == NULL || v == NULL) return;
|
||||
if (s == gCoreVocab->RDF_child) {
|
||||
RDF_Resource temp = (RDF_Resource)v;
|
||||
|
@ -325,6 +325,8 @@ nlocalStoreHasAssertion (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_
|
||||
uint16 n = 0;
|
||||
PRBool ans = 0;
|
||||
PRBool invp = (s == gCoreVocab->RDF_parent);
|
||||
|
||||
XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
data = (invp ? DBM_GetSlotValue(rdf, (RDF_Resource)v, s, 1, &size) :
|
||||
DBM_GetSlotValue(rdf, u, s, 0, &size));
|
||||
if (data == NULL) return 0;
|
||||
@ -369,6 +371,7 @@ nlocalStoreGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s,
|
||||
memcpy((char*)&ans, dataOfDBMAs(nas), sizeof(uint32));
|
||||
}
|
||||
freeMem(data);
|
||||
XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )ans)));
|
||||
return ans;
|
||||
}
|
||||
n = dbmasSize(nas) + n;
|
||||
@ -473,6 +476,7 @@ makeAsBlock (void* v, RDF_ValueType type, PRBool tv, size_t *size)
|
||||
/*
|
||||
ldiv_t cdiv ;
|
||||
*/
|
||||
XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
if (type == RDF_STRING_TYPE) {
|
||||
vsize = strlen(v);
|
||||
} else if (type == RDF_RESOURCE_TYPE) {
|
||||
@ -527,6 +531,7 @@ nlocalStoreAssert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
uint16 n = 0;
|
||||
size_t tsize;
|
||||
PRBool ans = 0;
|
||||
XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
|
||||
/* don't store RDF Commands in the local store */
|
||||
if (s == gNavCenter->RDF_Command) return 0;
|
||||
@ -594,6 +599,7 @@ PRBool
|
||||
nlocalStoreAssert1 (RDFFile f, RDFT rdf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
return nlocalStoreAssert(rdf, u, s, v, type, tv);
|
||||
}
|
||||
|
||||
@ -610,6 +616,7 @@ nlocalStoreUnassert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
size_t tsize;
|
||||
PRBool ans = 0;
|
||||
DBMAs nas;
|
||||
XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
data = DBM_GetSlotValue(rdf, u, s, 0, &size);
|
||||
if (data == NULL) return 1;
|
||||
while (n < size) {
|
||||
|
@ -386,8 +386,10 @@ pmGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type,
|
||||
if ((resourceType(u) == PM_RT) && tv && (!inversep) && (type == RDF_STRING_TYPE) && (u->pdata)) {
|
||||
MM msg = (MM) u->pdata;
|
||||
if (s == gNavCenter->from) {
|
||||
XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )msg->from)));
|
||||
return copyString(msg->from);
|
||||
} else if (s == gNavCenter->subject) {
|
||||
XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )msg->subject)));
|
||||
return copyString(msg->subject);
|
||||
} else if (s == gNavCenter->date) {
|
||||
return copyString(msg->date);
|
||||
@ -467,6 +469,7 @@ pmHasAssertion (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType
|
||||
PRBool
|
||||
pmRemove (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type)
|
||||
{
|
||||
XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
if ((startsWith("mailbox://", rdf->url)) && (resourceType(u) == PM_RT) && (s == gCoreVocab->RDF_parent)
|
||||
&& (type == RDF_RESOURCE_TYPE)) {
|
||||
RDF_Resource mbox = (RDF_Resource) v;
|
||||
|
@ -65,6 +65,7 @@ PRBool
|
||||
asEqual(RDFT r, Assertion as, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type)
|
||||
{
|
||||
XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
return ((as->db == r) && (as->u == u) && (as->s == s) && (as->type == type) &&
|
||||
((as->value == v) ||
|
||||
((type == RDF_STRING_TYPE) && (strcmp(v, as->value) == 0))));
|
||||
@ -77,6 +78,7 @@ makeNewAssertion (RDFT r, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
Assertion newAs = (Assertion) getMem(sizeof(struct RDF_AssertionStruct));
|
||||
XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
newAs->u = u;
|
||||
newAs->s = s;
|
||||
newAs->value = v;
|
||||
@ -107,6 +109,7 @@ remoteAssert3 (RDFFile fi, RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
Assertion as = remoteStoreAdd(mcf, u, s, v, type, tv);
|
||||
XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
if (as != NULL) {
|
||||
void addToAssertionList (RDFFile f, Assertion as) ;
|
||||
addToAssertionList(fi, as);
|
||||
@ -169,6 +172,7 @@ remoteStoreAdd (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
Assertion nextAs, prevAs, newAs;
|
||||
XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
nextAs = prevAs = u->rarg1;
|
||||
|
||||
if (s == gNavCenter->RDF_Command)
|
||||
@ -217,6 +221,7 @@ remoteStoreRemove (RDFT mcf, RDF_Resource u, RDF_Resource s,
|
||||
{
|
||||
Assertion nextAs, prevAs, ans;
|
||||
PRBool found = false;
|
||||
XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
nextAs = prevAs = u->rarg1;
|
||||
while (nextAs != null) {
|
||||
if (asEqual(mcf, nextAs, u, s, v, type)) {
|
||||
@ -297,6 +302,7 @@ PRBool
|
||||
remoteStoreHasAssertion (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
Assertion nextAs;
|
||||
XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
|
||||
if ((s == gNavCenter->RDF_Command) && (type == RDF_RESOURCE_TYPE) && (tv) && (v == gNavCenter->RDF_Command_Refresh))
|
||||
{
|
||||
@ -320,13 +326,18 @@ remoteStoreGetSlotValue (RDFT mcf, RDF_Resource u, RDF_Resource s, RDF_ValueType
|
||||
Assertion nextAs;
|
||||
|
||||
if ((s == gWebData->RDF_URL) && (tv) && (!inversep) && (type == RDF_STRING_TYPE))
|
||||
{
|
||||
|
||||
XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )resourceID(u))));
|
||||
return copyString(resourceID(u));
|
||||
}
|
||||
|
||||
nextAs = (inversep ? u->rarg2 : u->rarg1);
|
||||
while (nextAs != null) {
|
||||
if ((nextAs->db == mcf) && (nextAs->s == s) && (nextAs->tv == tv) && (nextAs->type == type)) {
|
||||
void* ans = (inversep ? nextAs->u : nextAs->value);
|
||||
if (type == RDF_STRING_TYPE) {
|
||||
XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )ans)));
|
||||
return copyString((char*)ans);
|
||||
} else return ans;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user