#include <cstring> /* strdup, strchr */
#include <cctype>
+using namespace std;
+
#include "config.hh"
#include "dimensions.hh"
#include "misc.hh"
#include "offset.hh"
#include "pitch.hh"
+#include "string-convert.hh"
#include "source-file.hh"
#include "version.hh"
#include "warn.hh"
ly_to_string (SCM scm)
{
return scm_call_3 (ly_lily_module_constant ("format"), SCM_BOOL_F,
+
scm_makfrom0str ("~S"), scm);
}
}
String
-gulp_file_to_string (String fn, bool must_exist)
+gulp_file_to_string (String fn, bool must_exist, int size)
{
String s = global_path.find (fn);
if (s == "")
if (be_verbose_global)
progress_indication ("[" + s);
- int n;
+ int n = size;
char *str = gulp_file (s, &n);
String result ((Byte *) str, n);
delete[] str;
if (lenp)
*lenp = len;
-
+
return new_str;
}
return 0;
SCM
index_get_cell (SCM s, Direction d)
{
-
+
assert (d);
return (d == LEFT) ? scm_car (s) : scm_cdr (s);
}
scm_set_cdr_x (s, v);
return s;
}
-
+
bool
is_number_pair (SCM p)
{
SCM
ly_interval2scm (Drul_array<Real> i)
{
- return scm_cons (scm_make_real (i[LEFT]), scm_make_real (i[RIGHT]));
+ return scm_cons (scm_from_double (i[LEFT]), scm_from_double (i[RIGHT]));
}
bool
SCM
ly_offset2scm (Offset o)
{
- return scm_cons (scm_make_real (o[X_AXIS]), scm_make_real (o[Y_AXIS]));
+ return scm_cons (scm_from_double (o[X_AXIS]), scm_from_double (o[Y_AXIS]));
}
Offset
SCM nv = scm_c_make_vector (len, SCM_UNDEFINED);
for (int i = 0;i < len; i++)
{
- SCM si = scm_int2num (i);
+ SCM si = scm_from_int (i);
scm_vector_set_x (nv, si, ly_deep_copy (scm_vector_ref (src, si)));
}
}
return src;
}
-
-
/* looks the key up in the cdrs of the alist-keys
- ignoring the car and ignoring non-pair keys.
Returns first match found, i.e.
if (scm_is_pair (alist))
{
SCM trykey = scm_caar (alist);
- if (scm_is_pair (trykey) && to_boolean (scm_equal_p (key, scm_cdr (trykey))))
+ if (scm_is_pair (trykey)
+ && to_boolean (scm_equal_p (key, scm_cdr (trykey))))
return scm_car (alist);
- else
- return ly_assoc_cdr (key, scm_cdr (alist));
+ return ly_assoc_cdr (key, scm_cdr (alist));
}
return SCM_BOOL_F;
}
-/* LST has the form "sym1 sym2 sym3\nsym4\nsym5"
- i.e. \n and ' ' can be used interchangeably as separators. */
SCM
-parse_symbol_list (char const *lst)
-{
- char *s = strdup (lst);
- char *orig = s;
- SCM create_list = SCM_EOL;
-
- char *e = s + strlen (s) - 1;
- while (e >= s && isspace (*e))
- *e-- = 0;
-
- for (char *p = s; *p; p++)
- if (*p == '\n')
- *p = ' ';
-
- if (!s[0])
- s = 0;
-
- while (s)
- {
- char *next = strchr (s, ' ');
- if (next)
- *next++ = 0;
-
- create_list = scm_cons (ly_symbol2scm (s), create_list);
- s = next;
- }
+ly_string_array_to_scm (Array<String> a)
+{
+ SCM s = SCM_EOL;
+ for (int i = a.size () - 1; i >= 0; i--)
+ s = scm_cons (ly_symbol2scm (a[i].to_str0 ()), s);
+ return s;
+}
- free (orig);
- return create_list;
+/* SYMBOLS is a whitespace separated list. */
+SCM
+parse_symbol_list (char const *symbols)
+{
+ while (isspace (*symbols))
+ *symbols++;
+ String s = symbols;
+ s.substitute ('\n', ' ');
+ s.substitute ('\t', ' ');
+ return ly_string_array_to_scm (String_convert::split (s, ' '));
}
SCM
{
SCM x = SCM_EOL;
for (SCM p = alist; scm_is_pair (p); p = scm_cdr (p))
- {
- x = scm_cons (scm_cdar (p), x);
- }
+ x = scm_cons (scm_cdar (p), x);
return x;
}