Enlightenment CVS committal

Author  : sebastid
Project : e17
Module  : libs/ecore

Dir     : e17/libs/ecore/src/lib/ecore_desktop


Modified Files:
        ecore_desktop_paths.c 


Log Message:
Bail early on error.
Fix nested if.

===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_desktop/ecore_desktop_paths.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -3 -r1.28 -r1.29
--- ecore_desktop_paths.c       23 Sep 2006 09:33:34 -0000      1.28
+++ ecore_desktop_paths.c       23 Sep 2006 09:36:59 -0000      1.29
@@ -381,11 +381,8 @@
        if (stat(temp, &path_stat) == 0)
          {
             path = strdup(temp);
-            if (func)
-              {
-                 if (func(data, temp))
-                   break;
-              }
+            if ((func) && (func(data, temp)))
+              break;
          }
        else if (sub != 0)
          path =
@@ -698,67 +695,60 @@
 {
    char               *fpath = NULL;
    DIR                *dir = NULL;
+   struct dirent      *script;
 
    if ((sub != 0) && (sub != -1))
       sub -= 1;
 
    dir = opendir(path);
+   if (!dir) return NULL;
 
-   if (dir != NULL)
+   while ((script = readdir(dir)) != NULL)
      {
-       struct dirent      *script;
+       struct stat         script_stat;
+       char                info_text[PATH_MAX];
 
-       while ((script = readdir(dir)) != NULL)
+       sprintf(info_text, "%s%s", path, script->d_name);
+       if ((stat(info_text, &script_stat) == 0))
          {
-            struct stat         script_stat;
-            char                info_text[PATH_MAX];
-
-            sprintf(info_text, "%s%s", path, script->d_name);
-            if ((stat(info_text, &script_stat) == 0))
+            if (S_ISDIR(script_stat.st_mode))
               {
-                 if (S_ISDIR(script_stat.st_mode))
+                 if ((strcmp(basename(info_text), ".") != 0) &&
+                     (strcmp(basename(info_text), "..") != 0))
                    {
-                      if ((strcmp(basename(info_text), ".") != 0)
-                          && (strcmp(basename(info_text), "..") != 0))
+                      snprintf(info_text, PATH_MAX, "%s%s/", path, 
script->d_name);
+                      if ((dir_func) && (dir_func(data, info_text)))
+                          break;
+                      if (sub != 0)
+                        fpath =
+                           ecore_desktop_paths_recursive_search(info_text, 
file, sub,
+                                                                dir_func, 
func, data);
+                   }
+              }
+            else
+              {
+                 if (file)
+                   {
+                      if (strcmp(basename(info_text), file) == 0)
                         {
-                           snprintf(info_text, PATH_MAX, "%s%s/", path,
-                                    script->d_name);
-                           if (dir_func)
-                              if (dir_func(data, info_text))
-                                 break;
-                           if (sub != 0)
-                              fpath =
-                                 ecore_desktop_paths_recursive_search
-                                 (info_text, file, sub, dir_func, func, data);
+                           if (fpath)
+                             free(fpath);
+                           fpath = strdup(info_text);
+                           if ((func) && (func(data, path)))
+                               break;
                         }
                    }
                  else
                    {
-                      if (file)
-                        {
-                           if (strcmp(basename(info_text), file) == 0)
-                             {
-                                if (fpath)
-                                   free(fpath);
-                                fpath = strdup(info_text);
-                                if (func)
-                                   if (func(data, path))
-                                      break;
-                             }
-                        }
-                      else
-                        {
-                           if (func)
-                              if (func(data, info_text))
-                                 break;
-                        }
+                      if ((func) && (func(data, info_text)))
+                          break;
                    }
-                 if (fpath && (!func))
-                    break;
               }
+            if (fpath && (!func))
+              break;
          }
-       closedir(dir);
      }
+   closedir(dir);
 
    return fpath;
 }



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to