1
0
Quellcode durchsuchen

Don't use internal clish/private.h in external headers

git-svn-id: https://klish.googlecode.com/svn/trunk@401 0eaa4687-2ee9-07dd-09d9-bcdd2d2dd5fb
Serj Kalichev vor 13 Jahren
Ursprung
Commit
dcfda01475
10 geänderte Dateien mit 31 neuen und 40 gelöschten Zeilen
  1. 7 7
      Makefile.in
  2. 0 1
      bin/konfd.c
  3. 2 2
      clish/command.h
  4. 4 4
      clish/command/command.c
  5. 1 0
      clish/module.am
  6. 2 2
      clish/param.h
  7. 3 3
      clish/param/param.c
  8. 0 9
      clish/private.h
  9. 10 10
      clish/shell/shell_help.c
  10. 2 2
      konf/tree/tree.c

+ 7 - 7
Makefile.in

@@ -666,13 +666,13 @@ AM_CXXFLAGS = -Wall $(DEBUG_CFLAGS)
 lib_LTLIBRARIES = libclish.la liblub.la $(am__append_2) libtinyrl.la \
 	libtinyxml.la libkonf.la
 lib_LIBRARIES = 
-nobase_include_HEADERS = clish/command.h clish/param.h clish/pargv.h \
-	clish/ptype.h clish/shell.h clish/variable.h clish/view.h \
-	clish/nspace.h clish/internal.h lub/argv.h lub/bintree.h \
-	lub/blockpool.h lub/ctype.h lub/dblockpool.h lub/c_decl.h \
-	lub/dump.h lub/heap.h lub/partition.h lub/string.h \
-	lub/size_fmt.h lub/test.h lub/types.h lub/system.h \
-	tinyrl/tinyrl.h tinyrl/history.h tinyrl/vt100.h \
+nobase_include_HEADERS = clish/types.h clish/command.h clish/param.h \
+	clish/pargv.h clish/ptype.h clish/shell.h clish/variable.h \
+	clish/view.h clish/nspace.h clish/internal.h lub/argv.h \
+	lub/bintree.h lub/blockpool.h lub/ctype.h lub/dblockpool.h \
+	lub/c_decl.h lub/dump.h lub/heap.h lub/partition.h \
+	lub/string.h lub/size_fmt.h lub/test.h lub/types.h \
+	lub/system.h tinyrl/tinyrl.h tinyrl/history.h tinyrl/vt100.h \
 	tinyxml/tinystr.h tinyxml/tinyxml.h konf/tree.h konf/query.h \
 	konf/buf.h konf/net.h
 EXTRA_DIST = bin/module.am clish/module.am lub/module.am \

+ 0 - 1
bin/konfd.c

@@ -35,7 +35,6 @@
 #endif
 
 #include "clish/internal.h"
-#include "clish/private.h"
 #include "konf/tree.h"
 #include "konf/query.h"
 #include "konf/buf.h"

+ 2 - 2
clish/command.h

@@ -8,10 +8,10 @@ typedef struct clish_command_s clish_command_t;
 
 #include "lub/bintree.h"
 #include "lub/argv.h"
+#include "clish/types.h"
 #include "clish/pargv.h"
 #include "clish/view.h"
 #include "clish/param.h"
-#include "clish/private.h"
 
 typedef enum {
 	CLISH_CONFIG_NONE,
@@ -44,7 +44,7 @@ clish_command_diff(const clish_command_t * cmd1, const clish_command_t * cmd2);
 void clish_command_delete(clish_command_t * instance);
 void
 clish_command_insert_param(clish_command_t * instance, clish_param_t * param);
-int clish_command_help(const clish_command_t * instance, help_argv_t *help,
+int clish_command_help(const clish_command_t * instance, clish_help_t *help,
 	const char *viewid, const char *line);
 void clish_command_dump(const clish_command_t * instance);
 

+ 4 - 4
clish/command/command.c

@@ -4,7 +4,7 @@
   * This file provides the implementation of a command definition  
   */
 #include "private.h"
-#include "clish/private.h"
+#include "clish/types.h"
 #include "clish/variable.h"
 #include "lub/bintree.h"
 #include "lub/string.h"
@@ -204,7 +204,7 @@ void clish_command_insert_param(clish_command_t * this, clish_param_t * param)
 }
 
 /*--------------------------------------------------------- */
-int clish_command_help(const clish_command_t * this, help_argv_t *help,
+int clish_command_help(const clish_command_t * this, clish_help_t *help,
 	const char * viewid, const char * line)
 {
 	const char *name = clish_command__get_name(this);
@@ -276,8 +276,8 @@ clish_command_t *clish_command_choose_longest(clish_command_t * cmd1,
 }
 
 /*--------------------------------------------------------- */
-int
-clish_command_diff(const clish_command_t * cmd1, const clish_command_t * cmd2)
+int clish_command_diff(const clish_command_t * cmd1,
+	const clish_command_t * cmd2)
 {
 	if (NULL == cmd1) {
 		if (NULL != cmd2)

+ 1 - 0
clish/module.am

@@ -15,6 +15,7 @@ libclish_la_LIBADD = \
 	libkonf.la
 
 nobase_include_HEADERS += \
+	clish/types.h \
 	clish/command.h \
 	clish/param.h \
 	clish/pargv.h \

+ 2 - 2
clish/param.h

@@ -18,9 +18,9 @@ the arguments which a user is inputing for a command.
 typedef struct clish_paramv_s clish_paramv_t;
 typedef struct clish_param_s clish_param_t;
 
+#include "clish/types.h"
 #include "clish/ptype.h"
 #include "clish/pargv.h"
-#include "clish/private.h"
 
 /**
  * The means by which the param is interpreted.
@@ -54,7 +54,7 @@ clish_param_t *clish_param_new(const char *name,
  * methods
  *----------------- */
 void clish_param_delete(clish_param_t * instance);
-void clish_param_help(const clish_param_t * instance, help_argv_t *help);
+void clish_param_help(const clish_param_t * instance, clish_help_t *help);
 void clish_param_help_arrow(const clish_param_t * instance, size_t offset);
 char *clish_param_validate(const clish_param_t * instance, const char *text);
 void clish_param_dump(const clish_param_t * instance);

+ 3 - 3
clish/param/param.c

@@ -5,8 +5,8 @@
  */
 #include "private.h"
 #include "lub/string.h"
+#include "clish/types.h"
 #include "clish/variable.h"
-#include "clish/private.h"
 
 #include <assert.h>
 #include <stdlib.h>
@@ -147,7 +147,7 @@ char *clish_param_validate(const clish_param_t * this, const char *text)
 }
 
 /*--------------------------------------------------------- */
-void clish_param_help(const clish_param_t * this, help_argv_t *help)
+void clish_param_help(const clish_param_t * this, clish_help_t *help)
 {
 	const char *range = clish_ptype__get_range(this->ptype);
 	const char *name;
@@ -179,7 +179,7 @@ void clish_param_help(const clish_param_t * this, help_argv_t *help)
 		lub_string_cat(&str, range);
 		lub_string_cat(&str, ")");
 	}
-	lub_argv_add(help->matches, name);
+	lub_argv_add(help->name, name);
 	lub_argv_add(help->help, str);
 	lub_string_free(str);
 	lub_argv_add(help->detail, NULL);

+ 0 - 9
clish/private.h

@@ -6,14 +6,5 @@
 #define _clish_private_h
 
 #include "lub/c_decl.h"
-#include "lub/argv.h"
-/*#include "clish/internal.h"*/
-
-struct help_argv_s {
-	lub_argv_t *matches;
-	lub_argv_t *help;
-	lub_argv_t *detail;
-};
-typedef struct help_argv_s help_argv_t;
 
 #endif /* _clish_private_h */

+ 10 - 10
clish/shell/shell_help.c

@@ -2,7 +2,7 @@
  * shell_help.c
  */
 #include "private.h"
-#include "clish/private.h"
+#include "clish/types.h"
 #include "lub/string.h"
 
 #include <stdio.h>
@@ -14,7 +14,7 @@
  * Provide a detailed list of the possible command completions
  */
 static int available_commands(clish_shell_t * this,
-	help_argv_t *help, const char *line)
+	clish_help_t *help, const char *line)
 {
 	size_t max_width = 0;
 	const clish_command_t *cmd;
@@ -28,7 +28,7 @@ static int available_commands(clish_shell_t * this,
 		width = strlen(name);
 		if (width > max_width)
 			max_width = width;
-		lub_argv_add(help->matches, name);
+		lub_argv_add(help->name, name);
 		lub_argv_add(help->help, clish_command__get_text(cmd));
 		lub_argv_add(help->detail, clish_command__get_detail(cmd));
 	}
@@ -39,12 +39,12 @@ static int available_commands(clish_shell_t * this,
 /*--------------------------------------------------------- */
 void clish_shell_help(clish_shell_t *this, const char *line)
 {
-	help_argv_t help;
+	clish_help_t help;
 	size_t max_width = 0;
 	const clish_command_t *cmd;
 	int i;
 
-	help.matches = lub_argv_new(NULL, 0);
+	help.name = lub_argv_new(NULL, 0);
 	help.help = lub_argv_new(NULL, 0);
 	help.detail = lub_argv_new(NULL, 0);
 
@@ -60,18 +60,18 @@ void clish_shell_help(clish_shell_t *this, const char *line)
 		if (width > max_width)
 			max_width = width;
 	}
-	if (lub_argv__get_count(help.matches) == 0)
+	if (lub_argv__get_count(help.name) == 0)
 		goto end;
 
 	/* Print help messages */
-	for (i = 0; i < lub_argv__get_count(help.matches); i++) {
+	for (i = 0; i < lub_argv__get_count(help.name); i++) {
 		fprintf(stderr, "  %-*s  %s\n", (int)max_width,
-			lub_argv__get_arg(help.matches, i),
+			lub_argv__get_arg(help.name, i),
 			lub_argv__get_arg(help.help, i));
 	}
 
 	/* Print details */
-	if ((lub_argv__get_count(help.matches) == 1) &&
+	if ((lub_argv__get_count(help.name) == 1) &&
 		(SHELL_STATE_HELPING == this->state)) {
 		const char *detail = lub_argv__get_arg(help.detail, 0);
 		if (detail)
@@ -85,7 +85,7 @@ void clish_shell_help(clish_shell_t *this, const char *line)
 		this->state = SHELL_STATE_HELPING;
 
 end:
-	lub_argv_delete(help.matches);
+	lub_argv_delete(help.name);
 	lub_argv_delete(help.help);
 	lub_argv_delete(help.detail);
 }

+ 2 - 2
konf/tree/tree.c

@@ -311,8 +311,6 @@ int konf_tree_del_pattern(konf_tree_t *this,
 	/* Iterate configuration tree */
 	lub_bintree_iterator_init(&iter, &this->tree, conf);
 	do {
-		if (0 != regexec(&regexp, conf->line, 0, NULL, 0))
-			continue;
 		if ((0 != priority) &&
 			(priority != conf->priority))
 			continue;
@@ -321,6 +319,8 @@ int konf_tree_del_pattern(konf_tree_t *this,
 			continue;
 		if (seq && (0 == seq_num) && (0 == conf->seq_num))
 			continue;
+		if (0 != regexec(&regexp, conf->line, 0, NULL, 0))
+			continue;
 		lub_bintree_remove(&this->tree, conf);
 		konf_tree_delete(conf);
 		del_cnt++;