aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--liolib.c (renamed from iolib.c)37
-rw-r--r--lualoc.h28
2 files changed, 29 insertions, 36 deletions
diff --git a/iolib.c b/liolib.c
index 9945d6b4..f44a1f76 100644
--- a/iolib.c
+++ b/liolib.c
@@ -1,17 +1,35 @@
1/*
2** $Id: $
3** Standard I/O (and system) library
4** See Copyright Notice in lua.h
5*/
6
7
1#include <stdio.h> 8#include <stdio.h>
2#include <string.h> 9#include <string.h>
3#include <time.h> 10#include <time.h>
4#include <stdlib.h> 11#include <stdlib.h>
5#include <errno.h> 12#include <errno.h>
6 13
7#include "lualoc.h" 14#include "lauxlib.h"
8#include "lua.h" 15#include "lua.h"
9#include "auxlib.h"
10#include "luadebug.h" 16#include "luadebug.h"
11#include "lualib.h" 17#include "lualib.h"
12 18
13 19
14int lua_tagio; 20#ifndef OLD_ANSI
21#include <locale.h>
22#else
23#define strcoll(a,b) strcmp(a,b)
24#define setlocale(a,b) 0
25#define LC_ALL 0
26#define LC_COLLATE 0
27#define LC_CTYPE 0
28#define LC_MONETARY 0
29#define LC_NUMERIC 0
30#define LC_TIME 0
31#define strerror(e) "O.S. is unable to define the error"
32#endif
15 33
16 34
17#ifdef POPEN 35#ifdef POPEN
@@ -23,6 +41,9 @@ int pclose();
23#endif 41#endif
24 42
25 43
44int lua_tagio;
45
46
26static void pushresult (int i) 47static void pushresult (int i)
27{ 48{
28 if (i) 49 if (i)
@@ -144,10 +165,10 @@ static void io_read (void)
144 p++; 165 p++;
145 } 166 }
146 else { 167 else {
147 char *ep = luaL_item_end(p); /* get what is next */ 168 char *ep; /* get what is next */
148 int m; /* match result */ 169 int m; /* match result */
149 if (c == NEED_OTHER) c = getc(f); 170 if (c == NEED_OTHER) c = getc(f);
150 m = (c == EOF) ? 0 : luaL_singlematch((char)c, p); 171 m = luaI_singlematch((c == EOF) ? 0 : (char)c, p, &ep);
151 if (m) { 172 if (m) {
152 if (inskip == 0) luaI_addchar(c); 173 if (inskip == 0) luaI_addchar(c);
153 c = NEED_OTHER; 174 c = NEED_OTHER;
@@ -214,7 +235,7 @@ static void io_tmpname (void)
214 235
215static void io_getenv (void) 236static void io_getenv (void)
216{ 237{
217 lua_pushstring(getenv(luaL_check_string(1))); /* if NULL push nil */ 238 lua_pushstring(getenv(luaL_check_string(1))); /* if NULL push nil */
218} 239}
219 240
220 241
@@ -240,7 +261,7 @@ static void setloc (void)
240 luaL_arg_check(0 <= op && op <= 5, 2, "invalid option"); 261 luaL_arg_check(0 <= op && op <= 5, 2, "invalid option");
241 lua_pushstring(setlocale(cat[op], luaL_check_string(1))); 262 lua_pushstring(setlocale(cat[op], luaL_check_string(1)));
242} 263}
243 264
244 265
245static void io_exit (void) 266static void io_exit (void)
246{ 267{
@@ -324,7 +345,7 @@ static struct luaL_reg iolib[] = {
324{"print_stack", errorfb} 345{"print_stack", errorfb}
325}; 346};
326 347
327void iolib_open (void) 348void lua_iolibopen (void)
328{ 349{
329 lua_tagio = lua_newtag(); 350 lua_tagio = lua_newtag();
330 setfile(stdin, "_INPUT"); 351 setfile(stdin, "_INPUT");
diff --git a/lualoc.h b/lualoc.h
deleted file mode 100644
index 957b08a5..00000000
--- a/lualoc.h
+++ /dev/null
@@ -1,28 +0,0 @@
1/*
2** lualoc.h
3** TecCGraf - PUC-Rio
4** $Id: lualoc.h,v 1.1 1997/07/02 18:45:09 roberto Exp roberto $
5*/
6
7#ifndef lualoc_h
8#define lualoc_h
9
10
11#ifndef OLD_ANSI
12#include <locale.h>
13#else
14
15#define strcoll(a,b) strcmp(a,b)
16#define setlocale(a,b) 0
17#define LC_ALL 0
18#define LC_COLLATE 0
19#define LC_CTYPE 0
20#define LC_MONETARY 0
21#define LC_NUMERIC 0
22#define LC_TIME 0
23
24#define strerror(e) "O.S. is unable to define the error"
25
26#endif
27
28#endif