Commit | Line | Data |
---|---|---|
19e2247d MV |
1 | /* This file contains definitions for deprecated features. When you |
2 | deprecate something, move it here when that is feasible. | |
3 | */ | |
4 | ||
5 | /* Copyright (C) 2003 Free Software Foundation, Inc. | |
6 | * | |
73be1d9e MV |
7 | * This library is free software; you can redistribute it and/or |
8 | * modify it under the terms of the GNU Lesser General Public | |
9 | * License as published by the Free Software Foundation; either | |
10 | * version 2.1 of the License, or (at your option) any later version. | |
19e2247d | 11 | * |
73be1d9e | 12 | * This library is distributed in the hope that it will be useful, |
19e2247d | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
73be1d9e MV |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | * Lesser General Public License for more details. | |
19e2247d | 16 | * |
73be1d9e MV |
17 | * You should have received a copy of the GNU Lesser General Public |
18 | * License along with this library; if not, write to the Free Software | |
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
20 | */ | |
19e2247d MV |
21 | |
22 | #include "libguile/_scm.h" | |
23 | #include "libguile/deprecated.h" | |
55d30fac | 24 | #include "libguile/deprecation.h" |
19e2247d MV |
25 | #include "libguile/snarf.h" |
26 | #include "libguile/validate.h" | |
27 | #include "libguile/strings.h" | |
28 | #include "libguile/strop.h" | |
a0454d72 MV |
29 | #include "libguile/modules.h" |
30 | #include "libguile/eval.h" | |
31 | #include "libguile/smob.h" | |
32 | #include "libguile/procprop.h" | |
33 | #include "libguile/vectors.h" | |
34 | #include "libguile/hashtab.h" | |
35 | #include "libguile/struct.h" | |
36 | #include "libguile/variable.h" | |
37 | #include "libguile/fluids.h" | |
38 | #include "libguile/ports.h" | |
965445d4 MV |
39 | #include "libguile/eq.h" |
40 | #include "libguile/read.h" | |
4abecea8 MV |
41 | #include "libguile/strports.h" |
42 | #include "libguile/smob.h" | |
cc5c1b66 | 43 | #include "libguile/alist.h" |
19e2247d | 44 | |
55d30fac MV |
45 | #include <stdio.h> |
46 | #include <string.h> | |
47 | ||
19e2247d MV |
48 | #if (SCM_ENABLE_DEPRECATED == 1) |
49 | ||
7e6e6b37 DH |
50 | /* From print.c: Internal symbol names of isyms. Deprecated in guile 1.7.0 on |
51 | * 2004-04-22. */ | |
52 | char *scm_isymnames[] = | |
53 | { | |
54 | "#@<deprecated>" | |
55 | }; | |
56 | ||
57 | ||
e90c3a89 DH |
58 | /* From eval.c: Error messages of the evaluator. These were deprecated in |
59 | * guile 1.7.0 on 2003-06-02. */ | |
60 | const char scm_s_expression[] = "missing or extra expression"; | |
61 | const char scm_s_test[] = "bad test"; | |
62 | const char scm_s_body[] = "bad body"; | |
63 | const char scm_s_bindings[] = "bad bindings"; | |
64 | const char scm_s_variable[] = "bad variable"; | |
65 | const char scm_s_clauses[] = "bad or missing clauses"; | |
66 | const char scm_s_formals[] = "bad formals"; | |
67 | ||
68 | ||
19e2247d MV |
69 | SCM_REGISTER_PROC(s_substring_move_left_x, "substring-move-left!", 5, 0, 0, scm_substring_move_x); |
70 | ||
71 | SCM_REGISTER_PROC(s_substring_move_right_x, "substring-move-right!", 5, 0, 0, scm_substring_move_x); | |
72 | ||
55d30fac MV |
73 | SCM |
74 | scm_wta (SCM arg, const char *pos, const char *s_subr) | |
75 | { | |
76 | if (!s_subr || !*s_subr) | |
77 | s_subr = NULL; | |
78 | if ((~0x1fL) & (long) pos) | |
79 | { | |
80 | /* error string supplied. */ | |
81 | scm_misc_error (s_subr, pos, scm_list_1 (arg)); | |
82 | } | |
83 | else | |
84 | { | |
85 | /* numerical error code. */ | |
86 | scm_t_bits error = (scm_t_bits) pos; | |
87 | ||
88 | switch (error) | |
89 | { | |
90 | case SCM_ARGn: | |
91 | scm_wrong_type_arg (s_subr, 0, arg); | |
92 | case SCM_ARG1: | |
93 | scm_wrong_type_arg (s_subr, 1, arg); | |
94 | case SCM_ARG2: | |
95 | scm_wrong_type_arg (s_subr, 2, arg); | |
96 | case SCM_ARG3: | |
97 | scm_wrong_type_arg (s_subr, 3, arg); | |
98 | case SCM_ARG4: | |
99 | scm_wrong_type_arg (s_subr, 4, arg); | |
100 | case SCM_ARG5: | |
101 | scm_wrong_type_arg (s_subr, 5, arg); | |
102 | case SCM_ARG6: | |
103 | scm_wrong_type_arg (s_subr, 6, arg); | |
104 | case SCM_ARG7: | |
105 | scm_wrong_type_arg (s_subr, 7, arg); | |
106 | case SCM_WNA: | |
107 | scm_wrong_num_args (arg); | |
108 | case SCM_OUTOFRANGE: | |
109 | scm_out_of_range (s_subr, arg); | |
110 | case SCM_NALLOC: | |
111 | scm_memory_error (s_subr); | |
112 | default: | |
113 | /* this shouldn't happen. */ | |
114 | scm_misc_error (s_subr, "Unknown error", SCM_EOL); | |
115 | } | |
116 | } | |
117 | return SCM_UNSPECIFIED; | |
118 | } | |
119 | ||
120 | /* Module registry | |
121 | */ | |
122 | ||
123 | /* We can't use SCM objects here. One should be able to call | |
124 | SCM_REGISTER_MODULE from a C++ constructor for a static | |
125 | object. This happens before main and thus before libguile is | |
126 | initialized. */ | |
127 | ||
128 | struct moddata { | |
129 | struct moddata *link; | |
130 | char *module_name; | |
131 | void *init_func; | |
132 | }; | |
133 | ||
134 | static struct moddata *registered_mods = NULL; | |
135 | ||
136 | void | |
137 | scm_register_module_xxx (char *module_name, void *init_func) | |
138 | { | |
139 | struct moddata *md; | |
140 | ||
141 | scm_c_issue_deprecation_warning | |
142 | ("`scm_register_module_xxx' is deprecated. Use extensions instead."); | |
143 | ||
144 | /* XXX - should we (and can we) DEFER_INTS here? */ | |
145 | ||
146 | for (md = registered_mods; md; md = md->link) | |
147 | if (!strcmp (md->module_name, module_name)) | |
148 | { | |
149 | md->init_func = init_func; | |
150 | return; | |
151 | } | |
152 | ||
153 | md = (struct moddata *) malloc (sizeof (struct moddata)); | |
154 | if (md == NULL) | |
155 | { | |
156 | fprintf (stderr, | |
157 | "guile: can't register module (%s): not enough memory", | |
158 | module_name); | |
159 | return; | |
160 | } | |
161 | ||
162 | md->module_name = module_name; | |
163 | md->init_func = init_func; | |
164 | md->link = registered_mods; | |
165 | registered_mods = md; | |
166 | } | |
167 | ||
168 | SCM_DEFINE (scm_registered_modules, "c-registered-modules", 0, 0, 0, | |
169 | (), | |
170 | "Return a list of the object code modules that have been imported into\n" | |
171 | "the current Guile process. Each element of the list is a pair whose\n" | |
172 | "car is the name of the module, and whose cdr is the function handle\n" | |
173 | "for that module's initializer function. The name is the string that\n" | |
174 | "has been passed to scm_register_module_xxx.") | |
175 | #define FUNC_NAME s_scm_registered_modules | |
176 | { | |
177 | SCM res; | |
178 | struct moddata *md; | |
179 | ||
180 | res = SCM_EOL; | |
181 | for (md = registered_mods; md; md = md->link) | |
182 | res = scm_cons (scm_cons (scm_makfrom0str (md->module_name), | |
183 | scm_ulong2num ((unsigned long) md->init_func)), | |
184 | res); | |
185 | return res; | |
186 | } | |
187 | #undef FUNC_NAME | |
188 | ||
189 | SCM_DEFINE (scm_clear_registered_modules, "c-clear-registered-modules", 0, 0, 0, | |
190 | (), | |
191 | "Destroy the list of modules registered with the current Guile process.\n" | |
192 | "The return value is unspecified. @strong{Warning:} this function does\n" | |
193 | "not actually unlink or deallocate these modules, but only destroys the\n" | |
194 | "records of which modules have been loaded. It should therefore be used\n" | |
195 | "only by module bookkeeping operations.") | |
196 | #define FUNC_NAME s_scm_clear_registered_modules | |
197 | { | |
198 | struct moddata *md1, *md2; | |
199 | ||
200 | SCM_DEFER_INTS; | |
201 | ||
202 | for (md1 = registered_mods; md1; md1 = md2) | |
203 | { | |
204 | md2 = md1->link; | |
205 | free (md1); | |
206 | } | |
207 | registered_mods = NULL; | |
208 | ||
209 | SCM_ALLOW_INTS; | |
210 | return SCM_UNSPECIFIED; | |
211 | } | |
212 | #undef FUNC_NAME | |
213 | ||
a0454d72 MV |
214 | void |
215 | scm_remember (SCM *ptr) | |
216 | { | |
217 | scm_c_issue_deprecation_warning ("`scm_remember' is deprecated. " | |
218 | "Use the `scm_remember_upto_here*' family of functions instead."); | |
219 | } | |
220 | ||
221 | SCM | |
222 | scm_protect_object (SCM obj) | |
223 | { | |
224 | scm_c_issue_deprecation_warning ("`scm_protect_object' is deprecated. " | |
225 | "Use `scm_gc_protect_object' instead."); | |
226 | return scm_gc_protect_object (obj); | |
227 | } | |
228 | ||
229 | SCM | |
230 | scm_unprotect_object (SCM obj) | |
231 | { | |
232 | scm_c_issue_deprecation_warning ("`scm_unprotect_object' is deprecated. " | |
233 | "Use `scm_gc_unprotect_object' instead."); | |
234 | return scm_gc_unprotect_object (obj); | |
235 | } | |
236 | ||
237 | SCM_SYMBOL (scm_sym_app, "app"); | |
238 | SCM_SYMBOL (scm_sym_modules, "modules"); | |
239 | static SCM module_prefix = SCM_BOOL_F; | |
240 | static SCM make_modules_in_var; | |
241 | static SCM beautify_user_module_x_var; | |
242 | static SCM try_module_autoload_var; | |
243 | ||
244 | static void | |
245 | init_module_stuff () | |
246 | { | |
247 | #define PERM(x) scm_permanent_object(x) | |
248 | ||
249 | if (module_prefix == SCM_BOOL_F) | |
250 | { | |
251 | module_prefix = PERM (scm_list_2 (scm_sym_app, scm_sym_modules)); | |
252 | make_modules_in_var = PERM (scm_c_lookup ("make-modules-in")); | |
253 | beautify_user_module_x_var = | |
254 | PERM (scm_c_lookup ("beautify-user-module!")); | |
255 | try_module_autoload_var = PERM (scm_c_lookup ("try-module-autoload")); | |
256 | } | |
257 | } | |
258 | ||
259 | SCM | |
260 | scm_the_root_module () | |
261 | { | |
262 | init_module_stuff (); | |
263 | scm_c_issue_deprecation_warning ("`scm_the_root_module' is deprecated. " | |
264 | "Use `scm_c_resolve_module (\"guile\")' " | |
265 | "instead."); | |
266 | ||
267 | return scm_c_resolve_module ("guile"); | |
268 | } | |
269 | ||
270 | static SCM | |
271 | scm_module_full_name (SCM name) | |
272 | { | |
273 | init_module_stuff (); | |
274 | if (SCM_EQ_P (SCM_CAR (name), scm_sym_app)) | |
275 | return name; | |
276 | else | |
277 | return scm_append (scm_list_2 (module_prefix, name)); | |
278 | } | |
279 | ||
280 | SCM | |
281 | scm_make_module (SCM name) | |
282 | { | |
283 | init_module_stuff (); | |
284 | scm_c_issue_deprecation_warning ("`scm_make_module' is deprecated. " | |
285 | "Use `scm_c_define_module instead."); | |
286 | ||
287 | return scm_call_2 (SCM_VARIABLE_REF (make_modules_in_var), | |
288 | scm_the_root_module (), | |
289 | scm_module_full_name (name)); | |
290 | } | |
291 | ||
292 | SCM | |
293 | scm_ensure_user_module (SCM module) | |
294 | { | |
295 | init_module_stuff (); | |
296 | scm_c_issue_deprecation_warning ("`scm_ensure_user_module' is deprecated. " | |
297 | "Use `scm_c_define_module instead."); | |
298 | ||
299 | scm_call_1 (SCM_VARIABLE_REF (beautify_user_module_x_var), module); | |
300 | return SCM_UNSPECIFIED; | |
301 | } | |
302 | ||
303 | SCM | |
304 | scm_load_scheme_module (SCM name) | |
305 | { | |
306 | init_module_stuff (); | |
307 | scm_c_issue_deprecation_warning ("`scm_load_scheme_module' is deprecated. " | |
308 | "Use `scm_c_resolve_module instead."); | |
309 | ||
310 | return scm_call_1 (SCM_VARIABLE_REF (try_module_autoload_var), name); | |
311 | } | |
312 | ||
313 | /* This is implemented in C solely for SCM_COERCE_OUTPORT ... */ | |
314 | ||
315 | static void | |
316 | maybe_close_port (void *data, SCM port) | |
317 | { | |
318 | SCM except = (SCM)data; | |
319 | ||
320 | while (!SCM_NULLP (except)) | |
321 | { | |
322 | SCM p = SCM_COERCE_OUTPORT (SCM_CAR (except)); | |
323 | if (SCM_EQ_P (p, port)) | |
324 | return; | |
325 | except = SCM_CDR (except); | |
326 | } | |
327 | ||
328 | scm_close_port (port); | |
329 | } | |
330 | ||
331 | SCM_DEFINE (scm_close_all_ports_except, "close-all-ports-except", 0, 0, 1, | |
332 | (SCM ports), | |
333 | "[DEPRECATED] Close all open file ports used by the interpreter\n" | |
334 | "except for those supplied as arguments. This procedure\n" | |
335 | "was intended to be used before an exec call to close file descriptors\n" | |
336 | "which are not needed in the new process. However it has the\n" | |
337 | "undesirable side effect of flushing buffers, so it's deprecated.\n" | |
338 | "Use port-for-each instead.") | |
339 | #define FUNC_NAME s_scm_close_all_ports_except | |
340 | { | |
341 | SCM p; | |
342 | SCM_VALIDATE_REST_ARGUMENT (ports); | |
343 | ||
344 | for (p = ports; !SCM_NULLP (p); p = SCM_CDR (p)) | |
345 | SCM_VALIDATE_OPPORT (SCM_ARG1, SCM_COERCE_OUTPORT (SCM_CAR (p))); | |
346 | ||
347 | scm_c_port_for_each (maybe_close_port, ports); | |
348 | ||
349 | return SCM_UNSPECIFIED; | |
350 | } | |
351 | #undef FUNC_NAME | |
55d30fac | 352 | |
965445d4 MV |
353 | SCM_DEFINE (scm_variable_set_name_hint, "variable-set-name-hint!", 2, 0, 0, |
354 | (SCM var, SCM hint), | |
355 | "Do not use this function.") | |
356 | #define FUNC_NAME s_scm_variable_set_name_hint | |
357 | { | |
358 | SCM_VALIDATE_VARIABLE (1, var); | |
359 | SCM_VALIDATE_SYMBOL (2, hint); | |
360 | scm_c_issue_deprecation_warning | |
361 | ("'variable-set-name-hint!' is deprecated. Do not use it."); | |
362 | return SCM_UNSPECIFIED; | |
363 | } | |
364 | #undef FUNC_NAME | |
365 | ||
366 | SCM_DEFINE (scm_builtin_variable, "builtin-variable", 1, 0, 0, | |
367 | (SCM name), | |
368 | "Do not use this function.") | |
369 | #define FUNC_NAME s_scm_builtin_variable | |
370 | { | |
371 | SCM_VALIDATE_SYMBOL (1,name); | |
372 | scm_c_issue_deprecation_warning ("`builtin-variable' is deprecated. " | |
373 | "Use module system operations instead."); | |
374 | return scm_sym2var (name, SCM_BOOL_F, SCM_BOOL_T); | |
375 | } | |
376 | #undef FUNC_NAME | |
377 | ||
378 | SCM | |
379 | scm_makstr (size_t len, int dummy) | |
380 | { | |
381 | scm_c_issue_deprecation_warning | |
382 | ("'scm_makstr' is deprecated. Use 'scm_allocate_string' instead."); | |
383 | return scm_allocate_string (len); | |
384 | } | |
385 | ||
386 | SCM | |
387 | scm_makfromstr (const char *src, size_t len, int dummy SCM_UNUSED) | |
388 | { | |
389 | scm_c_issue_deprecation_warning ("`scm_makfromstr' is deprecated. " | |
390 | "Use `scm_mem2string' instead."); | |
391 | ||
392 | return scm_mem2string (src, len); | |
393 | } | |
394 | ||
395 | SCM | |
396 | scm_internal_with_fluids (SCM fluids, SCM values, SCM (*cproc) (), void *cdata) | |
397 | { | |
398 | scm_c_issue_deprecation_warning ("`scm_internal_with_fluids' is deprecated. " | |
399 | "Use `scm_c_with_fluids' instead."); | |
400 | ||
401 | return scm_c_with_fluids (fluids, values, cproc, cdata); | |
402 | } | |
403 | ||
404 | SCM | |
405 | scm_make_gsubr (const char *name, int req, int opt, int rst, SCM (*fcn)()) | |
406 | { | |
407 | scm_c_issue_deprecation_warning | |
408 | ("`scm_make_gsubr' is deprecated. Use `scm_c_define_gsubr' instead."); | |
409 | ||
410 | return scm_c_define_gsubr (name, req, opt, rst, fcn); | |
411 | } | |
412 | ||
413 | SCM | |
414 | scm_make_gsubr_with_generic (const char *name, | |
415 | int req, int opt, int rst, | |
416 | SCM (*fcn)(), SCM *gf) | |
417 | { | |
418 | scm_c_issue_deprecation_warning | |
419 | ("`scm_make_gsubr_with_generic' is deprecated. " | |
420 | "Use `scm_c_define_gsubr_with_generic' instead."); | |
421 | ||
422 | return scm_c_define_gsubr_with_generic (name, req, opt, rst, fcn, gf); | |
423 | } | |
424 | ||
425 | SCM | |
426 | scm_create_hook (const char *name, int n_args) | |
427 | { | |
428 | scm_c_issue_deprecation_warning | |
429 | ("'scm_create_hook' is deprecated. " | |
430 | "Use 'scm_make_hook' and 'scm_c_define' instead."); | |
431 | { | |
7888309b | 432 | SCM hook = scm_make_hook (scm_from_int (n_args)); |
965445d4 MV |
433 | scm_c_define (name, hook); |
434 | return scm_permanent_object (hook); | |
435 | } | |
436 | } | |
437 | ||
438 | SCM_DEFINE (scm_sloppy_memq, "sloppy-memq", 2, 0, 0, | |
439 | (SCM x, SCM lst), | |
440 | "This procedure behaves like @code{memq}, but does no type or error checking.\n" | |
441 | "Its use is recommended only in writing Guile internals,\n" | |
442 | "not for high-level Scheme programs.") | |
443 | #define FUNC_NAME s_scm_sloppy_memq | |
444 | { | |
445 | scm_c_issue_deprecation_warning | |
446 | ("'sloppy-memq' is deprecated. Use 'memq' instead."); | |
447 | ||
448 | for(; SCM_CONSP (lst); lst = SCM_CDR(lst)) | |
449 | { | |
450 | if (SCM_EQ_P (SCM_CAR (lst), x)) | |
451 | return lst; | |
452 | } | |
453 | return lst; | |
454 | } | |
455 | #undef FUNC_NAME | |
456 | ||
457 | ||
458 | SCM_DEFINE (scm_sloppy_memv, "sloppy-memv", 2, 0, 0, | |
459 | (SCM x, SCM lst), | |
460 | "This procedure behaves like @code{memv}, but does no type or error checking.\n" | |
461 | "Its use is recommended only in writing Guile internals,\n" | |
462 | "not for high-level Scheme programs.") | |
463 | #define FUNC_NAME s_scm_sloppy_memv | |
464 | { | |
465 | scm_c_issue_deprecation_warning | |
466 | ("'sloppy-memv' is deprecated. Use 'memv' instead."); | |
467 | ||
468 | for(; SCM_CONSP (lst); lst = SCM_CDR(lst)) | |
469 | { | |
7888309b | 470 | if (! scm_is_false (scm_eqv_p (SCM_CAR (lst), x))) |
965445d4 MV |
471 | return lst; |
472 | } | |
473 | return lst; | |
474 | } | |
475 | #undef FUNC_NAME | |
476 | ||
477 | ||
478 | SCM_DEFINE (scm_sloppy_member, "sloppy-member", 2, 0, 0, | |
479 | (SCM x, SCM lst), | |
480 | "This procedure behaves like @code{member}, but does no type or error checking.\n" | |
481 | "Its use is recommended only in writing Guile internals,\n" | |
482 | "not for high-level Scheme programs.") | |
483 | #define FUNC_NAME s_scm_sloppy_member | |
484 | { | |
485 | scm_c_issue_deprecation_warning | |
486 | ("'sloppy-member' is deprecated. Use 'member' instead."); | |
487 | ||
488 | for(; SCM_CONSP (lst); lst = SCM_CDR(lst)) | |
489 | { | |
7888309b | 490 | if (! scm_is_false (scm_equal_p (SCM_CAR (lst), x))) |
965445d4 MV |
491 | return lst; |
492 | } | |
493 | return lst; | |
494 | } | |
495 | #undef FUNC_NAME | |
496 | ||
497 | SCM_SYMBOL (scm_end_of_file_key, "end-of-file"); | |
498 | ||
499 | SCM_DEFINE (scm_read_and_eval_x, "read-and-eval!", 0, 1, 0, | |
500 | (SCM port), | |
501 | "Read a form from @var{port} (standard input by default), and evaluate it\n" | |
502 | "(memoizing it in the process) in the top-level environment. If no data\n" | |
503 | "is left to be read from @var{port}, an @code{end-of-file} error is\n" | |
504 | "signalled.") | |
505 | #define FUNC_NAME s_scm_read_and_eval_x | |
506 | { | |
f8ba2197 DH |
507 | SCM form; |
508 | ||
965445d4 MV |
509 | scm_c_issue_deprecation_warning |
510 | ("'read-and-eval!' is deprecated. Use 'read' and 'eval' instead."); | |
511 | ||
f8ba2197 | 512 | form = scm_read (port); |
965445d4 MV |
513 | if (SCM_EOF_OBJECT_P (form)) |
514 | scm_ithrow (scm_end_of_file_key, SCM_EOL, 1); | |
515 | return scm_eval_x (form, scm_current_module ()); | |
516 | } | |
517 | #undef FUNC_NAME | |
518 | ||
4abecea8 MV |
519 | SCM |
520 | scm_make_subr_opt (const char *name, int type, SCM (*fcn) (), int set) | |
521 | { | |
522 | scm_c_issue_deprecation_warning | |
523 | ("`scm_make_subr_opt' is deprecated. Use `scm_c_make_subr' or " | |
524 | "`scm_c_define_subr' instead."); | |
525 | ||
526 | if (set) | |
527 | return scm_c_define_subr (name, type, fcn); | |
528 | else | |
529 | return scm_c_make_subr (name, type, fcn); | |
530 | } | |
531 | ||
532 | SCM | |
533 | scm_make_subr (const char *name, int type, SCM (*fcn) ()) | |
534 | { | |
535 | scm_c_issue_deprecation_warning | |
536 | ("`scm_make_subr' is deprecated. Use `scm_c_define_subr' instead."); | |
537 | ||
538 | return scm_c_define_subr (name, type, fcn); | |
539 | } | |
540 | ||
541 | SCM | |
542 | scm_make_subr_with_generic (const char *name, int type, SCM (*fcn) (), SCM *gf) | |
543 | { | |
544 | scm_c_issue_deprecation_warning | |
545 | ("`scm_make_subr_with_generic' is deprecated. Use " | |
546 | "`scm_c_define_subr_with_generic' instead."); | |
547 | ||
548 | return scm_c_define_subr_with_generic (name, type, fcn, gf); | |
549 | } | |
550 | ||
551 | /* Call thunk(closure) underneath a top-level error handler. | |
552 | * If an error occurs, pass the exitval through err_filter and return it. | |
553 | * If no error occurs, return the value of thunk. | |
554 | */ | |
555 | ||
556 | #ifdef _UNICOS | |
557 | typedef int setjmp_type; | |
558 | #else | |
559 | typedef long setjmp_type; | |
560 | #endif | |
561 | ||
562 | struct cce_handler_data { | |
563 | SCM (*err_filter) (); | |
564 | void *closure; | |
565 | }; | |
566 | ||
567 | static SCM | |
568 | invoke_err_filter (void *d, SCM tag, SCM args) | |
569 | { | |
570 | struct cce_handler_data *data = (struct cce_handler_data *)d; | |
571 | return data->err_filter (SCM_BOOL_F, data->closure); | |
572 | } | |
573 | ||
574 | SCM | |
575 | scm_call_catching_errors (SCM (*thunk)(), SCM (*err_filter)(), void *closure) | |
576 | { | |
577 | scm_c_issue_deprecation_warning | |
578 | ("'scm_call_catching_errors' is deprecated. " | |
579 | "Use 'scm_internal_catch' instead."); | |
580 | ||
581 | { | |
582 | struct cce_handler_data data; | |
583 | data.err_filter = err_filter; | |
584 | data.closure = closure; | |
585 | return scm_internal_catch (SCM_BOOL_T, | |
586 | (scm_t_catch_body)thunk, closure, | |
587 | (scm_t_catch_handler)invoke_err_filter, &data); | |
588 | } | |
589 | } | |
590 | ||
591 | long | |
592 | scm_make_smob_type_mfpe (char *name, size_t size, | |
593 | SCM (*mark) (SCM), | |
594 | size_t (*free) (SCM), | |
595 | int (*print) (SCM, SCM, scm_print_state *), | |
596 | SCM (*equalp) (SCM, SCM)) | |
597 | { | |
598 | scm_c_issue_deprecation_warning | |
599 | ("'scm_make_smob_type_mfpe' is deprecated. " | |
600 | "Use 'scm_make_smob_type' plus 'scm_set_smob_*' instead."); | |
601 | ||
602 | { | |
603 | long answer = scm_make_smob_type (name, size); | |
604 | scm_set_smob_mfpe (answer, mark, free, print, equalp); | |
605 | return answer; | |
606 | } | |
607 | } | |
608 | ||
609 | void | |
610 | scm_set_smob_mfpe (long tc, | |
611 | SCM (*mark) (SCM), | |
612 | size_t (*free) (SCM), | |
613 | int (*print) (SCM, SCM, scm_print_state *), | |
614 | SCM (*equalp) (SCM, SCM)) | |
615 | { | |
616 | scm_c_issue_deprecation_warning | |
617 | ("'scm_set_smob_mfpe' is deprecated. " | |
618 | "Use 'scm_set_smob_mark' instead, for example."); | |
619 | ||
620 | if (mark) scm_set_smob_mark (tc, mark); | |
621 | if (free) scm_set_smob_free (tc, free); | |
622 | if (print) scm_set_smob_print (tc, print); | |
623 | if (equalp) scm_set_smob_equalp (tc, equalp); | |
624 | } | |
625 | ||
626 | SCM | |
627 | scm_read_0str (char *expr) | |
628 | { | |
629 | scm_c_issue_deprecation_warning | |
630 | ("scm_read_0str is deprecated. Use scm_c_read_string instead."); | |
631 | ||
632 | return scm_c_read_string (expr); | |
633 | } | |
634 | ||
635 | SCM | |
636 | scm_eval_0str (const char *expr) | |
637 | { | |
638 | scm_c_issue_deprecation_warning | |
639 | ("scm_eval_0str is deprecated. Use scm_c_eval_string instead."); | |
640 | ||
641 | return scm_c_eval_string (expr); | |
642 | } | |
643 | ||
644 | SCM | |
645 | scm_strprint_obj (SCM obj) | |
646 | { | |
647 | scm_c_issue_deprecation_warning | |
648 | ("scm_strprint_obj is deprecated. Use scm_object_to_string instead."); | |
649 | return scm_object_to_string (obj, SCM_UNDEFINED); | |
650 | } | |
651 | ||
652 | char * | |
653 | scm_i_object_chars (SCM obj) | |
654 | { | |
655 | scm_c_issue_deprecation_warning | |
656 | ("SCM_CHARS is deprecated. Use SCM_STRING_CHARS or " | |
657 | "SCM_SYMBOL_CHARS instead."); | |
658 | if (SCM_STRINGP (obj)) | |
659 | return SCM_STRING_CHARS (obj); | |
660 | if (SCM_SYMBOLP (obj)) | |
661 | return SCM_SYMBOL_CHARS (obj); | |
662 | abort (); | |
663 | } | |
664 | ||
665 | long | |
666 | scm_i_object_length (SCM obj) | |
667 | { | |
668 | scm_c_issue_deprecation_warning | |
669 | ("SCM_LENGTH is deprecated. Use SCM_STRING_LENGTH instead, for example."); | |
670 | if (SCM_STRINGP (obj)) | |
671 | return SCM_STRING_LENGTH (obj); | |
672 | if (SCM_SYMBOLP (obj)) | |
673 | return SCM_SYMBOL_LENGTH (obj); | |
674 | if (SCM_VECTORP (obj)) | |
675 | return SCM_VECTOR_LENGTH (obj); | |
676 | abort (); | |
677 | } | |
678 | ||
cc5c1b66 MV |
679 | SCM |
680 | scm_sym2ovcell_soft (SCM sym, SCM obarray) | |
681 | { | |
682 | SCM lsym, z; | |
683 | size_t hash = SCM_SYMBOL_HASH (sym) % SCM_VECTOR_LENGTH (obarray); | |
684 | ||
685 | scm_c_issue_deprecation_warning ("`scm_sym2ovcell_soft' is deprecated. " | |
686 | "Use hashtables instead."); | |
687 | ||
688 | SCM_REDEFER_INTS; | |
689 | for (lsym = SCM_VECTOR_REF (obarray, hash); | |
690 | SCM_NIMP (lsym); | |
691 | lsym = SCM_CDR (lsym)) | |
692 | { | |
693 | z = SCM_CAR (lsym); | |
694 | if (SCM_EQ_P (SCM_CAR (z), sym)) | |
695 | { | |
696 | SCM_REALLOW_INTS; | |
697 | return z; | |
698 | } | |
699 | } | |
700 | SCM_REALLOW_INTS; | |
701 | return SCM_BOOL_F; | |
702 | } | |
703 | ||
704 | ||
705 | SCM | |
706 | scm_sym2ovcell (SCM sym, SCM obarray) | |
707 | #define FUNC_NAME "scm_sym2ovcell" | |
708 | { | |
709 | SCM answer; | |
710 | ||
711 | scm_c_issue_deprecation_warning ("`scm_sym2ovcell' is deprecated. " | |
712 | "Use hashtables instead."); | |
713 | ||
714 | answer = scm_sym2ovcell_soft (sym, obarray); | |
7888309b | 715 | if (scm_is_true (answer)) |
cc5c1b66 MV |
716 | return answer; |
717 | SCM_MISC_ERROR ("uninterned symbol: ~S", scm_list_1 (sym)); | |
718 | return SCM_UNSPECIFIED; /* not reached */ | |
719 | } | |
720 | #undef FUNC_NAME | |
721 | ||
722 | ||
723 | /* Intern a symbol whose name is the LEN characters at NAME in OBARRAY. | |
724 | ||
725 | OBARRAY should be a vector of lists, indexed by the name's hash | |
726 | value, modulo OBARRAY's length. Each list has the form | |
727 | ((SYMBOL . VALUE) ...), where SYMBOL is a symbol, and VALUE is the | |
728 | value associated with that symbol (in the current module? in the | |
729 | system module?) | |
730 | ||
731 | To "intern" a symbol means: if OBARRAY already contains a symbol by | |
732 | that name, return its (SYMBOL . VALUE) pair; otherwise, create a | |
733 | new symbol, add the pair (SYMBOL . SCM_UNDEFINED) to the | |
734 | appropriate list of the OBARRAY, and return the pair. | |
735 | ||
736 | If softness is non-zero, don't create a symbol if it isn't already | |
737 | in OBARRAY; instead, just return #f. | |
738 | ||
739 | If OBARRAY is SCM_BOOL_F, create a symbol listed in no obarray and | |
740 | return (SYMBOL . SCM_UNDEFINED). */ | |
741 | ||
742 | ||
743 | SCM | |
744 | scm_intern_obarray_soft (const char *name,size_t len,SCM obarray,unsigned int softness) | |
745 | { | |
746 | SCM symbol = scm_mem2symbol (name, len); | |
747 | size_t raw_hash = SCM_SYMBOL_HASH (symbol); | |
748 | size_t hash; | |
749 | SCM lsym; | |
750 | ||
751 | scm_c_issue_deprecation_warning ("`scm_intern_obarray_soft' is deprecated. " | |
752 | "Use hashtables instead."); | |
753 | ||
7888309b | 754 | if (scm_is_false (obarray)) |
cc5c1b66 MV |
755 | { |
756 | if (softness) | |
757 | return SCM_BOOL_F; | |
758 | else | |
759 | return scm_cons (symbol, SCM_UNDEFINED); | |
760 | } | |
761 | ||
762 | hash = raw_hash % SCM_VECTOR_LENGTH (obarray); | |
763 | ||
764 | for (lsym = SCM_VECTOR_REF(obarray, hash); | |
765 | SCM_NIMP (lsym); lsym = SCM_CDR (lsym)) | |
766 | { | |
767 | SCM a = SCM_CAR (lsym); | |
768 | SCM z = SCM_CAR (a); | |
769 | if (SCM_EQ_P (z, symbol)) | |
770 | return a; | |
771 | } | |
772 | ||
773 | if (softness) | |
774 | { | |
775 | return SCM_BOOL_F; | |
776 | } | |
777 | else | |
778 | { | |
779 | SCM cell = scm_cons (symbol, SCM_UNDEFINED); | |
780 | SCM slot = SCM_VECTOR_REF (obarray, hash); | |
781 | ||
782 | SCM_VECTOR_SET (obarray, hash, scm_cons (cell, slot)); | |
783 | ||
784 | return cell; | |
785 | } | |
786 | } | |
787 | ||
788 | ||
789 | SCM | |
790 | scm_intern_obarray (const char *name,size_t len,SCM obarray) | |
791 | { | |
792 | scm_c_issue_deprecation_warning ("`scm_intern_obarray' is deprecated. " | |
793 | "Use hashtables instead."); | |
794 | ||
795 | return scm_intern_obarray_soft (name, len, obarray, 0); | |
796 | } | |
797 | ||
798 | /* Lookup the value of the symbol named by the nul-terminated string | |
799 | NAME in the current module. */ | |
800 | SCM | |
801 | scm_symbol_value0 (const char *name) | |
802 | { | |
803 | scm_c_issue_deprecation_warning ("`scm_symbol_value0' is deprecated. " | |
804 | "Use `scm_lookup' instead."); | |
805 | ||
806 | return scm_variable_ref (scm_c_lookup (name)); | |
807 | } | |
808 | ||
809 | SCM_DEFINE (scm_string_to_obarray_symbol, "string->obarray-symbol", 2, 1, 0, | |
810 | (SCM o, SCM s, SCM softp), | |
811 | "Intern a new symbol in @var{obarray}, a symbol table, with name\n" | |
812 | "@var{string}.\n\n" | |
813 | "If @var{obarray} is @code{#f}, use the default system symbol table. If\n" | |
814 | "@var{obarray} is @code{#t}, the symbol should not be interned in any\n" | |
815 | "symbol table; merely return the pair (@var{symbol}\n" | |
816 | ". @var{#<undefined>}).\n\n" | |
817 | "The @var{soft?} argument determines whether new symbol table entries\n" | |
818 | "should be created when the specified symbol is not already present in\n" | |
819 | "@var{obarray}. If @var{soft?} is specified and is a true value, then\n" | |
820 | "new entries should not be added for symbols not already present in the\n" | |
821 | "table; instead, simply return @code{#f}.") | |
822 | #define FUNC_NAME s_scm_string_to_obarray_symbol | |
823 | { | |
824 | SCM vcell; | |
825 | SCM answer; | |
826 | int softness; | |
827 | ||
828 | SCM_VALIDATE_STRING (2, s); | |
7888309b | 829 | SCM_ASSERT (scm_is_bool (o) || SCM_VECTORP (o), o, SCM_ARG1, FUNC_NAME); |
cc5c1b66 MV |
830 | |
831 | scm_c_issue_deprecation_warning ("`string->obarray-symbol' is deprecated. " | |
832 | "Use hashtables instead."); | |
833 | ||
7888309b | 834 | softness = (!SCM_UNBNDP (softp) && scm_is_true(softp)); |
cc5c1b66 | 835 | /* iron out some screwy calling conventions */ |
7888309b | 836 | if (scm_is_false (o)) |
cc5c1b66 MV |
837 | { |
838 | /* nothing interesting to do here. */ | |
839 | return scm_string_to_symbol (s); | |
840 | } | |
841 | else if (SCM_EQ_P (o, SCM_BOOL_T)) | |
842 | o = SCM_BOOL_F; | |
843 | ||
844 | vcell = scm_intern_obarray_soft (SCM_STRING_CHARS(s), | |
845 | SCM_STRING_LENGTH (s), | |
846 | o, | |
847 | softness); | |
7888309b | 848 | if (scm_is_false (vcell)) |
cc5c1b66 MV |
849 | return vcell; |
850 | answer = SCM_CAR (vcell); | |
851 | return answer; | |
852 | } | |
853 | #undef FUNC_NAME | |
854 | ||
855 | SCM_DEFINE (scm_intern_symbol, "intern-symbol", 2, 0, 0, | |
856 | (SCM o, SCM s), | |
857 | "Add a new symbol to @var{obarray} with name @var{string}, bound to an\n" | |
858 | "unspecified initial value. The symbol table is not modified if a symbol\n" | |
859 | "with this name is already present.") | |
860 | #define FUNC_NAME s_scm_intern_symbol | |
861 | { | |
862 | size_t hval; | |
863 | SCM_VALIDATE_SYMBOL (2,s); | |
7888309b | 864 | if (scm_is_false (o)) |
cc5c1b66 MV |
865 | return SCM_UNSPECIFIED; |
866 | ||
867 | scm_c_issue_deprecation_warning ("`intern-symbol' is deprecated. " | |
868 | "Use hashtables instead."); | |
869 | ||
870 | SCM_VALIDATE_VECTOR (1,o); | |
871 | hval = SCM_SYMBOL_HASH (s) % SCM_VECTOR_LENGTH (o); | |
872 | /* If the symbol is already interned, simply return. */ | |
873 | SCM_REDEFER_INTS; | |
874 | { | |
875 | SCM lsym; | |
876 | SCM sym; | |
877 | for (lsym = SCM_VECTOR_REF (o, hval); | |
878 | SCM_NIMP (lsym); | |
879 | lsym = SCM_CDR (lsym)) | |
880 | { | |
881 | sym = SCM_CAR (lsym); | |
882 | if (SCM_EQ_P (SCM_CAR (sym), s)) | |
883 | { | |
884 | SCM_REALLOW_INTS; | |
885 | return SCM_UNSPECIFIED; | |
886 | } | |
887 | } | |
888 | SCM_VECTOR_SET (o, hval, | |
889 | scm_acons (s, SCM_UNDEFINED, | |
890 | SCM_VECTOR_REF (o, hval))); | |
891 | } | |
892 | SCM_REALLOW_INTS; | |
893 | return SCM_UNSPECIFIED; | |
894 | } | |
895 | #undef FUNC_NAME | |
896 | ||
897 | SCM_DEFINE (scm_unintern_symbol, "unintern-symbol", 2, 0, 0, | |
898 | (SCM o, SCM s), | |
899 | "Remove the symbol with name @var{string} from @var{obarray}. This\n" | |
900 | "function returns @code{#t} if the symbol was present and @code{#f}\n" | |
901 | "otherwise.") | |
902 | #define FUNC_NAME s_scm_unintern_symbol | |
903 | { | |
904 | size_t hval; | |
905 | ||
906 | scm_c_issue_deprecation_warning ("`unintern-symbol' is deprecated. " | |
907 | "Use hashtables instead."); | |
908 | ||
909 | SCM_VALIDATE_SYMBOL (2,s); | |
7888309b | 910 | if (scm_is_false (o)) |
cc5c1b66 MV |
911 | return SCM_BOOL_F; |
912 | SCM_VALIDATE_VECTOR (1,o); | |
913 | hval = SCM_SYMBOL_HASH (s) % SCM_VECTOR_LENGTH (o); | |
914 | SCM_DEFER_INTS; | |
915 | { | |
916 | SCM lsym_follow; | |
917 | SCM lsym; | |
918 | SCM sym; | |
919 | for (lsym = SCM_VECTOR_REF (o, hval), lsym_follow = SCM_BOOL_F; | |
920 | SCM_NIMP (lsym); | |
921 | lsym_follow = lsym, lsym = SCM_CDR (lsym)) | |
922 | { | |
923 | sym = SCM_CAR (lsym); | |
924 | if (SCM_EQ_P (SCM_CAR (sym), s)) | |
925 | { | |
926 | /* Found the symbol to unintern. */ | |
7888309b | 927 | if (scm_is_false (lsym_follow)) |
cc5c1b66 MV |
928 | SCM_VECTOR_SET (o, hval, lsym); |
929 | else | |
930 | SCM_SETCDR (lsym_follow, SCM_CDR(lsym)); | |
931 | SCM_ALLOW_INTS; | |
932 | return SCM_BOOL_T; | |
933 | } | |
934 | } | |
935 | } | |
936 | SCM_ALLOW_INTS; | |
937 | return SCM_BOOL_F; | |
938 | } | |
939 | #undef FUNC_NAME | |
940 | ||
941 | SCM_DEFINE (scm_symbol_binding, "symbol-binding", 2, 0, 0, | |
942 | (SCM o, SCM s), | |
943 | "Look up in @var{obarray} the symbol whose name is @var{string}, and\n" | |
944 | "return the value to which it is bound. If @var{obarray} is @code{#f},\n" | |
945 | "use the global symbol table. If @var{string} is not interned in\n" | |
946 | "@var{obarray}, an error is signalled.") | |
947 | #define FUNC_NAME s_scm_symbol_binding | |
948 | { | |
949 | SCM vcell; | |
950 | ||
951 | scm_c_issue_deprecation_warning ("`symbol-binding' is deprecated. " | |
952 | "Use hashtables instead."); | |
953 | ||
954 | SCM_VALIDATE_SYMBOL (2,s); | |
7888309b | 955 | if (scm_is_false (o)) |
cc5c1b66 MV |
956 | return scm_variable_ref (scm_lookup (s)); |
957 | SCM_VALIDATE_VECTOR (1,o); | |
958 | vcell = scm_sym2ovcell (s, o); | |
959 | return SCM_CDR(vcell); | |
960 | } | |
961 | #undef FUNC_NAME | |
962 | ||
963 | #if 0 | |
964 | SCM_DEFINE (scm_symbol_interned_p, "symbol-interned?", 2, 0, 0, | |
965 | (SCM o, SCM s), | |
966 | "Return @code{#t} if @var{obarray} contains a symbol with name\n" | |
967 | "@var{string}, and @code{#f} otherwise.") | |
968 | #define FUNC_NAME s_scm_symbol_interned_p | |
969 | { | |
970 | SCM vcell; | |
971 | ||
972 | scm_c_issue_deprecation_warning ("`symbol-interned?' is deprecated. " | |
973 | "Use hashtables instead."); | |
974 | ||
975 | SCM_VALIDATE_SYMBOL (2,s); | |
7888309b | 976 | if (scm_is_false (o)) |
cc5c1b66 MV |
977 | { |
978 | SCM var = scm_sym2var (s, SCM_BOOL_F, SCM_BOOL_F); | |
979 | if (var != SCM_BOOL_F) | |
980 | return SCM_BOOL_T; | |
981 | return SCM_BOOL_F; | |
982 | } | |
983 | SCM_VALIDATE_VECTOR (1,o); | |
984 | vcell = scm_sym2ovcell_soft (s, o); | |
985 | return (SCM_NIMP(vcell) | |
986 | ? SCM_BOOL_T | |
987 | : SCM_BOOL_F); | |
988 | } | |
989 | #undef FUNC_NAME | |
990 | #endif | |
991 | ||
992 | SCM_DEFINE (scm_symbol_bound_p, "symbol-bound?", 2, 0, 0, | |
993 | (SCM o, SCM s), | |
994 | "Return @code{#t} if @var{obarray} contains a symbol with name\n" | |
995 | "@var{string} bound to a defined value. This differs from\n" | |
996 | "@var{symbol-interned?} in that the mere mention of a symbol\n" | |
997 | "usually causes it to be interned; @code{symbol-bound?}\n" | |
998 | "determines whether a symbol has been given any meaningful\n" | |
999 | "value.") | |
1000 | #define FUNC_NAME s_scm_symbol_bound_p | |
1001 | { | |
1002 | SCM vcell; | |
1003 | ||
1004 | scm_c_issue_deprecation_warning ("`symbol-bound?' is deprecated. " | |
1005 | "Use hashtables instead."); | |
1006 | ||
1007 | SCM_VALIDATE_SYMBOL (2,s); | |
7888309b | 1008 | if (scm_is_false (o)) |
cc5c1b66 MV |
1009 | { |
1010 | SCM var = scm_sym2var (s, SCM_BOOL_F, SCM_BOOL_F); | |
1011 | if (SCM_VARIABLEP(var) && !SCM_UNBNDP(SCM_VARIABLE_REF(var))) | |
1012 | return SCM_BOOL_T; | |
1013 | return SCM_BOOL_F; | |
1014 | } | |
1015 | SCM_VALIDATE_VECTOR (1,o); | |
1016 | vcell = scm_sym2ovcell_soft (s, o); | |
7888309b | 1017 | return scm_from_bool (SCM_NIMP (vcell) && !SCM_UNBNDP (SCM_CDR (vcell))); |
cc5c1b66 MV |
1018 | } |
1019 | #undef FUNC_NAME | |
1020 | ||
1021 | ||
1022 | SCM_DEFINE (scm_symbol_set_x, "symbol-set!", 3, 0, 0, | |
1023 | (SCM o, SCM s, SCM v), | |
1024 | "Find the symbol in @var{obarray} whose name is @var{string}, and rebind\n" | |
1025 | "it to @var{value}. An error is signalled if @var{string} is not present\n" | |
1026 | "in @var{obarray}.") | |
1027 | #define FUNC_NAME s_scm_symbol_set_x | |
1028 | { | |
1029 | SCM vcell; | |
1030 | ||
1031 | scm_c_issue_deprecation_warning ("`symbol-set!' is deprecated. " | |
1032 | "Use the module system instead."); | |
1033 | ||
1034 | SCM_VALIDATE_SYMBOL (2,s); | |
7888309b | 1035 | if (scm_is_false (o)) |
cc5c1b66 MV |
1036 | { |
1037 | scm_define (s, v); | |
1038 | return SCM_UNSPECIFIED; | |
1039 | } | |
1040 | SCM_VALIDATE_VECTOR (1,o); | |
1041 | vcell = scm_sym2ovcell (s, o); | |
1042 | SCM_SETCDR (vcell, v); | |
1043 | return SCM_UNSPECIFIED; | |
1044 | } | |
1045 | #undef FUNC_NAME | |
1046 | ||
1047 | #define MAX_PREFIX_LENGTH 30 | |
1048 | ||
1049 | static int gentemp_counter; | |
1050 | ||
1051 | SCM_DEFINE (scm_gentemp, "gentemp", 0, 2, 0, | |
1052 | (SCM prefix, SCM obarray), | |
1053 | "Create a new symbol with a name unique in an obarray.\n" | |
1054 | "The name is constructed from an optional string @var{prefix}\n" | |
1055 | "and a counter value. The default prefix is @code{t}. The\n" | |
1056 | "@var{obarray} is specified as a second optional argument.\n" | |
1057 | "Default is the system obarray where all normal symbols are\n" | |
1058 | "interned. The counter is increased by 1 at each\n" | |
1059 | "call. There is no provision for resetting the counter.") | |
1060 | #define FUNC_NAME s_scm_gentemp | |
1061 | { | |
1062 | char buf[MAX_PREFIX_LENGTH + SCM_INTBUFLEN]; | |
1063 | char *name = buf; | |
1064 | int len, n_digits; | |
1065 | ||
1066 | scm_c_issue_deprecation_warning ("`gentemp' is deprecated. " | |
1067 | "Use `gensym' instead."); | |
1068 | ||
1069 | if (SCM_UNBNDP (prefix)) | |
1070 | { | |
1071 | name[0] = 't'; | |
1072 | len = 1; | |
1073 | } | |
1074 | else | |
1075 | { | |
1076 | SCM_VALIDATE_STRING (1, prefix); | |
1077 | len = SCM_STRING_LENGTH (prefix); | |
1078 | if (len > MAX_PREFIX_LENGTH) | |
1079 | name = SCM_MUST_MALLOC (MAX_PREFIX_LENGTH + SCM_INTBUFLEN); | |
1080 | strncpy (name, SCM_STRING_CHARS (prefix), len); | |
1081 | } | |
1082 | ||
1083 | if (SCM_UNBNDP (obarray)) | |
1084 | return scm_gensym (prefix); | |
1085 | else | |
1086 | SCM_ASSERT ((SCM_VECTORP (obarray) || SCM_WVECTP (obarray)), | |
1087 | obarray, | |
1088 | SCM_ARG2, | |
1089 | FUNC_NAME); | |
1090 | do | |
1091 | n_digits = scm_iint2str (gentemp_counter++, 10, &name[len]); | |
7888309b | 1092 | while (scm_is_true (scm_intern_obarray_soft (name, |
cc5c1b66 MV |
1093 | len + n_digits, |
1094 | obarray, | |
1095 | 1))); | |
1096 | { | |
1097 | SCM vcell = scm_intern_obarray_soft (name, | |
1098 | len + n_digits, | |
1099 | obarray, | |
1100 | 0); | |
1101 | if (name != buf) | |
1102 | scm_must_free (name); | |
1103 | return SCM_CAR (vcell); | |
1104 | } | |
1105 | } | |
1106 | #undef FUNC_NAME | |
1107 | ||
7888309b MV |
1108 | #if 0 |
1109 | SCM | |
1110 | SCM_MAKINUM (scm_t_signed_bits val) | |
1111 | { | |
1112 | scm_c_issue_deprecation_warning | |
1113 | ("SCM_MAKINUM is deprecated. Use scm_from_int or similar instead."); | |
1114 | return scm_from_int (val); | |
1115 | } | |
1116 | #endif | |
1117 | ||
19e2247d MV |
1118 | void |
1119 | scm_i_init_deprecated () | |
1120 | { | |
1121 | #include "libguile/deprecated.x" | |
1122 | } | |
1123 | ||
1124 | #endif |