summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Woodward2005-02-16 15:01:07 +0000
committerJason Woodward2005-02-16 15:01:07 +0000
commitb35d8c2ba530c055f4b31d2ebf2a645ce62c412a (patch)
treeca4bf38fed21d9dd0495b73e0d8a9d4894883a56 /src
parent5afcf678e0a577dbe8b8ef90c595e3071593b8a3 (diff)
downloadslapt-get-b35d8c2ba530c055f4b31d2ebf2a645ce62c412a.tar.gz
init_regex now returns on failure
Diffstat (limited to 'src')
-rw-r--r--src/common.c5
-rw-r--r--src/common.h2
-rw-r--r--src/package.c8
3 files changed, 9 insertions, 6 deletions
diff --git a/src/common.c b/src/common.c
index 43a3b3f..d7f5a2d 100644
--- a/src/common.c
+++ b/src/common.c
@@ -32,7 +32,7 @@ FILE *open_file(const char *file_name,const char *mode){
}
/* initialize regex structure and compilie the regular expression */
-void init_regex(sg_regex *regex_t, const char *regex_string){
+int init_regex(sg_regex *regex_t, const char *regex_string){
regex_t->nmatch = MAX_REGEX_PARTS;
@@ -47,9 +47,10 @@ void init_regex(sg_regex *regex_t, const char *regex_string){
if( (regerror_size = regerror(regex_t->reg_return, &regex_t->regex,errbuf,errbuf_size)) ){
printf(_("Regex Error: %s\n"),errbuf);
}
- exit(1);
+ return -1;
}
+ return 0;
}
/*
diff --git a/src/common.h b/src/common.h
index 1fab134..fd738fb 100644
--- a/src/common.h
+++ b/src/common.h
@@ -37,7 +37,7 @@ typedef struct {
FILE *open_file(const char *file_name,const char *mode);
-void init_regex(sg_regex *regex_t, const char *regex_string);
+int init_regex(sg_regex *regex_t, const char *regex_string);
void execute_regex(sg_regex *regex_t,const char *string);
void free_regex(sg_regex *regex_t);
void create_dir_structure(const char *dir_name);
diff --git a/src/package.c b/src/package.c
index 5a6f19b..d1dcad5 100644
--- a/src/package.c
+++ b/src/package.c
@@ -682,7 +682,8 @@ int is_excluded(const rc_config *global_config,pkg_info_t *pkg){
this regex has to be init'd and free'd within the loop b/c the regex is pulled
from the exclude list
*/
- init_regex(&exclude_reg,global_config->exclude_list->excludes[i]);
+ if( init_regex(&exclude_reg,global_config->exclude_list->excludes[i]) == -1 )
+ continue;
execute_regex(&exclude_reg,pkg->name);
name_reg_ret = exclude_reg.reg_return;
@@ -1007,10 +1008,11 @@ struct pkg_list *search_pkg_list(struct pkg_list *available,const char *pattern)
sg_regex search_regex;
struct pkg_list *matches;
- init_regex(&search_regex,pattern);
-
matches = init_pkg_list();
+ if( init_regex(&search_regex,pattern) == -1 )
+ return matches;
+
for(i = 0; i < available->pkg_count; i++ ){
execute_regex(&search_regex,available->pkgs[i]->name);