[Pkg-e-devel] Bug#535771: edje: FTBFS on hurd-i386

Manuel Menal mmenal at hurdfr.org
Sat Jul 4 21:13:32 UTC 2009


Package: edje
Severity: important
Tags: patch
Justification: fails to build from source

Hi,

edje uses the PATH_MAX constant, which is optional according to POSIX, and undefined on GNU/Hurd.
I have attached a patch that uses dynamic allocation when PATH_MAX is undefined.


diff -urp edje-0.9.92.060/src/bin/edje_cc.c ../edje-0.9.92.060/src/bin/edje_cc.c
--- edje-0.9.92.060/src/bin/edje_cc.c	2008-10-26 23:42:09.000000000 +0100
+++ ../edje-0.9.92.060/src/bin/edje_cc.c	2009-06-24 14:41:08.000000000 +0200
@@ -52,7 +52,9 @@ main(int argc, char **argv)
 {
    int i;
    struct stat st;
+#if defined(HAVE_REALPATH) && defined(PATH_MAX)
    char rpath[PATH_MAX], rpath2[PATH_MAX];
+#endif
 
    setlocale(LC_NUMERIC, "C");
 
@@ -130,7 +132,7 @@ main(int argc, char **argv)
    e_prefix_determine(argv[0]);
 
    /* check whether file_in exists */
-#ifdef HAVE_REALPATH
+#if defined(HAVE_REALPATH) && defined(PATH_MAX)
    if (!realpath(file_in, rpath) || stat(rpath, &st) || !S_ISREG(st.st_mode))
 #else
    if (stat(file_in, &st) || !S_ISREG(st.st_mode))
@@ -162,7 +164,7 @@ main(int argc, char **argv)
 	exit(-1);
      }
 
-#ifdef HAVE_REALPATH
+#if defined(HAVE_REALPATH) && defined(PATH_MAX)
    if (realpath(file_out, rpath2) && !strcmp (rpath, rpath2))
 #else
    if (!strcmp (file_in, file_out))
diff -urp edje-0.9.92.060/src/bin/edje_cc_out.c ../edje-0.9.92.060/src/bin/edje_cc_out.c
--- edje-0.9.92.060/src/bin/edje_cc_out.c	2009-02-26 04:13:15.000000000 +0100
+++ ../edje-0.9.92.060/src/bin/edje_cc_out.c	2009-06-24 11:03:32.000000000 +0200
@@ -773,8 +773,10 @@ data_write_scripts(Eet_File *ef)
 	if ((!cd->shared) && (!cd->programs))
 	  continue;
 
-	char tmpn[4096];
-	snprintf(tmpn, PATH_MAX, "%s/edje_cc.sma-tmp-XXXXXX", tmpdir);
+	char *tmpsuff = "edje_cc.sma-tmp-XXXXXX";
+	int tmplen = strlen(tmpdir) + 1 + strlen(tmpsuff) + 1;
+	char *tmpn = malloc (tmplen);
+	snprintf(tmpn, tmplen, "%s/edje_cc.sma-tmp-XXXXXX", tmpdir, tmpsuff);
 	fd = mkstemp(tmpn);
 	if (fd < 0)
 	  error_and_abort(ef, "Unable to open temp file \"%s\" for script "
@@ -783,8 +785,10 @@ data_write_scripts(Eet_File *ef)
 	create_script_file(ef, tmpn, cd);
 	close(fd);
 
-	char tmpo[4096];
-	snprintf(tmpo, PATH_MAX, "%s/edje_cc.amx-tmp-XXXXXX", tmpdir);
+	tmpsuff = "edje_cc.amx-tmp-XXXXXX";
+	tmplen = strlen(tmpdir) + 1 + strlen(tmpsuff) + 1;
+	char *tmpo = malloc(tmplen);
+	snprintf(tmpo, tmplen, "%s/%s", tmpdir, tmpsuff);
 	fd = mkstemp(tmpo);
 	if (fd < 0)
 	  {
@@ -797,7 +801,9 @@ data_write_scripts(Eet_File *ef)
 	close(fd);
 
 	unlink(tmpn);
+	free(tmpn);
 	unlink(tmpo);
+	free(tmpo);
      }
 }
 
diff -urp edje-0.9.92.060/src/bin/edje_cc_parse.c ../edje-0.9.92.060/src/bin/edje_cc_parse.c
--- edje-0.9.92.060/src/bin/edje_cc_parse.c	2009-02-26 04:13:15.000000000 +0100
+++ ../edje-0.9.92.060/src/bin/edje_cc_parse.c	2009-06-24 11:07:23.000000000 +0200
@@ -637,11 +637,12 @@ compile(void)
 {
    char buf[4096];
    char inc[4096];
-   static char tmpn[4096];
+   static char *tmpn = NULL;
+   int tmplen;
    int fd;
    off_t size;
    char *data, *p;
-   const char *tmpdir;
+   const char *tmpdir, *tmpsuff;
 
 #ifdef HAVE_EVIL
    tmpdir = evil_tmpdir_get();
@@ -654,7 +655,16 @@ compile(void)
    p = strrchr(inc, '/');
    if (!p) strcpy(inc, "./");
    else *p = 0;
-   snprintf (tmpn, PATH_MAX, "%s/edje_cc.edc-tmp-XXXXXX", tmpdir);
+
+   tmpsuff = "edje_cc.edc-tmp-XXXXXX";
+   tmplen = strlen(tmpdir) + 1 + strlen(tmpsuff) + 1;
+   if (tmpn) 
+     {
+       free(tmpn);
+       tmpn = NULL;
+     }
+   tmpn = malloc(tmplen);
+   snprintf (tmpn, tmplen, "%s/%s", tmpdir, tmpsuff);
    fd = mkstemp(tmpn);
    if (fd >= 0)
      {
diff -urp edje-0.9.92.060/src/bin/edje_cc_sources.c ../edje-0.9.92.060/src/bin/edje_cc_sources.c
--- edje-0.9.92.060/src/bin/edje_cc_sources.c	2008-12-19 00:58:37.000000000 +0100
+++ ../edje-0.9.92.060/src/bin/edje_cc_sources.c	2009-07-04 23:11:13.000000000 +0200
@@ -234,15 +234,19 @@ source_fetch_file(const char *fil, const
 void
 source_fetch(void)
 {
-   char buf[PATH_MAX] = {0}, *ptr;
+   char *buf, *ptr;
 
    ptr = strrchr(file_in, '/');
    if (ptr)
      {
-	snprintf(buf, sizeof (buf), "%s", ptr + 1);
+       buf = malloc(strlen(ptr));
+	snprintf(buf, strlen(ptr), "%s", ptr + 1);
      }
 
    source_fetch_file(file_in, buf[0] ? buf : file_in);
+
+   if (ptr)
+     free(buf);
 }
 
 int
diff -urp edje-0.9.92.060/src/lib/edje_edit.c ../edje-0.9.92.060/src/lib/edje_edit.c
--- edje-0.9.92.060/src/lib/edje_edit.c	2009-02-12 09:35:32.000000000 +0100
+++ ../edje-0.9.92.060/src/lib/edje_edit.c	2009-06-24 14:28:46.000000000 +0200
@@ -1735,18 +1735,33 @@ edje_edit_part_type_get(Evas_Object *obj
 EAPI const char *
 edje_edit_part_selected_state_get(Evas_Object *obj, const char *part)
 {
+#if !defined(PATH_MAX) && __GLIBC__
+   char *name;
+#else
    char name[PATH_MAX];
+#endif
+   char *ret;
 
    GET_RP_OR_RETURN(NULL);
 
    if (!rp->chosen_description)
      return "default 0.00";
 
+
+#if !defined(PATH_MAX) && __GLIBC__
+   asprintf(name, "%s %.2f", 
+            rp->chosen_description->state.name,
+            rp->chosen_description->state.value);
+   ret = eina_stringshare_add(name);
+   free(name);
+#else
    snprintf(name, PATH_MAX, "%s %.2f",
             rp->chosen_description->state.name,
             rp->chosen_description->state.value);
+   ret = eina_stringshare_add(name);
+#endif
 
-   return eina_stringshare_add(name);
+   return ret;
 }
 
 EAPI unsigned char
@@ -2095,7 +2110,11 @@ edje_edit_part_drag_event_set(Evas_Objec
 EAPI Eina_List *
 edje_edit_part_states_list_get(Evas_Object *obj, const char *part)
 {
+#if !defined(PATH_MAX) && __GLIBC__
+   char *state_name;
+#else
    char state_name[PATH_MAX];
+#endif
    Eina_List *states;
    Eina_List *l;
    Edje_Part_Description *state;
@@ -2111,17 +2130,31 @@ edje_edit_part_states_list_get(Evas_Obje
 
    //append default state
    state = rp->part->default_desc;
+#if !defined(PATH_MAX) && __GLIBC__
+   asprintf(state_name, 
+            "%s %.2f", state->state.name, state->state.value);
+   states = eina_list_append(states, eina_stringshare_add(state_name));
+   free(state_name);
+#else
    snprintf(state_name, PATH_MAX,
             "%s %.2f", state->state.name, state->state.value);
    states = eina_list_append(states, eina_stringshare_add(state_name));
+#endif
    //printf("NEW STATE def: %s\n", state->state.name);
 
    //append other states
    EINA_LIST_FOREACH(rp->part->other_desc, l, state)
      {
+#if !defined(PATH_MAX) && __GLIBC__
+	asprintf(state_name, 
+		 "%s %.2f", state->state.name, state->state.value);
+	states = eina_list_append(states, eina_stringshare_add(state_name));
+	free(state_name);
+#else
 	snprintf(state_name, sizeof(state_name),
 	         "%s %.2f", state->state.name, state->state.value);
 	states = eina_list_append(states, eina_stringshare_add(state_name));
+#endif
 	//printf("NEW STATE: %s\n", state_name);
      }
    return states;
@@ -3205,7 +3238,8 @@ edje_edit_fonts_list_get(Evas_Object *ob
 EAPI unsigned char
 edje_edit_font_add(Evas_Object *obj, const char* path)
 {
-   char buf[PATH_MAX];
+   char *buf;
+   int buflen = 0;
    Font *fn;
    Edje_Font_Directory_Entry *fnt;
    Eet_File *eetf;
@@ -3279,7 +3313,10 @@ edje_edit_font_add(Evas_Object *obj, con
 	fclose(f);
      }
    /* Write font to edje file */
-   snprintf(buf, sizeof(buf), "fonts/%s", fn->name);
+   
+   buflen = strlen("fonts/") + strlen(fn->name);
+   buf = malloc(buflen);
+   snprintf(buf, buflen, "fonts/%s", fn->name);
 
    if (fdata)
      {
@@ -3319,6 +3356,8 @@ edje_edit_font_add(Evas_Object *obj, con
 	eina_hash_direct_add(ed->file->font_hash, fnt->entry, fnt);
      }
 
+   free(buf);
+
    return 1;
 }
 
@@ -5277,7 +5316,7 @@ static const char* //return the name of 
 _edje_generate_source(Evas_Object *obj)
 {
    printf("\n****** GENERATE EDC SOURCE *********\n");
-   char tmpn[PATH_MAX];
+   char *tmpn;
    int fd;
    FILE *f;
 
@@ -5288,7 +5327,7 @@ _edje_generate_source(Evas_Object *obj)
    
    /* Open a temp file */
    //TODO this will not work on windows
-   strcpy(tmpn, "/tmp/edje_edit.edc-tmp-XXXXXX");
+   tmpn = "/tmp/edje_edit.edc-tmp-XXXXXX";
    if (!(fd = mkstemp(tmpn))) return NULL;
    printf("*** tmp file: %s\n", tmpn);
    if (!(f = fopen(tmpn, "w"))) return NULL;

-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: hurd-i386 (i686-AT386)

Kernel: GNU-Mach 1.3.99/Hurd-0.3
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash





More information about the Pkg-e-devel mailing list