/* Path setup. When we're ran with -ftest flag, add paths to refer to the files in the source tree. This is called after option processing and before loading init file. */ void test_paths_setup(void) { /* The order of directories is important. 'lib' should be searched first (hence it should come latter), since some extension modules are built from the file in src then linked from lib, and we want to test the one in lib. */ if (access("../src/gauche/config.h", R_OK) == 0 && access("../libsrc/srfi-1.scm", R_OK) == 0 && access("../lib/srfi-0.scm", R_OK) == 0) { Scm_AddLoadPath("../src", FALSE); Scm_AddLoadPath("../libsrc", FALSE); Scm_AddLoadPath("../lib", FALSE); } else if (access("../../src/gauche/config.h", R_OK) == 0 && access("../../libsrc/srfi-1.scm", R_OK) == 0 && access("../../lib/srfi-0.scm", R_OK) == 0) { Scm_AddLoadPath("../../src", FALSE); Scm_AddLoadPath("../../libsrc", FALSE); Scm_AddLoadPath("../../lib", FALSE); } }
/* Path setup. When we're ran with -ftest flag, add paths to refer to the files in the source tree. This is called after option processing and before loading init file. */ void test_paths_setup(void) { /* The order of directories is important. 'lib' should be searched first (hence it should come latter), since some extension modules are built from the file in src then linked from lib, and we want to test the one in lib. */ if (access("../src/gauche/config.h", R_OK) == 0 && access("../libsrc/srfi-1.scm", R_OK) == 0 && access("../lib/srfi-0.scm", R_OK) == 0) { Scm_AddLoadPath("../src", FALSE); Scm_AddLoadPath("../libsrc", FALSE); Scm_AddLoadPath("../lib", FALSE); } else if (access("../../src/gauche/config.h", R_OK) == 0 && access("../../libsrc/srfi-1.scm", R_OK) == 0 && access("../../lib/srfi-0.scm", R_OK) == 0) { Scm_AddLoadPath("../../src", FALSE); Scm_AddLoadPath("../../libsrc", FALSE); Scm_AddLoadPath("../../lib", FALSE); } /* Also set a feature identifier gauche.in-place, so that other modules may initialize differently if needed. */ Scm_AddFeature("gauche.in-place", NULL); }
/* Process command-line options that needs to run after Scheme runtime is initialized. CMD_ARGS is an list of (OPTION-CHAR . OPTION-ARG) */ static void process_command_args(ScmObj cmd_args) { ScmEvalPacket epak; ScmLoadPacket lpak; int standard_given = FALSE; ScmObj cp; SCM_FOR_EACH(cp, cmd_args) { ScmObj p = SCM_CAR(cp); ScmObj v = SCM_CDR(p); switch (SCM_CHAR_VALUE(SCM_CAR(p))) { case 'I': Scm_AddLoadPath(Scm_GetStringConst(SCM_STRING(v)), FALSE); break; case 'A': Scm_AddLoadPath(Scm_GetStringConst(SCM_STRING(v)), TRUE); break; case 'l': if (Scm_Load(Scm_GetStringConst(SCM_STRING(v)), 0, &lpak) < 0) error_exit(lpak.exception); break; case 'L': if (Scm_Load(Scm_GetStringConst(SCM_STRING(v)), SCM_LOAD_QUIET_NOFILE, &lpak) < 0) error_exit(lpak.exception); break; case 'u': if (Scm_Require(Scm_StringJoin(Scm_StringSplitByChar(SCM_STRING(v), '.'), SCM_STRING(SCM_MAKE_STR("/")), SCM_STRING_JOIN_INFIX), 0, &lpak) < 0) { error_exit(lpak.exception); } Scm_ImportModule(SCM_CURRENT_MODULE(), Scm_Intern(SCM_STRING(v)), SCM_FALSE, 0); break; case 'e': if (Scm_EvalCString(Scm_GetStringConst(SCM_STRING(v)), SCM_OBJ(Scm_UserModule()), &epak) < 0) { error_exit(epak.exception); } break; case 'E': v = Scm_StringAppend(SCM_LIST3(SCM_MAKE_STR("("), v, SCM_MAKE_STR(")"))); if (Scm_EvalCString(Scm_GetStringConst(SCM_STRING(v)), SCM_OBJ(Scm_UserModule()), &epak) < 0) { error_exit(epak.exception); } break; case 'r': if (standard_given) { Scm_Error("Multiple -r option is specified."); } else { /* R7RS mode. Preload r7rs module, set the default toplevel to r7rs.user, and define *r7rs-mode* in user module so that gauche.interactive can do proper setup. */ const char *std = Scm_GetStringConst(SCM_STRING(v)); if (strcmp(std, "7") == 0) { if (Scm_Require(SCM_MAKE_STR("r7rs"), 0, &lpak) < 0) { error_exit(lpak.exception); } SCM_DEFINE(Scm_UserModule(), "*r7rs-mode*", SCM_TRUE); default_toplevel_module = SCM_FIND_MODULE("r7rs.user", 0); standard_given = TRUE; } else { Scm_Error("Unsupported standard for -r option: %s", std); } } } }