Enlightenment CVS committal

Author  : tsauerbeck
Project : e17
Module  : libs/edje

Dir     : e17/libs/edje/src/bin


Modified Files:
        edje_cc_sources.c 


Log Message:
fixed edc source inclusion in edje_source edd.
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/edje/src/bin/edje_cc_sources.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- edje_cc_sources.c   25 Oct 2004 17:47:16 -0000      1.9
+++ edje_cc_sources.c   25 Oct 2004 19:09:39 -0000      1.10
@@ -61,27 +61,28 @@
 {
    FILE *f;
    char buf[256 * 1024];
+   long sz;
+   SrcFile *sf;
    
    f = fopen(fil, "rb");
    if (!f)
-     return;
-   else
      {
-       long sz;
-       SrcFile *sf;
-       
-       fseek(f, 0, SEEK_END);
-       sz = ftell(f);
-       fseek(f, 0, SEEK_SET);
-       sf = mem_alloc(SZ(SrcFile));
-       sf->name = mem_strdup(filname);
-       sf->file = mem_alloc(sz + 1);
-       fread(sf->file, sz, 1, f);
-       sf->file[sz] = '\0';
-       fseek(f, 0, SEEK_SET);
-       srcfiles.list = evas_list_append(srcfiles.list, sf);
-    }
-   
+       fprintf(stderr, "%s: Warning. Cannot open file '%s'\n",
+             progname, fil);
+       exit(-1);
+     }
+
+   fseek(f, 0, SEEK_END);
+   sz = ftell(f);
+   fseek(f, 0, SEEK_SET);
+   sf = mem_alloc(SZ(SrcFile));
+   sf->name = mem_strdup(filname);
+   sf->file = mem_alloc(sz + 1);
+   fread(sf->file, sz, 1, f);
+   sf->file[sz] = '\0';
+   fseek(f, 0, SEEK_SET);
+   srcfiles.list = evas_list_append(srcfiles.list, sf);
+
    while (fgets(buf, sizeof(buf), f))
      {
        char *p = buf, *pp;
@@ -103,60 +104,71 @@
                    }
                  p++;
               }
-            else
+
+            if (!haveinclude)
               {
-                 if (!haveinclude)
+                 if (!isspace(*p))
                    {
-                      if (!isspace(*p))
+                      if (!strncmp(p, "include", 7))
                         {
-                           if (!strncmp(p, "include", 7))
-                             {
-                                haveinclude = 1;
-                                p += 7;
-                             }
-                           else
-                             forgetit = 1;
+                           haveinclude = 1;
+                           p += 7;
                         }
+                      else
+                        forgetit = 1;
                    }
-                 else
+              }
+            else
+              {
+                 if (!isspace(*p))
                    {
-                      if (!isspace(*p))
+                      char end = '\0';
+
+                      if (*p == '"')
+                           end = '"';
+                      else if (*p == '<')
+                           end = '>';
+
+                      if (end)
                         {
-                           if (*p == '"')
+                           pp = strchr(p + 1, end);
+                           if (!pp)
+                             forgetit = 1;
+                           else
                              {
-                                pp = strchr(p + 1, '"');
-                                if (!pp)
-                                  forgetit = 1;
-                                else
+                                char *slash, *dir = NULL;
+                                ssize_t dir_len = 0, l = 0;
+
+                                /* get the directory of the current file */
+                                if (strrchr (filname, '/'))
                                   {
-                                     file = mem_alloc(pp - p);
-                                     strncpy(file, p + 1, pp - p - 1);
-                                     file[pp - p - 1] = 0;
-                                     forgetit = 1;
+                                     dir = mem_strdup(filname);
+                                     slash = strrchr (dir, '/');
+                                     *slash = '\0';
+                                     dir_len = strlen (dir);
+                                     l++; /* one extra char for the delimiter */
                                   }
-                             }
-                           else if (*p == '<')
-                             {
-                                pp = strchr(p + 1, '>');
-                                if (!pp)
-                                  forgetit = 1;
+
+                                l += pp - p + dir_len;
+                                file = mem_alloc(l);
+
+                                if (!dir_len)
+                                  snprintf(file, l, "%s", p + 1);
                                 else
-                                  {
-                                     file = mem_alloc(pp - p);
-                                     strncpy(file, p + 1, pp - p - 1);
-                                     file[pp - p - 1] = 0;
-                                     forgetit = 1;
-                                  }
+                                  snprintf(file, l, "%s/%s", dir, p + 1);
+
+                                free (dir);
+                                forgetit = 1;
                              }
-                           else
-                             forgetit = 1;
                         }
                       else
-                        p++;
+                        forgetit = 1;
                    }
-
-                 got_hash = 0;
+                 else
+                   p++;
               }
+
+            got_hash = 0;
          }
        if (file)
          {




-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to