]> git.donarmstrong.com Git - lilypond.git/blob - lily/lily-guile.cc
* configure.in: Test for and accept lmodern if EC fonts not found.
[lilypond.git] / lily / lily-guile.cc
1 /*
2   lily-guile.cc -- implement assorted guile functions
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1998--2004 Jan Nieuwenhuizen <janneke@gnu.org>
7                  Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
9
10 #include "lily-guile.hh"
11
12 #include <cstdio>
13 #include <cstdlib>
14 #include <cmath>   /* isinf */
15 #include <cstring> /* strdup, strchr */
16 #include <cctype>
17
18 #include <libintl.h>            // gettext on macos x
19
20 #include "version.hh"
21
22 /* MacOS S fix:
23    source-file.hh includes cmath which undefines isinf and isnan
24
25    FIXME: #ifdef MACOS_X?
26 */
27 inline int my_isinf (Real r) { return isinf (r); }
28 inline int my_isnan (Real r) { return isnan (r); }
29
30 #include "libc-extension.hh"
31 #include "main.hh"
32 #include "file-path.hh"
33 #include "warn.hh"
34 #include "direction.hh"
35 #include "offset.hh"
36 #include "pitch.hh"
37 #include "dimensions.hh"
38 #include "source-file.hh"
39
40 // #define TEST_GC
41
42 SCM
43 ly_to_symbol (SCM scm)
44 {
45   return scm_string_to_symbol (ly_to_string (scm));
46 }
47
48 SCM
49 ly_to_string (SCM scm)
50 {
51   return scm_call_3 (ly_scheme_function ("format"), SCM_BOOL_F,
52                      scm_makfrom0str ("~S"), scm);
53 }
54
55 SCM
56 ly_last (SCM list)
57 {
58   return scm_car (scm_last_pair (list));
59 }
60
61 SCM
62 ly_write2scm (SCM s)
63 {
64   SCM port = scm_mkstrport (SCM_INUM0, 
65                             scm_make_string (SCM_INUM0, SCM_UNDEFINED),
66                             SCM_OPN | SCM_WRTNG,
67                             "ly_write2string");
68   //  SCM write = scm_eval_3 (ly_symbol2scm ("write"), s, SCM_EOL);
69   SCM write = scm_primitive_eval (ly_symbol2scm ("write"));
70   
71   // scm_apply (write, port, SCM_EOL);
72   scm_call_2 (write, s, port);
73   return scm_strport_to_string (port);
74 }
75
76 SCM
77 ly_quote_scm (SCM s)
78 {
79   return scm_list_n (ly_symbol2scm ("quote"), s, SCM_UNDEFINED);
80 }
81
82 String
83 ly_symbol2string (SCM s)
84 {
85   /*
86     Ugh. this is not very efficient.
87    */
88   SCM str = scm_symbol_to_string (s);
89   return ly_scm2string (str);
90 }
91
92 String
93 gulp_file_to_string (String fn, bool must_exist)
94 {
95   String s = global_path.find (fn);
96   if (s == "")
97     {
98       if (must_exist)
99         {
100           String e = _f ("can't find file: `%s'", fn);
101           e += " ";
102           e += _f ("(load path: `%s')", global_path.to_string ());
103           error (e);
104           /* unreachable */
105         }
106       return s;
107     }
108
109   if (verbose_global_b)
110     progress_indication ("[" + s);
111
112   int n;
113   char *str = gulp_file (s, &n);
114   String result (str);
115   delete[] str;
116   
117   if (verbose_global_b)
118     progress_indication ("]");
119
120   return result;
121 }
122
123 LY_DEFINE (ly_gulp_file, "ly:gulp-file",
124            1, 0, 0, (SCM name),
125            "Read the file @var{name}, and return its contents in a string.  "
126            "The file is looked up using the search path.")
127 {
128   SCM_ASSERT_TYPE (scm_is_string (name), name, SCM_ARG1, __FUNCTION__, "string");
129   return scm_makfrom0str (gulp_file_to_string (ly_scm2string (name),
130                                                true).to_str0 ());
131                                                
132 }
133
134
135 extern "C" {
136   // maybe gdb 5.0 becomes quicker if it doesn't do fancy C++ typing?
137 void
138 ly_display_scm (SCM s)
139 {
140   scm_display (s, scm_current_output_port ());
141   scm_newline (scm_current_output_port ());
142 }
143 };
144
145 String
146 ly_scm2string (SCM str)
147 {
148   assert (scm_is_string (str));
149   return String ((Byte*)scm_i_string_chars (str),
150                  (int) scm_i_string_length (str));
151 }
152
153 char *
154 ly_scm2newstr (SCM str, size_t *lenp)
155 {
156   SCM_ASSERT_TYPE (scm_is_string (str), str, SCM_ARG1, __FUNCTION__, "string");
157
158   size_t len = SCM_STRING_LENGTH (str);
159   if (char *new_str = (char *) malloc ((len + 1) * sizeof (char)))
160     {
161       memcpy (new_str, scm_i_string_chars (str), len);
162       new_str[len] = '\0';
163
164       if (lenp)
165         *lenp = len;
166       
167       return new_str;
168     }
169   return 0;
170 }
171
172 SCM
173 index_get_cell (SCM s, Direction d)
174 {
175   
176   assert (d);
177   return (d == LEFT) ? scm_car (s) : scm_cdr (s);
178 }
179
180 SCM
181 index_set_cell (SCM s, Direction d, SCM v)
182 {
183   if (d == LEFT)
184     scm_set_car_x (s, v);
185   else if (d == RIGHT)
186     scm_set_cdr_x (s, v);
187   return s;
188 }
189   
190 LY_DEFINE (ly_warn, "ly:warn",
191            1, 0, 1, (SCM str, SCM rest),
192            "Scheme callable function to issue the warning @code{msg}. "
193            "The message is formatted with @code{format} and @code{rest}.")
194 {
195   SCM_ASSERT_TYPE (scm_is_string (str), str, SCM_ARG1, __FUNCTION__, "string");
196   progress_indication ("\n");
197
198   str = scm_simple_format (SCM_BOOL_F, str, rest);
199   warning ("lily-guile: " + ly_scm2string (str));
200   return SCM_UNSPECIFIED;
201 }
202
203 LY_DEFINE (ly_programming_error, "ly:programming-error",
204            1, 0, 1, (SCM str, SCM rest),
205            "Scheme callable function to issue the warning @code{msg}. "
206            "The message is formatted with @code{format} and @code{rest}.")
207 {
208   SCM_ASSERT_TYPE (scm_is_string (str), str, SCM_ARG1, __FUNCTION__, "string");
209   progress_indication ("\n");
210
211   str = scm_simple_format (SCM_BOOL_F, str, rest);
212   programming_error (ly_scm2string (str));
213   return SCM_UNSPECIFIED;
214 }
215
216 LY_DEFINE (ly_dir_p, "ly:dir?",
217            1, 0, 0, (SCM s),
218           "type predicate. A direction is @code{-1}, @code{0} or "
219            "@code{1}, where @code{-1} represents "
220           "left or down and @code{1} represents right or up.")
221 {
222   if (scm_is_number (s))
223     {
224       int i = scm_to_int (s);
225       return (i>= -1 && i <= 1)  ? SCM_BOOL_T : SCM_BOOL_F; 
226     }
227   return SCM_BOOL_F;
228 }
229
230 bool
231 is_number_pair (SCM p)
232 {
233   return scm_is_pair (p)
234     && scm_is_number (scm_car (p)) && scm_is_number (scm_cdr (p));
235 }
236
237 typedef void (*Void_fptr) ();
238 Array<Void_fptr> *scm_init_funcs_;
239
240 void add_scm_init_func (void (*f) ())
241 {
242   if (!scm_init_funcs_)
243     scm_init_funcs_ = new Array<Void_fptr>;
244
245   scm_init_funcs_->push (f);
246 }
247
248 void
249 ly_init_ly_module (void *)
250 {
251   for (int i = scm_init_funcs_->size () ; i--;)
252     (scm_init_funcs_->elem (i)) ();
253
254   if (verbose_global_b)
255     progress_indication ("\n");
256   
257   scm_primitive_load_path (scm_makfrom0str ("lily.scm"));
258 }
259
260 SCM global_lily_module;
261
262 void
263 ly_c_init_guile ()
264 {
265   global_lily_module = scm_c_define_module ("lily", ly_init_ly_module, 0);
266   scm_c_use_module ("lily");
267 }
268
269 unsigned int
270 ly_scm_hash (SCM s)
271 {
272   return scm_ihashv (s, ~1u);
273 }
274
275 bool
276 is_direction (SCM s)
277 {
278   if (scm_is_number (s))
279     {
280       int i = scm_to_int (s);
281       return i>= -1 && i <= 1; 
282     }
283   return false;
284 }
285
286 LY_DEFINE (ly_assoc_get, "ly:assoc-get",
287            2, 1, 0,
288            (SCM key, SCM alist, SCM default_value),
289            "Return value if KEY in ALIST, else DEFAULT-VALUE "
290            "(or #f if not specified).")
291 {
292   SCM handle = scm_assoc (key, alist);
293
294   if (default_value == SCM_UNDEFINED)
295     default_value = SCM_BOOL_F;
296   
297   if (scm_is_pair (handle))
298     return scm_cdr (handle);
299   else
300     return default_value;
301 }
302
303 bool
304 is_axis (SCM s)
305 {
306   if (scm_is_number (s))
307     {
308       int i = scm_to_int (s);
309       return i== 0 || i == 1;
310     }
311   return false;
312 }
313
314 Direction
315 to_dir (SCM s)
316 {
317   return scm_is_integer (s) ? (Direction) scm_to_int (s) : CENTER;
318 }
319
320 Interval
321 ly_scm2interval (SCM p)
322 {
323   return Interval (scm_to_double (scm_car (p)), scm_to_double (scm_cdr (p)));
324 }
325
326 Drul_array<Real>
327 ly_scm2realdrul (SCM p)
328 {
329   return Drul_array<Real> (scm_to_double (scm_car (p)),
330                            scm_to_double (scm_cdr (p)));
331 }
332
333 SCM
334 ly_interval2scm (Drul_array<Real> i)
335 {
336   return scm_cons (scm_make_real (i[LEFT]), scm_make_real (i[RIGHT]));
337 }
338
339 bool
340 to_boolean (SCM s)
341 {
342   return scm_is_bool (s) && ly_scm2bool (s);
343 }
344
345 /* Appendable list L: the cdr contains the list, the car the last cons
346    in the list.  */
347 SCM
348 appendable_list ()
349 {
350   SCM s = scm_cons (SCM_EOL, SCM_EOL);
351   scm_set_car_x (s, s);
352   
353   return s;
354 }
355
356 void
357 appendable_list_append (SCM l, SCM elt)
358 {
359   SCM newcons = scm_cons (elt, SCM_EOL);
360   
361   scm_set_cdr_x (scm_car (l), newcons);      
362   scm_set_car_x (l, newcons);
363 }
364
365 SCM
366 ly_offset2scm (Offset o)
367 {
368   return scm_cons (scm_make_real (o[X_AXIS]), scm_make_real (o[Y_AXIS]));
369 }
370
371 Offset
372 ly_scm2offset (SCM s)
373 {
374   return Offset (scm_to_double (scm_car (s)),
375                  scm_to_double (scm_cdr (s)));
376 }
377
378 LY_DEFINE (ly_number2string, "ly:number->string",
379            1, 0, 0, (SCM s),
380            "Convert @var{num} to a string without generating many decimals.")
381 {
382   SCM_ASSERT_TYPE (scm_is_number (s), s, SCM_ARG1, __FUNCTION__, "number");
383
384   char str[400];                        // ugh.
385
386   if (scm_exact_p (s) == SCM_BOOL_F)
387     {
388       Real r (scm_to_double (s));
389
390       if (my_isinf (r) || my_isnan (r))
391         {
392           programming_error ("Infinity or NaN encountered while converting Real number; setting to zero.");
393           r = 0.0;
394         }
395
396       sprintf (str, "%08.4f", r);
397     }
398   else
399     sprintf (str, "%d", scm_to_int (s));
400
401   return scm_makfrom0str (str);
402 }
403
404
405
406 LY_DEFINE (ly_version,  "ly:version", 0, 0, 0, (),
407           "Return the current lilypond version as a list, e.g. @code{(1 3 127 uu1)}. ")
408 {
409   char const* vs = "\'(" MAJOR_VERSION " " MINOR_VERSION " "  PATCH_LEVEL " " MY_PATCH_LEVEL ")" ;
410   
411   return scm_c_eval_string ((char*)vs);
412 }
413
414 LY_DEFINE (ly_unit,  "ly:unit", 0, 0, 0, (),
415           "Return the unit used for lengths as a string.")
416 {
417   return scm_makfrom0str (INTERNAL_UNIT);
418 }
419
420
421
422 LY_DEFINE (ly_dimension_p,  "ly:dimension?", 1, 0, 0, (SCM d),
423           "Return @var{d} is a number. Used to distinguish length "
424           "variables from normal numbers.")
425 {
426   return scm_number_p (d);
427 }
428
429 SCM
430 ly_deep_copy (SCM src)
431 {
432   if (scm_is_pair (src))
433     return scm_cons (ly_deep_copy (scm_car (src)), ly_deep_copy (scm_cdr (src)));
434   else if (ly_c_vector_p (src))
435     {
436       int len = SCM_VECTOR_LENGTH (src);
437       SCM nv = scm_c_make_vector (len, SCM_UNDEFINED);
438       for (int i = 0 ;i < len ; i++)
439         {
440           SCM si = scm_int2num (i);
441           scm_vector_set_x (nv, si, ly_deep_copy (scm_vector_ref (src, si))); 
442         }
443     }
444   return src;
445 }
446
447
448
449
450 SCM
451 ly_assoc_chain (SCM key, SCM achain)
452 {
453   if (scm_is_pair (achain))
454     {
455       SCM handle = scm_assoc (key, scm_car (achain));
456       if (scm_is_pair (handle))
457         return handle;
458       else
459         return ly_assoc_chain (key, scm_cdr (achain));
460     }
461   else
462     return SCM_BOOL_F;
463 }
464
465 /* looks the key up in the cdrs of the alist-keys
466    - ignoring the car and ignoring non-pair keys.
467    Returns first match found, i.e.
468
469    alist = ((1 . 10)
470                    ((1 . 2) . 11)
471                    ((2 . 1) . 12)
472                    ((3 . 0) . 13)
473                    ((4 . 1) . 14) )
474
475 I would like (ly_assoc_cdr 1) to return 12 - because it's the first
476 element with the cdr of the key = 1.  In other words (alloc_cdr key)
477 corresponds to call
478
479 (alloc (anything . key))
480
481
482
483 */
484 SCM
485 ly_assoc_cdr (SCM key, SCM alist)
486 {
487   if (scm_is_pair (alist))
488     {
489       SCM trykey = scm_caar (alist);
490       if (scm_is_pair (trykey) && to_boolean (scm_equal_p (key, scm_cdr (trykey))))
491         return scm_car (alist);
492       else
493         return ly_assoc_cdr (key, scm_cdr (alist));
494     }
495   return SCM_BOOL_F;
496 }
497
498 /* LST has the form "sym1 sym2 sym3\nsym4\nsym5"
499    i.e. \n and ' ' can be used interchangeably as separators.  */
500 SCM
501 parse_symbol_list (char const *lst)
502 {
503   char *s = strdup (lst);
504   char *orig = s;
505   SCM create_list = SCM_EOL;
506
507   char * e = s + strlen (s) - 1;
508   while (e >= s && isspace (*e))
509     *e-- = 0;
510
511   for (char * p = s; *p; p++)
512     if (*p == '\n')
513       *p = ' ';
514   
515   if (!s[0])
516     s = 0;
517   
518   while (s)
519     {
520       char *next = strchr (s, ' ');
521       if (next)
522         *next++ = 0;
523
524       create_list = scm_cons (ly_symbol2scm (s), create_list);
525       s = next;
526     }
527
528   free (orig);
529   return create_list;
530 }
531
532 SCM
533 ly_truncate_list (int k, SCM lst)
534 {
535   if (k == 0)
536     lst = SCM_EOL;
537   else
538     {
539       SCM s = lst;
540       k--;
541       for (; scm_is_pair (s) && k--; s = scm_cdr (s))
542         ;
543
544       if (scm_is_pair (s))
545         scm_set_cdr_x (s, SCM_EOL);
546     }
547   return lst;
548 }
549
550 String
551 print_scm_val (SCM val)
552 {
553   String realval = ly_scm2string (ly_write2scm (val));
554   if (realval.length () > 200)
555     realval = realval.left_string (100)
556       + "\n :\n :\n"
557       + realval.right_string (100);
558   return realval;        
559 }
560
561 bool
562 type_check_assignment (SCM sym, SCM val,  SCM type_symbol) 
563 {
564   bool ok = true;
565
566   /*
567     Always succeeds.
568
569
570     TODO: should remove #f from allowed vals?
571    */
572   if (val == SCM_EOL || val == SCM_BOOL_F)
573     return ok;
574
575   if (!scm_is_symbol (sym))
576 #if 0
577     return false;
578 #else
579   /*
580     This is used for autoBeamSettings.
581
582     TODO: deprecate the use of \override and \revert for
583     autoBeamSettings?
584
585     or use a symbol autoBeamSettingS?  
586    */
587   return true; 
588 #endif
589   
590   SCM type = scm_object_property (sym, type_symbol);
591
592   if (type != SCM_EOL && !ly_c_procedure_p (type))
593       {
594         warning (_f ("Can't find property type-check for `%s' (%s).",
595                      ly_symbol2string (sym).to_str0 (),
596                      ly_symbol2string (type_symbol).to_str0 ())
597                  + "  " + _ ("Perhaps you made a typing error?"));
598
599         /* Be strict when being anal :) */
600         if (internal_type_checking_global_b)
601           abort ();
602         
603         warning (_ ("Doing assignment anyway."));
604       }
605   else
606     {
607       if (val != SCM_EOL
608           && ly_c_procedure_p (type)
609           && scm_call_1 (type, val) == SCM_BOOL_F)
610         {
611           SCM errport = scm_current_error_port ();
612           ok = false;
613           SCM typefunc = ly_scheme_function ("type-name");
614           SCM type_name = scm_call_1 (typefunc, type);
615
616          
617           scm_puts (_f ("Type check for `%s' failed; value `%s' must be of type `%s'",
618                         ly_symbol2string (sym).to_str0 (),
619                         print_scm_val (val),
620                         ly_scm2string (type_name).to_str0 ()).to_str0 (),
621                     errport);
622           scm_puts ("\n", errport);                   
623         }
624     }
625   return ok;
626 }
627
628
629 /* some SCM abbrevs
630
631    zijn deze nou handig?
632    zijn ze er al in scheme, maar heten ze anders? */
633
634
635 /* Remove doubles from (sorted) list */
636 SCM
637 ly_unique (SCM list)
638 {
639   SCM unique = SCM_EOL;
640   for (SCM i = list; scm_is_pair (i); i = scm_cdr (i))
641     {
642       if (!scm_is_pair (scm_cdr (i))
643           || !ly_c_equal_p (scm_car (i), scm_cadr (i)))
644         unique = scm_cons (scm_car (i), unique);
645     }
646   return scm_reverse_x (unique, SCM_EOL);
647 }
648
649
650 static int
651 scm_default_compare (void const *a, void const *b)
652 {
653   SCM pa = *(SCM*) a;
654   SCM pb = *(SCM*) b;
655   if (pa == pb)
656     return 0;
657   return pa < pb ? -1 : 1;
658 }
659
660 /*  Modify LST in place: qsort it.  */
661 SCM
662 ly_list_qsort_uniq_x (SCM lst)
663 {
664   int len = scm_ilength (lst);
665   SCM *arr = new SCM[len];
666   int k = 0;
667   for (SCM s = lst; SCM_NNULLP (s); s = scm_cdr (s))
668     arr[k++] = scm_car (s);
669
670   assert (k == len);
671   qsort (arr, len, sizeof (SCM), &scm_default_compare);
672
673   SCM *tail = &lst;
674   for (int i = 0; i < len; i++)
675     if (!i || arr[i] != arr[i - 1])
676       {
677         SCM_SETCAR (*tail, arr[i]);
678         tail = SCM_CDRLOC (*tail);
679       }
680
681   *tail = SCM_EOL;
682   delete[] arr;
683
684   return lst; 
685 }
686
687
688 /* tail add */
689 SCM
690 ly_snoc (SCM s, SCM list)
691 {
692   return ly_append2 (list, scm_list_n (s, SCM_UNDEFINED));
693 }
694
695 /* Split list at member s, removing s.
696    Return (BEFORE . AFTER)  */
697 SCM
698 ly_split_list (SCM s, SCM list)
699 {
700   SCM before = SCM_EOL;
701   SCM after = list;
702   for (; scm_is_pair (after);)
703     {
704       SCM i = scm_car (after);
705       after = scm_cdr (after);
706       if (ly_c_equal_p (i, s))
707         break;
708       before = scm_cons (i, before);
709     }
710   return scm_cons ( scm_reverse_x (before, SCM_EOL),  after);
711   
712 }
713
714
715 void
716 taint (SCM *)
717 {
718   /*
719     nop.
720    */
721 }
722
723 /*
724   display stuff without using stack
725  */
726 SCM
727 display_list (SCM s)
728 {
729   SCM p = scm_current_output_port ();
730
731   scm_puts ("(", p);
732   for (; scm_is_pair (s); s =scm_cdr (s))
733     {
734       scm_display (scm_car (s), p);
735       scm_puts (" ", p);      
736     }
737   scm_puts (")", p);
738   return SCM_UNSPECIFIED;
739 }
740
741 Slice
742 int_list_to_slice (SCM l)
743 {
744   Slice s;
745   s.set_empty ();
746   for (; scm_is_pair (l); l = scm_cdr (l))
747     if (scm_is_number (scm_car (l)))
748       s.add_point (scm_to_int (scm_car (l))); 
749   return s;
750 }
751
752 /* Return I-th element, or last elt L. If I < 0, then we take the first
753    element.
754    
755    PRE: length (L) > 0  */
756 SCM
757 robust_list_ref (int i, SCM l)
758 {
759   while (i-- > 0 && scm_is_pair (scm_cdr (l)))
760     l = scm_cdr (l);
761   return scm_car (l);
762 }
763
764 Real
765 robust_scm2double (SCM k, double x)
766 {
767   if (scm_is_number (k))
768     x = scm_to_double (k);
769   return x;
770 }
771
772 Interval
773 robust_scm2interval (SCM k, Drul_array<Real> v)
774 {
775   Interval i;
776   i[LEFT]= v[LEFT];
777   i[RIGHT]= v[RIGHT];
778   if (is_number_pair (k))
779     i = ly_scm2interval (k);
780   return i;
781 }
782
783 Drul_array<Real>
784 robust_scm2drul (SCM k, Drul_array<Real> v)
785 {
786   if (is_number_pair (k))
787     v = ly_scm2interval (k);
788   return v;
789 }
790
791 Offset
792 robust_scm2offset (SCM k, Offset o)
793 {
794   if (is_number_pair (k))
795     o = ly_scm2offset (k);
796   return o;
797 }
798
799 int
800 robust_scm2int (SCM k, int o)
801 {
802   if (scm_integer_p (k) == SCM_BOOL_T)
803     o = scm_to_int (k);
804   return o;
805 }
806
807 SCM
808 alist_to_hashq (SCM alist)
809 {
810   int i = scm_ilength (alist);
811   if (i < 0)
812     return scm_c_make_hash_table (0);
813           
814   SCM tab = scm_c_make_hash_table (i);
815   for (SCM s = alist; scm_is_pair (s); s = scm_cdr (s))
816     {
817       SCM pt = scm_cdar (s);
818       scm_hashq_set_x (tab, scm_caar (s), pt);
819     }
820   return tab; 
821 }
822
823 #if 1
824 /*
825   Debugging mem leaks:
826  */
827 LY_DEFINE (ly_protects, "ly:protects",
828            0, 0, 0, (),
829           "Return hash of protected objects.")
830 {
831   return scm_protects;
832 }
833 #endif
834
835
836 #if HAVE_PANGO_FC_FONT_MAP_ADD_DECODER_FIND_FUNC
837
838 #include "pangofc-afm-decoder.hh"
839
840 LY_DEFINE (ly_pango_add_afm_decoder, "ly:pango-add-afm-decoder",
841            1, 0, 0, (SCM font_family),
842            "Add pango afm decoder for FONT-FAMILY.")
843 {
844   SCM_ASSERT_TYPE (scm_is_string (font_family), font_family, SCM_ARG1,
845                    __FUNCTION__, "font_family");
846   pango_fc_afm_add_decoder (ly_scm2newstr (font_family, 0));
847   return SCM_UNSPECIFIED;
848 }
849
850 #endif
851
852 LY_DEFINE (ly_gettext, "ly:gettext",
853            1, 0, 0, (SCM string),
854            "Gettext wrapper.")
855 {
856   SCM_ASSERT_TYPE (scm_is_string (string), string, SCM_ARG1,
857                    __FUNCTION__, "string");
858   return scm_makfrom0str (gettext (scm_i_string_chars (string)));
859 }
860