Enlightenment CVS committal

Author  : sebastid
Project : e17
Module  : libs/ecore

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


Modified Files:
        ecore_desktop.c 


Log Message:
Return immediatly on error.

===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_desktop/ecore_desktop.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -3 -r1.38 -r1.39
--- ecore_desktop.c     22 Sep 2006 14:55:43 -0000      1.38
+++ ecore_desktop.c     23 Sep 2006 08:05:23 -0000      1.39
@@ -46,102 +46,100 @@
 ecore_desktop_ini_get(const char *file)
 {
    Ecore_Hash         *result;
+   FILE               *f;
+   char                buffer[PATH_MAX];
+   Ecore_Hash         *current = NULL;
 
    result = ecore_hash_new(ecore_str_hash, ecore_str_compare);
-   if (result)
-     {
-       FILE               *f;
-       char                buffer[PATH_MAX];
-       Ecore_Hash         *current = NULL;
+   if (!result) NULL;
 
-       f = fopen(file, "r");
-       if (!f)
-         {
-            fprintf(stderr, "ERROR: Cannot Open File %s\n", file);
-            ecore_hash_destroy(result);
-            return NULL;
-         }
-       ecore_hash_set_free_key(result, free);
-       ecore_hash_set_free_value(result, (Ecore_Free_Cb) ecore_hash_destroy);
-       *buffer = '\0';
+   f = fopen(file, "r");
+   if (!f)
+     {
+       fprintf(stderr, "ERROR: Cannot Open File %s\n", file);
+       ecore_hash_destroy(result);
+       return NULL;
+     }
+   ecore_hash_set_free_key(result, free);
+   ecore_hash_set_free_value(result, (Ecore_Free_Cb) ecore_hash_destroy);
+   *buffer = '\0';
 #ifdef DEBUG
-       fprintf(stdout, "PARSING INI %s\n", file);
+   fprintf(stdout, "PARSING INI %s\n", file);
 #endif
-       while (fgets(buffer, sizeof(buffer), f) != NULL)
+   while (fgets(buffer, sizeof(buffer), f) != NULL)
+     {
+       char               *c;
+       char               *key;
+       char               *value;
+
+       c = buffer;
+       /* Strip preceeding blanks. */
+       while (((*c == ' ') || (*c == '\t')) && (*c != '\n')
+             && (*c != '\0'))
+         c++;
+       /* Skip blank lines and comments */
+       if ((*c == '\0') || (*c == '\n') || (*c == '#'))
+         continue;
+       if (*c == '[')  /* New group. */
          {
-            char               *c;
-            char               *key;
-            char               *value;
-
-            c = buffer;
-            /* Strip preceeding blanks. */
-            while (((*c == ' ') || (*c == '\t')) && (*c != '\n')
-                   && (*c != '\0'))
-               c++;
-            /* Skip blank lines and comments */
-            if ((*c == '\0') || (*c == '\n') || (*c == '#'))
-               continue;
-            if (*c == '[')     /* New group. */
+            key = c + 1;
+            while ((*c != ']') && (*c != '\n') && (*c != '\0'))
+              c++;
+            *c++ = '\0';
+            current = ecore_hash_new(ecore_str_hash, ecore_str_compare);
+            if (current)
               {
-                 key = c + 1;
-                 while ((*c != ']') && (*c != '\n') && (*c != '\0'))
-                    c++;
-                 *c++ = '\0';
-                 current = ecore_hash_new(ecore_str_hash, ecore_str_compare);
-                 if (current)
-                   {
-                      ecore_hash_set_free_key(current, free);
-                      ecore_hash_set_free_value(current, free);
-                      ecore_hash_set(result, strdup(key), current);
+                 ecore_hash_set_free_key(current, free);
+                 ecore_hash_set_free_value(current, free);
+                 ecore_hash_set(result, strdup(key), current);
 #ifdef DEBUG
-                      fprintf(stdout, "  GROUP [%s]\n", key);
+                 fprintf(stdout, "  GROUP [%s]\n", key);
 #endif
-                   }
               }
-            else if (current)  /* key=value pair of current group. */
-              {
-                 char               *tv;
+         }
+       else if (current)       /* key=value pair of current group. */
+         {
+            char               *tv;
 
-                 key = c;
-                 /* Find trailing blanks or =. */
-                 while ((*c != '=') && (*c != ' ') && (*c != '\t')
-                        && (*c != '\n') && (*c != '\0'))
-                    c++;
-                 if (*c != '=')        /* Find equals. */
-                   {
-                      *c++ = '\0';
-                      while ((*c != '=') && (*c != '\n') && (*c != '\0'))
-                         c++;
-                   }
-                 if (*c == '=')        /* Equals found. */
-                   {
-                      *c++ = '\0';
-                      /* Strip preceeding blanks. */
-                      while (((*c == ' ') || (*c == '\t')) && (*c != '\n')
-                             && (*c != '\0'))
-                         c++;
-                      value = c;
-                      /* Find end. */
-                      while ((*c != '\n') && (*c != '\0'))
-                         c++;
-                      *c++ = '\0';
-                      /* FIXME: should strip space at end, then unescape 
value. */
-                      tv = ecore_hash_remove(current, key);
-                      if (tv)
-                         free(tv);
-                      if (value[0] != '\0')
-                         ecore_hash_set(current, strdup(key), strdup(value));
+            key = c;
+            /* Find trailing blanks or =. */
+            while ((*c != '=') && (*c != ' ') && (*c != '\t')
+                  && (*c != '\n') && (*c != '\0'))
+              c++;
+            if (*c != '=')     /* Find equals. */
+              {
+                 *c++ = '\0';
+                 while ((*c != '=') && (*c != '\n') && (*c != '\0'))
+                   c++;
+              }
+            if (*c == '=')     /* Equals found. */
+              {
+                 *c++ = '\0';
+                 /* Strip preceeding blanks. */
+                 while (((*c == ' ') || (*c == '\t')) && (*c != '\n')
+                       && (*c != '\0'))
+                   c++;
+                 value = c;
+                 /* Find end. */
+                 while ((*c != '\n') && (*c != '\0'))
+                   c++;
+                 *c++ = '\0';
+                 /* FIXME: should strip space at end, then unescape value. */
+                 tv = ecore_hash_remove(current, key);
+                 if (tv)
+                   free(tv);
+                 if (value[0] != '\0')
+                   ecore_hash_set(current, strdup(key), strdup(value));
 #ifdef DEBUG
-                      fprintf(stdout, "    %s=%s\n", key, value);
+                 fprintf(stdout, "    %s=%s\n", key, value);
 #endif
-                   }
               }
-
          }
-       buffer[0] = (char)0;
 
-       fclose(f);
      }
+   buffer[0] = (char)0;
+
+   fclose(f);
    return result;
 }
 



-------------------------------------------------------------------------
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