Browse Source

Case sensibility konfd

git-svn-id: https://klish.googlecode.com/svn/trunk@556 0eaa4687-2ee9-07dd-09d9-bcdd2d2dd5fb
Serj Kalichev 12 years ago
parent
commit
db8902279a
5 changed files with 3 additions and 23 deletions
  1. 0 1
      konf/query.h
  2. 0 1
      konf/query/private.h
  3. 0 9
      konf/query/query.c
  4. 0 1
      konf/tree/private.h
  5. 3 11
      konf/tree/tree.c

+ 0 - 1
konf/query.h

@@ -28,7 +28,6 @@ konf_query_op_t konf_query__get_op(konf_query_t *instance);
 char * konf_query__get_path(konf_query_t *instance);
 const char * konf_query__get_pattern(konf_query_t *instance);
 const char * konf_query__get_line(konf_query_t *instance);
-const char * konf_query__get_lower_line(konf_query_t *instance);
 unsigned short konf_query__get_priority(konf_query_t *instance);
 bool_t konf_query__get_splitter(konf_query_t *instance);
 bool_t konf_query__get_seq(konf_query_t *instance);

+ 0 - 1
konf/query/private.h

@@ -13,7 +13,6 @@ struct konf_query_s {
 	unsigned int pwdc;
 	char **pwd;
 	char *line;
-	char *lower_line;
 	char *path;
 	bool_t splitter;
 	bool_t unique;

+ 0 - 9
konf/query/query.c

@@ -35,7 +35,6 @@ konf_query_t *konf_query_new(void)
 	this->pwdc = 0;
 	this->pwd = NULL;
 	this->line = NULL;
-	this->lower_line = NULL;
 	this->path = NULL;
 	this->splitter = BOOL_TRUE;
 	this->unique = BOOL_TRUE;
@@ -70,7 +69,6 @@ void konf_query_free(konf_query_t *this)
 
 	free(this->pattern);
 	free(this->line);
-	free(this->lower_line);
 	free(this->path);
 	if (this->pwdc > 0) {
 		for (i = 0; i < this->pwdc; i++)
@@ -170,7 +168,6 @@ int konf_query_parse(konf_query_t *this, int argc, char **argv)
 			break;
 		case 'l':
 			this->line = strdup(optarg);
-			this->lower_line = lub_string_tolower(optarg);
 			break;
 		case 'f':
 			this->path = strdup(optarg);
@@ -281,12 +278,6 @@ const char * konf_query__get_line(konf_query_t *this)
 	return this->line;
 }
 
-/*-------------------------------------------------------- */
-const char * konf_query__get_lower_line(konf_query_t *this)
-{
-	return this->lower_line;
-}
-
 /*-------------------------------------------------------- */
 unsigned short konf_query__get_priority(konf_query_t *this)
 {

+ 0 - 1
konf/tree/private.h

@@ -14,7 +14,6 @@
 struct konf_tree_s {
 	lub_list_t *list;
 	char *line;
-	char *lower_line;
 	unsigned short priority;
 	unsigned short seq_num;
 	unsigned short sub_num;

+ 3 - 11
konf/tree/tree.c

@@ -34,7 +34,7 @@ static int konf_tree_compare(const void *first, const void *second)
 	if (f->sub_num != s->sub_num)
 		return (f->sub_num - s->sub_num);
 	/* Line check */
-	return strcmp(f->lower_line, s->lower_line);
+	return strcmp(f->line, s->line);
 }
 
 /*---------------------------------------------------------
@@ -45,7 +45,6 @@ static void konf_tree_init(konf_tree_t * this, const char *line,
 {
 	/* set up defaults */
 	this->line = strdup(line);
-	this->lower_line = lub_string_tolower(line);
 	this->priority = priority;
 	this->seq_num = 0;
 	this->sub_num = KONF_ENTRY_OK;
@@ -75,8 +74,6 @@ static void konf_tree_fini(konf_tree_t * this)
 	/* free our memory */
 	free(this->line);
 	this->line = NULL;
-	free(this->lower_line);
-	this->lower_line = NULL;
 }
 
 /*---------------------------------------------------------
@@ -227,7 +224,6 @@ konf_tree_t *konf_tree_find_conf(konf_tree_t * this,
 	konf_tree_t *conf;
 	lub_list_node_t *iter;
 	int check_pri = 0;
-	char *lower_line;
 
 	/* If list is empty */
 	if (!(iter = lub_list__get_tail(this->list)))
@@ -236,7 +232,6 @@ konf_tree_t *konf_tree_find_conf(konf_tree_t * this,
 	if ((0 != priority) && (0 != seq_num))
 		check_pri = 1;
 	/* Iterate non-empty tree */
-	lower_line = lub_string_tolower(line);
 	do {
 		conf = (konf_tree_t *)lub_list_node__get_data(iter);
 		if (check_pri) {
@@ -249,12 +244,9 @@ konf_tree_t *konf_tree_find_conf(konf_tree_t * this,
 			if (seq_num > conf->seq_num)
 				break;
 		}
-		if (!strcmp(conf->lower_line, lower_line)) {
-			free(lower_line);
+		if (!strcmp(conf->line, line))
 			return conf;
-		}
 	} while ((iter = lub_list_node__get_prev(iter)));
-	free(lower_line);
 
 	return NULL;
 }
@@ -297,7 +289,7 @@ int konf_tree_del_pattern(konf_tree_t *this,
 			continue;
 		if (0 != regexec(&regexp, conf->line, 0, NULL, 0))
 			continue;
-		if (unique && line && !strcmp(conf->lower_line, line)) {
+		if (unique && line && !strcmp(conf->line, line)) {
 			res++;
 			continue;
 		}