Enlightenment CVS committal
Author : raster
Project : e17
Module : libs/embryo
Dir : e17/libs/embryo/src/lib
Modified Files:
Embryo.h embryo_amx.c embryo_str.c
Log Message:
fix str... snprintf... oops
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/embryo/src/lib/Embryo.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- Embryo.h 26 Mar 2004 08:07:47 -0000 1.4
+++ Embryo.h 30 Mar 2004 09:35:50 -0000 1.5
@@ -71,6 +71,8 @@
void embryo_swap_32(unsigned int *v);
Embryo_Function embryo_program_function_find(Embryo_Program *ep, char *name);
Embryo_Cell embryo_program_variable_find(Embryo_Program *ep, char *name);
+ int embryo_program_variable_count_get(Embryo_Program *ep);
+ Embryo_Cell embryo_program_variable_get(Embryo_Program *ep, int num);
void embryo_program_error_set(Embryo_Program *ep, int error);
int embryo_program_error_get(Embryo_Program *ep);
void embryo_program_data_set(Embryo_Program *ep, void *data);
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/embryo/src/lib/embryo_amx.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -3 -r1.14 -r1.15
--- embryo_amx.c 29 Mar 2004 11:58:57 -0000 1.14
+++ embryo_amx.c 30 Mar 2004 09:35:50 -0000 1.15
@@ -468,6 +468,32 @@
return EMBRYO_CELL_NONE;
}
+int
+embryo_program_variable_count_get(Embryo_Program *ep)
+{
+ Embryo_Header *hdr;
+
+ if (!ep) return 0;
+ if (!ep->base) return 0;
+ hdr = (Embryo_Header *)ep->base;
+ return NUMENTRIES(hdr, pubvars, tags);
+}
+
+Embryo_Cell
+embryo_program_variable_get(Embryo_Program *ep, int num)
+{
+ Embryo_Header *hdr;
+ Embryo_Cell paddr;
+ char pname[sNAMEMAX + 1];
+
+ if (!ep) return EMBRYO_CELL_NONE;
+ if (!ep->base) return EMBRYO_CELL_NONE;
+ hdr = (Embryo_Header *)ep->base;
+ if (_embryo_var_get(ep, num, pname, &paddr) == EMBRYO_ERROR_NONE)
+ return paddr;
+ return EMBRYO_CELL_NONE;
+}
+
void
embryo_program_error_set(Embryo_Program *ep, int error)
{
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/embryo/src/lib/embryo_str.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- embryo_str.c 29 Mar 2004 11:58:57 -0000 1.1
+++ embryo_str.c 30 Mar 2004 09:35:50 -0000 1.2
@@ -257,7 +257,7 @@
if (!s2) return -1;
s2[0] = 0;
pnum = (params[0] / sizeof(Embryo_Cell)) - 3;
- for (p = 0, o = 0; (s1[i]) && (o < (params[2] - 1)) && (p < pnum); i++)
+ for (p = 0, o = 0, i = 0; (s1[i]) && (o < (params[2] - 1)) && (p < (pnum + 1));
i++)
{
if ((!inesc) && (!insub))
{
@@ -271,6 +271,8 @@
}
else
{
+ Embryo_Cell *cptr;
+
if (inesc)
{
switch (s1[i])
@@ -290,7 +292,7 @@
}
inesc = 0;
}
- if (insub)
+ if ((insub) && (p < pnum))
{
switch (s1[i])
{
@@ -299,7 +301,8 @@
o++;
break;
case 'c':
- s2[o] = params[4 + p];
+ cptr = embryo_data_address_get(ep, params[4 + p]);
+ if (cptr) s2[o] = (char)(*cptr);
p++;
o++;
break;
@@ -316,7 +319,8 @@
else if (s1[i] == 'd') strcpy(fmt, "%d");
else if (s1[i] == 'x') strcpy(fmt, "%x");
else if (s1[i] == 'X') strcpy(fmt, "%08x");
- snprintf(tmp, sizeof(tmp), fmt, params[4 + p]);
+ cptr = embryo_data_address_get(ep, params[4 + p]);
+ if (cptr) snprintf(tmp, sizeof(tmp), fmt, (int)(*cptr));
l = strlen(tmp);
if ((o + l) > (params[2] - 1))
{
@@ -324,7 +328,7 @@
if (l < 0) l = 0;
tmp[l] = 0;
}
- strcat(s2, tmp);
+ strcpy(s2 + o, tmp);
o += l;
p++;
}
@@ -334,7 +338,8 @@
char tmp[256] = "";
int l;
- snprintf(tmp, sizeof(tmp), "%f",
EMBRYO_CELL_TO_FLOAT(params[4 + p]));
+ cptr = embryo_data_address_get(ep, params[4 + p]);
+ if (cptr) snprintf(tmp, sizeof(tmp), "%f",
(double)EMBRYO_CELL_TO_FLOAT(*cptr));
l = strlen(tmp);
if ((o + l) > (params[2] - 1))
{
@@ -342,7 +347,7 @@
if (l < 0) l = 0;
tmp[l] = 0;
}
- strcat(s2, tmp);
+ strcpy(s2 + o, tmp);
o += l;
p++;
}
@@ -360,7 +365,7 @@
if (l < 0) l = 0;
tmp[l] = 0;
}
- strcat(s2, tmp);
+ strcpy(s2 + o, tmp);
o += l;
p++;
}
@@ -370,6 +375,8 @@
}
insub = 0;
}
+ else if (insub)
+ insub = 0;
}
}
s2[o] = 0;
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs