setmime: hash() conflicts with std::hash.
* found with GCC6
This commit is contained in:
+22
-22
@@ -103,7 +103,7 @@ const char* kAttrEditable = "-attrEditable";
|
|||||||
const char* kAttrExtra = "-attrExtra";
|
const char* kAttrExtra = "-attrExtra";
|
||||||
|
|
||||||
|
|
||||||
const uint32 hash(const char* str)
|
const uint32 hash_function(const char* str)
|
||||||
{
|
{
|
||||||
uint32 h = 0;
|
uint32 h = 0;
|
||||||
uint32 g = 0;
|
uint32 g = 0;
|
||||||
@@ -466,7 +466,7 @@ MimeAttribute::StoreInto(BMessage* target)
|
|||||||
const char*
|
const char*
|
||||||
MimeAttribute::UserArgValue(TUserArgs& map, const char* name)
|
MimeAttribute::UserArgValue(TUserArgs& map, const char* name)
|
||||||
{
|
{
|
||||||
TUserArgsI i = map.find(hash(name));
|
TUserArgsI i = map.find(hash_function(name));
|
||||||
if (i == map.end())
|
if (i == map.end())
|
||||||
return NULL;
|
return NULL;
|
||||||
return i->second != NULL ? i->second : "";
|
return i->second != NULL ? i->second : "";
|
||||||
@@ -574,7 +574,7 @@ MimeType::_Init(char** argv) throw (Error)
|
|||||||
map<uint32, const CmdOption*> cmdOptionsMap;
|
map<uint32, const CmdOption*> cmdOptionsMap;
|
||||||
for (size_t i = 0; i < sizeof(gCmdOptions) / sizeof(gCmdOptions[0]); i++)
|
for (size_t i = 0; i < sizeof(gCmdOptions) / sizeof(gCmdOptions[0]); i++)
|
||||||
cmdOptionsMap.insert(pair<uint32, CmdOption*>(
|
cmdOptionsMap.insert(pair<uint32, CmdOption*>(
|
||||||
hash(gCmdOptions[i].fName), &gCmdOptions[i]));
|
hash_function(gCmdOptions[i].fName), &gCmdOptions[i]));
|
||||||
|
|
||||||
// parse the command line arguments
|
// parse the command line arguments
|
||||||
for (char** arg = argv; *arg; arg++) {
|
for (char** arg = argv; *arg; arg++) {
|
||||||
@@ -588,7 +588,7 @@ MimeType::_Init(char** argv) throw (Error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check op.modes, options and attribs
|
// check op.modes, options and attribs
|
||||||
uint32 key = hash(*arg);
|
uint32 key = hash_function(*arg);
|
||||||
|
|
||||||
map<uint32, const CmdOption*>::iterator I = cmdOptionsMap.find(key);
|
map<uint32, const CmdOption*>::iterator I = cmdOptionsMap.find(key);
|
||||||
if (I == cmdOptionsMap.end())
|
if (I == cmdOptionsMap.end())
|
||||||
@@ -605,7 +605,7 @@ MimeType::_Init(char** argv) throw (Error)
|
|||||||
throw Error(kWrongModeMessage);
|
throw Error(kWrongModeMessage);
|
||||||
fOpMode = key;
|
fOpMode = key;
|
||||||
|
|
||||||
if (hash(I->second->fName) != hash(kCheckSniffRule))
|
if (hash_function(I->second->fName) != hash_function(kCheckSniffRule))
|
||||||
break;
|
break;
|
||||||
// else -> fallthrough, CheckRule works both as mode and Option
|
// else -> fallthrough, CheckRule works both as mode and Option
|
||||||
case CmdOption::kOption:
|
case CmdOption::kOption:
|
||||||
@@ -669,15 +669,15 @@ MimeType::_Init(char** argv) throw (Error)
|
|||||||
throw Error("error instantiating mime for '%s': %s",
|
throw Error("error instantiating mime for '%s': %s",
|
||||||
Type(), strerror(InitCheck()));
|
Type(), strerror(InitCheck()));
|
||||||
|
|
||||||
fDoAdd = fOpMode == hash(kAdd);
|
fDoAdd = fOpMode == hash_function(kAdd);
|
||||||
fDoSet = fOpMode == hash(kSet);
|
fDoSet = fOpMode == hash_function(kSet);
|
||||||
fDoForce = fOpMode == hash(kForce);
|
fDoForce = fOpMode == hash_function(kForce);
|
||||||
fDoRemove = fOpMode == hash(kRemove);
|
fDoRemove = fOpMode == hash_function(kRemove);
|
||||||
fDumpNormal = fOpMode == hash(kDump);
|
fDumpNormal = fOpMode == hash_function(kDump);
|
||||||
fDumpRule = fOpMode == hash(kDumpSniffRule);
|
fDumpRule = fOpMode == hash_function(kDumpSniffRule);
|
||||||
fDumpIcon = fOpMode == hash(kDumpIcon);
|
fDumpIcon = fOpMode == hash_function(kDumpIcon);
|
||||||
fDumpAll = fOpMode == hash(kDumpAll);
|
fDumpAll = fOpMode == hash_function(kDumpAll);
|
||||||
fCheckSniffRule = fOpMode == hash(kCheckSniffRule);
|
fCheckSniffRule = fOpMode == hash_function(kCheckSniffRule);
|
||||||
|
|
||||||
if (fDoAdd || fDoSet || fDoForce || fDoRemove) {
|
if (fDoAdd || fDoSet || fDoForce || fDoRemove) {
|
||||||
if (Type() == NULL)
|
if (Type() == NULL)
|
||||||
@@ -835,7 +835,7 @@ MimeType::_SetTo(const char* mimetype) throw (Error)
|
|||||||
uint32 i = 0;
|
uint32 i = 0;
|
||||||
const char* ext = NULL;
|
const char* ext = NULL;
|
||||||
while (exts.FindString("extensions", i++, &ext) == B_OK)
|
while (exts.FindString("extensions", i++, &ext) == B_OK)
|
||||||
fExtensions.insert(pair<uint32, BString>(hash(ext), ext));
|
fExtensions.insert(pair<uint32, BString>(hash_function(ext), ext));
|
||||||
}
|
}
|
||||||
|
|
||||||
BMessage attrs;
|
BMessage attrs;
|
||||||
@@ -847,7 +847,7 @@ MimeType::_SetTo(const char* mimetype) throw (Error)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
fAttributes.insert(
|
fAttributes.insert(
|
||||||
pair<uint32, MimeAttribute>(hash(attr.fName), attr));
|
pair<uint32, MimeAttribute>(hash_function(attr.fName), attr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -871,7 +871,7 @@ MimeType::_SetTo(const char* mimetype) throw (Error)
|
|||||||
const char*
|
const char*
|
||||||
MimeType::_UserArgValue(const char* name)
|
MimeType::_UserArgValue(const char* name)
|
||||||
{
|
{
|
||||||
TUserArgsI i = fUserArguments.find(hash(name));
|
TUserArgsI i = fUserArguments.find(hash_function(name));
|
||||||
if (i == fUserArguments.end())
|
if (i == fUserArguments.end())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -1030,9 +1030,9 @@ MimeType::_DoEdit() throw (Error)
|
|||||||
|
|
||||||
// handle extensions update
|
// handle extensions update
|
||||||
pair<TUserArgsI, TUserArgsI> exts
|
pair<TUserArgsI, TUserArgsI> exts
|
||||||
= fUserArguments.equal_range(hash(kExtension));
|
= fUserArguments.equal_range(hash_function(kExtension));
|
||||||
for (TUserArgsI i = exts.first; i != exts.second; i++) {
|
for (TUserArgsI i = exts.first; i != exts.second; i++) {
|
||||||
uint32 key = hash(i->second);
|
uint32 key = hash_function(i->second);
|
||||||
if (fExtensions.find(key) == fExtensions.end())
|
if (fExtensions.find(key) == fExtensions.end())
|
||||||
fExtensions.insert(pair<uint32, BString>(key, i->second));
|
fExtensions.insert(pair<uint32, BString>(key, i->second));
|
||||||
}
|
}
|
||||||
@@ -1054,18 +1054,18 @@ MimeType::_DoEdit() throw (Error)
|
|||||||
userAttr != fUserAttributes.end(); userAttr++ )
|
userAttr != fUserAttributes.end(); userAttr++ )
|
||||||
{
|
{
|
||||||
// search for -attribute "name" in args map
|
// search for -attribute "name" in args map
|
||||||
TUserArgsI attrArgs = userAttr->find(hash(kAttribute));
|
TUserArgsI attrArgs = userAttr->find(hash_function(kAttribute));
|
||||||
if (attrArgs == userAttr->end())
|
if (attrArgs == userAttr->end())
|
||||||
throw Error("internal error: %s arg not found", kAttribute);
|
throw Error("internal error: %s arg not found", kAttribute);
|
||||||
|
|
||||||
// check if we already have this attribute cached
|
// check if we already have this attribute cached
|
||||||
map<uint32, MimeAttribute>::iterator
|
map<uint32, MimeAttribute>::iterator
|
||||||
attr = fAttributes.find(hash(attrArgs->second));
|
attr = fAttributes.find(hash_function(attrArgs->second));
|
||||||
if (attr == fAttributes.end()) {
|
if (attr == fAttributes.end()) {
|
||||||
// add new one
|
// add new one
|
||||||
MimeAttribute mimeAttr(*userAttr);
|
MimeAttribute mimeAttr(*userAttr);
|
||||||
fAttributes.insert(
|
fAttributes.insert(
|
||||||
pair<uint32, MimeAttribute>(hash(mimeAttr.fName), mimeAttr));
|
pair<uint32, MimeAttribute>(hash_function(mimeAttr.fName), mimeAttr));
|
||||||
} else if (!fDoAdd)
|
} else if (!fDoAdd)
|
||||||
attr->second.SyncWith(*userAttr);
|
attr->second.SyncWith(*userAttr);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user