rev 355 - trunk/src

SVN User <[email protected]>
Newsgroups gmane.comp.lang.prothon.cvs
Message-ID <[email protected]>
Author: mark
Date: 2004-04-14 18:32:09 -0400 (Wed, 14 Apr 2004)
New Revision: 355

Modified:
   trunk/src/builtins-string.c
Log:
added type to argv array for string.__mod__()

Modified: trunk/src/builtins-string.c
===================================================================
--- trunk/src/builtins-string.c	2004-04-14 21:52:31 UTC (rev 354)
+++ trunk/src/builtins-string.c	2004-04-14 22:32:09 UTC (rev 355)
@@ -232,10 +232,19 @@
 	return obj;
 }
 
+#define ARG_TYPE_INT	0
+#define ARG_TYPE_FLOAT	1
+#define ARG_TYPE_STRING	2
+
 typedef union {
 	i64_t   i64;
 	double	f64;
 	char*	str;
+} arg_types_t;
+
+typedef struct {
+	arg_types_t	arg;
+	u8_t		type;
 } arg_t;
 
 typedef arg_t* arg_p;
@@ -255,13 +264,16 @@
 	argv = pr_malloc(argc * sizeof(arg_t));
 	for (i=0; i < argc; i++) {
 		obj_p arg_obj = list_item(ist, argv_obj, (int) i);
-		if (has_proto_QUES(ist, arg_obj, OBJ(INT_PROTO)))
-			argv[i].i64 = arg_obj->data.i64;
-		else if (has_proto_QUES(ist, arg_obj, OBJ(FLOAT_PROTO)))
-			argv[i].f64 = arg_obj->data.f64;
-		else if (has_proto_QUES(ist, arg_obj, OBJ(STRING_PROTO)))
-			argv[i].str = strch(arg_obj);
-		else {
+		if (has_proto_QUES(ist, arg_obj, OBJ(INT_PROTO))) {
+			argv[i].arg.i64 = arg_obj->data.i64;
+			argv[i].type    = ARG_TYPE_INT;
+		} else if (has_proto_QUES(ist, arg_obj, OBJ(FLOAT_PROTO))) {
+			argv[i].arg.f64 = arg_obj->data.f64;
+			argv[i].type    = ARG_TYPE_FLOAT;
+		} else if (has_proto_QUES(ist, arg_obj, OBJ(STRING_PROTO))) {
+			argv[i].arg.str = strch(arg_obj);
+			argv[i].type    = ARG_TYPE_STRING;
+		} else {
 			raise_exception(ist, OBJ(TYPE_EXC), "invalid type for string (%) format");
 			return NULL;
 		}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.