+1.3.114.jcn1
+============
+
+* Moved writing of \header strings feature from lilypond-book to lilypond.
+
1.3.113.jcn2
============
MAJOR_VERSION=1
MINOR_VERSION=3
PATCH_LEVEL=114
-MY_PATCH_LEVEL=
+MY_PATCH_LEVEL=jcn1
# use the above to send patches: MY_PATCH_LEVEL is always empty for a
# released version.
{
\translator {
\ChordNamesContext
- ChordNames \override #'word-space = #1
+ ChordName \override #'word-space = #1
}
}
}
\translator {
\ChordNamesContext
- ChordNames \override #'word-space = #1
+ ChordName \override #'word-space = #1
}
}
}
>
\paper
{
- \translator { \ChordNamesContext ChordNames \override #'word-space = #1 }
+ \translator { \ChordNamesContext ChordName \override #'word-space = #1 }
% \translator { \LyricsContext textScriptWordSpace = #0.3 }
}
}
extern void set_inclusion_names (Array<String>);
extern File_path global_path;
+extern Array<String> global_score_header_fields;
extern String default_outname_base_global;
extern String default_outname_suffix_global;
SCM font_descriptions ()const;
virtual ~Paper_def ();
static int default_count_i_;
+ String current_output_base_;
+
/*
JUNKME
*/
void output_comment (String s);
void output_string (SCM s);
void output_scheme (SCM scm);
+ static void output_score_header_field (String filename, String key, String value);
+ static void output_score_header_fields (Paper_def *paper);
};
#endif // PAPER_OUTPUTTER_HH
{
public:
bool outputting_comment_b_;
- ostream *os;
+ ostream *os_;
int nest_level;
/// to check linelen in output. TeX has limits.
int line_len_i_;
void break_line();
};
+class ostream;
+ostream *open_file_stream (String filename);
+void close_file_stream (ostream *os);
+
+
#endif // PAPER_STREAM_HH
int default_count_global;
File_path global_path;
+Array<String> global_score_header_fields;
+
bool safe_global_b = false;
bool experimental_features_global_b = false;
bool dependency_global_b = false;
Long_option_init theopts[] = {
{_i ("EXT"), "output-format", 'f', _i ("use output format EXT (scm, ps, tex or as)")},
{0, "help", 'h', _i ("this help")},
+ {_i ("FIELD"), "header", 'H', _i ("write header field to BASENAME.FIELD")},
{_i ("DIR"), "include", 'I', _i ("add DIR to search path")},
{_i ("FILE"), "init", 'i', _i ("use FILE as init file")},
{0, "dependencies", 'M', _i ("write Makefile dependencies for every input file")},
global_path.add (p);
#if !KPATHSEA
- /*
- Although kpathsea seems nice, it is not universally available
- (GNU/Windows).
-
- Compiling kpathsea seems not possible without
- (compiling) a matching tex installation. Apart from the fact
- that I cannot get kpathsea compiled for GNU/Windows, another
- major problem is that TeX installations may be different on
- different clients, so it wouldn't work anyway. While ugly,
- this code is simple and effective.
- -- jcn
- */
-
/* Urg: GNU make's $(word) index starts at 1 */
int i = 1;
while (global_path.try_add (p + to_str (".") + to_str (i)))
case 'Q':
find_old_relative_b= true;
break;
+ case 'H':
+ global_score_header_fields.push (oparser_global_p->optional_argument_ch_C_);
+ break;
case 'I':
global_path.push (oparser_global_p->optional_argument_ch_C_);
break;
}
+/* URGURGUGUUGH
+
+ not const.
+
+ Wat een puinhoop is dit. */
String
Paper_def::base_output_str () const
{
if (def)
str += "-" + to_str (def);
}
+
+ /* Must store value, as this function can be called only once */
+ Paper_def *urg = (Paper_def*)this;
+ urg->current_output_base_ = str;
+
return str;
}
#include "scope.hh"
#include "identifier.hh"
#include "lily-version.hh"
+#include "paper-def.hh"
+#include "file-results.hh"
/*
free (c);
}
}
+
void
Paper_outputter::output_scope (Scope *scope, String prefix)
{
output_scheme (scm);
}
-
-
void
Paper_outputter::output_string (SCM str)
{
*stream_p_ << ly_scm2string (str);
}
+
+void
+Paper_outputter::output_score_header_field (String filename, String key, String value)
+{
+ if (filename != "-")
+ filename += String (".") + key;
+ progress_indication (_f ("writing header field %s to %s...",
+ key,
+ filename == "-" ? String ("<stdout>") : filename));
+
+ ostream *os = open_file_stream (filename);
+ *os << value;
+ close_file_stream (os);
+ progress_indication ("\n");
+}
+
+void
+Paper_outputter::output_score_header_fields (Paper_def *paper)
+{
+ if (global_score_header_fields.size ())
+ {
+ SCM fields;
+#if 0 // ugh, how to reach current Score or Paper_score?
+ if (paper->header_l_)
+ fields = paper->header_l_->to_alist ();
+ else
+#endif
+ fields = header_global_p->to_alist ();
+ String base = paper->current_output_base_;
+ for (int i = 0; i < global_score_header_fields.size (); i++)
+ {
+ String key = global_score_header_fields[i];
+ // SCM val = gh_assoc (ly_str02scm (key.ch_C ()), fields);
+ SCM val = gh_assoc (ly_symbol2scm (key.ch_C ()), fields);
+ String s;
+ if (gh_pair_p (val))
+ s = ly_scm2string (gh_cdr (val));
+ output_score_header_field (base, key, s);
+ }
+ }
+}
return sol;
}
-
-
/*
urg. clean me
*/
outputter_l_->output_scheme (scm);
progress_indication ("\n");
+
+ outputter_l_->output_score_header_fields (paper_l_);
+
// huh?
delete outputter_l_;
outputter_l_ = 0;
-
+
if (verbose_global_b)
ly_display_scm (scm_gc_stats ());
}
const int MAXLINELEN = 200;
-Paper_stream::Paper_stream (String filename)
+ostream *
+open_file_stream (String filename)
{
+ ostream *os;
if (filename.length_i () && (filename != "-"))
os = new ofstream (filename.ch_C ());
else
- // os = new ostream (cout.ostreambuf ());
os = new ostream (cout._strbuf);
if (!*os)
error (_f ("can't open file: `%s'", filename));
- nest_level = 0;
- line_len_i_ = 0;
- outputting_comment_b_=false;
+ return os;
}
-Paper_stream::~Paper_stream ()
+void
+close_file_stream (ostream *os)
{
*os << flush;
if (!*os)
exit_status_i_ = 1;
}
delete os;
+}
+
+Paper_stream::Paper_stream (String filename)
+{
+ os_ = open_file_stream (filename);
+ nest_level = 0;
+ line_len_i_ = 0;
+ outputting_comment_b_=false;
+}
+
+Paper_stream::~Paper_stream ()
+{
+ close_file_stream (os_);
assert (nest_level == 0);
}
{
if (outputting_comment_b_)
{
- *os << *cp;
+ *os_ << *cp;
if (*cp == '\n')
{
outputting_comment_b_=false;
{
case '%':
outputting_comment_b_ = true;
- *os << *cp;
+ *os_ << *cp;
break;
case '{':
nest_level++;
- *os << *cp;
+ *os_ << *cp;
break;
case '}':
nest_level--;
- *os << *cp;
+ *os_ << *cp;
if (nest_level < 0)
{
- delete os; // we want to see the remains.
+ delete os_; // we want to see the remains.
assert (nest_level>=0);
}
if (nest_level == 0)
break;
- *os << '%';
+ *os_ << '%';
break_line ();
break;
case '\n':
break_line ();
break;
case ' ':
- *os << ' ';
+ *os_ << ' ';
if (line_len_i_ > MAXLINELEN)
break_line ();
break;
default:
- *os << *cp;
+ *os_ << *cp;
break;
}
}
//urg, for debugging only!!
- *os << flush;
+ *os_ << flush;
return *this;
}
void
Paper_stream::break_line ()
{
- *os << '\n';
- *os << to_str (' ', nest_level);
+ *os_ << '\n';
+ *os_ << to_str (' ', nest_level);
outputting_comment_b_ = false;
line_len_i_ = 0;
}
lilypond_header:
HEADER '{' lilypond_header_body '}' {
$$ = $3;
- THIS->lexer_p_-> scope_l_arr_.pop ();
+ THIS->lexer_p_-> scope_l_arr_.pop ();
}
;
# should also support fragment in
'output-all': r"""
-@include %(fn)s-doc.texi
+@include %(fn)s.texidoc
@tex
\catcode`\@=12
\input lilyponddefs
error ('Error command exited with value %d\n' % st)
return st
-
-texidoc_re = re.compile (r'.*?\n\s*texidoc\s*=\s*"((([^"])|([^\\]\\"))*)".*', re.DOTALL)
-def extract_texidoc (lyfile):
- """
- Extract the ``texidoc'' entry from the lyfile.ly, and write it to
- lyfile-doc.texi.
-
- Maybe this should be output by `lilypond --header=texidoc' or so?
- """
- outfile = os.path.basename (os.path.splitext (lyfile)[0]) + "-doc.texi"
- sys.stderr.write ("Writing `%s'\n" % outfile)
- f = open (lyfile)
- s = f.read (-1)
-# doc = re.sub (r'(.|\n)*?\n\s*texidoc\s*=\s*"((([^"])|([^\\]\\"))*)"(.|\n)*', '\\2', s) + '\n'
- m = texidoc_re.match (s)
- doc = ''
- if m:
- doc = m.group (1) + '\n'
- f = open (outfile, 'w')
- f.write (doc)
- f.close ()
-
def compile_all_files (chunks):
eps = []
tex = []
incs = map (incl_opt, include_path)
lilyopts = string.join (incs, ' ' )
texfiles = string.join (tex, ' ')
- system ('lilypond %s %s' % (lilyopts, texfiles))
- for i in tex:
- extract_texidoc (i)
+ system ('lilypond --header=texidoc %s %s' % (lilyopts, texfiles))
for e in eps:
system(r"tex '\nonstopmode \input %s'" % e)
system(r"dvips -E -o %s %s" % (e + '.eps', e))