nss-pam-ldapd commit: r1278 - in nss-pam-ldapd: common tests
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
nss-pam-ldapd commit: r1278 - in nss-pam-ldapd: common tests
- From: Commits of the nss-pam-ldapd project <nss-pam-ldapd-commits [at] lists.arthurdejong.org>
- To: nss-pam-ldapd-commits [at] lists.arthurdejong.org
- Reply-to: nss-pam-ldapd-users [at] lists.arthurdejong.org
- Subject: nss-pam-ldapd commit: r1278 - in nss-pam-ldapd: common tests
- Date: Fri, 15 Oct 2010 12:21:36 +0200 (CEST)
Author: arthur
Date: Fri Oct 15 12:21:35 2010
New Revision: 1278
URL: http://arthurdejong.org/viewvc/nss-pam-ldapd?view=rev&revision=1278
Log:
make DICTs and SETs case-sensitive
Modified:
nss-pam-ldapd/common/dict.c
nss-pam-ldapd/common/dict.h
nss-pam-ldapd/common/set.h
nss-pam-ldapd/tests/test_dict.c
nss-pam-ldapd/tests/test_set.c
Modified: nss-pam-ldapd/common/dict.c
==============================================================================
--- nss-pam-ldapd/common/dict.c Fri Oct 15 11:22:01 2010 (r1277)
+++ nss-pam-ldapd/common/dict.c Fri Oct 15 12:21:35 2010 (r1278)
@@ -2,7 +2,7 @@
dict.c - dictionary functions
This file is part of the nss-pam-ldapd library.
- Copyright (C) 2007, 2008, 2009 Arthur de Jong
+ Copyright (C) 2007, 2008, 2009, 2010 Arthur de Jong
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -69,13 +69,12 @@
struct dict_entry **table; /* the hashtable */
};
-/* Simple hash function that computes the hash value of a lower-cased
- string. */
+/* Simple hash function that computes the hash value of a string. */
static uint32_t stringhash(const char *str)
{
uint32_t hash=0;
while (*str!='\0')
- hash=3*hash+tolower(*str++);
+ hash=3*hash+*str++;
return hash;
}
@@ -170,7 +169,7 @@
for (entry=dict->table[hash%dict->size];entry!=NULL;entry=entry->next)
{
if ( (entry->hash==hash) &&
- (strcasecmp(entry->key,key)==0) )
+ (strcmp(entry->key,key)==0) )
return entry->value;
}
/* no matches found */
@@ -196,7 +195,7 @@
prev=entry,entry=entry->next)
{
if ( (entry->hash==hash) &&
- (strcasecmp(entry->key,key)==0) )
+ (strcmp(entry->key,key)==0) )
{
/* check if we should unset the entry */
if (value==NULL)
Modified: nss-pam-ldapd/common/dict.h
==============================================================================
--- nss-pam-ldapd/common/dict.h Fri Oct 15 11:22:01 2010 (r1277)
+++ nss-pam-ldapd/common/dict.h Fri Oct 15 12:21:35 2010 (r1278)
@@ -2,7 +2,7 @@
dict.h - dictionary functions
This file is part of the nss-pam-ldapd library.
- Copyright (C) 2007, 2008, 2009 Arthur de Jong
+ Copyright (C) 2007, 2008, 2009, 2010 Arthur de Jong
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -26,8 +26,7 @@
#include "compat/attrs.h"
/*
- These functions provide a mapping between a case insensitive
- string and a pointer.
+ These functions provide a mapping between a string and a pointer.
*/
typedef struct dictionary DICT;
@@ -40,17 +39,17 @@
and can be reused by the caller. The pointer is just stored.
This function returns non-0 in case of memory allocation
errors. If the key was previously in use the value
- is replaced. All key comparisons are case insensitive. */
+ is replaced. All key comparisons are case sensitive. */
int dict_put(DICT *dict,const char *key,void *value);
/* Look up a key in the dictionary and return the associated
value. NULL is returned if the key is not found in the dictionary.
- All key comparisons are case insensitive. */
+ All key comparisons are case sensitive. */
void *dict_get(DICT *dict,const char *key)
MUST_USE;
/* Delete a key-value association from the dictionary.
- All key comparisons are case insensitive. */
+ All key comparisons are case sensitive. */
/*void dict_del(DICT *dict,const char *key);*/
/* Remove the dictionary from memory. All allocated storage
Modified: nss-pam-ldapd/common/set.h
==============================================================================
--- nss-pam-ldapd/common/set.h Fri Oct 15 11:22:01 2010 (r1277)
+++ nss-pam-ldapd/common/set.h Fri Oct 15 12:21:35 2010 (r1278)
@@ -2,7 +2,7 @@
set.h - set functions
This file is part of the nss-pam-ldapd library.
- Copyright (C) 2008, 2009 Arthur de Jong
+ Copyright (C) 2008, 2009, 2010 Arthur de Jong
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -26,7 +26,7 @@
#include "compat/attrs.h"
/*
- These functions provide a set of string in an unordered
+ These functions provide a set of strings in an unordered
collection.
*/
typedef struct set SET;
@@ -39,11 +39,11 @@
/* Add a string in the set. The value is duplicated
and can be reused by the caller.
This function returns non-0 in case of memory allocation
- errors. All value comparisons are case insensitive. */
+ errors. All value comparisons are case sensitive. */
int set_add(SET *set,const char *value);
/* Return non-zero if the value is in the set.
- All value comparisons are case insensitive. */
+ All value comparisons are case sensitive. */
int set_contains(SET *set,const char *value)
MUST_USE;
Modified: nss-pam-ldapd/tests/test_dict.c
==============================================================================
--- nss-pam-ldapd/tests/test_dict.c Fri Oct 15 11:22:01 2010 (r1277)
+++ nss-pam-ldapd/tests/test_dict.c Fri Oct 15 12:21:35 2010 (r1278)
@@ -2,7 +2,7 @@
test_dict.c - simple test for the dict module
This file is part of the nss-pam-ldapd library.
- Copyright (C) 2007, 2008, 2009 Arthur de Jong
+ Copyright (C) 2007, 2008, 2009, 2010 Arthur de Jong
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -47,19 +47,21 @@
dict_put(dict,"key1",value1);
dict_put(dict,"key2",value2);
dict_put(dict,"key3",dict);
- dict_put(dict,"KEY2",replace2);
+ dict_put(dict,"key2",replace2);
/* check dictionary contents */
- val=dict_get(dict,"KeY1");
+ val=dict_get(dict,"key1");
assert(val==value1);
- val=dict_get(dict,"kEy2");
+ val=dict_get(dict,"key2");
assert(val==replace2);
- val=dict_get(dict,"KeY3");
+ val=dict_get(dict,"key3");
assert(val==dict);
val=dict_get(dict,"key4");
assert(val==NULL);
+ val=dict_get(dict,"KEY1");
+ assert(val==NULL);
/* remove a key */
- dict_put(dict,"kEy3",NULL);
- val=dict_get(dict,"keY3");
+ dict_put(dict,"key3",NULL);
+ val=dict_get(dict,"key3");
assert(val==NULL);
/* loop over dictionary contents */
keys=dict_keys(dict);
Modified: nss-pam-ldapd/tests/test_set.c
==============================================================================
--- nss-pam-ldapd/tests/test_set.c Fri Oct 15 11:22:01 2010 (r1277)
+++ nss-pam-ldapd/tests/test_set.c Fri Oct 15 12:21:35 2010 (r1278)
@@ -2,7 +2,7 @@
test_set.c - simple test for the set module
This file is part of the nss-pam-ldapd library.
- Copyright (C) 2008, 2009 Arthur de Jong
+ Copyright (C) 2008, 2009, 2010 Arthur de Jong
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -44,21 +44,22 @@
set_add(set,"key1");
set_add(set,"key2");
set_add(set,"key3");
- set_add(set,"KEY2");
+ set_add(set,"key2");
/* check set contents */
- assert(set_contains(set,"KeY1"));
- assert(set_contains(set,"kEy2"));
- assert(set_contains(set,"KeY3"));
+ assert(set_contains(set,"key1"));
+ assert(set_contains(set,"key2"));
+ assert(set_contains(set,"key3"));
assert(!set_contains(set,"key4"));
+ assert(!set_contains(set,"KEY1"));
/* loop over set contents */
list=set_tolist(set);
for (i=0;list[i]!=NULL;i++)
{
- assert( (strcasecmp(list[i],"key1")==0) ||
- (strcasecmp(list[i],"key2")==0) ||
- (strcasecmp(list[i],"key3")==0) );
+ assert( (strcmp(list[i],"key1")==0) ||
+ (strcmp(list[i],"key2")==0) ||
+ (strcmp(list[i],"key3")==0) );
}
/* free set */
--
To unsubscribe send an email to
nss-pam-ldapd-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/nss-pam-ldapd-commits
- nss-pam-ldapd commit: r1278 - in nss-pam-ldapd: common tests,
Commits of the nss-pam-ldapd project