Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Jun 2014 18:35:36 GMT
From:      pedrosouza@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r269082 - in soc2014/pedrosouza/lua_loader/head/sys: boot/common lua/src
Message-ID:  <201406041835.s54IZagH051426@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pedrosouza
Date: Wed Jun  4 18:35:35 2014
New Revision: 269082
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=269082

Log:
  Add function declarations to lstd.h & copyrights

Modified:
  soc2014/pedrosouza/lua_loader/head/sys/boot/common/interp_lua.c
  soc2014/pedrosouza/lua_loader/head/sys/lua/src/lstd.c
  soc2014/pedrosouza/lua_loader/head/sys/lua/src/lstd.h
  soc2014/pedrosouza/lua_loader/head/sys/lua/src/luaconf.h

Modified: soc2014/pedrosouza/lua_loader/head/sys/boot/common/interp_lua.c
==============================================================================
--- soc2014/pedrosouza/lua_loader/head/sys/boot/common/interp_lua.c	Wed Jun  4 17:57:48 2014	(r269081)
+++ soc2014/pedrosouza/lua_loader/head/sys/boot/common/interp_lua.c	Wed Jun  4 18:35:35 2014	(r269082)
@@ -116,7 +116,7 @@
 	data_chunk ds;
 	ds.data = (void*)str;
 	ds.size = size;
-	res = lua_load(L, read_chunk, &ds, "do_string", 0);
+	res = lua_load(L, read_chunk, &ds, "do_string_", 0);
 	res = lua_pcall(L, 0, LUA_MULTRET, 0);
 	return res;
 }

Modified: soc2014/pedrosouza/lua_loader/head/sys/lua/src/lstd.c
==============================================================================
--- soc2014/pedrosouza/lua_loader/head/sys/lua/src/lstd.c	Wed Jun  4 17:57:48 2014	(r269081)
+++ soc2014/pedrosouza/lua_loader/head/sys/lua/src/lstd.c	Wed Jun  4 18:35:35 2014	(r269082)
@@ -1,3 +1,30 @@
+/*-
+ * Copyright (c) 2014 Pedro Souza <pedrosouza@freebsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
 #include "lstd.h"
 
 #ifdef BOOT_LUA
@@ -95,7 +122,7 @@
 
 	if (has_frac == 0 && has_num == 0)
 	{
-		if (*endPtr)
+		if (endPtr)
 			*endPtr = (char*)string;
 		return 0.;
 	}
@@ -105,7 +132,7 @@
 
 	if (*ptr == 'e' || *ptr == 'E')
 	{
-		if (*endPtr)
+		if (endPtr)
 			*endPtr = (char*)ptr;
 		++ptr;
 		if (*ptr == '-') 
@@ -126,7 +153,7 @@
 			return ret;
 	}
 
-	if (*endPtr)
+	if (endPtr)
 		*endPtr = (char*)ptr;
 
 	if (has_exp)
@@ -143,4 +170,49 @@
 	return ret * exp_m;
 }
 
+char * dtostr(double value, char * buf)
+{
+	int c, i;
+	char tmp[20];
+	char *ptr, *bb = buf;
+	long long num = (long long) value;
+	double frac = value - num;
+
+	tmp[19] = 0;
+	ptr = &tmp[19];
+	while (num > 0)
+	{
+		c = num % 10;
+		num = num / 10;
+		*(--ptr) = '0' + c;
+	}
+
+	if (ptr == &tmp[19])
+		*buf++ = '0';
+	else
+	{
+		while (*ptr)
+		{
+			*buf++ = *ptr++;
+		}
+	}
+	if (abs(frac) > 0.0000001)
+	{
+		*buf++ = 0;
+		return bb;
+	} else 
+	{
+		*buf++ = '.';
+
+		for (i = 0; i < 7; ++i)
+		{
+			frac *= 10;
+			c = (long long)frac;
+			*buf++ = '0' + c;
+			frac -= c;
+		}
+		*buf = 0; 
+	}
+	return bb;
+}
 #endif //BOOT_LUA
\ No newline at end of file

Modified: soc2014/pedrosouza/lua_loader/head/sys/lua/src/lstd.h
==============================================================================
--- soc2014/pedrosouza/lua_loader/head/sys/lua/src/lstd.h	Wed Jun  4 17:57:48 2014	(r269081)
+++ soc2014/pedrosouza/lua_loader/head/sys/lua/src/lstd.h	Wed Jun  4 18:35:35 2014	(r269082)
@@ -1,3 +1,29 @@
+/*-
+ * Copyright (c) 2014 Pedro Souza <pedrosouza@freebsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
 #ifndef LSTD_H
 #define LSDT_H
 
@@ -21,6 +47,18 @@
 
 int abs(int v);
 
+double floor(double v);
+
+char * strpbrk (const char * str1, const char * str2);
+
+double ldexp (double x, int exp);
+
+double pow(double a, double b);
+
+double strtod(const char *string, char **endPtr);
+
+char * dtostr(double value, char * buf);
+
 #endif
 #endif //LSTD_H
 

Modified: soc2014/pedrosouza/lua_loader/head/sys/lua/src/luaconf.h
==============================================================================
--- soc2014/pedrosouza/lua_loader/head/sys/lua/src/luaconf.h	Wed Jun  4 17:57:48 2014	(r269081)
+++ soc2014/pedrosouza/lua_loader/head/sys/lua/src/luaconf.h	Wed Jun  4 18:35:35 2014	(r269082)
@@ -412,7 +412,7 @@
 */
 #define LUA_NUMBER_SCAN		"%lf"
 #define LUA_NUMBER_FMT		"%f"
-#define lua_number2str(s,n)	sprintf((s), LUA_NUMBER_FMT, (n))
+#define lua_number2str(s,n)	dtostr((n), (s)) //sprintf((s), LUA_NUMBER_FMT, (n))
 #define LUAI_MAXNUMBER2STR	32 /* 16 digits, sign, point, and \0 */
 
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201406041835.s54IZagH051426>