* Removed references to NOMAIN.
* Replaced / with \ under Win32. * The Win32 version looks for .scm files in the scm subdirectory of the executable's current directory. git-svn-id: svn://svn.zoy.org/elk/trunk@148 55e467fa-43c5-0310-a8a2-de718669efc6
This commit is contained in:
parent
892fa3085f
commit
b12222213e
|
@ -111,7 +111,7 @@ extern Object General_Load P_((Object, Object));
|
||||||
*/
|
*/
|
||||||
extern Object General_Assoc P_((Object, Object, int));
|
extern Object General_Assoc P_((Object, Object, int));
|
||||||
|
|
||||||
/* main.c
|
/* libelk.c
|
||||||
*/
|
*/
|
||||||
extern char *stkbase, *A_Out_Name;
|
extern char *stkbase, *A_Out_Name;
|
||||||
extern int Stack_Grows_Down;
|
extern int Stack_Grows_Down;
|
||||||
|
@ -121,6 +121,8 @@ extern char *Brk_On_Dump;
|
||||||
extern int Verb_Load, Verb_Init, Case_Insensitive;
|
extern int Verb_Load, Verb_Init, Case_Insensitive;
|
||||||
extern SYMTAB *The_Symbols;
|
extern SYMTAB *The_Symbols;
|
||||||
extern void Exit_Handler P_((void));
|
extern void Exit_Handler P_((void));
|
||||||
|
extern char *Scm_Dir;
|
||||||
|
extern char *Lib_Dir;
|
||||||
#ifndef HAVE_ATEXIT
|
#ifndef HAVE_ATEXIT
|
||||||
extern void exit P_((int));
|
extern void exit P_((int));
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
NULL =
|
NULL =
|
||||||
|
|
||||||
lib_LTLIBRARIES = libelk.la
|
lib_LTLIBRARIES = libelk.la
|
||||||
libelk_la_CFLAGS = -I/usr/include/libelf -DNOMAIN
|
libelk_la_CFLAGS = -I/usr/include/libelf
|
||||||
libelk_la_LDFLAGS =
|
libelk_la_LDFLAGS =
|
||||||
libelk_la_LIBADD = @ELK_LIBS@
|
libelk_la_LIBADD = @ELK_LIBS@
|
||||||
libelk_la_SOURCES = \
|
libelk_la_SOURCES = \
|
||||||
|
|
17
src/io.c
17
src/io.c
|
@ -189,7 +189,11 @@ Object General_File_Operation (Object s, register int op) {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
Alloca (r, char*, strlen (dir) + 1 + strlen (p) + 1);
|
Alloca (r, char*, strlen (dir) + 1 + strlen (p) + 1);
|
||||||
|
#ifdef WIN32
|
||||||
|
sprintf (r, "%s\\%s", dir, p);
|
||||||
|
#else
|
||||||
sprintf (r, "%s/%s", dir, p);
|
sprintf (r, "%s/%s", dir, p);
|
||||||
|
#endif
|
||||||
ret = Make_String (r, strlen (r));
|
ret = Make_String (r, strlen (r));
|
||||||
Alloca_End;
|
Alloca_End;
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -236,7 +240,11 @@ Object Open_File (char *name, int flags, int err) {
|
||||||
p = Internal_Tilde_Expand (name, &dir);
|
p = Internal_Tilde_Expand (name, &dir);
|
||||||
if (p) {
|
if (p) {
|
||||||
Alloca (name, char*, strlen (dir) + 1 + strlen (p) + 1);
|
Alloca (name, char*, strlen (dir) + 1 + strlen (p) + 1);
|
||||||
|
#ifdef WIN32
|
||||||
|
sprintf (name, "%s\\%s", dir, p);
|
||||||
|
#else
|
||||||
sprintf (name, "%s/%s", dir, p);
|
sprintf (name, "%s/%s", dir, p);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (!err && stat (name, &st) == -1 &&
|
if (!err && stat (name, &st) == -1 &&
|
||||||
(errno == ENOENT || errno == ENOTDIR)) {
|
(errno == ENOENT || errno == ENOTDIR)) {
|
||||||
|
@ -271,7 +279,11 @@ Object General_Open_File (Object name, int flags, Object path) {
|
||||||
name = Get_File_Name (name);
|
name = Get_File_Name (name);
|
||||||
len = STRING(name)->size;
|
len = STRING(name)->size;
|
||||||
fn = STRING(name)->data;
|
fn = STRING(name)->data;
|
||||||
|
#ifdef WIN32
|
||||||
|
if (fn[0] < 'A' || fn[0] > 'Z' || fn[1] != ':' ) {
|
||||||
|
#else
|
||||||
if (fn[0] != '/' && fn[0] != '~') {
|
if (fn[0] != '/' && fn[0] != '~') {
|
||||||
|
#endif
|
||||||
for ( ; TYPE(path) == T_Pair; path = Cdr (path)) {
|
for ( ; TYPE(path) == T_Pair; path = Cdr (path)) {
|
||||||
pref = Car (path);
|
pref = Car (path);
|
||||||
if (TYPE(pref) == T_Symbol)
|
if (TYPE(pref) == T_Symbol)
|
||||||
|
@ -286,8 +298,13 @@ Object General_Open_File (Object name, int flags, Object path) {
|
||||||
Alloca (buf, char*, blen);
|
Alloca (buf, char*, blen);
|
||||||
}
|
}
|
||||||
memcpy (buf, STRING(pref)->data, plen);
|
memcpy (buf, STRING(pref)->data, plen);
|
||||||
|
#ifdef WIN32
|
||||||
|
if (buf[plen-1] != '\\')
|
||||||
|
buf[plen++] = '\\';
|
||||||
|
#else
|
||||||
if (buf[plen-1] != '/')
|
if (buf[plen-1] != '/')
|
||||||
buf[plen++] = '/';
|
buf[plen++] = '/';
|
||||||
|
#endif
|
||||||
memcpy (buf+plen, fn, len);
|
memcpy (buf+plen, fn, len);
|
||||||
buf[len+plen] = '\0';
|
buf[len+plen] = '\0';
|
||||||
port = Open_File (buf, flags, 0);
|
port = Open_File (buf, flags, 0);
|
||||||
|
|
60
src/libelk.c
60
src/libelk.c
|
@ -45,6 +45,10 @@
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
# include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef FIND_AOUT
|
#ifdef FIND_AOUT
|
||||||
# ifdef HAVE_UNISTD_H
|
# ifdef HAVE_UNISTD_H
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
|
@ -101,6 +105,8 @@ int Verb_Load = 0, Verb_Init = 0;
|
||||||
char **Argv;
|
char **Argv;
|
||||||
int Argc, First_Arg;
|
int Argc, First_Arg;
|
||||||
|
|
||||||
|
char *Scm_Dir;
|
||||||
|
char *Lib_Dir;
|
||||||
#ifdef FIND_AOUT
|
#ifdef FIND_AOUT
|
||||||
char *A_Out_Name;
|
char *A_Out_Name;
|
||||||
char *Find_Executable();
|
char *Find_Executable();
|
||||||
|
@ -145,22 +151,12 @@ char *Brk_On_Dump;
|
||||||
* an incompatible way.
|
* an incompatible way.
|
||||||
*/
|
*/
|
||||||
void Check_If_Dump_Works () {
|
void Check_If_Dump_Works () {
|
||||||
#ifdef NOMAIN
|
|
||||||
Primitive_Error ("not yet supported for standalone applications");
|
Primitive_Error ("not yet supported for standalone applications");
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef NOMAIN
|
|
||||||
|
|
||||||
void Elk_Init (int ac, char **av, int init_objects, char *toplevel) {
|
void Elk_Init (int ac, char **av, int init_objects, char *toplevel) {
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int main (int ac, char **av) {
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* To avoid that the stack copying code overwrites argv if a dumped
|
/* To avoid that the stack copying code overwrites argv if a dumped
|
||||||
* copy of the interpreter is invoked with more arguments than the
|
* copy of the interpreter is invoked with more arguments than the
|
||||||
* original a.out, move the stack base INITIAL_STK_OFFSET bytes down.
|
* original a.out, move the stack base INITIAL_STK_OFFSET bytes down.
|
||||||
|
@ -175,7 +171,7 @@ int main (int ac, char **av) {
|
||||||
Object file;
|
Object file;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
extern int errno;
|
extern int errno;
|
||||||
#if defined(CAN_DUMP) && defined(NOMAIN)
|
#if defined(CAN_DUMP)
|
||||||
# define foo (av[0][0])
|
# define foo (av[0][0])
|
||||||
#else
|
#else
|
||||||
char foo;
|
char foo;
|
||||||
|
@ -189,9 +185,29 @@ int main (int ac, char **av) {
|
||||||
}
|
}
|
||||||
Get_Stack_Limit ();
|
Get_Stack_Limit ();
|
||||||
|
|
||||||
#ifdef FIND_AOUT
|
Lib_Dir = NULL;
|
||||||
|
Scm_Dir = NULL;
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
if (av[0]) {
|
||||||
|
char path[MAX_PATH], *exe;
|
||||||
|
GetFullPathName (av[0], MAX_PATH, path, &exe);
|
||||||
|
if (exe > path && exe[-1] == '\\') {
|
||||||
|
char newpath[MAX_PATH+5];
|
||||||
|
exe[-1] = '\0';
|
||||||
|
sprintf (newpath, "%s\\lib", path);
|
||||||
|
Lib_Dir = strdup (newpath);
|
||||||
|
sprintf (newpath, "%s\\scm", path);
|
||||||
|
Scm_Dir = strdup (newpath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#elif defined(FIND_AOUT)
|
||||||
A_Out_Name = Find_Executable (av[0]);
|
A_Out_Name = Find_Executable (av[0]);
|
||||||
#endif
|
#endif
|
||||||
|
if (Scm_Dir == NULL)
|
||||||
|
Scm_Dir = strdup (SCM_DIR);
|
||||||
|
if (Lib_Dir == NULL)
|
||||||
|
Lib_Dir = strdup (LIB_DIR);
|
||||||
|
|
||||||
Argc = ac; Argv = av;
|
Argc = ac; Argv = av;
|
||||||
First_Arg = 1;
|
First_Arg = 1;
|
||||||
|
@ -275,18 +291,11 @@ int main (int ac, char **av) {
|
||||||
Fatal_Error ("atexit returned non-zero value");
|
Fatal_Error ("atexit returned non-zero value");
|
||||||
#endif
|
#endif
|
||||||
#ifdef INIT_OBJECTS
|
#ifdef INIT_OBJECTS
|
||||||
#ifdef NOMAIN
|
|
||||||
if (init_objects) {
|
if (init_objects) {
|
||||||
Set_Error_Tag ("init-objects");
|
Set_Error_Tag ("init-objects");
|
||||||
The_Symbols = Open_File_And_Snarf_Symbols (A_Out_Name);
|
The_Symbols = Open_File_And_Snarf_Symbols (A_Out_Name);
|
||||||
Call_Initializers (The_Symbols, (char *)0, PR_EXTENSION);
|
Call_Initializers (The_Symbols, (char *)0, PR_EXTENSION);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
Set_Error_Tag ("init-objects");
|
|
||||||
The_Symbols = Open_File_And_Snarf_Symbols (A_Out_Name);
|
|
||||||
Call_Initializers (The_Symbols, (char *)0, PR_CONSTRUCTOR);
|
|
||||||
Call_Initializers (The_Symbols, (char *)0, PR_EXTENSION);
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
if (loadpath || (loadpath = getenv (LOADPATH_ENV)))
|
if (loadpath || (loadpath = getenv (LOADPATH_ENV)))
|
||||||
Init_Loadpath (loadpath);
|
Init_Loadpath (loadpath);
|
||||||
|
@ -299,8 +308,12 @@ int main (int ac, char **av) {
|
||||||
* the load-path, so that -p can be used.
|
* the load-path, so that -p can be used.
|
||||||
*/
|
*/
|
||||||
Set_Error_Tag ("scheme-init");
|
Set_Error_Tag ("scheme-init");
|
||||||
initfile = Safe_Malloc (strlen (SCM_DIR) + 1 + sizeof (INITFILE) + 1);
|
initfile = Safe_Malloc (strlen (Scm_Dir) + 1 + sizeof (INITFILE) + 1);
|
||||||
sprintf (initfile, "%s/%s", SCM_DIR, INITFILE);
|
#ifdef WIN32
|
||||||
|
sprintf (initfile, "%s\\%s", Scm_Dir, INITFILE);
|
||||||
|
#else
|
||||||
|
sprintf (initfile, "%s/%s", Scm_Dir, INITFILE);
|
||||||
|
#endif
|
||||||
if (stat (initfile, &st) == -1 && errno == ENOENT)
|
if (stat (initfile, &st) == -1 && errno == ENOENT)
|
||||||
file = Make_String (INITFILE, sizeof(INITFILE)-1);
|
file = Make_String (INITFILE, sizeof(INITFILE)-1);
|
||||||
else
|
else
|
||||||
|
@ -311,7 +324,6 @@ int main (int ac, char **av) {
|
||||||
Install_Intr_Handler ();
|
Install_Intr_Handler ();
|
||||||
|
|
||||||
Set_Error_Tag ("top-level");
|
Set_Error_Tag ("top-level");
|
||||||
#ifdef NOMAIN
|
|
||||||
if (toplevel == 0) {
|
if (toplevel == 0) {
|
||||||
Interpreter_Initialized = 1;
|
Interpreter_Initialized = 1;
|
||||||
GC_Debug = debug;
|
GC_Debug = debug;
|
||||||
|
@ -320,7 +332,6 @@ int main (int ac, char **av) {
|
||||||
/* Special case: if toplevel is "", act as if run from main() */
|
/* Special case: if toplevel is "", act as if run from main() */
|
||||||
if (loadfile == 0 && toplevel[0] != '\0')
|
if (loadfile == 0 && toplevel[0] != '\0')
|
||||||
loadfile = toplevel;
|
loadfile = toplevel;
|
||||||
#endif
|
|
||||||
if (loadfile == 0)
|
if (loadfile == 0)
|
||||||
loadfile = "toplevel.scm";
|
loadfile = "toplevel.scm";
|
||||||
file = Make_String (loadfile, strlen (loadfile));
|
file = Make_String (loadfile, strlen (loadfile));
|
||||||
|
@ -330,9 +341,6 @@ int main (int ac, char **av) {
|
||||||
Load_Source_Port (Standard_Input_Port);
|
Load_Source_Port (Standard_Input_Port);
|
||||||
else
|
else
|
||||||
(void)General_Load (file, The_Environment);
|
(void)General_Load (file, The_Environment);
|
||||||
#ifndef NOMAIN
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *Usage_Msg[] = {
|
static char *Usage_Msg[] = {
|
||||||
|
|
|
@ -47,8 +47,8 @@ void Load_Source (Object);
|
||||||
void Init_Load () {
|
void Init_Load () {
|
||||||
Define_Variable (&V_Load_Path, "load-path",
|
Define_Variable (&V_Load_Path, "load-path",
|
||||||
Cons (Make_String (".", 1),
|
Cons (Make_String (".", 1),
|
||||||
Cons (Make_String (SCM_DIR, sizeof (SCM_DIR) - 1),
|
Cons (Make_String (Scm_Dir, strlen (Scm_Dir)),
|
||||||
Cons (Make_String (LIB_DIR, sizeof (LIB_DIR) - 1), Null))));
|
Cons (Make_String (Lib_Dir, strlen (Lib_Dir)), Null))));
|
||||||
Define_Variable (&V_Load_Noisilyp, "load-noisily?", False);
|
Define_Variable (&V_Load_Noisilyp, "load-noisily?", False);
|
||||||
Define_Variable (&V_Load_Libraries, "load-libraries", Make_String ("", 0));
|
Define_Variable (&V_Load_Libraries, "load-libraries", Make_String ("", 0));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue