rev 166 - in trunk: include/prothon modules/File modules/Re pr src

SVN User <[email protected]>
Newsgroups gmane.comp.lang.prothon.cvs
Message-ID <[email protected]>
Author: bcollins
Date: 2004-03-27 19:16:31 -0500 (Sat, 27 Mar 2004)
New Revision: 166

Modified:
   trunk/include/prothon/prothon.h
   trunk/include/prothon/prothon_dll.h
   trunk/modules/File/File.c
   trunk/modules/Re/Re.c
   trunk/pr/test.pr
   trunk/src/builtins.c
   trunk/src/interp.c
   trunk/src/object.c
   trunk/src/parser_routines.c
   trunk/src/sys.c
Log:
Make raise_exception() use va_list, so we can pass it args like printf.
This means no more functions need to create the string before passing.
Saves a lot of stack space.


Modified: trunk/include/prothon/prothon.h
===================================================================
--- trunk/include/prothon/prothon.h	2004-03-27 23:47:00 UTC (rev 165)
+++ trunk/include/prothon/prothon.h	2004-03-28 00:16:31 UTC (rev 166)
@@ -781,7 +781,8 @@
 // both NULL, then it will catch all exception objects.  When this function catches the 
 // exception and returns it, the exception object is no longer raised unless you call
 // raise_exception again with that object.
-void raise_exception(isp ist, obj_p proto_obj, char* doc);
+void raise_exception(isp ist, obj_p proto_obj, const char *format, ...)
+	__attribute__((format(printf,3,4)));
 obj_p catch_exception(isp ist, obj_p proto, obj_p proto_list);
 
 // EXCEPT: Convenience macro to catch all exceptions and return if exception caught

Modified: trunk/include/prothon/prothon_dll.h
===================================================================
--- trunk/include/prothon/prothon_dll.h	2004-03-27 23:47:00 UTC (rev 165)
+++ trunk/include/prothon/prothon_dll.h	2004-03-28 00:16:31 UTC (rev 166)
@@ -88,7 +88,8 @@
 	obj_p		(*call_func)(isp ist, obj_p self, obj_p func_sym, int parm_cnt, obj_p* lbl_val_arr, obj_p dyn_locals);
 	obj_p		(*call_func1_f)(isp ist, obj_p self, obj_p sym, obj_p parm);
 	obj_p   	(*sym)(isp ist, char* symbol);
-	void		(*raise_exception)(isp ist, obj_p proto_obj, char* comment);
+	void		(*raise_exception)(isp ist, obj_p proto_obj, const char *format, ...)
+		__attribute__((format(printf,3,4)));
 	obj_p		(*new_object)(obj_p proto);
 	void		(*add_doc_to_obj)(isp ist, obj_p obj, char* str);
 	apr_pool_t* (*get_pr_head_pool)(void);

Modified: trunk/modules/File/File.c
===================================================================
--- trunk/modules/File/File.c	2004-03-27 23:47:00 UTC (rev 165)
+++ trunk/modules/File/File.c	2004-03-28 00:16:31 UTC (rev 166)
@@ -134,10 +134,8 @@
 
 	aprerr = apr_file_open(&f, file, flags, APR_OS_DEFAULT, subpool);
 	if (aprerr != APR_SUCCESS) {
-		char msg[1024];
-		apr_snprintf(msg, sizeof(msg), "Unable to open file %s: %s",
-			     file, apr_strerror(aprerr, err_buf, sizeof(err_buf)));
-		raise_exception(ist, OBJ(IOEXCEPTION), msg);
+		raise_exception(ist, OBJ(IOEXCEPTION), "Unable to open file %s: %s",
+				file, apr_strerror(aprerr, err_buf, sizeof(err_buf)));
 		apr_pool_destroy(subpool);
 		return NULL;
 	}
@@ -238,7 +236,8 @@
 	num_read = size;
 	aprerr = apr_file_read(STREAM(self), buf, &num_read);
 	if (aprerr != APR_SUCCESS && aprerr != APR_EOF) {
-		raise_exception(ist, OBJ(IOEXCEPTION), apr_strerror(aprerr, err_buf, sizeof(err_buf)));
+		raise_exception(ist, OBJ(IOEXCEPTION), "%s",
+				apr_strerror(aprerr, err_buf, sizeof(err_buf)));
 		return NULL;
 	}
 	total_read += num_read;
@@ -255,7 +254,8 @@
 		num_read = next_read;
 		aprerr = apr_file_read(STREAM(self), buf + total_read, &num_read);
 		if (aprerr != APR_SUCCESS && aprerr != APR_EOF) {
-			raise_exception(ist, OBJ(IOEXCEPTION), apr_strerror(aprerr, err_buf, sizeof(err_buf)));
+			raise_exception(ist, OBJ(IOEXCEPTION), "%s",
+					apr_strerror(aprerr, err_buf, sizeof(err_buf)));
 			return NULL;
 		}
 		total_read += num_read;
@@ -307,7 +307,8 @@
 	}
 	aprerr = apr_file_gets(buf, (int)(size + 1), STREAM(self));
 	if (aprerr != APR_SUCCESS && aprerr != APR_EOF) {
-		raise_exception(ist, OBJ(IOEXCEPTION), apr_strerror(aprerr, err_buf, sizeof(err_buf)));
+		raise_exception(ist, OBJ(IOEXCEPTION), "%s",
+				apr_strerror(aprerr, err_buf, sizeof(err_buf)));
 		return NULL;
 	}
 	total_read = strlen(buf);
@@ -323,7 +324,8 @@
 		}
 		aprerr = apr_file_gets(buf + total_read, (int)(next_read + 1), STREAM(self));
 		if (aprerr != APR_SUCCESS && aprerr != APR_EOF) {
-			raise_exception(ist, OBJ(IOEXCEPTION), apr_strerror(aprerr, err_buf, sizeof(err_buf)));
+			raise_exception(ist, OBJ(IOEXCEPTION), "%s",
+					apr_strerror(aprerr, err_buf, sizeof(err_buf)));
 			return NULL;
 		}
 		total_read = strlen(buf);
@@ -378,7 +380,8 @@
 		}
 		aprerr = apr_file_gets(buf, (int)(size - total_read + 1), STREAM(self));
 		if (aprerr != APR_SUCCESS && aprerr != APR_EOF) {
-			raise_exception(ist, OBJ(IOEXCEPTION), apr_strerror(aprerr,
+			raise_exception(ist, OBJ(IOEXCEPTION), "%s",
+					apr_strerror(aprerr,
 					err_buf, sizeof(err_buf)));
 			return NULL;
 		}
@@ -396,7 +399,8 @@
 			}
 			aprerr = apr_file_gets(buf + num_read, (int)(next_read + 1), STREAM(self));
 			if (aprerr != APR_SUCCESS && aprerr != APR_EOF) {
-				raise_exception(ist, OBJ(IOEXCEPTION), apr_strerror(aprerr,
+				raise_exception(ist, OBJ(IOEXCEPTION), "%s",
+						apr_strerror(aprerr,
 						err_buf, sizeof(err_buf)));
 				return NULL;
 			}
@@ -447,7 +451,8 @@
 
 	aprerr = apr_file_seek(STREAM(self), origin, &pos);
 	if (aprerr != APR_SUCCESS) {
-		raise_exception(ist, OBJ(IOEXCEPTION), apr_strerror(aprerr, err_buf, sizeof(err_buf)));
+		raise_exception(ist, OBJ(IOEXCEPTION), "%s",
+				apr_strerror(aprerr, err_buf, sizeof(err_buf)));
 		return NULL;
 	}
 	return OBJ(NONE);
@@ -485,7 +490,8 @@
 
 	aprerr = apr_file_trunc(STREAM(self), size);
 	if(aprerr != APR_SUCCESS) {
-		raise_exception(ist, OBJ(IOEXCEPTION), apr_strerror(aprerr, err_buf, sizeof(err_buf)));
+		raise_exception(ist, OBJ(IOEXCEPTION), "%s",
+				apr_strerror(aprerr, err_buf, sizeof(err_buf)));
 		return NULL;
 	}
 	return OBJ(NONE);
@@ -511,7 +517,8 @@
 
 	aprerr = apr_file_write(STREAM(self), str, &size);
 	if (aprerr != APR_SUCCESS) {
-		raise_exception(ist, OBJ(IOEXCEPTION), apr_strerror(aprerr, err_buf, sizeof(err_buf)));
+		raise_exception(ist, OBJ(IOEXCEPTION), "%s",
+				apr_strerror(aprerr, err_buf, sizeof(err_buf)));
 		return NULL;
 	}
 	return parms[1];
@@ -537,7 +544,7 @@
 		size = pr_strlen(parms[1]);
 		aprerr = apr_file_write(STREAM(self), str, &size);
 		if (aprerr != APR_SUCCESS) {
-			raise_exception(ist, OBJ(IOEXCEPTION),
+			raise_exception(ist, OBJ(IOEXCEPTION), "%s",
 					apr_strerror(aprerr, err_buf, sizeof(err_buf)));
 			return NULL;
 		}
@@ -553,7 +560,7 @@
 			size = pr_strlen(item);
 			aprerr = apr_file_write(STREAM(self), str, &size);
 			if (aprerr != APR_SUCCESS) {
-				raise_exception(ist, OBJ(IOEXCEPTION),
+				raise_exception(ist, OBJ(IOEXCEPTION), "%s",
 						apr_strerror(aprerr, err_buf, sizeof(err_buf)));
 				return NULL;
 			}

Modified: trunk/modules/Re/Re.c
===================================================================
--- trunk/modules/Re/Re.c	2004-03-27 23:47:00 UTC (rev 165)
+++ trunk/modules/Re/Re.c	2004-03-28 00:16:31 UTC (rev 166)
@@ -89,10 +89,10 @@
 		if ((buf_size = regerror(err, NULL, msg, 1024)) > 1024) {
 			char* msg2 = pr_malloc(buf_size+1);
 			regerror(err, NULL, msg2, buf_size);
-			raise_exception(ist, RE_EXC, msg2);
+			raise_exception(ist, RE_EXC, "%s", msg2);
 			pr_free(msg2);
 		} else 
-			raise_exception(ist, RE_EXC, msg);
+			raise_exception(ist, RE_EXC, "%s", msg);
 		pr_free(e);
 		return NULL;
 	}
@@ -134,10 +134,10 @@
 			if ((buf_size = regerror(err, NULL, msg, 1024)) > 1024) {
 				char* msg2 = pr_malloc(buf_size+1);
 				regerror(err, NULL, msg2, buf_size);
-				raise_exception(ist, RE_EXC, msg2);
+				raise_exception(ist, RE_EXC, "%s", msg2);
 				pr_free(msg2);
 			} else 
-				raise_exception(ist, RE_EXC, msg);
+				raise_exception(ist, RE_EXC, "%s", msg);
 			pr_free(m);
 			return NULL;
 		}
@@ -196,10 +196,10 @@
 		if ((buf_size = regerror(err, NULL, msg, 1024)) > 1024) {
 			char* msg2 = pr_malloc(buf_size+1);
 			regerror(err, NULL, msg2, buf_size);
-			raise_exception(ist, RE_EXC, msg2);
+			raise_exception(ist, RE_EXC, "%s", msg2);
 			pr_free(msg2);
 		} else 
-			raise_exception(ist, RE_EXC, msg);
+			raise_exception(ist, RE_EXC, "%s", msg);
 		pr_free(m);
 		return NULL;
 	}
@@ -254,10 +254,10 @@
 			if ((buf_size = regerror(err, NULL, msg, 1024)) > 1024) {
 				char* msg2 = pr_malloc(buf_size+1);
 				regerror(err, NULL, msg2, buf_size);
-				raise_exception(ist, RE_EXC, msg2);
+				raise_exception(ist, RE_EXC, "%s", msg2);
 				pr_free(msg2);
 			} else 
-				raise_exception(ist, RE_EXC, msg);
+				raise_exception(ist, RE_EXC, "%s", msg);
 			pr_free(m);
 			return NULL;
 		}
@@ -411,10 +411,10 @@
 			if ((buf_size = regerror(err, NULL, msg, 1024)) > 1024) {
 				char* msg2 = pr_malloc(buf_size+1);
 				regerror(err, NULL, msg2, buf_size);
-				raise_exception(ist, RE_EXC, msg2);
+				raise_exception(ist, RE_EXC, "%s", msg2);
 				pr_free(msg2);
 			} else 
-				raise_exception(ist, RE_EXC, msg);
+				raise_exception(ist, RE_EXC, "%s", msg);
 			pr_free(m);
 			return NULL;
 		}

Modified: trunk/pr/test.pr
===================================================================
--- trunk/pr/test.pr	2004-03-27 23:47:00 UTC (rev 165)
+++ trunk/pr/test.pr	2004-03-28 00:16:31 UTC (rev 166)
@@ -2,6 +2,8 @@
 
 print Sys.version
 
+print Sys.platform
+
 /*
 f = File("test.txt", "w")
 

Modified: trunk/src/builtins.c
===================================================================
--- trunk/src/builtins.c	2004-03-27 23:47:00 UTC (rev 165)
+++ trunk/src/builtins.c	2004-03-28 00:16:31 UTC (rev 166)
@@ -224,7 +224,7 @@
 DEF(EXCEPTION_OBJ, __init__,  FORM_STAR_PARAM) {
 	obj_p res;
 	if (list_len(ist, parms[1]) > 0)
-		raise_exception(ist, self, as_str(ist, list_item(ist, parms[1], 0)));
+		raise_exception(ist, self, "%s", as_str(ist, list_item(ist, parms[1], 0)));
 	else
 		raise_exception(ist, self, NULL);
 	res = ist->exception_obj;
@@ -306,9 +306,7 @@
 		index1 = (int)(slice_item1->data.i64);
 		if (index1 < 0) index1 += self_len;						
 		if (index1 < 0 || index1 >= self_len) {			
-			char msg[1024];									
-			sprintf(msg, "Index (%d) out of range", index1);	
-			raise_exception(ist, OBJ(INDEX_EXC), msg);	
+			raise_exception(ist, OBJ(INDEX_EXC), "Index (%d) out of range", index1);
 			return NULL;									
 		}
 		if (slice_len == 1) {
@@ -344,9 +342,7 @@
 		index2 = (int)(slice_item2->data.i64);
 		if (index2 < 0) index2 += self_len;						
 		if (index2 < 0 || index2 > self_len) {			
-			char msg[1024];									
-			sprintf(msg, "Second index (%d) out of range", index2);	
-			raise_exception(ist, OBJ(INDEX_EXC), msg);	
+			raise_exception(ist, OBJ(INDEX_EXC), "Second index (%d) out of range", index2);
 			return NULL;									
 		}
 	}
@@ -489,9 +485,7 @@
 		index1 = (int)(slice_item1->data.i64);
 		if (index1 < 0) index1 += self_len;						
 		if (index1 < 0 || index1 >= self_len) {			
-			char msg[1024];									
-			sprintf(msg, "Index (%d) out of range", index1);	
-			raise_exception(ist, OBJ(INDEX_EXC), msg);
+			raise_exception(ist, OBJ(INDEX_EXC), "Index (%d) out of range", index1);
 			write_unlock(ist, self);  read_lock(ist, self); 
 			return NULL;									
 		}
@@ -537,9 +531,7 @@
 		index2 = (int)(slice_item2->data.i64);
 		if (index2 < 0) index2 += self_len;						
 		if (index2 < 0 || index2 > self_len) {			
-			char msg[1024];									
-			sprintf(msg, "Second index (%d) out of range", index2);	
-			raise_exception(ist, OBJ(INDEX_EXC), msg);	
+			raise_exception(ist, OBJ(INDEX_EXC), "Second index (%d) out of range", index2);
 			write_unlock(ist, self);  read_lock(ist, self); 
 			return NULL;									
 		}
@@ -603,9 +595,7 @@
 		index1 = (int)(slice_item1->data.i64);
 		if (index1 < 0) index1 += self_len;						
 		if (index1 < 0 || index1 >= self_len) {			
-			char msg[1024];									
-			sprintf(msg, "Index (%d) out of range", index1);	
-			raise_exception(ist, OBJ(INDEX_EXC), msg);
+			raise_exception(ist, OBJ(INDEX_EXC), "Index (%d) out of range", index1);
 			write_unlock(ist, self);   read_lock(ist, self); 
 			return NULL;									
 		}
@@ -648,9 +638,7 @@
 		index2 = (int)(slice_item2->data.i64);
 		if (index2 < 0) index2 += self_len;						
 		if (index2 < 0 || index2 > self_len) {			
-			char msg[1024];									
-			sprintf(msg, "Second index (%d) out of range", index2);	
-			raise_exception(ist, OBJ(INDEX_EXC), msg);	
+			raise_exception(ist, OBJ(INDEX_EXC), "Second index (%d) out of range", index2);
 			write_unlock(ist, self);   read_lock(ist, self); 
 			return NULL;									
 		}
@@ -733,9 +721,8 @@
 		return NULL;
 	}
 	if (!(res = dict_item(ist, self, list_item(ist, parms[1],0)))) {
-		char msg[1024];
-		sprintf(msg, "no entry found with key: %s", as_str(ist, list_item(ist, parms[1],0)));
-		raise_exception(ist, OBJ(INDEX_EXC), msg);	
+		raise_exception(ist, OBJ(INDEX_EXC), "no entry found with key: %s",
+				as_str(ist, list_item(ist, parms[1],0)));
 		return NULL;
 	}
 	return res;

Modified: trunk/src/interp.c
===================================================================
--- trunk/src/interp.c	2004-03-27 23:47:00 UTC (rev 165)
+++ trunk/src/interp.c	2004-03-28 00:16:31 UTC (rev 166)
@@ -331,10 +331,9 @@
 
 	aprerr = apr_dso_sym(&dll_entry, handle, "dll_entry");
 	if (aprerr != APR_SUCCESS) {
-		apr_snprintf(dll_path, sizeof(dll_path),
-			     "Loadable module `%s': initialization failed", module_name);
 		apr_dso_unload(handle);
-		raise_exception(ist, OBJ(INTERNAL_EXC), dll_path);
+		raise_exception(ist, OBJ(INTERNAL_EXC), "Loadable module `%s': initialization failed",
+				module_name);
 		return PR_FALSE;
 	}
 
@@ -424,9 +423,8 @@
 	}
 
 	if (pkg_depth < param-1) {
-		apr_snprintf(full_path, sizeof(full_path), "Package %s not found",
-			     symch(ist, fr_data(pkg_depth)));
-		raise_exception(ist, OBJ(INTERPRETER_EXC), full_path);
+		raise_exception(ist, OBJ(INTERPRETER_EXC), "Package %s not found",
+				symch(ist, fr_data(pkg_depth)));
 		return NULL;
 	}
 
@@ -469,8 +467,8 @@
 			if_exc_return NULL;
 		}
 	}
-	apr_snprintf(full_path, sizeof(full_path), "Import module %s not found", module_name);
-	raise_exception(ist, OBJ(INTERPRETER_EXC), full_path);
+	raise_exception(ist, OBJ(INTERPRETER_EXC), "Import module %s not found",
+			module_name);
 	return NULL;
 
 success:
@@ -899,10 +897,9 @@
 				func_obj = get_proto_attr(ist, fr_stack[fr_sp], fr_stack[fr_sp+1], NULL);  if_exc_return NULL;
 				if (intrp_exobj) break;
 				if (!func_obj) {
-					char str[1024];
-					apr_snprintf(str, sizeof(str), "Function %s not found",
-						     as_str(ist, fr_stack[fr_sp+1]));
-					raise_exception(ist, OBJ(FUNCNOTFOUND_EXC), str);
+					raise_exception(ist, OBJ(FUNCNOTFOUND_EXC),
+							"Function %s not found",
+							as_str(ist, fr_stack[fr_sp+1]));
 					break;
 				}
 				if (func_obj->data_type == OBJ_TYPE_FUNCPTR){
@@ -944,18 +941,21 @@
 					fr_push(func_obj);
 				} else {
 					obj_p value;
-					char str[128];
+
 					if (fr_stack[fr_sp+1] != SYM(__INIT__)) {
-						value = get_proto_attr(ist, fr_stack[fr_sp], fr_stack[fr_sp+1], NULL); if_exc_return NULL;
+						value = get_proto_attr(ist, fr_stack[fr_sp],
+								fr_stack[fr_sp+1], NULL);
+						if_exc_return NULL;
+
 						if (value) {
 							fr_stack[fr_sp]   = new_object(value);
 							fr_stack[fr_sp+1] = SYM(__INIT__);
 							goto call_get_func;
 						}
 					}
-					apr_snprintf(str, sizeof(str), "Function not found: \"%s\"",
-						     as_str(ist, fr_stack[fr_sp+1]));
-					raise_exception(ist, OBJ(FUNCNOTFOUND_EXC), str);
+					raise_exception(ist, OBJ(FUNCNOTFOUND_EXC),
+							"Function not found: \"%s\"",
+							as_str(ist, fr_stack[fr_sp+1]));
 				}
 			}	break;
 			case OP_RAISE:
@@ -995,10 +995,9 @@
 				}
 				obj = get_attr(ist, fr_tos, fr_data(1));
 				if (!obj) {
-					char msg[1024];
-					apr_snprintf(msg, sizeof(msg), "Attribute not found in module %s",
-						symch(ist, fr_data(1)));
-					raise_exception(ist, OBJ(INTERPRETER_EXC), msg);
+					raise_exception(ist, OBJ(INTERPRETER_EXC),
+							"Attribute not found in module %s",
+							symch(ist, fr_data(1)));
 					break;
 				}
 				set_attr(ist, frame->globals, fr_data(1), obj);
@@ -1008,11 +1007,9 @@
 				for(i=1; i < param-1; i++) {
 					obj = get_attr(ist, obj, fr_data(i));
 					if (!obj) {
-						char msg[1024];
-						apr_snprintf(msg, sizeof(msg),
-							     "Attribute not found in module %s",
-							     symch(ist, fr_data(i)));
-						raise_exception(ist, OBJ(INTERPRETER_EXC), msg);
+						raise_exception(ist, OBJ(INTERPRETER_EXC),
+								"Attribute not found in module %s",
+								symch(ist, fr_data(i)));
 						break;
 					}
 				}
@@ -1030,9 +1027,7 @@
 				printf("\n");
 			}   break;
 			default: {
-				char str[80];
-				apr_snprintf(str, sizeof(str), "Bad opcode: %d", op);
-				raise_exception(ist, OBJ(INTERNAL_EXC), str);
+				raise_exception(ist, OBJ(INTERNAL_EXC), "Bad opcode: %d", op);
 			}
 		}
 endcase:
@@ -1122,14 +1117,12 @@
 	if (func_sym) {
 		func_obj = get_proto_attr(ist, self, func_sym, NULL); if_exc_return NULL;
 		if (!func_obj) {
-			char err_str[1024];
-			apr_snprintf(err_str, sizeof(err_str), "Function not found: \"%s\"",
-					as_str(ist, func_sym));
 			if (!ist) {
-				printf("Internal error with exceptions disabled: %s", err_str);
+				printf("Internal error with exceptions disabled: Function not found: \"%s\"", as_str(ist, func_sym));
 				pr_exit(1);
 			}
-			raise_exception(ist, OBJ(FUNCNOTFOUND_EXC), err_str);
+			raise_exception(ist, OBJ(FUNCNOTFOUND_EXC), "Function not found: \"%s\"",
+					as_str(ist, func_sym));
 			return NULL;
 		}
 	} else {

Modified: trunk/src/object.c
===================================================================
--- trunk/src/object.c	2004-03-27 23:47:00 UTC (rev 165)
+++ trunk/src/object.c	2004-03-28 00:16:31 UTC (rev 166)
@@ -57,6 +57,9 @@
 #include <stdio.h>
 #include <string.h>
 #include <time.h>
+
+#include <apr_strings.h>
+
 #include "object.h"
 #include "bytecodes.h"
 #include "clist.h"
@@ -323,11 +326,21 @@
 }
 
 //********************************* raise_exception ***************************
-void raise_exception(isp ist, obj_p proto_obj, char* comment){
-	if (!proto_obj) proto_obj = OBJ(EXCEPTION);
+void raise_exception(isp ist, obj_p proto_obj, const char *format, ...)
+{
+	if (!proto_obj)
+		proto_obj = OBJ(EXCEPTION);
 	ist->exception_obj = new_object(proto_obj);
-	if (comment)
-		add_doc_to_obj(ist, ist->exception_obj, comment);
+	if (format) {
+		char err_buf[512];
+		va_list ap;
+
+		va_start(ap, format);
+		apr_vsnprintf(err_buf, sizeof(err_buf), format, ap);
+		va_end(ap);
+
+		add_doc_to_obj(ist, ist->exception_obj, err_buf);
+	}
 }
 
 //********************************* if_exc_return ************************************
@@ -860,9 +873,8 @@
 		if_exc_return NULL;
 		res = get_proto_attr(ist, ref_self, ref_key, NULL);
 		if (!res) {
-			char msg[1024];
-			sprintf(msg, "Attribute %s not found", symch(ist, ref_key));
-			raise_exception(ist, OBJ(NAME_EXC), msg);
+			raise_exception(ist, OBJ(NAME_EXC), "Attribute %s not found",
+					symch(ist, ref_key));
 		}
 		return res;
 	} else if (has_proto(ist, ref_key, OBJ(SLICE_PROTO))) {

Modified: trunk/src/parser_routines.c
===================================================================
--- trunk/src/parser_routines.c	2004-03-27 23:47:00 UTC (rev 165)
+++ trunk/src/parser_routines.c	2004-03-28 00:16:31 UTC (rev 166)
@@ -101,8 +101,7 @@
 	parse_state*  parse_state;
 	if (filename) {
 		if ( !(stream = fopen(filename, "rb")) ) {
-			char msg[512]; sprintf(msg, "File: %s", filename);
-			raise_exception(ist, OBJ(FILENOTFOUND_EXC), msg);
+			raise_exception(ist, OBJ(FILENOTFOUND_EXC), "File: %s", filename);
 			return NULL;
 		}
 		if ( !(parse_state = new_parse_state(ist, stream, NULL)) ) return NULL;

Modified: trunk/src/sys.c
===================================================================
--- trunk/src/sys.c	2004-03-27 23:47:00 UTC (rev 165)
+++ trunk/src/sys.c	2004-03-28 00:16:31 UTC (rev 166)
@@ -112,8 +112,7 @@
 
 #ifdef WIN32
 	if(!_fullpath( full_path, path, sizeof(full_path))) {
-		sprintf(full_path, "Bad path in PROTHONPATH: %s", path);
-		raise_exception(ist, OBJ(IOEXCEPTION), full_path);
+		raise_exception(ist, OBJ(IOEXCEPTION), "Bad path in PROTHONPATH: %s", path);
 		return;
 	}
 #else
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.