Roberto Ierusalimschy пре 26 година
родитељ
комит
8278468041
2 измењених фајлова са 42 додато и 17 уклоњено
  1. 31 9
      liolib.c
  2. 11 8
      lmathlib.c

+ 31 - 9
liolib.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: liolib.c,v 1.27 1998/12/27 20:21:28 roberto Exp roberto $
+** $Id: liolib.c,v 1.28 1998/12/28 13:44:54 roberto Exp $
 ** Standard I/O (and system) library
 ** Standard I/O (and system) library
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -52,11 +52,6 @@ int pclose();
 
 
 
 
 
 
-static int gettag (int i) {
-  return (int)lua_getnumber(lua_getparam(i));
-}
-
-
 static void pushresult (int i) {
 static void pushresult (int i) {
   if (i)
   if (i)
     lua_pushuserdata(NULL);
     lua_pushuserdata(NULL);
@@ -68,6 +63,17 @@ static void pushresult (int i) {
 }
 }
 
 
 
 
+/*
+** {======================================================
+** FILE Operations
+** =======================================================
+*/
+
+static int gettag (int i) {
+  return (int)lua_getnumber(lua_getparam(i));
+}
+
+
 static int ishandler (lua_Object f) {
 static int ishandler (lua_Object f) {
   if (lua_isuserdata(f)) {
   if (lua_isuserdata(f)) {
     if (lua_tag(f) == gettag(CLOSEDTAG))
     if (lua_tag(f) == gettag(CLOSEDTAG))
@@ -190,9 +196,11 @@ static void io_appendto (void) {
 
 
 
 
 
 
-/*====================================================
+/*
+** {======================================================
 ** READ
 ** READ
-**===================================================*/
+** =======================================================
+*/
 
 
 static int read_pattern (FILE *f, char *p) {
 static int read_pattern (FILE *f, char *p) {
   int inskip = 0;  /* {skip} level */
   int inskip = 0;  /* {skip} level */
@@ -314,6 +322,8 @@ static void io_read (void) {
   } while ((p = luaL_opt_string(arg++, NULL)) != NULL);
   } while ((p = luaL_opt_string(arg++, NULL)) != NULL);
 }
 }
 
 
+/* }====================================================== */
+
 
 
 static void io_write (void) {
 static void io_write (void) {
   int arg = FIRSTARG;
   int arg = FIRSTARG;
@@ -350,6 +360,14 @@ static void io_flush (void) {
   pushresult(fflush(f) == 0);
   pushresult(fflush(f) == 0);
 }
 }
 
 
+/* }====================================================== */
+
+
+/*
+** {======================================================
+** Other O.S. Operations
+** =======================================================
+*/
 
 
 static void io_execute (void) {
 static void io_execute (void) {
   lua_pushnumber(system(luaL_check_string(1)));
   lua_pushnumber(system(luaL_check_string(1)));
@@ -412,6 +430,9 @@ static void io_exit (void) {
   exit(lua_isnumber(o) ? (int)lua_getnumber(o) : 1);
   exit(lua_isnumber(o) ? (int)lua_getnumber(o) : 1);
 }
 }
 
 
+/* }====================================================== */
+
+
 
 
 static void io_debug (void) {
 static void io_debug (void) {
   for (;;) {
   for (;;) {
@@ -439,7 +460,8 @@ static void errorfb (void) {
     char *chunkname;
     char *chunkname;
     int linedefined;
     int linedefined;
     lua_funcinfo(func, &chunkname, &linedefined);
     lua_funcinfo(func, &chunkname, &linedefined);
-    strcat(buff, (level==2) ? "Active Stack:\n\t" : "\t");
+    if (level == 2) strcat(buff, "Active Stack:\n");
+    strcat(buff, "\t");
     if (strlen(buff) > MAXMESSAGE-MESSAGESIZE) {
     if (strlen(buff) > MAXMESSAGE-MESSAGESIZE) {
       strcat(buff, "...\n");
       strcat(buff, "...\n");
       break;  /* buffer is full */
       break;  /* buffer is full */

+ 11 - 8
lmathlib.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lmathlib.c,v 1.13 1998/12/30 17:22:17 roberto Exp roberto $
+** $Id: lmathlib.c,v 1.14 1998/12/30 21:23:26 roberto Exp $
 ** Lua standard mathematical library
 ** Lua standard mathematical library
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -12,15 +12,18 @@
 #include "lua.h"
 #include "lua.h"
 #include "lualib.h"
 #include "lualib.h"
 
 
-#ifdef M_PI
-#define PI                      M_PI
-#else
-#define PI          ((double)3.14159265358979323846)
-#endif
 
 
+#define PI	(3.14159265358979323846)
 
 
-#define FROMRAD(a) ((a)*(180.0/PI))
-#define TORAD(a)    ((a)*(PI/180.0))
+
+/*
+** If you want Lua to operate in radians (instead of degrees),
+** changes these two macros to identities:
+** #define FROMRAD(a)	(a)
+** #define TORAD(a)	(a)
+*/
+#define FROMRAD(a)	((a)*(180.0/PI))
+#define TORAD(a)	((a)*(PI/180.0))
 
 
 
 
 static void math_abs (void)
 static void math_abs (void)