load.c 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219
  1. /* Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2004, 2006, 2008,
  2. * 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public License
  6. * as published by the Free Software Foundation; either version 3 of
  7. * the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  17. * 02110-1301 USA
  18. */
  19. #ifdef HAVE_CONFIG_H
  20. # include <config.h>
  21. #endif
  22. #include <string.h>
  23. #include <stdio.h>
  24. #include "libguile/_scm.h"
  25. #include "libguile/libpath.h"
  26. #include "libguile/fports.h"
  27. #include "libguile/read.h"
  28. #include "libguile/eval.h"
  29. #include "libguile/throw.h"
  30. #include "libguile/alist.h"
  31. #include "libguile/dynwind.h"
  32. #include "libguile/root.h"
  33. #include "libguile/strings.h"
  34. #include "libguile/modules.h"
  35. #include "libguile/chars.h"
  36. #include "libguile/srfi-13.h"
  37. #include "libguile/validate.h"
  38. #include "libguile/load.h"
  39. #include "libguile/fluids.h"
  40. #include "libguile/vm.h" /* for load-compiled/vm */
  41. #include <sys/types.h>
  42. #include <sys/stat.h>
  43. #include <unistd.h>
  44. #ifdef HAVE_PWD_H
  45. #include <pwd.h>
  46. #endif /* HAVE_PWD_H */
  47. #ifndef R_OK
  48. #define R_OK 4
  49. #endif
  50. #include <stat-time.h>
  51. /* Loading a file, given an absolute filename. */
  52. /* Hook to run when we load a file, perhaps to announce the fact somewhere.
  53. Applied to the full name of the file. */
  54. static SCM *scm_loc_load_hook;
  55. /* The current reader (a fluid). */
  56. static SCM the_reader = SCM_BOOL_F;
  57. SCM_DEFINE (scm_primitive_load, "primitive-load", 1, 0, 0,
  58. (SCM filename),
  59. "Load the file named @var{filename} and evaluate its contents in\n"
  60. "the top-level environment. The load paths are not searched;\n"
  61. "@var{filename} must either be a full pathname or be a pathname\n"
  62. "relative to the current directory. If the variable\n"
  63. "@code{%load-hook} is defined, it should be bound to a procedure\n"
  64. "that will be called before any code is loaded. See the\n"
  65. "documentation for @code{%load-hook} later in this section.")
  66. #define FUNC_NAME s_scm_primitive_load
  67. {
  68. SCM hook = *scm_loc_load_hook;
  69. SCM ret = SCM_UNSPECIFIED;
  70. SCM_VALIDATE_STRING (1, filename);
  71. if (scm_is_true (hook) && scm_is_false (scm_procedure_p (hook)))
  72. SCM_MISC_ERROR ("value of %load-hook is neither a procedure nor #f",
  73. SCM_EOL);
  74. if (!scm_is_false (hook))
  75. scm_call_1 (hook, filename);
  76. {
  77. SCM port;
  78. port = scm_open_file_with_encoding (filename,
  79. scm_from_latin1_string ("r"),
  80. SCM_BOOL_T, /* guess_encoding */
  81. scm_from_latin1_string ("UTF-8"));
  82. scm_dynwind_begin (SCM_F_DYNWIND_REWINDABLE);
  83. scm_i_dynwind_current_load_port (port);
  84. while (1)
  85. {
  86. SCM reader, form;
  87. /* Lookup and use the current reader to read the next
  88. expression. */
  89. reader = scm_fluid_ref (the_reader);
  90. if (scm_is_false (reader))
  91. form = scm_read (port);
  92. else
  93. form = scm_call_1 (reader, port);
  94. if (SCM_EOF_OBJECT_P (form))
  95. break;
  96. ret = scm_primitive_eval_x (form);
  97. }
  98. scm_dynwind_end ();
  99. scm_close_port (port);
  100. }
  101. return ret;
  102. }
  103. #undef FUNC_NAME
  104. SCM
  105. scm_c_primitive_load (const char *filename)
  106. {
  107. return scm_primitive_load (scm_from_locale_string (filename));
  108. }
  109. /* Builtin path to scheme library files. */
  110. #ifdef SCM_PKGDATA_DIR
  111. SCM_DEFINE (scm_sys_package_data_dir, "%package-data-dir", 0, 0, 0,
  112. (),
  113. "Return the name of the directory where Scheme packages, modules and\n"
  114. "libraries are kept. On most Unix systems, this will be\n"
  115. "@samp{/usr/local/share/guile}.")
  116. #define FUNC_NAME s_scm_sys_package_data_dir
  117. {
  118. return scm_from_locale_string (SCM_PKGDATA_DIR);
  119. }
  120. #undef FUNC_NAME
  121. #endif /* SCM_PKGDATA_DIR */
  122. #ifdef SCM_LIBRARY_DIR
  123. SCM_DEFINE (scm_sys_library_dir, "%library-dir", 0,0,0,
  124. (),
  125. "Return the directory where the Guile Scheme library files are installed.\n"
  126. "E.g., may return \"/usr/share/guile/1.3.5\".")
  127. #define FUNC_NAME s_scm_sys_library_dir
  128. {
  129. return scm_from_locale_string (SCM_LIBRARY_DIR);
  130. }
  131. #undef FUNC_NAME
  132. #endif /* SCM_LIBRARY_DIR */
  133. #ifdef SCM_SITE_DIR
  134. SCM_DEFINE (scm_sys_site_dir, "%site-dir", 0,0,0,
  135. (),
  136. "Return the directory where users should install Scheme code for use\n"
  137. "with this version of Guile.\n\n"
  138. "E.g., may return \"/usr/share/guile/site/" SCM_EFFECTIVE_VERSION "\".")
  139. #define FUNC_NAME s_scm_sys_site_dir
  140. {
  141. return scm_from_locale_string (SCM_SITE_DIR);
  142. }
  143. #undef FUNC_NAME
  144. #endif /* SCM_SITE_DIR */
  145. #ifdef SCM_GLOBAL_SITE_DIR
  146. SCM_DEFINE (scm_sys_global_site_dir, "%global-site-dir", 0,0,0,
  147. (),
  148. "Return the directory where users should install Scheme code for use\n"
  149. "with all versions of Guile.\n\n"
  150. "E.g., may return \"/usr/share/guile/site\".")
  151. #define FUNC_NAME s_scm_sys_global_site_dir
  152. {
  153. return scm_from_locale_string (SCM_GLOBAL_SITE_DIR);
  154. }
  155. #undef FUNC_NAME
  156. #endif /* SCM_GLOBAL_SITE_DIR */
  157. #ifdef SCM_SITE_CCACHE_DIR
  158. SCM_DEFINE (scm_sys_site_ccache_dir, "%site-ccache-dir", 0,0,0,
  159. (),
  160. "Return the directory where users should install compiled\n"
  161. "@code{.go} files for use with this version of Guile.\n\n"
  162. "E.g., may return \"/usr/lib/guile/" SCM_EFFECTIVE_VERSION "/site-ccache\".")
  163. #define FUNC_NAME s_scm_sys_site_ccache_dir
  164. {
  165. return scm_from_locale_string (SCM_SITE_CCACHE_DIR);
  166. }
  167. #undef FUNC_NAME
  168. #endif /* SCM_SITE_CCACHE_DIR */
  169. /* Initializing the load path, and searching it. */
  170. /* List of names of directories we search for files to load. */
  171. static SCM *scm_loc_load_path;
  172. /* List of extensions we try adding to the filenames. */
  173. static SCM *scm_loc_load_extensions;
  174. /* Like %load-path and %load-extensions, but for compiled files. */
  175. static SCM *scm_loc_load_compiled_path;
  176. static SCM *scm_loc_load_compiled_extensions;
  177. /* Whether we should try to auto-compile. */
  178. static SCM *scm_loc_load_should_auto_compile;
  179. /* Whether to treat all auto-compiled files as stale. */
  180. static SCM *scm_loc_fresh_auto_compile;
  181. /* The fallback path for auto-compilation */
  182. static SCM *scm_loc_compile_fallback_path;
  183. /* Ellipsis: "..." */
  184. static SCM scm_ellipsis;
  185. SCM_DEFINE (scm_parse_path, "parse-path", 1, 1, 0,
  186. (SCM path, SCM tail),
  187. "Parse @var{path}, which is expected to be a colon-separated\n"
  188. "string, into a list and return the resulting list with\n"
  189. "@var{tail} appended. If @var{path} is @code{#f}, @var{tail}\n"
  190. "is returned.")
  191. #define FUNC_NAME s_scm_parse_path
  192. {
  193. #ifdef __MINGW32__
  194. SCM sep = SCM_MAKE_CHAR (';');
  195. #else
  196. SCM sep = SCM_MAKE_CHAR (':');
  197. #endif
  198. if (SCM_UNBNDP (tail))
  199. tail = SCM_EOL;
  200. return (scm_is_false (path)
  201. ? tail
  202. : scm_append_x (scm_list_2 (scm_string_split (path, sep), tail)));
  203. }
  204. #undef FUNC_NAME
  205. SCM_DEFINE (scm_parse_path_with_ellipsis, "parse-path-with-ellipsis", 2, 0, 0,
  206. (SCM path, SCM base),
  207. "Parse @var{path}, which is expected to be a colon-separated\n"
  208. "string, into a list and return the resulting list with\n"
  209. "@var{base} (a list) spliced in place of the @code{...} path\n"
  210. "component, if present, or else @var{base} is added to the end.\n"
  211. "If @var{path} is @code{#f}, @var{base} is returned.")
  212. #define FUNC_NAME s_scm_parse_path_with_ellipsis
  213. {
  214. SCM lst = scm_parse_path (path, SCM_EOL);
  215. SCM walk = lst;
  216. SCM *prev = &lst;
  217. while (!scm_is_null (walk) &&
  218. scm_is_false (scm_equal_p (scm_car (walk), scm_ellipsis)))
  219. {
  220. prev = SCM_CDRLOC (walk);
  221. walk = *prev;
  222. }
  223. *prev = scm_is_null (walk)
  224. ? base
  225. : scm_append (scm_list_2 (base, scm_cdr (walk)));
  226. return lst;
  227. }
  228. #undef FUNC_NAME
  229. /* On Posix hosts, just return PATH unaltered. On Windows,
  230. destructively replace all backslashes in PATH with Unix-style
  231. forward slashes, so that Scheme code always gets d:/foo/bar style
  232. file names. This avoids multiple subtle problems with comparing
  233. file names as strings, and with redirections in /bin/sh command
  234. lines.
  235. Note that, if PATH is result of a call to 'getenv', this
  236. destructively modifies the environment variables, so both
  237. scm_getenv and subprocesses will afterwards see the values with
  238. forward slashes. That is OK as long as applied to Guile-specific
  239. environment variables, since having scm_getenv return the same
  240. value as used by the callers of this function is good for
  241. consistency and file-name comparison. Avoid using this function on
  242. values returned by 'getenv' for general-purpose environment
  243. variables; instead, make a copy of the value and work on that. */
  244. SCM_INTERNAL char *
  245. scm_i_mirror_backslashes (char *path)
  246. {
  247. #ifdef __MINGW32__
  248. if (path)
  249. {
  250. char *p = path;
  251. while (*p)
  252. {
  253. if (*p == '\\')
  254. *p = '/';
  255. p++;
  256. }
  257. }
  258. #endif
  259. return path;
  260. }
  261. /* Initialize the global variable %load-path, given the value of the
  262. SCM_SITE_DIR and SCM_LIBRARY_DIR preprocessor symbols and the
  263. GUILE_LOAD_PATH environment variable. */
  264. void
  265. scm_init_load_path ()
  266. {
  267. char *env;
  268. SCM path = SCM_EOL;
  269. SCM cpath = SCM_EOL;
  270. #ifdef SCM_LIBRARY_DIR
  271. env = scm_i_mirror_backslashes (getenv ("GUILE_SYSTEM_PATH"));
  272. if (env && strcmp (env, "") == 0)
  273. /* special-case interpret system-path=="" as meaning no system path instead
  274. of '("") */
  275. ;
  276. else if (env)
  277. path = scm_parse_path (scm_from_locale_string (env), path);
  278. else
  279. path = scm_list_4 (scm_from_locale_string (SCM_LIBRARY_DIR),
  280. scm_from_locale_string (SCM_SITE_DIR),
  281. scm_from_locale_string (SCM_GLOBAL_SITE_DIR),
  282. scm_from_locale_string (SCM_PKGDATA_DIR));
  283. env = scm_i_mirror_backslashes (getenv ("GUILE_SYSTEM_COMPILED_PATH"));
  284. if (env && strcmp (env, "") == 0)
  285. /* like above */
  286. ;
  287. else if (env)
  288. cpath = scm_parse_path (scm_from_locale_string (env), cpath);
  289. else
  290. {
  291. cpath = scm_list_2 (scm_from_locale_string (SCM_CCACHE_DIR),
  292. scm_from_locale_string (SCM_SITE_CCACHE_DIR));
  293. }
  294. #endif /* SCM_LIBRARY_DIR */
  295. {
  296. char cachedir[1024];
  297. char *e;
  298. #ifdef HAVE_GETPWENT
  299. struct passwd *pwd;
  300. #endif
  301. #define FALLBACK_DIR \
  302. "guile/ccache/" SCM_EFFECTIVE_VERSION "-" SCM_OBJCODE_MACHINE_VERSION_STRING
  303. if ((e = getenv ("XDG_CACHE_HOME")))
  304. snprintf (cachedir, sizeof(cachedir), "%s/" FALLBACK_DIR, e);
  305. else if ((e = getenv ("HOME")))
  306. snprintf (cachedir, sizeof(cachedir), "%s/.cache/" FALLBACK_DIR, e);
  307. #ifdef HAVE_GETPWENT
  308. else if ((pwd = getpwuid (getuid ())) && pwd->pw_dir)
  309. snprintf (cachedir, sizeof(cachedir), "%s/.cache/" FALLBACK_DIR,
  310. pwd->pw_dir);
  311. #endif /* HAVE_GETPWENT */
  312. #ifdef __MINGW32__
  313. else if ((e = getenv ("LOCALAPPDATA")))
  314. snprintf (cachedir, sizeof (cachedir), "%s/.cache/" FALLBACK_DIR, e);
  315. else if ((e = getenv ("APPDATA")))
  316. snprintf (cachedir, sizeof (cachedir), "%s/.cache/" FALLBACK_DIR, e);
  317. #endif /* __MINGW32__ */
  318. else
  319. cachedir[0] = 0;
  320. if (cachedir[0])
  321. {
  322. scm_i_mirror_backslashes (cachedir);
  323. *scm_loc_compile_fallback_path = scm_from_locale_string (cachedir);
  324. }
  325. }
  326. env = scm_i_mirror_backslashes (getenv ("GUILE_LOAD_PATH"));
  327. if (env)
  328. path = scm_parse_path_with_ellipsis (scm_from_locale_string (env), path);
  329. env = scm_i_mirror_backslashes (getenv ("GUILE_LOAD_COMPILED_PATH"));
  330. if (env)
  331. cpath = scm_parse_path_with_ellipsis (scm_from_locale_string (env), cpath);
  332. *scm_loc_load_path = path;
  333. *scm_loc_load_compiled_path = cpath;
  334. }
  335. SCM scm_listofnullstr;
  336. /* Utility functions for assembling C strings in a buffer.
  337. */
  338. struct stringbuf
  339. {
  340. char *buf, *ptr;
  341. size_t buf_len;
  342. };
  343. static void
  344. stringbuf_grow (struct stringbuf *buf)
  345. {
  346. size_t ptroff, prev_len;
  347. void *prev_buf = buf->buf;
  348. prev_len = buf->buf_len;
  349. ptroff = buf->ptr - buf->buf;
  350. buf->buf_len *= 2;
  351. buf->buf = scm_gc_malloc_pointerless (buf->buf_len, "search-path");
  352. memcpy (buf->buf, prev_buf, prev_len);
  353. buf->ptr = buf->buf + ptroff;
  354. }
  355. static void
  356. stringbuf_cat_locale_string (struct stringbuf *buf, SCM str)
  357. {
  358. size_t max_len = buf->buf_len - (buf->ptr - buf->buf) - 1;
  359. size_t len = scm_to_locale_stringbuf (str, buf->ptr, max_len);
  360. if (len > max_len)
  361. {
  362. /* buffer is too small, double its size and try again.
  363. */
  364. stringbuf_grow (buf);
  365. stringbuf_cat_locale_string (buf, str);
  366. }
  367. else
  368. {
  369. /* string fits, terminate it and check for embedded '\0'.
  370. */
  371. buf->ptr[len] = '\0';
  372. if (strlen (buf->ptr) != len)
  373. scm_misc_error (NULL,
  374. "string contains #\\nul character: ~S",
  375. scm_list_1 (str));
  376. buf->ptr += len;
  377. }
  378. }
  379. static void
  380. stringbuf_cat (struct stringbuf *buf, char *str)
  381. {
  382. size_t max_len = buf->buf_len - (buf->ptr - buf->buf) - 1;
  383. size_t len = strlen (str);
  384. if (len > max_len)
  385. {
  386. /* buffer is too small, double its size and try again.
  387. */
  388. stringbuf_grow (buf);
  389. stringbuf_cat (buf, str);
  390. }
  391. else
  392. {
  393. /* string fits, copy it into buffer.
  394. */
  395. strcpy (buf->ptr, str);
  396. buf->ptr += len;
  397. }
  398. }
  399. /* Return non-zero if STR is suffixed by a dot followed by one of
  400. EXTENSIONS. */
  401. static int
  402. string_has_an_ext (SCM str, SCM extensions)
  403. {
  404. for (; !scm_is_null (extensions); extensions = SCM_CDR (extensions))
  405. {
  406. SCM extension;
  407. extension = SCM_CAR (extensions);
  408. if (scm_is_true (scm_string_suffix_p (extension, str,
  409. SCM_UNDEFINED, SCM_UNDEFINED,
  410. SCM_UNDEFINED, SCM_UNDEFINED)))
  411. return 1;
  412. }
  413. return 0;
  414. }
  415. /* Defined as "/" for Unix and Windows alike, so that file names
  416. constructed by the functions in this module wind up with Unix-style
  417. forward slashes as directory separators. */
  418. #define FILE_NAME_SEPARATOR_STRING "/"
  419. static int
  420. is_file_name_separator (SCM c)
  421. {
  422. if (scm_is_eq (c, SCM_MAKE_CHAR ('/')))
  423. return 1;
  424. #ifdef __MINGW32__
  425. if (scm_is_eq (c, SCM_MAKE_CHAR ('\\')))
  426. return 1;
  427. #endif
  428. return 0;
  429. }
  430. static int
  431. is_drive_letter (SCM c)
  432. {
  433. #ifdef __MINGW32__
  434. if (SCM_CHAR (c) >= 'a' && SCM_CHAR (c) <= 'z')
  435. return 1;
  436. else if (SCM_CHAR (c) >= 'A' && SCM_CHAR (c) <= 'Z')
  437. return 1;
  438. #endif
  439. return 0;
  440. }
  441. static int
  442. is_absolute_file_name (SCM filename)
  443. {
  444. size_t filename_len = scm_c_string_length (filename);
  445. if (filename_len >= 1
  446. && is_file_name_separator (scm_c_string_ref (filename, 0))
  447. #ifdef __MINGW32__
  448. /* On Windows, one initial separator indicates a drive-relative
  449. path. Two separators indicate a Universal Naming Convention
  450. (UNC) path. UNC paths are always absolute. */
  451. && filename_len >= 2
  452. && is_file_name_separator (scm_c_string_ref (filename, 1))
  453. #endif
  454. )
  455. return 1;
  456. if (filename_len >= 3
  457. && is_drive_letter (scm_c_string_ref (filename, 0))
  458. && scm_is_eq (scm_c_string_ref (filename, 1), SCM_MAKE_CHAR (':'))
  459. && is_file_name_separator (scm_c_string_ref (filename, 2)))
  460. return 1;
  461. return 0;
  462. }
  463. /* Return true if COMPILED_FILENAME is newer than source file
  464. FULL_FILENAME, false otherwise. */
  465. static int
  466. compiled_is_fresh (SCM full_filename, SCM compiled_filename,
  467. struct stat *stat_source, struct stat *stat_compiled)
  468. {
  469. int compiled_is_newer;
  470. struct timespec source_mtime, compiled_mtime;
  471. source_mtime = get_stat_mtime (stat_source);
  472. compiled_mtime = get_stat_mtime (stat_compiled);
  473. if (source_mtime.tv_sec < compiled_mtime.tv_sec
  474. || (source_mtime.tv_sec == compiled_mtime.tv_sec
  475. && source_mtime.tv_nsec <= compiled_mtime.tv_nsec))
  476. compiled_is_newer = 1;
  477. else
  478. {
  479. compiled_is_newer = 0;
  480. scm_puts_unlocked (";;; note: source file ", scm_current_warning_port ());
  481. scm_display (full_filename, scm_current_warning_port ());
  482. scm_puts_unlocked ("\n;;; newer than compiled ", scm_current_warning_port ());
  483. scm_display (compiled_filename, scm_current_warning_port ());
  484. scm_puts_unlocked ("\n", scm_current_warning_port ());
  485. }
  486. return compiled_is_newer;
  487. }
  488. /* Search PATH for a directory containing a file named FILENAME.
  489. The file must be readable, and not a directory.
  490. If we find one, return its full pathname; otherwise, return #f.
  491. If FILENAME is absolute, return it unchanged.
  492. We also fill *stat_buf corresponding to the returned pathname.
  493. If given, EXTENSIONS is a list of strings; for each directory
  494. in PATH, we search for FILENAME concatenated with each EXTENSION.
  495. If SOURCE_FILE_NAME is SCM_BOOL_F, then return the first matching
  496. file name that we find in the path. Otherwise only return a file if
  497. it is newer than SOURCE_STAT_BUF, otherwise issuing a warning if we
  498. see a stale file earlier in the path, setting *FOUND_STALE_FILE to 1.
  499. */
  500. static SCM
  501. search_path (SCM path, SCM filename, SCM extensions, SCM require_exts,
  502. struct stat *stat_buf,
  503. SCM source_file_name, struct stat *source_stat_buf,
  504. int *found_stale_file)
  505. {
  506. struct stringbuf buf;
  507. char *filename_chars;
  508. size_t filename_len;
  509. SCM result = SCM_BOOL_F;
  510. char initial_buffer[256];
  511. if (scm_ilength (path) < 0)
  512. scm_misc_error ("%search-path", "path is not a proper list: ~a",
  513. scm_list_1 (path));
  514. if (scm_ilength (extensions) < 0)
  515. scm_misc_error ("%search-path", "bad extensions list: ~a",
  516. scm_list_1 (extensions));
  517. scm_dynwind_begin (0);
  518. filename_chars = scm_to_locale_string (filename);
  519. filename_len = strlen (filename_chars);
  520. scm_dynwind_free (filename_chars);
  521. /* If FILENAME is absolute and is still valid, return it unchanged. */
  522. if (is_absolute_file_name (filename))
  523. {
  524. if ((scm_is_false (require_exts) ||
  525. string_has_an_ext (filename, extensions))
  526. && stat (filename_chars, stat_buf) == 0
  527. && !(stat_buf->st_mode & S_IFDIR))
  528. result = filename;
  529. goto end;
  530. }
  531. /* If FILENAME has an extension, don't try to add EXTENSIONS to it. */
  532. {
  533. char *endp;
  534. for (endp = filename_chars + filename_len - 1;
  535. endp >= filename_chars;
  536. endp--)
  537. {
  538. if (*endp == '.')
  539. {
  540. if (scm_is_true (require_exts) &&
  541. !string_has_an_ext (filename, extensions))
  542. {
  543. /* This filename has an extension, but not one of the right
  544. ones... */
  545. goto end;
  546. }
  547. /* This filename already has an extension, so cancel the
  548. list of extensions. */
  549. extensions = SCM_EOL;
  550. break;
  551. }
  552. else if (is_file_name_separator (SCM_MAKE_CHAR (*endp)))
  553. /* This filename has no extension, so keep the current list
  554. of extensions. */
  555. break;
  556. }
  557. }
  558. /* This simplifies the loop below a bit.
  559. */
  560. if (scm_is_null (extensions))
  561. extensions = scm_listofnullstr;
  562. buf.buf_len = sizeof initial_buffer;
  563. buf.buf = initial_buffer;
  564. /* Try every path element.
  565. */
  566. for (; scm_is_pair (path); path = SCM_CDR (path))
  567. {
  568. SCM dir = SCM_CAR (path);
  569. SCM exts;
  570. size_t sans_ext_len;
  571. buf.ptr = buf.buf;
  572. stringbuf_cat_locale_string (&buf, dir);
  573. /* Concatenate the path name and the filename. */
  574. if (buf.ptr > buf.buf
  575. && !is_file_name_separator (SCM_MAKE_CHAR (buf.ptr[-1])))
  576. stringbuf_cat (&buf, FILE_NAME_SEPARATOR_STRING);
  577. stringbuf_cat (&buf, filename_chars);
  578. sans_ext_len = buf.ptr - buf.buf;
  579. /* Try every extension. */
  580. for (exts = extensions; scm_is_pair (exts); exts = SCM_CDR (exts))
  581. {
  582. SCM ext = SCM_CAR (exts);
  583. buf.ptr = buf.buf + sans_ext_len;
  584. stringbuf_cat_locale_string (&buf, ext);
  585. /* If the file exists at all, we should return it. If the
  586. file is inaccessible, then that's an error. */
  587. if (stat (buf.buf, stat_buf) == 0
  588. && ! (stat_buf->st_mode & S_IFDIR))
  589. {
  590. SCM found =
  591. scm_from_locale_string (scm_i_mirror_backslashes (buf.buf));
  592. if (scm_is_true (source_file_name) &&
  593. !compiled_is_fresh (source_file_name, found,
  594. source_stat_buf, stat_buf))
  595. {
  596. if (found_stale_file)
  597. *found_stale_file = 1;
  598. continue;
  599. }
  600. if (found_stale_file && *found_stale_file)
  601. {
  602. scm_puts_unlocked (";;; found fresh compiled file at ",
  603. scm_current_warning_port ());
  604. scm_display (found, scm_current_warning_port ());
  605. scm_newline (scm_current_warning_port ());
  606. }
  607. result = found;
  608. goto end;
  609. }
  610. }
  611. if (!SCM_NULL_OR_NIL_P (exts))
  612. scm_wrong_type_arg_msg (NULL, 0, extensions, "proper list");
  613. }
  614. if (!SCM_NULL_OR_NIL_P (path))
  615. scm_wrong_type_arg_msg (NULL, 0, path, "proper list");
  616. end:
  617. scm_dynwind_end ();
  618. return result;
  619. }
  620. SCM_DEFINE (scm_search_path, "search-path", 2, 0, 1,
  621. (SCM path, SCM filename, SCM rest),
  622. "Search @var{path} for a directory containing a file named\n"
  623. "@var{filename}. The file must be readable, and not a directory.\n"
  624. "If we find one, return its full filename; otherwise, return\n"
  625. "@code{#f}. If @var{filename} is absolute, return it unchanged.\n"
  626. "If given, @var{rest} is a list of extension strings; for each\n"
  627. "directory in @var{path}, we search for @var{filename}\n"
  628. "concatenated with each extension.")
  629. #define FUNC_NAME s_scm_search_path
  630. {
  631. SCM extensions, require_exts;
  632. struct stat stat_buf;
  633. if (SCM_UNBNDP (rest) || scm_is_null (rest))
  634. {
  635. /* Called either by Scheme code that didn't provide the optional
  636. arguments, or C code that used the Guile 1.8 signature (2 required,
  637. 1 optional arg) and passed '() or nothing as the EXTENSIONS
  638. argument. */
  639. extensions = SCM_EOL;
  640. require_exts = SCM_UNDEFINED;
  641. }
  642. else
  643. {
  644. if (scm_is_null (SCM_CAR (rest)) || scm_is_pair (SCM_CAR (rest)))
  645. {
  646. /* Called by Scheme code written for 1.9. */
  647. extensions = SCM_CAR (rest);
  648. if (scm_is_null (SCM_CDR (rest)))
  649. require_exts = SCM_UNDEFINED;
  650. else
  651. {
  652. require_exts = SCM_CADR (rest);
  653. if (SCM_UNLIKELY (!scm_is_null (SCM_CDDR (rest))))
  654. scm_wrong_num_args (scm_from_locale_string (FUNC_NAME));
  655. }
  656. }
  657. else
  658. {
  659. /* Called by C code that uses the 1.8 signature, i.e., which
  660. expects the 3rd argument to be EXTENSIONS. */
  661. extensions = rest;
  662. require_exts = SCM_UNDEFINED;
  663. }
  664. }
  665. if (SCM_UNBNDP (extensions))
  666. extensions = SCM_EOL;
  667. if (SCM_UNBNDP (require_exts))
  668. require_exts = SCM_BOOL_F;
  669. return search_path (path, filename, extensions, require_exts, &stat_buf,
  670. SCM_BOOL_F, NULL, NULL);
  671. }
  672. #undef FUNC_NAME
  673. /* Search %load-path for a directory containing a file named FILENAME.
  674. The file must be readable, and not a directory.
  675. If we find one, return its full filename; otherwise, return #f.
  676. If FILENAME is absolute, return it unchanged. */
  677. SCM_DEFINE (scm_sys_search_load_path, "%search-load-path", 1, 0, 0,
  678. (SCM filename),
  679. "Search @var{%load-path} for the file named @var{filename},\n"
  680. "which must be readable by the current user. If @var{filename}\n"
  681. "is found in the list of paths to search or is an absolute\n"
  682. "pathname, return its full pathname. Otherwise, return\n"
  683. "@code{#f}. Filenames may have any of the optional extensions\n"
  684. "in the @code{%load-extensions} list; @code{%search-load-path}\n"
  685. "will try each extension automatically.")
  686. #define FUNC_NAME s_scm_sys_search_load_path
  687. {
  688. struct stat stat_buf;
  689. SCM_VALIDATE_STRING (1, filename);
  690. return search_path (*scm_loc_load_path, filename, *scm_loc_load_extensions,
  691. SCM_BOOL_F, &stat_buf, SCM_BOOL_F, NULL, NULL);
  692. }
  693. #undef FUNC_NAME
  694. SCM_KEYWORD (kw_env, "env");
  695. SCM_KEYWORD (kw_opts, "opts");
  696. SCM_SYMBOL (sym_compile_file, "compile-file");
  697. SCM_SYMBOL (sym_auto_compilation_options, "%auto-compilation-options");
  698. static SCM
  699. do_try_auto_compile (void *data)
  700. {
  701. SCM source = SCM_PACK_POINTER (data);
  702. SCM comp_mod, compile_file;
  703. scm_puts_unlocked (";;; compiling ", scm_current_warning_port ());
  704. scm_display (source, scm_current_warning_port ());
  705. scm_newline (scm_current_warning_port ());
  706. comp_mod = scm_c_resolve_module ("system base compile");
  707. compile_file = scm_module_variable (comp_mod, sym_compile_file);
  708. if (scm_is_true (compile_file))
  709. {
  710. /* Auto-compile in the context of the current module. */
  711. SCM res, opts;
  712. SCM args[5];
  713. opts = scm_module_variable (scm_the_root_module (),
  714. sym_auto_compilation_options);
  715. if (SCM_VARIABLEP (opts))
  716. opts = SCM_VARIABLE_REF (opts);
  717. else
  718. opts = SCM_EOL;
  719. args[0] = source;
  720. args[1] = kw_opts;
  721. args[2] = opts;
  722. args[3] = kw_env;
  723. args[4] = scm_current_module ();
  724. /* Assume `*current-warning-prefix*' has an appropriate value. */
  725. res = scm_call_n (scm_variable_ref (compile_file), args, 5);
  726. scm_puts_unlocked (";;; compiled ", scm_current_warning_port ());
  727. scm_display (res, scm_current_warning_port ());
  728. scm_newline (scm_current_warning_port ());
  729. return res;
  730. }
  731. else
  732. {
  733. scm_puts_unlocked (";;; it seems ", scm_current_warning_port ());
  734. scm_display (source, scm_current_warning_port ());
  735. scm_puts_unlocked ("\n;;; is part of the compiler; skipping auto-compilation\n",
  736. scm_current_warning_port ());
  737. return SCM_BOOL_F;
  738. }
  739. }
  740. static SCM
  741. auto_compile_catch_handler (void *data, SCM tag, SCM throw_args)
  742. {
  743. SCM source = SCM_PACK_POINTER (data);
  744. SCM oport, lines;
  745. oport = scm_open_output_string ();
  746. scm_print_exception (oport, SCM_BOOL_F, tag, throw_args);
  747. scm_puts_unlocked (";;; WARNING: compilation of ", scm_current_warning_port ());
  748. scm_display (source, scm_current_warning_port ());
  749. scm_puts_unlocked (" failed:\n", scm_current_warning_port ());
  750. lines = scm_string_split (scm_get_output_string (oport),
  751. SCM_MAKE_CHAR ('\n'));
  752. for (; scm_is_pair (lines); lines = scm_cdr (lines))
  753. if (scm_c_string_length (scm_car (lines)))
  754. {
  755. scm_puts_unlocked (";;; ", scm_current_warning_port ());
  756. scm_display (scm_car (lines), scm_current_warning_port ());
  757. scm_newline (scm_current_warning_port ());
  758. }
  759. scm_close_port (oport);
  760. return SCM_BOOL_F;
  761. }
  762. SCM_DEFINE (scm_sys_warn_auto_compilation_enabled, "%warn-auto-compilation-enabled", 0, 0, 0,
  763. (void), "")
  764. #define FUNC_NAME s_scm_sys_warn_auto_compilation_enabled
  765. {
  766. static int message_shown = 0;
  767. if (!message_shown)
  768. {
  769. scm_puts_unlocked (";;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0\n"
  770. ";;; or pass the --no-auto-compile argument to disable.\n",
  771. scm_current_warning_port ());
  772. message_shown = 1;
  773. }
  774. return SCM_UNSPECIFIED;
  775. }
  776. #undef FUNC_NAME
  777. static SCM
  778. scm_try_auto_compile (SCM source)
  779. {
  780. if (scm_is_false (*scm_loc_load_should_auto_compile))
  781. return SCM_BOOL_F;
  782. scm_sys_warn_auto_compilation_enabled ();
  783. return scm_c_catch (SCM_BOOL_T,
  784. do_try_auto_compile,
  785. SCM_UNPACK_POINTER (source),
  786. auto_compile_catch_handler,
  787. SCM_UNPACK_POINTER (source),
  788. NULL, NULL);
  789. }
  790. /* The auto-compilation code will residualize a .go file in the cache
  791. dir: by default, $HOME/.cache/guile/2.0/ccache/PATH.go. This
  792. function determines the PATH to use as a key into the compilation
  793. cache. See also (system base compile):compiled-file-name. */
  794. static SCM
  795. canonical_suffix (SCM fname)
  796. {
  797. SCM canon;
  798. /* CANON should be absolute. */
  799. canon = scm_canonicalize_path (fname);
  800. #ifdef __MINGW32__
  801. {
  802. size_t len = scm_c_string_length (canon);
  803. /* On Windows, an absolute file name that doesn't start with a
  804. separator starts with a drive component. Transform the drive
  805. component to a file name element: c:\foo -> \c\foo. */
  806. if (len >= 2
  807. && is_absolute_file_name (canon)
  808. && !is_file_name_separator (scm_c_string_ref (canon, 0)))
  809. return scm_string_append
  810. (scm_list_3 (scm_from_latin1_string (FILE_NAME_SEPARATOR_STRING),
  811. scm_c_substring (canon, 0, 1),
  812. scm_c_substring (canon, 2, len)));
  813. }
  814. #endif
  815. return canon;
  816. }
  817. SCM_DEFINE (scm_primitive_load_path, "primitive-load-path", 0, 0, 1,
  818. (SCM args),
  819. "Search @var{%load-path} for the file named @var{filename} and\n"
  820. "load it into the top-level environment.\n\n"
  821. "If @var{filename} is a relative pathname and is not found in\n"
  822. "the list of search paths, one of three things may happen,\n"
  823. "depending on the optional second argument,\n"
  824. "@var{exception_on_not_found}. If it is @code{#f}, @code{#f}\n"
  825. "will be returned. If it is a procedure, it will be called\n"
  826. "with no arguments. Otherwise an error is signalled.")
  827. #define FUNC_NAME s_scm_primitive_load_path
  828. {
  829. SCM filename, exception_on_not_found;
  830. SCM full_filename, compiled_filename;
  831. SCM hook = *scm_loc_load_hook;
  832. struct stat stat_source, stat_compiled;
  833. int found_stale_compiled_file = 0;
  834. if (scm_is_true (hook) && scm_is_false (scm_procedure_p (hook)))
  835. SCM_MISC_ERROR ("value of %load-hook is neither a procedure nor #f",
  836. SCM_EOL);
  837. if (scm_is_string (args))
  838. {
  839. /* C code written for 1.8 and earlier expects this function to take a
  840. single argument (the file name). */
  841. filename = args;
  842. exception_on_not_found = SCM_UNDEFINED;
  843. }
  844. else
  845. {
  846. /* Starting from 1.9, this function takes 1 required and 1 optional
  847. argument. */
  848. long len;
  849. SCM_VALIDATE_LIST_COPYLEN (SCM_ARG1, args, len);
  850. if (len < 1 || len > 2)
  851. scm_error_num_args_subr (FUNC_NAME);
  852. filename = SCM_CAR (args);
  853. SCM_VALIDATE_STRING (SCM_ARG1, filename);
  854. exception_on_not_found = len > 1 ? SCM_CADR (args) : SCM_UNDEFINED;
  855. }
  856. if (SCM_UNBNDP (exception_on_not_found))
  857. exception_on_not_found = SCM_BOOL_T;
  858. full_filename = search_path (*scm_loc_load_path, filename,
  859. *scm_loc_load_extensions, SCM_BOOL_F,
  860. &stat_source, SCM_BOOL_F, NULL, NULL);
  861. compiled_filename =
  862. search_path (*scm_loc_load_compiled_path, filename,
  863. *scm_loc_load_compiled_extensions, SCM_BOOL_T,
  864. &stat_compiled, full_filename, &stat_source,
  865. &found_stale_compiled_file);
  866. if (scm_is_false (compiled_filename)
  867. && scm_is_true (full_filename)
  868. && scm_is_true (*scm_loc_compile_fallback_path)
  869. && scm_is_false (*scm_loc_fresh_auto_compile)
  870. && scm_is_pair (*scm_loc_load_compiled_extensions)
  871. && scm_is_string (scm_car (*scm_loc_load_compiled_extensions)))
  872. {
  873. SCM fallback;
  874. char *fallback_chars;
  875. fallback = scm_string_append
  876. (scm_list_3 (*scm_loc_compile_fallback_path,
  877. canonical_suffix (full_filename),
  878. scm_car (*scm_loc_load_compiled_extensions)));
  879. fallback_chars = scm_to_locale_string (fallback);
  880. if (stat (fallback_chars, &stat_compiled) == 0
  881. && compiled_is_fresh (full_filename, fallback,
  882. &stat_source, &stat_compiled))
  883. {
  884. if (found_stale_compiled_file)
  885. {
  886. scm_puts_unlocked (";;; found fresh local cache at ",
  887. scm_current_warning_port ());
  888. scm_display (fallback, scm_current_warning_port ());
  889. scm_newline (scm_current_warning_port ());
  890. }
  891. compiled_filename = fallback;
  892. }
  893. free (fallback_chars);
  894. }
  895. if (scm_is_false (full_filename) && scm_is_false (compiled_filename))
  896. {
  897. if (scm_is_true (scm_procedure_p (exception_on_not_found)))
  898. return scm_call_0 (exception_on_not_found);
  899. else if (scm_is_false (exception_on_not_found))
  900. return SCM_BOOL_F;
  901. else
  902. SCM_MISC_ERROR ("Unable to find file ~S in load path",
  903. scm_list_1 (filename));
  904. }
  905. if (!scm_is_false (hook))
  906. scm_call_1 (hook, (scm_is_true (full_filename)
  907. ? full_filename : compiled_filename));
  908. if (scm_is_true (compiled_filename))
  909. return scm_load_compiled_with_vm (compiled_filename);
  910. else
  911. {
  912. SCM freshly_compiled = scm_try_auto_compile (full_filename);
  913. if (scm_is_true (freshly_compiled))
  914. return scm_load_compiled_with_vm (freshly_compiled);
  915. else
  916. return scm_primitive_load (full_filename);
  917. }
  918. }
  919. #undef FUNC_NAME
  920. SCM
  921. scm_c_primitive_load_path (const char *filename)
  922. {
  923. return scm_primitive_load_path (scm_from_locale_string (filename));
  924. }
  925. void
  926. scm_init_eval_in_scheme (void)
  927. {
  928. SCM eval_scm, eval_go;
  929. struct stat stat_source, stat_compiled;
  930. int found_stale_eval_go = 0;
  931. eval_scm = search_path (*scm_loc_load_path,
  932. scm_from_locale_string ("ice-9/eval.scm"),
  933. SCM_EOL, SCM_BOOL_F, &stat_source,
  934. SCM_BOOL_F, NULL, NULL);
  935. eval_go = search_path (*scm_loc_load_compiled_path,
  936. scm_from_locale_string ("ice-9/eval.go"),
  937. SCM_EOL, SCM_BOOL_F, &stat_compiled,
  938. eval_scm, &stat_source, &found_stale_eval_go);
  939. if (scm_is_true (eval_go))
  940. scm_load_compiled_with_vm (eval_go);
  941. else
  942. /* If we have no eval.go, we shouldn't load any compiled code at all
  943. because we can't guarantee that tail calls will work. */
  944. *scm_loc_load_compiled_path = SCM_EOL;
  945. }
  946. /* Information about the build environment. */
  947. SCM_VARIABLE_INIT (sys_host_type, "%host-type",
  948. scm_from_locale_string (HOST_TYPE));
  949. /* Initialize the scheme variable %guile-build-info, based on data
  950. provided by the Makefile, via libpath.h. */
  951. static void
  952. init_build_info ()
  953. {
  954. static struct { char *name; char *value; } info[] = SCM_BUILD_INFO;
  955. SCM *loc = SCM_VARIABLE_LOC (scm_c_define ("%guile-build-info", SCM_EOL));
  956. unsigned long i;
  957. for (i = 0; i < (sizeof (info) / sizeof (info[0])); i++)
  958. {
  959. SCM key = scm_from_utf8_symbol (info[i].name);
  960. SCM val = scm_from_locale_string (info[i].value);
  961. *loc = scm_acons (key, val, *loc);
  962. }
  963. #ifdef PACKAGE_PACKAGER
  964. *loc = scm_acons (scm_from_latin1_symbol ("packager"),
  965. scm_from_latin1_string (PACKAGE_PACKAGER),
  966. *loc);
  967. #endif
  968. #ifdef PACKAGE_PACKAGER_VERSION
  969. *loc = scm_acons (scm_from_latin1_symbol ("packager-version"),
  970. scm_from_latin1_string (PACKAGE_PACKAGER_VERSION),
  971. *loc);
  972. #endif
  973. #ifdef PACKAGE_PACKAGER_BUG_REPORTS
  974. *loc = scm_acons (scm_from_latin1_symbol ("packager-bug-reports"),
  975. scm_from_latin1_string (PACKAGE_PACKAGER_BUG_REPORTS),
  976. *loc);
  977. #endif
  978. }
  979. void
  980. scm_init_load ()
  981. {
  982. scm_listofnullstr = scm_list_1 (scm_nullstr);
  983. scm_loc_load_path = SCM_VARIABLE_LOC (scm_c_define ("%load-path", SCM_EOL));
  984. scm_loc_load_extensions
  985. = SCM_VARIABLE_LOC (scm_c_define ("%load-extensions",
  986. scm_list_2 (scm_from_locale_string (".scm"),
  987. scm_nullstr)));
  988. scm_loc_load_compiled_path
  989. = SCM_VARIABLE_LOC (scm_c_define ("%load-compiled-path", SCM_EOL));
  990. scm_loc_load_compiled_extensions
  991. = SCM_VARIABLE_LOC (scm_c_define ("%load-compiled-extensions",
  992. scm_list_1 (scm_from_locale_string (".go"))));
  993. scm_loc_load_hook = SCM_VARIABLE_LOC (scm_c_define ("%load-hook", SCM_BOOL_F));
  994. scm_loc_compile_fallback_path
  995. = SCM_VARIABLE_LOC (scm_c_define ("%compile-fallback-path", SCM_BOOL_F));
  996. scm_loc_load_should_auto_compile
  997. = SCM_VARIABLE_LOC (scm_c_define ("%load-should-auto-compile", SCM_BOOL_F));
  998. scm_loc_fresh_auto_compile
  999. = SCM_VARIABLE_LOC (scm_c_define ("%fresh-auto-compile", SCM_BOOL_F));
  1000. scm_ellipsis = scm_from_latin1_string ("...");
  1001. the_reader = scm_make_fluid_with_default (SCM_BOOL_F);
  1002. scm_c_define("current-reader", the_reader);
  1003. scm_c_define ("load-compiled",
  1004. scm_c_make_gsubr ("load-compiled/vm", 1, 0, 0,
  1005. scm_load_compiled_with_vm));
  1006. init_build_info ();
  1007. #include "libguile/load.x"
  1008. }
  1009. void
  1010. scm_init_load_should_auto_compile ()
  1011. {
  1012. char *auto_compile = getenv ("GUILE_AUTO_COMPILE");
  1013. if (auto_compile && strcmp (auto_compile, "0") == 0)
  1014. {
  1015. *scm_loc_load_should_auto_compile = SCM_BOOL_F;
  1016. *scm_loc_fresh_auto_compile = SCM_BOOL_F;
  1017. }
  1018. /* Allow "freshen" also. */
  1019. else if (auto_compile && strncmp (auto_compile, "fresh", 5) == 0)
  1020. {
  1021. *scm_loc_load_should_auto_compile = SCM_BOOL_T;
  1022. *scm_loc_fresh_auto_compile = SCM_BOOL_T;
  1023. }
  1024. else
  1025. {
  1026. *scm_loc_load_should_auto_compile = SCM_BOOL_T;
  1027. *scm_loc_fresh_auto_compile = SCM_BOOL_F;
  1028. }
  1029. }
  1030. /*
  1031. Local Variables:
  1032. c-file-style: "gnu"
  1033. End:
  1034. */