Imported Upstream version 0.60.8
[platform/upstream/aspell.git] / lib / find_speller.cpp
index 3ea469c..d83c738 100644 (file)
@@ -283,7 +283,7 @@ namespace acommon {
 
   PosibErr<Config *> find_word_list(Config * c) 
   {
-    Config * config = new_config();
+    StackPtr<Config> config(new_config());
     RET_ON_ERR(config->read_in_settings(c));
     String dict_name;
 
@@ -365,7 +365,8 @@ namespace acommon {
       else if (config->have("module-search-order"))
         config->retrieve_list("module-search-order", &b_module.list);
       {
-        StackPtr<ModuleInfoEnumeration> els(get_module_info_list(config)->elements());
+        RET_ON_ERR_SET(get_module_info_list(config), const ModuleInfoList *, modules);
+        StackPtr<ModuleInfoEnumeration> els(modules->elements());
         const ModuleInfo * entry;
         while ( (entry = els->next()) != 0)
           b_module.list.add(entry->name);
@@ -384,7 +385,7 @@ namespace acommon {
         b_size.req_type = '+';
       }
       if (!asc_isdigit(p[0]) || !asc_isdigit(p[1]) || p[2] != '\0')
-        abort(); //FIXME: create an error condition here
+        return make_err(aerror_bad_value, "size", str, "valid");
       b_size.requested = atoi(p);
       b_size.init();
 
@@ -429,11 +430,7 @@ namespace acommon {
       //
       if (best != 0) {
         String main_wl,flags;
-        PosibErrBase ret = get_dict_file_name(best, main_wl, flags);
-        if (ret.has_err()) {
-          delete config;
-          return ret;
-        }
+        RET_ON_ERR(get_dict_file_name(best, main_wl, flags));
         dict_name = best->name;
         config->replace("lang", b_code.best);
         config->replace("language-tag", b_code.best);
@@ -449,7 +446,6 @@ namespace acommon {
         }
         config->replace("size", b_size.best_str);
       } else {
-        delete config;
         return make_err(no_wordlist_for_lang, code);
       }
     }
@@ -457,7 +453,7 @@ namespace acommon {
     const StringMap * dict_aliases = get_dict_aliases(config);
     const char * val = dict_aliases->lookup(dict_name);
     if (val) config->replace("master", val);
-    return config;
+    return config.release();
   }
 
   PosibErr<void> reload_filters(Speller * m)