use const char for parameters, uint to avoid warnings, and strcasecmp for name comparisons

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9910 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
shatty
2004-11-11 07:35:47 +00:00
parent e25788aa41
commit ec5b4cac39
2 changed files with 11 additions and 10 deletions
@@ -74,14 +74,14 @@ public:
* This function executes in linear time.
* @return the character set with the given print name, or NULL if none exists
**/
static const BCharacterSet * FindCharacterSetByPrintName(char * name);
static const BCharacterSet * FindCharacterSetByPrintName(const char * name);
/**
* @brief return the character set with the given name, or NULL if none exists
* This function will match aliases as well.
* This function executes in linear time.
* @return the character set with the given name, or NULL if none exists
**/
static const BCharacterSet * FindCharacterSetByName(char * name);
static const BCharacterSet * FindCharacterSetByName(const char * name);
private:
uint32 index; //! the state variable for iteration
};
+9 -8
View File
@@ -1,3 +1,4 @@
#include <string.h>
#include <CharacterSet.h>
#include <CharacterSetRoster.h>
#include "character_sets.h"
@@ -79,9 +80,9 @@ BCharacterSetRoster::GetCharacterSetByMIBenum(uint32 MIBenum)
}
const BCharacterSet *
BCharacterSetRoster::FindCharacterSetByPrintName(char * name)
BCharacterSetRoster::FindCharacterSetByPrintName(const char * name)
{
for (int id = 0 ; (id < character_sets_by_id_count) ; id++) {
for (uint id = 0 ; (id < character_sets_by_id_count) ; id++) {
if (strcmp(character_sets_by_id[id]->GetPrintName(),name) == 0) {
return character_sets_by_id[id];
}
@@ -90,22 +91,22 @@ BCharacterSetRoster::FindCharacterSetByPrintName(char * name)
}
const BCharacterSet *
BCharacterSetRoster::FindCharacterSetByName(char * name)
BCharacterSetRoster::FindCharacterSetByName(const char * name)
{
// first search standard names and mime names
for (int id = 0 ; (id < character_sets_by_id_count) ; id++) {
if (strcmp(character_sets_by_id[id]->GetName(),name) == 0) {
for (uint id = 0 ; (id < character_sets_by_id_count) ; id++) {
if (strcasecmp(character_sets_by_id[id]->GetName(),name) == 0) {
return character_sets_by_id[id];
}
const char * mime = character_sets_by_id[id]->GetMIMEName();
if ((mime != NULL) && (strcmp(mime,name) == 0)) {
if ((mime != NULL) && (strcasecmp(mime,name) == 0)) {
return character_sets_by_id[id];
}
}
// only after searching all the above names do we look at aliases
for (int id = 0 ; (id < character_sets_by_id_count) ; id++) {
for (uint id = 0 ; (id < character_sets_by_id_count) ; id++) {
for (int alias = 0 ; (alias < character_sets_by_id[id]->CountAliases()) ; alias++) {
if (strcmp(character_sets_by_id[id]->AliasAt(alias),name) == 0) {
if (strcasecmp(character_sets_by_id[id]->AliasAt(alias),name) == 0) {
return character_sets_by_id[id];
}
}