From: Han-Wen Nienhuys Date: Wed, 19 Mar 1997 00:52:59 +0000 (+0100) Subject: release: 0.0.42.pre3 X-Git-Tag: release/0.0.42.pre3 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=01ddcb81463d7a68530971100469d3e2baf8c94b;p=lilypond.git release: 0.0.42.pre3 --- diff --git a/.dstreamrc b/.dstreamrc index c7b8c24c77..4448ee7d89 100644 --- a/.dstreamrc +++ b/.dstreamrc @@ -1,8 +1,7 @@ # class name silence? Dstream 1 -My_flex_lexer 1 -yyFlexLexer 1 +My_flex_lexer 0 PCol 1 Score_column 1 Ineq_constrained_qp 1 @@ -14,7 +13,7 @@ Idealspacing 1 # yydebug InitParser 1 -Parser 1 +Parser 0 InitDeclarations 1 # FlexLexer debug diff --git a/.version b/.version index 71f7750ff1..e268239e5d 100644 --- a/.version +++ b/.version @@ -4,5 +4,5 @@ TOPLEVEL_PATCH_LEVEL = 42 # use to send patches, always empty for released version: # include separator: ".postfix", "-pl" makes rpm barf -TOPLEVEL_MY_PATCH_LEVEL = +TOPLEVEL_MY_PATCH_LEVEL =.3 # diff --git a/ANNOUNCE b/ANNOUNCE index df31a15ba0..afcf2ffd5d 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,4 +1,4 @@ -[Draft version] + [Draft version] CALL FOR HACKERS: LilyPond, the Music Typesetter diff --git a/Documentation/CodingStyle.pod b/Documentation/CodingStyle.pod index 8df4c8fd42..66ee04705f 100644 --- a/Documentation/CodingStyle.pod +++ b/Documentation/CodingStyle.pod @@ -9,26 +9,29 @@ Please use these standards while doing programming for LilyPond Functions and methods do not return errorcodes, but use assert for checking status. - A program should be light and agile, its subroutines - connected like a strings of pearls. The spirit and intent of - the program should be retained throughout. There should be - neither too little nor too much, neither needless loops nor - useless variables, neither lack of structure nor overwhelming - rigidity. - - A program should follow the 'Law of Least - Astonishment'. What is this law? It is simply that the - program should always respond to the user in the way that - astonishes him least. - - A program, no matter how complex, should act as a - single unit. The program should be directed by the logic - within rather than by outward appearances. - - If the program fails in these requirements, it will be - in a state of disorder and confusion. The only way to correct - this is to rewrite the program. - -- Geoffrey James, "The Tao of Programming" +=head2 Quote: + +A program should be light and agile, its subroutines +connected like a strings of pearls. The spirit and intent of +the program should be retained throughout. There should be +neither too little nor too much, neither needless loops nor +useless variables, neither lack of structure nor overwhelming +rigidity. + +A program should follow the 'Law of Least +Astonishment'. What is this law? It is simply that the +program should always respond to the user in the way that +astonishes him least. + +A program, no matter how complex, should act as a +single unit. The program should be directed by the logic +within rather than by outward appearances. + +If the program fails in these requirements, it will be +in a state of disorder and confusion. The only way to correct +this is to rewrite the program. + +-- Geoffrey James, "The Tao of Programming" =head2 INDENTATION @@ -109,7 +112,7 @@ symbols. Staff is the "brains" for PStaff NB: in PCursor (which is part of the library) P stands for PointerCursor -=head2 MEMBERS(2) +=head2 MEMBERS (2) Standard methods: @@ -176,26 +179,33 @@ existed. I feel so stupid and ashamed! =over 5 =item * + more keystrokes (disk space!) =item * + it looks silly C =item * + it looks like code from micro suckers =item * + (which) might scare away some (otherwise good?) progammers, or make you a paria in the free software community =item * + it has ambiguities =item * + not very useful if not used consistently =item * + usefullness in I (but how many classes is very large?) remains an issue. @@ -209,16 +219,20 @@ remains an issue. =over 5 =item * + learn about cut and paste / use emacs or vi or lean to type using ten fingers =item * + Use emacs dabbrev-expand, with dabbrev-case-fold-search set to nil. =item * + use no, or pick less silly, abbrvs. =item * + use non-ambiguous postfixes C =back @@ -230,30 +244,41 @@ with the parts of the names separated by underscores. =over 5 =item C + + unsigned char. (The postfix _by is ambiguous) =item C + + bool =item C + bit =item C + char =item C + float =item C + signed integer =item C + string class =item C + Zero terminated c string =item C + unsigned integer =back @@ -275,21 +300,27 @@ These are precede the prefixes: =over 5 =item C + array =item C + user built array. =item C -const + +const. Note that the proper order C i.s.o. C =item C + temporary pointer to object (link) =item C

+ pointer to newed object =item C + reference =back @@ -297,24 +328,31 @@ reference =over 5 =item C + Variable loop: an integer =item C + Temporary variable: an unsigned integer =item C + Variable test: a character =item C + Variable first_name: a String class object =item C + Variable last_name: a C array =item C + Variable foo: an C that you must delete =item C + Variable bar: an C that you must not delete =back diff --git a/Documentation/Makefile b/Documentation/Makefile index 9f74fbb9a9..272ea0d279 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -8,22 +8,18 @@ depth = .. # identify module: # NAME = Documentation -MAJOR_VERSION = $(TOPLEVEL_MAJOR_VERSION) -MINOR_VERSION = $(TOPLEVEL_MINOR_VERSION) -PATCH_LEVEL = $(TOPLEVEL_PATCH_LEVEL) -# use to send patches, always empty for released version: -MY_PATCH_LEVEL = $(TOPLEVEL_MY_PATCH_LEVEL) -build = ./$(depth)/lily/$(outdir)/.build + # # generic variables: # include ./$(depth)/make/Variables.make +include ./$(depth)/make/Version.make +include ./$(depth)/make/Files.make # -# list of source files: # -PODFILES = $(shell ls *.pod) + OUTPODFILES = $(patsubst %,$(outdir)/%,$(PODFILES)) TEXTFILES = $(OUTPODFILES:.pod=.text) GROFFFILES = $(OUTPODFILES:.pod=.1) @@ -32,7 +28,7 @@ HTMLFILES = $(OUTPODFILES:.pod=.html) # list of distribution files: # -DISTFILES = $(PODFILES) Makefile lelie_logo.gif +EXTRA_DISTFILES = lelie_icon.gif lelie_logo.gif # default: do-doc diff --git a/Documentation/faq.pod b/Documentation/faq.pod index 2c5ceb2cb9..d63883106d 100644 --- a/Documentation/faq.pod +++ b/Documentation/faq.pod @@ -6,6 +6,40 @@ FAQ - LilyPond FAQs Some questions that have been answered before. +Q: I can type + + + +to make a few chords, but why do I have to type + + + < { a() e } { c () g } > + +in stead of + + <)e )g> + +to generate slurs between the chords? + +A: When you type + + + +this is shorthand for + + < { a } { c } > < { e } { g } > + +Slurs have to be confined to `voices', and the a and the e are in +different {} blocks, so they are in different voices. You should view +the desired construct as a "generalised chord" (two voices stacked +vertically). It might help you visualise this by using the following +formatting: + + < { a () e } + { c () g } + > + + Q: Why are [] around the notes, and () inbetween? A: [] designate beams, a note can only be in one beam at the same diff --git a/Documentation/lelie_icon.gif b/Documentation/lelie_icon.gif new file mode 100644 index 0000000000..59b6c23680 Binary files /dev/null and b/Documentation/lelie_icon.gif differ diff --git a/Documentation/lilygut.pod b/Documentation/lilygut.pod index 1ac0c5290d..b4d2f07813 100644 --- a/Documentation/lilygut.pod +++ b/Documentation/lilygut.pod @@ -174,7 +174,9 @@ To decide on merging, C has grouped several registers. There are a few groups: =item * + Staff wide, contains + Local_key_register Bar_register Key_register @@ -182,13 +184,17 @@ Staff wide, contains Clef_register =item * + Voice group, contains + Stem_beam_register Script_register Text_register =item * + Voice, contains + Slur_register Notehead_register @@ -316,7 +322,7 @@ Ross, Ted. ``Teach yourself the art of music engraving and processing'' Miami, FL 33139 (305) 532-5461 -[This is about *engraving* i.e. professional music typesetting, and includes +[This is about I i.e. professional music typesetting, and includes some good spacing tables] Read, Gardner. ``Modern Rhythmic Notation.'' Indiana University Press, 1978. diff --git a/Documentation/lilyinput-pre-0.1.pod b/Documentation/lilyinput-pre-0.1.pod new file mode 100644 index 0000000000..58a4378d4b --- /dev/null +++ b/Documentation/lilyinput-pre-0.1.pod @@ -0,0 +1,79 @@ +=head1 NAME + +LilyInput - LilyPond input format + +=head1 DESCRIPTION + +This page globally documents the the LilyPond input format, mudela. +To get a better impression, please study some examples. + +=head2 Overview + +General format of a construct: + + BLOCKNAME { } + +Some types allow declarations: + + IDENTIFIER = BLOCKNAME { + + } + + .. + + BLOCKNAME { + IDENTIFIER + ... + } + + +In musicmode, eg, + + ''!c8.-"text"_v + +and in lyricmode, eg, + + Twin- kle, twin- kle lit- tle star,2 + +a lot of characters parse differently +than in "command" mode, eg, + + identifier = score { .. } + +So you have to signal this to the tokenizer. This is done with +'$'. '$' is a delimiter, which used by the tokenizer only. The same +goes for lyrics, it has a '@' delimiter. + +=item * +musicmode: The brace still is used to group grammatical groups. + +=item * +musicmode: "word" are preceded by a '\' (backslash) + +This means you can write some stuff in a zillion ways: + +=item 1. + $\var = \blockname { ... } $ + +=item 2. + var = blockname { $ ... $ } + +=item 3. + var = $ $ $\blockname { ... $ } + +=head2 Comments + +Not really crystallized; you can use '#' or '%' as line comment + +=head2 other + +LilyPond first reads 'symbol.ini', which contains declarations crucial +to proper operation of LilyPond (symbol tables, note names). + +This language looks a lot like Rayce's (Rayce is a raytracer that I've +written as a hobby project. I used as a practice program for writing +(among others) C++ and Yacc. It also gave me RSI :-( ) which in turn +owes a lot to the POVRay raytracer. Now, I know, musictypesetting and +Raytracing do not necessarily require the same input format, but I was +just to lazy to make up a new and/or better input format. Suggestions +appreciated. diff --git a/Documentation/lilyinput.pod b/Documentation/lilyinput.pod index 58a4378d4b..b7fe60ff83 100644 --- a/Documentation/lilyinput.pod +++ b/Documentation/lilyinput.pod @@ -1,79 +1,372 @@ =head1 NAME -LilyInput - LilyPond input format +LilyInput - LilyPond input format -- Mudela 0.1 + +B this doc describes the I input format, S. =head1 DESCRIPTION -This page globally documents the the LilyPond input format, mudela. -To get a better impression, please study some examples. +This document describes the the LilyPond input format, which is an +effective language for definining music. We call this language +(rather arrogantly) The Musical Definition Language (S). -=head2 Overview +The first aim of Mudela is to define a piece of music, +being complete from both from a musical typesetting, +as from a musical performing point of view. -General format of a construct: +The design of Mudela has been (perfect past tense, hopefully) +an ongoing process, +the most important criteria being: - BLOCKNAME { } +=over 4 -Some types allow declarations: +=item * - IDENTIFIER = BLOCKNAME { - - } +define the (musical) message of the composer as unambiguously as possible, - .. +=item * - BLOCKNAME { - IDENTIFIER - ... - } +be intuitive, and easily readable +(compared to, say, Musi*TeX input, or MIDI :-), + +=item * + +be writable in ASCII with a simple texteditor, yfte(TM). + +=back + +Other considerations were (and will be): + +=over 4 + +=item * + +be able to edit the layout +without danger of changing the original music (Urtekst), + +=item * + +allow for adding different interpretations, again, +without danger of changing the original, + +=item * + +easy to create a conductor's score, +as well as the scores for all individual instruments, +=item * + +provide simple musical manipulations, such as +S<(i) extracting> a slice of music from a previously defined piece, +S<(ii) extracting> only the rhythm from a piece of music, +S<(iii) transposing>, etc., + +=item * + +easy to comprehend to both programmers and others. + +=back + +Musical pieces could be + +=over 5 + +=item * -In musicmode, eg, +Mahlerian orchestral scores, - ''!c8.-"text"_v +=item * -and in lyricmode, eg, +piano pieces (Schubertian, Rachmaninovian), - Twin- kle, twin- kle lit- tle star,2 +=item * -a lot of characters parse differently -than in "command" mode, eg, +pop songs (lyrics and chords), - identifier = score { .. } +=item * -So you have to signal this to the tokenizer. This is done with -'$'. '$' is a delimiter, which used by the tokenizer only. The same -goes for lyrics, it has a '@' delimiter. +gregorian chants, =item * -musicmode: The brace still is used to group grammatical groups. + +Bach multivoice organ pieces, =item * -musicmode: "word" are preceded by a '\' (backslash) -This means you can write some stuff in a zillion ways: +short excerpts to be used in musicological publications. + +=back -=item 1. - $\var = \blockname { ... } $ -=item 2. - var = blockname { $ ... $ } +=head1 Overview -=item 3. - var = $ $ $\blockname { ... $ } +The Musical Definition Language (Mudela) S, +has a logical structure, +making use of typing and naming (using identifiers), +that allows for flexible input, and definition reuse. =head2 Comments -Not really crystallized; you can use '#' or '%' as line comment +Line comments are introduced by a C<%> + +=head2 Keywords + +Keywords are preceded by a backslash "\". + +The actual musical part of Mudela that defines a melody, is known as +I. + +Mudela uses the brace (C<{> and C<}>) for hierarchical structures. To +aid the eye in reading, for chords we have used the C<<> and the C<>> +as nesting braces. + + +The general structure consists of declarations: + + IDENTIFIER = \TYPE{ + + } + +and instantiations: + + \TYPE{ } + +(Currently, C<\score> is the only type that can be instantiated +at top level. Currently declarations can only be done at top level) + +Most instantiations that use an IDENTIFIER are specified as follows: + + \TYPE { IDENTIFIER [...] } + +Some exceptions on this rule have been made to prevent inputting +Mudela becoming tedious + +=head1 Music + +=head2 Simple mudela + +Simple mudela is the most common type of music. It consists of a list +of notes, chords, and commands. The below included for explanatory +purposes only (i.e., for a complete and up-to-date definition, see +F and F): + +Simple mudela basically is a sequence of the notes you want to +enter. + + a'4 % dutch names + +is a A-1 pitched quaver. The ' signifies an octave change. +A-1 is 440 Hz concert-pitch. C is also known as the central +c. More examples: + + a` % 110 + a % 220 + a' % 440 + a'' % 880 + +another example: + + as`4.*2/3 + +This is an A flat, (just below 110 Hz concert-pitch). The C<*2/3> +signifies that this note is part of a triplet (3 in stead of 2). The +duration is one and a half quaver times 2/3. + +The default language for notenames is defined to be dutch, + + % double sharp + cisis disis eisis fisis gisis aisis bisis + % sharps + cis dis eis fis gis ais bis + % naturals + c d e f g a b + % flats + ces des es fes ges as bes + % double flats + ceses deses eses feses geses ases beses + +The standard notenames also have uppercase versions, which octavate +down: + + a % 220 + A % 110 + 'A % 55 + A' % 220 + +These notenames along with duration is enough material to construct +simple melodies: + + c4 c4 g4 g4 a4 a4 g2 + f4 f4 e4 e4 d4 d4 c2 + +Music is able to express more. generally speaking, the other +'features' are either connected between notes (slurs, beams: spanning +requests) or attached to notes (eg. accents). The former are +implemented as START and STOP stop features and then attached to the note. + + [] START/STOP a beam + () START/STOP a slur + + +example: + + [c8 () d8 () e8 ] + +Please note that these two parentheses do I necesarrily nest, eg: + + [c8 e8(] [)g8 c'8] + + +Symbols which can be put at either side of a staff are entered as follows: + + a-^ % marcato, direction: default + a^- % portato, direction: above note + a_. % staccato, direction: below note + a^\script { "symbolindex" . . . } % see script.ini for details. + +Dynamics can be put after the notename: + + a4 \dynamic { 0 } % 0 = fff, 7 = ppp + +Mudela defines the following dynamic identifiers: + + ppp pp p mp mf df ff fff % df iso f, f is a notename. -=head2 other +The general form of a note is: -LilyPond first reads 'symbol.ini', which contains declarations crucial + post-requests de-octavate notename octavate duration pre-requests + +Notenames are just identifiers, and can be declared for any +language appropriate (see F). + + +=head2 Lyrics + +Lyrics in Mudela resemble Simple mudela a lot, +with notes substituted by text. +All syllables are entered separately, separated by whitespace +("Twin-4 kle4 twin-4 kle4 ... "). +Two syllables or words that compose a single duration entry +are bound together using an underscore ("He_could4 not4"). + +=head2 Rhythms + +Rhythms in Mudela are entered identical to Simple mudela. +The melodic part of the information is ignored. + +=head1 STRUCTURE + +In concrete, a piece of Mudela has the following structure: + + % declare pieces of music: + melody = \music{ } + accompany = \music{ } + + % instantiate (=create tex, midi output) the score: + \score{ + \staff{ melody } + \staff{ accompany } + \commands{ } + \midi{ } + \paper{ , which contains declarations crucial to proper operation of LilyPond (symbol tables, note names). -This language looks a lot like Rayce's (Rayce is a raytracer that I've -written as a hobby project. I used as a practice program for writing -(among others) C++ and Yacc. It also gave me RSI :-( ) which in turn -owes a lot to the POVRay raytracer. Now, I know, musictypesetting and -Raytracing do not necessarily require the same input format, but I was -just to lazy to make up a new and/or better input format. Suggestions -appreciated. +=head1 Decisions (Sat 1997-3-15, dommelpijpje no21) + +=over 4 + +=item * + +\keyword, bo difference notes vs. notenames, + +=item * + +{} hierachical, nest., + +=item * + +<> chords, + +=item * + +drop staff (NOT)?, + +=item * + +melody = \melodic{ } vs. \melodic melody = { } + +=item * + +lexer mode switch by types: \lyric{ }, \melodic{ }, etc., + +=item * + +octaves: low 'C C c c' c'' high; 'c' == c === "c-klein", comment: a ' +' a . Which ' for which a? Now using a!'`. + +=over 4 + +=item * + +\meter{ 2/4 }, + +=item * + +\grouping{ 2*8 3*8 }, + +=item * + +\skip{ 2: 2*8 3*32 }, + +=item * + +abbrev: [c2 c2]\noplet{1/2} (wat bout [c2 c2]1/2\noplet?), + +=item * + +abbrev: c4=16 (heu, =?), + +=item * + +plet === midi-note: c4*2/3; c4*385/384, + +=back + +=item * + +drop \music, + +=item * + +\meter compulsory in Simple mudela, + +=item * + +++ concat + +=item * + +C<+> is merge + +=item * + + \transpose{ \from c \to g \melodic{ c d e } } + \transpose{ \from c \to g melody } %!? + +=item * + + \extract{ \from 2:3*4 \to 5 oboe } + +=back + diff --git a/Documentation/lilypond.pod b/Documentation/lilypond.pod index 09ce63e36e..067c596d74 100644 --- a/Documentation/lilypond.pod +++ b/Documentation/lilypond.pod @@ -66,34 +66,43 @@ add F to the search path for input files. =over 5 =item * + ASCII script input, with identifiers (for music reuse), customizable notenames, customizable fontset =item * + MIDI output lets you check if you have entered the correct notes. =item * + MIDI to Mudela conversion through the mi2mu program. =item * + Multiple staffs in one score. Each staff can have a different meters. =item * + multiple stafftypes (melodic, rhythmic) [broken from pl28 on] =item * + beams, slurs, chords, super/subscripts (accents and text), triplets, general n-plet (triplet, quadruplets, etc.), lyrics =item * + multiple voices within one staff; beams optionally shared between voices. (well, more than 2 voices won't look pretty --yet.) =item * + multiple scores within one input file. Each score is output to a different file. =item * + clef changes, meter changes, cadenza-mode, key changes, repeat bars =back @@ -105,29 +114,14 @@ LilyPond was written with some considerations in mind: =over 5 =item * + Describing a well-defined language for defining music. We call this language (rather arrogantly) The Musical Definition Language (mudela for short). LilyPond reads a mudela sourcefile and outputs a -TeX file. This musical definition language should: - -=over 5 - -=item 1. -define the musical message of the writer as unambigiously as -possible. - -=item 2. -be easily readable. (as compared to, say, MusixTeX input) - -=item 3. -be writable in ASCII (with a simple texteditor). - -=back - -At this time, the language isn't yet defined precisely. It is evolving as -LilyPond is getting more complex. +TeX file. =item * + We want to provide an easy-to-use interface for typesetting music in its broadest sense. This interface should be intuitive from a musical point of view. By broadest sense we mean: it is designed for music @@ -135,35 +129,41 @@ printed left to right in staffs, using notes to designate rythm and pitch. =item * + LilyPond uses MusiXTeX fonts and TeX for its output. This is not a key issue: in a future version, LilyPond might bypass TeX, but at the moment TeX is very convenient for producing output. =item * + Generate high-quality output. Ideally it should be of a professional quality. We'd like to render Herbert Chlapiks words, "Fine music setting is not possible without a knowledgeable printer," untrue. =item * + LilyPond does not display notes directly, nor will it be rehacked to be used interactively. LilyPond writes output to a file. It will not be extended to play music, or to recognize music. =item * + LilyPond is intended to run on Unix platforms, but it should be portable to any platform which can run TeX and the GNU tools =item * + LilyPond is free. Commercial windows packages for setting music are abundant. Free musicprinting software is scarce. =item * + LilyPond is written in GNU C++. It will not be downgraded/ported to fit broken systems. =back -=head1 +=head1 DISCLAIMER & COPYING POLICY LilyPond is copyright 1996,97 by its authors. LilyPond is @@ -177,14 +177,17 @@ the GNU General Public License, which is in the file F =over 5 =item * + Han-Wen Nienhuys , Main author =item * + Jan Nieuwenhuizen , Context errors, Lyrics, mi2mu, MIDI stuff, make structure, bits of FlowerLib, general comments. =item * + Mats Bengtsson , bugfixes, testing, general comments. =back @@ -207,7 +210,7 @@ This is what the output looks like over here: LilyPond 0.0.40 #0/FlowerLib 1.1.7 #2. Compile: Mar 11 1997, 22:58:47 (g++ 2.7.2) Parsing ... [./init//symbol.ini[./init//dynamic.ini][./init//dutch.ini][./init//script.ini][./init//table_sixteen.ini]][./input/wohltemperirt.ly] Setting up music ...Processing music ............ - Preprocessing ... + Preprocessing ... Calculating column positions ... [3][6][9] Postprocessing ... TeX output to lelie.out ... @@ -249,7 +252,7 @@ This is a beta version of LilyPond. Please send your helpful comments and patches to me (see AUTHORS section) LilyPond is updated very frequently, the latest version is always available at: -ftp://pcnov095.win.tue.nl/pub/lilypond. +ftp://pcnov095.win.tue.nl/pub/lilypond. =head1 FILES @@ -265,7 +268,7 @@ includes files from the directory F. =head1 SEE ALSO There are some documentation files in the subdirectory F, -among others: lilygut, lilyinput, error, faq, +among others: lilygut, lilyinput, error, faq, =head1 REMARKS diff --git a/INSTALL.text b/INSTALL.text index 515c41da0f..fa4c437bca 100644 --- a/INSTALL.text +++ b/INSTALL.text @@ -61,7 +61,7 @@ CCCCOOOONNNNFFFFIIIIGGGGUUUURRRRIIIINNNNGGGG a -14/Mar/97 LilyPond 0.0.41 1 +14/Mar/97 LilyPond 0.0.42 1 @@ -127,7 +127,7 @@ RRRRUUUUNNNNNNNNIIIINNNNGGGG -14/Mar/97 LilyPond 0.0.41 2 +14/Mar/97 LilyPond 0.0.42 2 @@ -193,6 +193,6 @@ AAAAUUUUTTTTHHHHOOOORRRRSSSS -14/Mar/97 LilyPond 0.0.41 3 +14/Mar/97 LilyPond 0.0.42 3 diff --git a/Makefile b/Makefile index 9c9f9b7737..7ac03e335c 100644 --- a/Makefile +++ b/Makefile @@ -16,15 +16,8 @@ depth = . # identify module: # NAME = lilypond - -# edit in .version only! -MAJOR_VERSION = $(TOPLEVEL_MAJOR_VERSION) -MINOR_VERSION = $(TOPLEVEL_MINOR_VERSION) -PATCH_LEVEL = $(TOPLEVEL_PATCH_LEVEL) -# use to send patches, always empty for released version: -MY_PATCH_LEVEL = $(TOPLEVEL_MY_PATCH_LEVEL) -build = ./$(depth)/lily/$(outdir)/.build -# +include .version +include ./$(depth)/make/Version.make # generic variables: # @@ -42,7 +35,7 @@ SUBDIRS = flower lib lily mi2mu \ # SYMLINKS = # naah, configure SCRIPTS = configure configure.in install-sh README_FILES = ANNOUNCE COPYING NEWS README TODO INSTALL.text -DISTFILES= Makefile .dstreamrc .version $(README_FILES) $(SCRIPTS) $(SYMLINKS) +EXTRA_DISTFILES= .dstreamrc .version $(README_FILES) $(SCRIPTS) $(SYMLINKS) # @@ -55,9 +48,8 @@ include ./$(depth)/make/Rules.make localdist: configure # ugh. I know dep is not quite what is really needed. -INSTALL.text: Documentation +INSTALL.text: check-doc-deps rm -f INSTALL.text - $(MAKE) -C Documentation ln `find -name INSTALL.text|head -1` . localclean: diff --git a/NEWS b/NEWS index c4e313d9b9..0ed6c6a5d5 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,20 @@ +pl 42.3 + - const naming change (T const <-> const T) + - Mudela 0.1 + +pl 42.2 + - new lilyinput (Mudela 0.1) doc. +Examples + - new-twinkle.ly (in Mudela 0.1, hopefully) + +pl 42.1 + - further Makefile revamping. + - moved flowerlib + +******* +pl 42 + + pl 41.hwn3 - struct Lexer_prefs - parser bug diff --git a/TODO b/TODO index 8f67365717..6a36fe3b9d 100644 --- a/TODO +++ b/TODO @@ -1,9 +1,8 @@ - * remove notename.* README.pod LilyPond.pod - before 0.1 + * fix Lyric mode * remove spurious/outdated comments in .ly, debug .ly - + * pushgroup, popgroup. * basic dynamics @@ -11,26 +10,19 @@ before 0.1 * basic syntax & parser/lexer cleanup. * decent TeX page layout - - * clean split for m2m of sources. - - * caching of Register_group_register hierarchies. + + * avoid unnecessary confusing constructs from .ly This is an assorted collection of stuff that will be done, might be done, or is an idea that I want to think about MAKE-STUFF - * fix increase build ( libflower rebuilt when making lilypond. ) - * sort out headers, see m2m * do platform stuff: configure, header(s), targets, build (out?) - - * make install. BUGS - * plet bugs: scales.ly * key at clef change. @@ -48,26 +40,35 @@ BUGS SEVERELY LACKING: + * hairpins + * grace notes +FURTHER FOR ORCHESTRAL SCORE: + + * multibar rests + + * barnumbers, markers + + * abbreviations c4=16 + INPUTLANGUAGE * read ENV for include path - * lose the $ and @ ? - * figured bass? * transposition * rest name configurable - * < .. > vs. { .. } syntax? ! +SMALLISH PROJECTS - * '*' vs. '/' + * use dstream feature in mi2mu -SMALLISH PROJECTS + * qtor, btor, mtor-> tor( QUIET_ver ), tor( DEBUG_ver ), etc. + * use tors feature in lily * midi esp.: use I32 iso int where 32 bits are needed (or assumed...) @@ -101,6 +102,9 @@ SMALLISH PROJECTS * Brackets * space rest. + + * caching of Register_group_register hierarchies. + * use (char *) iso. String for communication between lexer and parser. @@ -151,8 +155,6 @@ FUTURE * piano staff - * abbreviations a4*8 - IDEAS * integrate Register/Midi stuff diff --git a/bin/Makefile b/bin/Makefile index c1c0767811..7284a0b5ff 100644 --- a/bin/Makefile +++ b/bin/Makefile @@ -5,16 +5,14 @@ depth = .. # -build = ./$(depth)/lily/$(outdir)/.build - +include ./$(depth)/make/Include.make # generic stuff/Makefile # -include ./$(depth)/make/Stuff.make # # list of distribution files: # -SCRIPTS = clearlily cpgento genheader make_patch make_version make_website -DISTFILES = Makefile $(SCRIPTS) +SCRIPTS = clearlily cpgento genheader make_patch make_version make_website release +EXTRA_DISTFILES = $(SCRIPTS) # diff --git a/bin/release b/bin/release new file mode 100755 index 0000000000..faec64d8fd --- /dev/null +++ b/bin/release @@ -0,0 +1,36 @@ +#!/bin/sh + + +function setversion() { +eval `sed -n 's/^\([A-Z_]*\) *= *\(.*\)$/\1=\2/p' .version` +MJ=$TOPLEVEL_MAJOR_VERSION +MI=$TOPLEVEL_MINOR_VERSION +PA=$TOPLEVEL_PATCH_LEVEL +MP=$TOPLEVEL_MY_PATCH_LEVEL +NEWVER=$MJ.$MI.$PA$MP +if [ -z $MP ] +then + LASTVER=$MJ.$MI.`expr $PA - 1` +else + LASTVER=$MJ.$MI.$PA +fi + +echo +echo "Current version ("`pwd`") is $NEWVER, Last version: $LASTVER" +echo +} +heredir=`pwd` + make dist; + setversion + LILYVER=$NEWVER + cp lilypond-$LILYVER.tar.gz ../releases + $heredir/bin/make_patch $LASTVER $NEWVER lilypond + gzip -f9 patch-$NEWVER + mv {lilypond-,patch-}*.gz ../ +cd .. +tar cf updeet {lily,patch-}*.gz + +mv patch-*gz patches/ +mv lilypond*tar.gz releases/ + +#time make diff --git a/configure b/configure index bd351d2ca4..c79b71d92c 100755 --- a/configure +++ b/configure @@ -12,15 +12,15 @@ ac_help= ac_default_prefix=/usr/local # Any additions from configure.in: ac_help="$ac_help - printing set debug printing" + enable-printing set debug printing" ac_help="$ac_help - checking set runtime checks" + disable-checking set runtime checks" ac_help="$ac_help - debug set debug info" + disable-debug set debug info" ac_help="$ac_help - optimise use maximal speed optimisations" + enable-optimise use maximal speed optimisations" ac_help="$ac_help - profiling compile with gprof support" + enable-profiling compile with gprof support" ac_help="$ac_help texprefix=DIR set the tex-directory to put the lilypond subdir in." @@ -457,7 +457,7 @@ echo > confdefs.h # A filename unique to this package, relative to the directory that # configure is in, which we can look for to find out if srcdir is correct. -ac_unique_file=flower/lib/choleski.cc +ac_unique_file=flower/choleski.cc # Find the source files, if location was not specified. if test -z "$srcdir"; then @@ -524,6 +524,8 @@ else fi + + ac_ext=C # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CXXCPP $CPPFLAGS' @@ -542,14 +544,14 @@ fi # Check whether --enable-checking or --disable-checking was given. if test "${enable_checking+set}" = set; then enableval="$enable_checking" - : -else DEFINES="$DEFINES -DNDEBUG=1" fi # Check whether --enable-debug or --disable-debug was given. if test "${enable_debug+set}" = set; then enableval="$enable_debug" + : +else DEFINES="$DEFINES -g" fi @@ -619,7 +621,7 @@ else yes; #endif EOF -if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:623: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:625: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gxx=yes else ac_cv_prog_gxx=no @@ -1021,12 +1023,12 @@ ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CXX-g++} -o conftest $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' CXXCPP="${CXX-g++} -E" cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1030: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1032: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then : @@ -1048,12 +1050,12 @@ if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1057: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1059: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -1407,6 +1409,8 @@ touch make/out/Site.make # ugr (cd mi2mu; CXX="$ac_cv_prog_CXX" ../bin/make_version > out/version.hh ) +# rgu +sed 's/TOPLEVEL_//g' < .version > lily/.version (cd lily; CXX="$ac_cv_prog_CXX" ../bin/make_version > out/version.hh ) (cd flower; diff --git a/configure.in b/configure.in index 4e48c76e27..cbb4430499 100644 --- a/configure.in +++ b/configure.in @@ -34,26 +34,28 @@ AC_DEFUN(AC_TEX_SUBDIR, [ AC_MSG_RESULT($$1) ]) +AC_INIT(flower/choleski.cc) + -AC_INIT(flower/lib/choleski.cc) AC_LANG_CPLUSPLUS AC_ARG_ENABLE(printing, - [ printing set debug printing], + [ enable-printing set debug printing], [], [DEFINES="$DEFINES -DNPRINT=1"]) AC_ARG_ENABLE(checking, - [ checking set runtime checks], - [], - [DEFINES="$DEFINES -DNDEBUG=1"]) + [ disable-checking set runtime checks], + [DEFINES="$DEFINES -DNDEBUG=1"], + []) AC_ARG_ENABLE(debug, - [ debug set debug info], + [ disable-debug set debug info], + [], [DEFINES="$DEFINES -g"]) AC_ARG_ENABLE(optimise, - [ optimise use maximal speed optimisations], + [ enable-optimise use maximal speed optimisations], [DEFINES="$DEFINES -O2 -DSTRING_UTILS_INLINED"]) AC_ARG_ENABLE(profiling, - [ profiling compile with gprof support], + [ enable-profiling compile with gprof support], [DEFINES="$DEFINES -pg"]) AC_ARG_ENABLE(texprefix, [ texprefix=DIR set the tex-directory to put the lilypond subdir in.], @@ -154,6 +156,8 @@ touch make/out/Site.make (cd mi2mu; CXX="$ac_cv_prog_CXX" ../bin/make_version > out/version.hh dnl echo 0 > out/.build ) +# rgu +sed 's/TOPLEVEL_//g' < .version > lily/.version (cd lily; CXX="$ac_cv_prog_CXX" ../bin/make_version > out/version.hh dnl echo 0 > out/.build ) diff --git a/flower/.version b/flower/.version index 45d4ace492..c4828f0767 100644 --- a/flower/.version +++ b/flower/.version @@ -1,6 +1,6 @@ MAJOR_VERSION = 1 MINOR_VERSION = 1 -PATCH_LEVEL = 7 +PATCH_LEVEL = 8 # use to send patches, always empty for released version: MY_PATCH_LEVEL = # include separator: "-1" or ".a" # diff --git a/flower/Makefile b/flower/Makefile index a4ee94bd5d..6a71998fde 100644 --- a/flower/Makefile +++ b/flower/Makefile @@ -19,28 +19,29 @@ NAME = flower MODULE_NAME = flower # # edit .version only -include ./$(depth)/flower/.version include ./$(depth)/.version -build = ./$(depth)/flower/$(outdir)/.build -# +include ./$(depth)/flower/.version # generic variables: # -include ./$(depth)/make/Variables.make -# +include ./$(depth)/make/Variables.make +include ./$(depth)/make/Files.make +# +CXXFLAGS+=-O2 # descent order into subdirectories: # -SUBDIRS = lib test +SUBDIRS = test include # # list of distribution files: # SCRIPTS = README_FILES = NEWS README TODO -DISTFILES= configure config.hh.in configure.in Makefile .version $(README_FILES) $(SCRIPTS) +EXTRA_DISTFILES= configure config.hh.in configure.in .version $(README_FILES) $(SCRIPTS) # + # generic targets and rules: # include ./$(depth)/make/Targets.make diff --git a/flower/NEWS b/flower/NEWS index e4d17c55f5..4dd5330743 100644 --- a/flower/NEWS +++ b/flower/NEWS @@ -1,3 +1,6 @@ +pl 1.1.8 + + pl 1.1.7 - PQueue blondification. - String_convert::i2hex_str fix, unsigned eqvs introduced diff --git a/flower/choleski.cc b/flower/choleski.cc new file mode 100644 index 0000000000..1d64f949ac --- /dev/null +++ b/flower/choleski.cc @@ -0,0 +1,91 @@ +#include "choleski.hh" +const Real EPS = 1e-7; // so sue me. Hard coded + +Vector +Choleski_decomposition::solve(Vector rhs)const +{ + int n= rhs.dim(); + assert(n == L.dim()); + Vector y(n); + + // forward substitution + for (int i=0; i < n; i++) { + Real sum(0.0); + for (int j=0; j < i; j++) + sum += y(j) * L(i,j); + y(i) = (rhs(i) - sum)/L(i,i); + } + for (int i=0; i < n; i++) + y(i) /= D(i); + + // backward subst + Vector &x(rhs); // using input as return val. + for (int i=n-1; i >= 0; i--) { + Real sum(0.0); + for (int j=i+1; j < n; j++) + sum += L(j,i)*x(j); + x(i) = (y(i) - sum)/L(i,i); + } + return x; +} + +/* + Standard matrix algorithm. + */ + +Choleski_decomposition::Choleski_decomposition(Matrix P) + : L(P.dim()), D(P.dim()) +{ + int n = P.dim(); + assert((P-P.transposed()).norm()/P.norm() < EPS); + + L.unit(); + for (int k= 0; k < n; k++) { + for (int j = 0; j < k; j++){ + Real sum(0.0); + for (int l=0; l < j; l++) + sum += L(k,l)*L(j,l)*D(l); + L(k,j) = (P(k,j) - sum)/D(j); + } + Real sum=0.0; + + for (int l=0; l < k; l++) + sum += sqr(L(k,l))*D(l); + Real d = P(k,k) - sum; + D(k) = d; + } + +#ifdef NDEBUG + assert((original()-P).norm() / P.norm() < EPS); +#endif +} + +Matrix +Choleski_decomposition::original() const +{ + Matrix T(L.dim()); + T.set_diag(D); + return L*T*L.transposed(); +} + +Matrix +Choleski_decomposition::inverse() const +{ + int n=L.dim(); + Matrix invm(n); + Vector e_i(n); + for (int i = 0; i < n; i++) { + e_i.set_unit(i); + Vector inv(solve(e_i)); + for (int j = 0 ; j confdefs.h # A filename unique to this package, relative to the directory that # configure is in, which we can look for to find out if srcdir is correct. -ac_unique_file=lib/choleski.cc +ac_unique_file=choleski.cc # Find the source files, if location was not specified. if test -z "$srcdir"; then @@ -916,7 +916,7 @@ done ac_given_srcdir=$srcdir -trap 'rm -fr `echo " lib/out/config.hh:config.hh.in" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +trap 'rm -fr `echo " out/config.hh:config.hh.in" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 EOF cat >> $CONFIG_STATUS < out/version.hh diff --git a/flower/data-file.cc b/flower/data-file.cc new file mode 100644 index 0000000000..0dad79c91f --- /dev/null +++ b/flower/data-file.cc @@ -0,0 +1,95 @@ +#include +#include + +#include "data-file.hh" + +void +Data_file::gobble_white() +{ + char c; + + while ((c=data_get()) == ' ' ||c == '\t') + if (eof()) + break; + + data_unget(c); +} + +String +Data_file::get_word() +{// should handle escape seq's + String s; + + while (1) + { + char c = data_get(); + + if (isspace(c) || eof()) + { + data_unget(c); + break; + } + + + if (c == '\"') + { + rawmode= true; + + while ((c = data_get()) != '\"') + if (eof()) + error("EOF in a string"); + else + s += c; + + + rawmode= false; + } + else + s += c; + } + + return s; +} + +/** get a char + Only class member who uses text_file::get + */ +char +Data_file::data_get() { + char c = get(); + if (!rawmode && c == '#') // gobble comment + { + while ((c = get()) != '\n' && !eof()) + ; + return '\n'; + } + + return c; +} + +/// read line, gobble '\n' +String Data_file::get_line() +{ + char c; + String s; + + while ((c = data_get()) != '\n' && !eof()) + s += c; + return s; +} + +/// gobble stuff before first entry on a line. +void +Data_file::gobble_leading_white() +{ + // eat blank lines. + while (!eof()) { + char c = data_get(); + if (!isspace(c)) { + data_unget(c); + break; + } + } +} + + diff --git a/flower/dstream.cc b/flower/dstream.cc new file mode 100644 index 0000000000..05ee3e6958 --- /dev/null +++ b/flower/dstream.cc @@ -0,0 +1,161 @@ + + +#include +#include "assoc.hh" +#include "dstream.hh" +#include "scalar.hh" +#include "text-db.hh" +#include "string-convert.hh" + +/// indent of each level +const INDTAB = 2; + +/* + should use Regexp library. + */ +static String +strip_pretty(String pretty_str) +{ + int i = pretty_str.index_i('('); + if (i>=0) + pretty_str = pretty_str.left_str(i); + + int l = pretty_str.index_last_i(' '); // strip until last ' ' + if (l>=0) + pretty_str = pretty_str.nomid_str(0,l+1); + return pretty_str; +} + +static String +strip_member(String pret) +{ + int l=pret.index_last_i(':')-1; + if (l>=0) + pret = pret.left_str(l ); + return pret; +} + +Dstream& +Dstream::identify_as(String name) +{ + if (!os) + return *this; + + String mem(strip_pretty(name)); + String cl(strip_member(mem)); + String idx = cl; + + if (silent->elt_query(mem)) + idx = mem; + else if (silent->elt_query(cl)) + idx = cl; + else { + (*silent)[idx] = false; + } + local_silence = (*silent)[idx]; + if (classname != idx && !local_silence) { + classname=idx; + if (!(*silent)["Dstream"]) + *os << "[" << classname << ":]"; // messy. + } + return *this; +} + +bool +Dstream::silence(String s) +{ + if (!silent->elt_query(s)) + return false; + return (*silent)[s]; +} + +/** Output a string via the Dstream. This is the only output + interface. It delegates all conversion to String class. */ +Dstream & +Dstream::operator<<(String s) +{ + output(s); + return *this; +} + +Dstream & +Dstream::operator<<(void const *v_l) +{ + output(String_convert::pointer_str(v_l)); + return *this; +} + +Dstream & +Dstream::operator<<(char const *ch_l) +{ + output(ch_l); + return *this; +} + +void +Dstream::output(String s) +{ + if (local_silence|| !os) + return ; + + for (char const *cp = s ; *cp; cp++) + switch(*cp) { + case '{': + case '[': + case '(': indentlvl += INDTAB; + *os << *cp; + break; + + case ')': + case ']': + case '}': + indentlvl -= INDTAB; + *os << *cp ; + + assert (indentlvl>=0) ; + break; + + case '\n': + *os << '\n' << String (' ', indentlvl) << flush; + break; + default: + *os << *cp; + break; + } + return ; +} + + +Dstream::Dstream(ostream *r, char const * cfg_nm ) +{ + os = r; + silent = new Assoc; + indentlvl = 0; + if (!os) + return; + + char const * fn =cfg_nm ? cfg_nm : ".dstreamrc"; + { + ifstream ifs(fn); // can't open + if (!ifs) + return; + } + + Text_db cfg(fn); + while (! cfg.eof()){ + Text_record r( cfg++); + if (r.size() != 2) { + r.message("not enough fields in Dstream init."); + continue; + } + (*silent)[r[0]] = (bool)(int)(Scalar(r[1])); + } + +} + + +Dstream::~Dstream() +{ + delete silent; + assert(!indentlvl) ; +} diff --git a/flower/flower-version.cc b/flower/flower-version.cc new file mode 100644 index 0000000000..fd37845588 --- /dev/null +++ b/flower/flower-version.cc @@ -0,0 +1,16 @@ +#include "version.hh" // urg +#include + +static char *s = "FlowerLib " MAJOR_VERSION "." MINOR_VERSION "." PATCH_LEVEL MY_PATCH_LEVEL " #%d"; + +static const int build= +#include ".build" +; + +char const * +flower_version_sz() +{ + static char v[1024]; + sprintf(v, s, build); + return v; +} diff --git a/flower/include/Makefile b/flower/include/Makefile new file mode 100644 index 0000000000..e783a73603 --- /dev/null +++ b/flower/include/Makefile @@ -0,0 +1,18 @@ +# flower/lib/include/Makefile + +# subdir level: +# +depth = ../.. +# + +# generic stuff/Makefile +# +include ./$(depth)/make/Include.make +include ./$(depth)/flower/.version + +# identify module: +# +MODULE_NAME = flower + +# + diff --git a/flower/include/assoc-iter.hh b/flower/include/assoc-iter.hh new file mode 100644 index 0000000000..34b88df22d --- /dev/null +++ b/flower/include/assoc-iter.hh @@ -0,0 +1,39 @@ +/* + associter.hh -- part of flowerlib + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef ASSOCITER_HH +#define ASSOCITER_HH + +#include "assoc.hh" + +/// an iterator for the #Assoc# class +template +struct Assoc_iter { + int i; + Assoc &assoc_; + /// we don't want to be bothered by const correctness + Assoc_iter(const Assoc &a) : + assoc_((Assoc &)a) + { + i= next(0); + } + int next(int j) { + while (j < assoc_.arr.size() && assoc_.arr[j].free) + j++; + return j; + } + bool ok() const { + return i < assoc_.arr.size(); + } + void OK()const { + assert(!ok() || !assoc_.arr[i].free); + } + void operator++(int) { i++; i = next(i); } + K key() { return assoc_.arr[i].key; } + V &val() { return assoc_.arr[i].val; } +}; + +#endif diff --git a/flower/include/assoc.hh b/flower/include/assoc.hh new file mode 100644 index 0000000000..bf22881d90 --- /dev/null +++ b/flower/include/assoc.hh @@ -0,0 +1,78 @@ +#ifndef ASSOC_HH +#define ASSOC_HH + +#include "varray.hh" +#include + +/** + A helper for Assoc + */ +template +struct Assoc_ent_ { + bool free; + K key; + V val; +}; + + +/** mindblowingly stupid Associative array implementation. + Hungarian: map + */ +template +struct Assoc { + Array< Assoc_ent_ > arr; + + /* ************** */ + + int find(K key) const { + for (int i = 0; i < arr.size(); i++) { + if (!arr[i].free && key == arr[i].key) + return i; + } + return -1; + } + int find_creat(K key) { + int free = -1; + for (int i = 0; i < arr.size(); i++) { + if (key == arr[i].key) { + return i; + } else if (arr[i].free ) { + free = i; + } + } + if (free >= 0){ + arr[free].free = false; + arr[free].key = key; + return free; + } + + Assoc_ent_ ae; + ae.free = false; + ae.key = key; + arr.push(ae); + return arr.size() -1; + } +public: + bool elt_query(K key) const { + return find(key) >= 0; + } + void del(K key) { + assert(elt_query(key)); + int i= find(key); + arr[i].free = true; + } + void + add(K key, V val) { + int i = find_creat(key); + arr[i].val = val; + } + V& operator[](K key) { + return arr[find_creat(key)].val; + } + V const & operator[](K key) const { + assert(elt_query(key)); + return arr[find(key)].val; + } +}; + +#endif diff --git a/flower/include/choleski.hh b/flower/include/choleski.hh new file mode 100644 index 0000000000..f5e9fb4f5a --- /dev/null +++ b/flower/include/choleski.hh @@ -0,0 +1,46 @@ +#ifndef CHOLESKI_HH +#define CHOLESKI_HH + +#include "matrix.hh" + +/** + Choleski decomposition of a matrix + structure for using the LU decomposition of a positive definite matrix. + + #P# is split into + + LD transpose(L) + */ +struct Choleski_decomposition { + + /// lower triangle of Choleski decomposition + Matrix L; + + /// diagonal + Vector D; + + /** Create decomposition of P. + PRE + P needs to be symmetric positive definite + */ + + Choleski_decomposition(Matrix P); + + /** + solve Px = rhs + */ + Vector solve(Vector rhs) const; + + Vector operator * (Vector rhs) const { return solve (rhs); } + /** + return the inverse of the matrix P. + */ + Matrix inverse() const; + /** + return P, calc'ed from L and D + */ + Matrix original() const; + + +}; +#endif diff --git a/flower/include/compare.hh b/flower/include/compare.hh new file mode 100644 index 0000000000..203ba014e7 --- /dev/null +++ b/flower/include/compare.hh @@ -0,0 +1,55 @@ +/* + flowerlib + + (c) 1996 Han-Wen Nienhuys + */ +#ifndef COMPARE_HH +#define COMPARE_HH + +#define one_operator(type, function, op) \ +inline bool \ +operator op (type t1, type t2) {\ + return function(t1, t2) op 0;\ +}\ + +#define gpp_minmax_operator(type, op, opp) \ +inline type \ +operator op(type t1, type t2)\ +{\ + return (t1 opp t2) ? t1 : t2;\ +}\ + + +#if defined (__GNUG__) && ! defined (__STRICT_ANSI__) +#define gpp_minmax(type, prefix)\ + prefix gpp_minmax_operator(type, ?, >) +#else +#define gpp_minmax(type, prefix) +#endif + +/** handy notations for a signed comparison. + make the operators{<,<=,==,>=,>} and the MAX and MIN of two. + Please fill a & in the type argument if necessary. + */ +#define template_instantiate_compare(type, function, prefix) \ +prefix one_operator(type, function, >)\ +prefix one_operator(type, function, >=)\ +prefix one_operator(type, function, ==)\ +prefix one_operator(type, function, !=)\ +prefix one_operator(type, function, <)\ +prefix one_operator(type, function, <=)\ +gpp_minmax(type, prefix)\ +prefix inline type max(type t1, type t2) { return (t1 > t2 )? t1 : t2; }\ +prefix inline type min(type t1, type t2) { return (t1 < t2 )? t1 : t2; }\ + \ +prefix bool operator<(type t1, type t2) /* stupid fix to allow ; */ + + + +#define instantiate_compare(type, func) template_instantiate_compare(type,func, ) + + + +#endif + diff --git a/flower/include/cursor.hh b/flower/include/cursor.hh new file mode 100644 index 0000000000..af2e251a08 --- /dev/null +++ b/flower/include/cursor.hh @@ -0,0 +1,113 @@ +// cursor.hh + +#ifndef __CURSOR_HH +#define __CURSOR_HH + +#include "link.hh" +template class List; + +/** iterator to List. + add and insert extend the list + items are always stored as copies in List, but: + List : copies of String stored + List : copies of String* stored! + + the operations add and insert actually delegate the work to List class. + */ +template +class Cursor +{ + public: + /** create cursor, set at top. The const part isn't true, actually, #list# + surely isn't const, but I get tired of the warning messages. */ + Cursor( const List& list, Link* pointer = 0 ); + + Cursor( const Cursor& cursor ); + + T& thing(); + + /// return current T + T& operator *() { return thing(); } + operator T() { return thing(); } + Cursor operator =( const Cursor& c ); + + /// make cursor with #no# items back + Cursor operator -( int no) const; + + /// make cursor with #no# items further + Cursor operator +( int no) const; + int operator -(Cursor op) const; + Cursor operator -=(int); + Cursor operator +=(int); + + /// return current and move one down + Cursor operator ++( int ); + + /// return current and move one up + Cursor operator --( int ); + + /// point to link? + bool ok(); + + /// ++ items left? + bool forward(); + + /// -- items left? + bool backward(); + + /** put (copy) after me in List. + analogously to editor. ok() interpreted as at end + of line. + + PRE: !ok, POST: added to bottom() + + PRE: ok, POST: added after me + + cursor points to same object, cursor.next() is newly added + object. + */ + void add( T const & thing ); + + /** put (copy) before me in List. + analogously to editor. ok() interpreted as at begin of + line. + + PRE: !ok, POST: add to top() + + PRE: ok, POST: add before me + + cursor points to same object, cursor.previous() + is newly inserted object. + */ + + void insert( T const & thing ); + /// + void backspace(); + + /// + void del(); + + /// access the list this came from + List& list() const ; + Link* pointer(); + static int compare(Cursor a,Cursorb) { return a-b; } +private: + List& list_; + Link* pointer_; +}; + + +/* + comparisons. + */ +#include "compare.hh" + + +template_instantiate_compare(Cursor, Cursor::compare, template); + +#include "pcursor.hh" +#include "list.hh" +#include "cursor.inl" +#include "iterate.hh" + +#endif // CURSOR_HH diff --git a/flower/include/cursor.inl b/flower/include/cursor.inl new file mode 100644 index 0000000000..54d3703e60 --- /dev/null +++ b/flower/include/cursor.inl @@ -0,0 +1,113 @@ + // cursor.inl -*-c++-*- +#ifndef CURSOR_INL +#define CURSOR_INL +#include + + +template +inline +Cursor::Cursor( const List& list, Link* pointer ) : + list_((List&) list ) +{ + if ( list.size() ) + pointer_ = pointer ? pointer : list.top_; + else + pointer_ = pointer; +} + +template +inline +Cursor::Cursor( const Cursor& cursor ) : + list_( cursor.list_ ) +{ + pointer_ = cursor.pointer_; +} + +template +inline T& +Cursor::thing() +{ + assert( pointer_ ); + return pointer_->thing(); +} + +template +Cursor +Cursor::operator =( const Cursor& c ) +{ + assert( &list_ == &c.list_ ); + pointer_ = c.pointer_; + return *this; +} + +template +inline void +Cursor::add( const T& th ) +{ + list_.add( th, *this ); +} + +template +inline void +Cursor::insert( const T& th ) +{ + list_.insert( th, *this ); +} + +template +inline List& +Cursor::list() const +{ + return list_; +} + +template +inline Link* +Cursor::pointer() +{ + return pointer_; +} + +template +inline bool +Cursor::backward() +{ + return ( pointer_ != 0 ); +} + +template +inline bool +Cursor::forward() +{ + return ( pointer_ != 0 ); +} + +template +inline bool +Cursor::ok() +{ + return ( pointer_ != 0 ); +} + + +template +inline Cursor +Cursor::operator ++( int ) +{ + Cursor r (*this); + assert( pointer_ ); + pointer_ = pointer_->next(); + return r; +} + +template +inline Cursor +Cursor::operator --( int ) +{ + Cursor r (*this); + assert( pointer_ ); + pointer_ = pointer_->previous(); + return r; +} + +#endif diff --git a/flower/include/cursor.tcc b/flower/include/cursor.tcc new file mode 100644 index 0000000000..3be73fe5d2 --- /dev/null +++ b/flower/include/cursor.tcc @@ -0,0 +1,109 @@ +#ifndef CURSOR_CC +#define CURSOR_CC + +#include "cursor.hh" +#include + +template + void +Cursor::backspace() +{ + Cursor c(*this); + if ( c.ok() ) + c--; + list_.remove( *this ); +} + +template + void +Cursor::del() +{ + Cursor c(*this); + if ( c.ok() ) + c++; + list_.remove( *this ); + *this = c; +} + + +template +Cursor +Cursor::operator -=( int j ) +{ + while (j--) + (*this)--; + return *this; +} +template +Cursor +Cursor::operator +=( int j ) +{ + while (j++) + (*this)++; + return *this; +} + +template +Cursor +Cursor::operator +( int i ) const +{ + Cursor r = *this; + + if (i<0) + return r -(-i); + + while (i--) + r++; + + return r; +} + +template +Cursor +Cursor::operator -( int i ) const +{ + Cursor r = *this; + if (i<0) + return r +(-i); + + while (i--) + r--; + + return r; +} +/* + warning: can't use Cursor::operator == (Cursor), + since it uses Cursor::operator-(Cursor) + */ +template +int +Cursor::operator-(Cursor rhs) const +{ + assert(rhs.list == list); + int dif = 0; + + // search from *this on further up (positive difference) + Cursor c(*this); + while (c.ok() && c.pointer_ != rhs.pointer_) { + c--; + dif++; + } + + if (c.ok()) + goto gotcha; // so, sue me. + + // search in direction of bottom. (negative diff) + dif =0; + c=*this; + while (c.ok() && c.pointer_ !=rhs.pointer_) { + dif --; + c++; + } + assert(c.ok()); + +gotcha: + assert((*this - dif).pointer_ == c.pointer_); + return dif; +} + +#endif diff --git a/flower/include/data-file.hh b/flower/include/data-file.hh new file mode 100644 index 0000000000..dae9e56347 --- /dev/null +++ b/flower/include/data-file.hh @@ -0,0 +1,59 @@ +/* + data-file.hh -- declare Data_file + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef DATAFILE_HH +#define DATAFILE_HH + +#include "text-stream.hh" + +/// read a data file +class Data_file : private Text_stream +{ + + public: + bool rawmode; + + Text_stream::line; + Text_stream::eof; + Text_stream::get_name; + + char data_get(); + void data_unget(char c) { + unget(c); + } + + /// read line, eat #\n# + String get_line(); + + /// read a word till next space, leave space. Also does quotes + String get_word(); + + /// gobble horizontal white stuff. + void gobble_white(); + + /// gobble empty stuff before first field. + void gobble_leading_white(); + Data_file(String s) : Text_stream(s) { + //*mlog << "(" << s << flush; + rawmode= false; + } + + ~Data_file() { + // *mlog << ")"< +struct Assoc; + +/** debug stream. + a class for providing debug output of nested structures, + with indents according to \{\}()[]. + + One can turn on and off specific messages using the Assoc silent. + This can be done automatically: + + #define DEBUG dstream_.identify_as(__PRETTY_FUNCTION__) + + DEBUG << "a message\n"; + + Init for the class names which should be silent can be given in a rc file. + + */ +class Dstream +{ + ostream *os; + int indentlvl; + bool local_silence; + String classname; + void output(String s); + Assoc *silent; +public: + + bool silence(String); + + /** + if rcfile == 0, then do not read any rc file. + */ + + Dstream(ostream *r, char const * rcfile); + virtual ~Dstream(); + Dstream &identify_as(String s); + + Dstream &operator << (String s); + /** + Output memory locations. + */ + Dstream &operator << (void const *); + Dstream &operator << (char const *); +}; +#endif + diff --git a/flower/include/fproto.hh b/flower/include/fproto.hh new file mode 100644 index 0000000000..c2fc98399c --- /dev/null +++ b/flower/include/fproto.hh @@ -0,0 +1,54 @@ +/* + fproto.hh -- typenames in flowerlib + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef FPROTO_HH +#define FPROTO_HH + + +char const * flower_version_sz(); + +// what the F*** is "int" ? +// depreciate int, long, etc., use i32, i64, remember: linux-16/linux-64 ? +/// (i32) +typedef int i32; +/// (i64) +typedef long long I64; + +template struct Array; +template struct sstack; +template struct Assoc; +template struct List; +template struct PointerList; +template struct IPointerList; +template struct Cursor; +template struct PCursor; +template struct Link; +template struct Handle; +template struct Interval_t; +template struct PQueue; + +#include "real.hh" + +typedef Interval_t Interval; + +struct Choleski_decomposition; + +struct Long_option_init; +struct Getopt_long; +struct Matrix; +struct String_data; +struct String_handle; +struct String_convert; +struct String; +struct virtual_smat; +struct Vector ; +struct Text_stream; +struct Data_file; +struct Text_db; +struct Scalar; +typedef unsigned char Byte; +#endif // FPROTO_HH + diff --git a/flower/include/handle.hh b/flower/include/handle.hh new file mode 100644 index 0000000000..26328bd26b --- /dev/null +++ b/flower/include/handle.hh @@ -0,0 +1,58 @@ +#ifndef HANDLE_HH +#define HANDLE_HH + +/// reference counting handle +template +class Handle { + T *obj; + int *refs; + + /// let go of ref. Delete if necessary + void down() { + if (!(*refs--)) { + delete obj; + delete refs; + } + obj = 0; + refs = 0; + } + /// point to new object. + void up(T *t, int *r) { + if (!r) { + refs = new int; + *refs = 1; + } else { + refs =r; + *refs++; + } + obj = t; + } + /// POST: *refs == 1 + void copy() { + if(*refs != 1){ + T * newobj = new T(*obj ); + down(); + up(newobj); + } + } + Handle(Handle const &src) { + up(src.obj, src.refs); + } + Handle(T & o) { + up (&o); + } + void operator=(Handle const& src) { + if (this == &src) + return; + down(); + up(src.o, src.refs); + } + operator T const &() { + return *obj; + } + operator T&() { + copy(); + return *obj; + } +} +#endif diff --git a/flower/include/interval.hh b/flower/include/interval.hh new file mode 100644 index 0000000000..aae16381db --- /dev/null +++ b/flower/include/interval.hh @@ -0,0 +1,125 @@ +/* + interval.hh -- part of flowerlib + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef INTERVAL_HH +#define INTERVAL_HH + +#include +#include "fproto.hh" +#include "real.hh" + + +/** a T interval. + this represents the closed interval [left,right]. + No invariants. T must be a totally ordered ring + */ +template +struct Interval_t { + T left, right; + + /* ************** */ + + T center() { return (left + right) / T(2);} + void translate(T t) { + left += t; + right += t; + } + T& idx(int j) { + if (j==-1) + return left; + else if (j==1) + return right; + else + assert(false); + return left; + } + T& operator[](int j) { + return idx(j); + } + T operator[](int j) const { + return ((Interval_t *)this)->idx(j); + } + T &max() { return right;} + T max()const { return right;} + T min()const{ return left; } + T &min(){ return left; } + /** + PRE + *this and h are comparable + */ + void unite(Interval_t h); + void intersect(Interval_t h); + + T length() const; + void set_empty() ; + bool empty() const { return left > right; } + Interval_t() { + set_empty(); + } + Interval_t(T m, T M) { + left =m; + right = M; + } + Interval_t &operator += (T r) { + left += r; + right +=r; + return *this; + } + String str() const; + bool elt_q(T r); +}; + + +/** + inclusion ordering. Crash if not comparable. + */ +template +int Interval__compare(const Interval_t&,Interval_t const&); + +/* + INLINE + */ + +#include "compare.hh" + +template_instantiate_compare(Interval_t&, Interval__compare, template); + + +template +inline Interval_t +intersection(Interval_t a, Interval_t const&b) +{ + a.intersect(b); + return a; + +} + + +template +inline +Interval_t operator +(T a,Interval_t i ) +{ + i += a; + return i; +} + +template +inline +Interval_t operator +(Interval_t i,T a ){ + return a+i; +} + +typedef Interval_t Interval; + + +#define Interval__instantiate(T) template struct Interval_t;\ + template int Interval__compare(const Interval_t&,Interval_t const&) + + +#endif // INTERVAL_HH + + + diff --git a/flower/include/interval.tcc b/flower/include/interval.tcc new file mode 100644 index 0000000000..6e7b0b1279 --- /dev/null +++ b/flower/include/interval.tcc @@ -0,0 +1,106 @@ +#include +#include +#include "interval.hh" +#include "string.hh" + + +template +int +_Interval__compare(const Interval_t&a,Interval_t const&b) +{ + if (a.left == b.left && a.right == b.right) + return 0; + + if (a.left <= b.left && a.right >= b.right) + return 1; + + if (a.left >= b.left && a.right <= b.right) + return -1; + + return -2; +} + + +template +int +Interval__compare(const Interval_t&a,Interval_t const&b) +{ + int i = _Interval__compare(a,b); + if (i < -1) + assert(false); + return i; +} + +#ifdef AIX +const Real INFTY = 1e8; // ARGh. AIX sucks +#else +const Real INFTY = HUGE_VAL; +#endif + +template +void +Interval_t::set_empty() +{ + left = INFTY; + right = -INFTY; +} + +template +T +Interval_t::length() const { + assert(right >= left); + return right-left; +} + +template +void +Interval_t::unite(Interval_t h) +{ + if (h.leftright) + right = h.right; +} + +/** + smallest Interval which includes *this and #h# + */ + +template +void +Interval_t::intersect(Interval_t h) +{ +#if defined (__GNUG__) && ! defined (__STRICT_ANSI__) + left = h.left >? left; + right = h.right +Interval_t +intersect(Interval_t x, Interval_t const &y) +{ + x.intersect(y); + return x; +} + +template +String +Interval_t::str() const +{ + if (empty()) + return "[empty]"; + String s("["); + + return s + left + "," + right +"]"; +} + +template +bool +Interval_t::elt_q(T r) +{ + return r >= left && r <= right; +} diff --git a/flower/include/iterate.hh b/flower/include/iterate.hh new file mode 100644 index 0000000000..1e924f0790 --- /dev/null +++ b/flower/include/iterate.hh @@ -0,0 +1,22 @@ +/* + iterate.hh -- define some list macros + + source file of the flowerlib + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef ITERATE_HH +#define ITERATE_HH + + + +#define iterator(set) typeof((set).top()) +#define iterator_bot(set) typeof((set).bottom()) + +// should use top() +#define iter_top(set,var) iterator(set) var(set) +#define iter_bot(set,var) iterator(set) var(set.bottom()) + +#endif // ITERATE_HH diff --git a/flower/include/lgetopt.hh b/flower/include/lgetopt.hh new file mode 100644 index 0000000000..22f45d2adb --- /dev/null +++ b/flower/include/lgetopt.hh @@ -0,0 +1,94 @@ +#ifndef LGETOPT_HH +#define LGETOPT_HH + +#include + + +class ostream; + +/** + a struct this for initialising the commandline options. + */ +struct Long_option_init { + bool take_arg; + char const * longname; + char shortname; + + ostream &printon(ostream &errorout); +}; + + +/** C++ for version of long_getopt. For processing GNU style command + line arguments. No pointer (return values, arguments) contents are + copied. */ +class Getopt_long { +public: + /** errorcodes: no error, argument expected, no argument expected, + unknown option, illegal argument (eg. int expected). */ + enum Errorcod { E_NOERROR = 0, E_ARGEXPECT, E_NOARGEXPECT, E_UNKNOWNOPTION, + E_ILLEGALARG } ; + + +private: + + /// the option info. + Long_option_init *the_opts; + int table_len; + + /// if doing short option, argv[optind][optindind] is processed next. + int optindind; + + /// the option found + Long_option_init *beet; + + /// get ready for processing next error. + bool next(); + Long_option_init *parselong(); + Long_option_init *parseshort(); + + ostream *errorout; + + /// report an error and abort + void report(Errorcod c); +public: + + /// argument. Set to 0 if not present + char* optarg; + + /// current error status + Errorcod error; + + /// return an integer (with err. detect) + long intarg(); + /// argv[optind] will be processed next. + int optind; + + /// the arguments + char **argv; + + /// the arg. count + int argc; + + /* *************** */ + + /** + What to do with errors. + report messages on #*os#, and abort. + if #os# is null, then do not report nor abort, just set #error# + */ + + void seterror(ostream *os); + + /// construct: pass arguments and option info. + Getopt_long(int c, char **v, Long_option_init *lo); + + /** get the next option. + @return pointer to next option found. + 0 if error occurred, or next argument is no option. + */ + Long_option_init *operator()(); + + char *current_arg(); + char * get_next_arg(); +}; +#endif diff --git a/flower/include/libc-extension.hh b/flower/include/libc-extension.hh new file mode 100644 index 0000000000..96f3df00e1 --- /dev/null +++ b/flower/include/libc-extension.hh @@ -0,0 +1,33 @@ +/* + libc-extension.hh -- declare some string.h extensions + + source file of the flowerlib + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef LIBC_EXTENSION_HH +#define LIBC_EXTENSION_HH +#include "fproto.hh" +#include "config.hh" + +char* strnlwr( char* start_l ,int n); +char* strnupr( char* start_l, int n); + +#if !HAVE_MEMMEM // GNU extension. +char *memmem(Byte const * haystack, int haystack_len, + Byte const *needle, int needle_len); +#endif HAVE_MEMMEM + +#if !HAVE_SNPRINTF // GNU extension. +int snprintf (char *str, size_t n, + char const *format, ... ); +#endif + + +Byte *memrchr(Byte const * p, int n, char c); +Byte *strrev( Byte* byte_l, int length_i ); + + +#endif // LIBC_EXTENSION_HH diff --git a/flower/include/link.hh b/flower/include/link.hh new file mode 100644 index 0000000000..22fcec4e71 --- /dev/null +++ b/flower/include/link.hh @@ -0,0 +1,38 @@ +// link.hh + +#ifndef __LINK_HH +#define __LINK_HH +template +class List; + + +/// class for List +template +class Link +{ +// friend class Cursor; +public: + Link( T const & thing ); + + Link* previous(); + Link* next(); + + /// put new Link item after me in list + void add( T const & thing ); + /// put new Link item before me in list + void insert( T const & thing ); + void remove(List &l); + + T& thing(); + void OK() const; +private: + Link( Link* previous, Link* next, T const & thing ); + + T thing_; + Link* previous_; + Link* next_; +}; + +#include "link.inl" + +#endif // __LINK_HH // diff --git a/flower/include/link.inl b/flower/include/link.inl new file mode 100644 index 0000000000..3926d6bc2a --- /dev/null +++ b/flower/include/link.inl @@ -0,0 +1,102 @@ +// link.inl -*-c++-*- +#ifndef LINK_INL +#define LINK_INL +#include +template +inline +void +Link::OK() const +{ +#ifndef NDEBUG + if (previous_) { + assert(previous_->next_ == this); + } + if (next_) { + assert(next_->previous_ == this); + } +#endif +} + +template +inline +Link::Link( const T& thing ) : + thing_( thing ) +{ + previous_ = next_ = 0; +} + +template +inline +Link::Link( Link* previous, Link* next, const T& thing ) : + thing_( thing ) +{ + previous_ = previous; + next_ = next; +} + +template +inline +Link* +Link::next() +{ + return next_; +} + +template +inline +Link* +Link::previous() +{ + return previous_; +} + +template +inline +void +Link::add( const T& thing ) +{ + + Link* l = new Link( this, next_, thing ); + if ( next_ ) + next_->previous_ = l; + next_ = l; +} + +template +inline void +Link::insert( const T& thing ) +{ + // Link* l = new Link( next_, this, thing ); + // bugfix hwn 16/9/96 + Link* l = new Link( previous_, this, thing ); + if ( previous_ ) + previous_->next_ = l; + previous_ = l; +} + +/* + don't forget to adjust #l#'s top_ and bottom_. + */ +template +inline void +Link::remove(List &l) +{ + if ( previous_ ) + previous_->next_ = next_; + else + l.top_ = next_; + + if ( next_ ) + next_->previous_ = previous_; + else + l.bottom_ = previous_; +} + +template +inline +T& +Link::thing() +{ + return thing_; +} +#endif diff --git a/flower/include/list.hh b/flower/include/list.hh new file mode 100644 index 0000000000..fbb79e6edf --- /dev/null +++ b/flower/include/list.hh @@ -0,0 +1,98 @@ +#ifndef __LIST_HH +#define __LIST_HH + +class ostream; +template class Cursor; +template class Link; + +/** all-purpose doubly linked list. + + List can be seen as all items written down on paper, + from top to bottom + + class Cursor is used to extend List + + items are always stored as copies in List, but: + #List# : copies of #String# stored + #List# : copies of #String*# stored! + (do not use, use \Ref{PointerList} ## instead.) + + {\bf note:} + retrieving "invalid" cursors, i.e. + #top()/bottom()# from empty list, #find()# without success, + results in a nonvalid Cursor ( #!ok()# ) + + + INVARIANTEN! +*/ + +template +class List +{ + public: + List(List const&src); + + /// construct empty list + List(); + virtual ~List(); + + int size() const; + + Cursor bottom() const; // const sucks. + Cursor top() const; + + void OK() const; // check list + + protected: + friend class Cursor; + friend class Link; + + void concatenate(List const &s); + + /** make *this empty. + + POST: + size == 0 + + WARNING: + contents lost, and not deleted. + */ + void set_empty(); + + void add( T const & thing, Cursor &after_me ); + + /// put thing before #before_me# + void insert( T const & thing, Cursor &before_me ); + + /** Remove link pointed to by me. Destructor of contents called + (nop for pointers) + + POST + none; + + + WARNING: do not use #me# after calling + */ + void remove( Cursor me ); + + + /* ************** */ + + int size_; + Link* top_; + Link* bottom_; +}; + +#include "list.inl" +#include "cursor.hh" + +// instantiate a template: explicit instantiation. +#define L_instantiate(a) template class List; template class Cursor; \ + template class Link + + +#endif // __LIST_HH // + + + + diff --git a/flower/include/list.inl b/flower/include/list.inl new file mode 100644 index 0000000000..df0687b7c8 --- /dev/null +++ b/flower/include/list.inl @@ -0,0 +1,56 @@ +// -*-c++-*- + +#ifndef LIST_INL +#define LIST_INL + +template +inline +List::List() +{ + set_empty(); +} + +template +inline void +List::set_empty() +{ + top_ = bottom_ = 0; + size_ = 0; +} + +template +inline void +List::remove( Cursor me ) +{ + if ( me.ok() ){ + Link *lp = me.pointer(); + lp->remove(*this); + delete lp; + size_--; + } +} + +template +inline int +List::size() const +{ + return size_; +} + +template +inline Cursor +List::top()const +{ + return Cursor( *this, top_ ); +} + + +template +inline Cursor +List::bottom()const +{ + return Cursor( *this, bottom_ ); +} + + +#endif diff --git a/flower/include/list.tcc b/flower/include/list.tcc new file mode 100644 index 0000000000..bd3a16b0c6 --- /dev/null +++ b/flower/include/list.tcc @@ -0,0 +1,112 @@ +#ifndef LIST_CC +#define LIST_CC + +#include "list.hh" + +template +List::List(List const&src) +{ + set_empty(); + // probably el stupido + for (Cursor c(src); c.ok(); c++) + bottom().add(c); +} + +template +void +List::OK() const +{ + int i = size_; + Link *lp = top_; + while (i--) { + assert(lp); + lp->OK(); + lp = lp->next(); + } + assert(!lp); + i = size_; + lp = bottom_; + while (i--) { + assert(lp); + lp->OK(); + lp = lp->previous(); + } + assert(!lp); +} + + +template +List::~List() +{ + Cursor c(*this); + while (c.ok()) + c.del(); +} + +/** + + add after after_me. + + Procedure: + \begin{itemize} + \item if #after_me# is #ok()#, add after #after_me#, else + \item if list !empty simply add to bottom, else + \item list is empty: create first \Ref{Link} and initialize + #bottom_# and #top_#. + \end{itemize} +*/ +template +void +List::add( T const & thing, Cursor &after_me ) +{ + if (!size_) { // not much choice if list is empty + bottom_ = top_ = new Link( thing ); + if (!after_me.ok()) + after_me = bottom(); + } else { // add at aprioprate place + if (!after_me.ok()) + after_me = bottom(); + Link *p =after_me.pointer(); + p->add(thing); + if (p == bottom_) // adjust bottom_ if necessary. + bottom_ = p->next(); + } + + size_++; +} + +template +void +List::insert( T const & thing, Cursor &before_me ) +{ + if (!size_) { + bottom_ = top_ = new Link( thing ); + if (!before_me.ok()) + before_me = top(); + + } else { + if (!before_me.ok()) + before_me = top(); + + Link *p = before_me.pointer() ; + + p->insert(thing); + if (p == top_) + top_ = p->previous(); + } + + size_++; +} + + +template +void +List::concatenate(List const&s) +{ + Cursor b(bottom()); + for (Cursor c(s); c.ok(); c++) { + b.add(c); + b++; + } +} +#endif diff --git a/flower/include/matrix.hh b/flower/include/matrix.hh new file mode 100644 index 0000000000..e4f447041b --- /dev/null +++ b/flower/include/matrix.hh @@ -0,0 +1,135 @@ +#ifndef MATRIX_HH +#define MATRIX_HH + + +#include "vsmat.hh" +#include "vector.hh" + +/** a Real matrix. This is a class for a nonsquare block of #Real#s. The + implementation of sparse matrices is done in the appropriate #smat# + class. Matrix only does the mathematical actions (adding, + multiplying, etc.) + + + TODO + implement ref counting? */ + + +class Matrix { + virtual_smat *dat; + +public: + void OK() const { dat->OK(); } + int cols() const { return dat->cols(); } + int rows() const { return dat->rows(); } + + /** return the size of a matrix. + PRE + the matrix needs to be square. + */ + int dim() const; + + // Matrix() { dat = 0; } + ~Matrix() { delete dat; } + + /// set entries to r + void fill(Real r); + + /// set diagonal to d + void set_diag(Real d); + + void set_diag(Vector d); + /// set unit matrix + void unit() { set_diag(1.0); } + + void operator+=(Matrix const &m); + void operator-=(Matrix const &m); + void operator*=(Real a); + void operator/=(Real a) { (*this) *= 1/a; } + + /** add a row. + add a row to the matrix before row k + + PRE + v.dim() == cols() + 0 <= k <= rows() + */ + void insert_row(Vector v,int k); + /** . + delete a row from this matrix. + + PRE + 0 <= k < rows(); + */ + void delete_row(int k) { dat->delete_row(k); } + void delete_column(int k) { dat->delete_column(k); } + + /** + square n matrix, initialised to null + */ + Matrix(int n); + + /** + n x m matrix, init to 0 + */ + Matrix(int n, int m); + Matrix(Matrix const &m); + + /// dyadic product: v * w.transpose + Matrix(Vector v, Vector w); + void operator=(Matrix const &m); + + /// access an element + Real operator()(int i,int j) const { return dat->elem(i,j); } + + /// access an element + Real &operator()(int i, int j) { return dat->elem(i,j); } + + /// Matrix multiply with vec (from right) + Vector operator *(Vector const &v) const; + + /// set this to m1*m2. + void set_product(Matrix const &m1, Matrix const &m2); + + + Vector left_multiply(Vector const &) const; + + Matrix operator-() const; + + /// transpose this. + void transpose(); + + /// return a transposed copy. + Matrix transposed() const ; + + Real norm() const; + /** swap. + PRE + 0 <= c1,c2 < cols() + */ + void swap_columns(int c1, int c2); + + /** swap. + PRE + 0 <= c1,c2 < rows() + */ + void swap_rows(int c1, int c2); + + + Vector row(int ) const; + Vector col(int) const; + + operator String() const; + void print() const; +}; + +inline Vector +operator *(Vector &v, Matrix const & m) { return m.left_multiply(v); } +Matrix operator *(Matrix const & m1,Matrix const &m2); +Matrix operator /(Matrix const &m1,Real a); +inline Matrix operator -(Matrix m1,const Matrix m2) +{ + m1 -= m2; + return m1; +} +#endif diff --git a/flower/include/path.hh b/flower/include/path.hh new file mode 100644 index 0000000000..bc4d9f3776 --- /dev/null +++ b/flower/include/path.hh @@ -0,0 +1,32 @@ +#ifndef PATH_HH +#define PATH_HH +#include "string.hh" +#include "varray.hh" + + +/** searching directory for file. + + Abstraction of PATH variable. An interface for searching input files. + Search a number of dirs for a file. + + Should use kpathsea? + +*/ + +class File_path : private Array +{ +public: + /// locate a file in the search path + String find(String nm); + + /// construct using prefix. Normally argv[0]. + File_path(String); + + /// add to end of path. + Array::push; + void add(String str) { push(str); } +}; +/// split path into its components +void split_path(String path, String &drive, String &dirs, String &filebase, String &extension); + +#endif diff --git a/flower/include/pcursor.tcc b/flower/include/pcursor.tcc new file mode 100644 index 0000000000..ffb01bcfe8 --- /dev/null +++ b/flower/include/pcursor.tcc @@ -0,0 +1,16 @@ +#include "pcursor.hh" + +template +void +PCursor::junk() +{ +#if !defined(NDEBUG) && defined(PARANOID) + list().OK(); +#endif + + delete ptr(); +#if !defined(NDEBUG)&&defined(PARANOID) + thing() = 0; + list().OK(); +#endif +} diff --git a/flower/include/plist.tcc b/flower/include/plist.tcc new file mode 100644 index 0000000000..ac9daedf71 --- /dev/null +++ b/flower/include/plist.tcc @@ -0,0 +1,21 @@ +#include "plist.hh" + +template +IPointerList::~IPointerList() +{ + PCursor c( *this ); + while (c.ok()) { + delete c.remove_p(); + } +} + +template +PCursor +PointerList::find(T what ) const +{ + PCursor i(*this); + for (; i.ok(); i++) + if (i.ptr() == what) + break; + return i; +} diff --git a/flower/include/pqueue.hh b/flower/include/pqueue.hh new file mode 100644 index 0000000000..c8dfe1bea6 --- /dev/null +++ b/flower/include/pqueue.hh @@ -0,0 +1,72 @@ +/* + pqueue.hh -- declare + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef PQUEUE_HH +#define PQUEUE_HH + +#include "varray.hh" + +/** + Stupid Prioq. Should use Lists and STL. + Smallest is put at the front. + +Actually, this sux. Should use a template struct PQuee_ent + */ + +template +struct PQueue +{ + Array value_arr_; + Array indices_arr_; + void OK() const + { + + assert(value_arr_.size() == indices_arr_.size()); + } + + void enter(V v, I idx) { + int j=0; + for (; j < value_arr_.size(); j++) + if (indices_arr_[j] > idx) + break; + + insert(j,v,idx); + + } + int size() { return value_arr_.size(); } + V front_val() { return value_arr_[0]; } + I front_idx() { return indices_arr_[0]; } + void del(int i) + { + value_arr_.del(i); + indices_arr_.del(i); + } + int size() const + { + OK(); + return value_arr_.size(); + } + + + void insert(int j, V v, I idx) + { + value_arr_.insert(v, j); + indices_arr_.insert(idx, j); + } + + + + V get() { + V retval = front_val(); + del(0); + return retval; + } + +}; +#endif // PQUEUE_HH diff --git a/flower/include/rational.hh b/flower/include/rational.hh new file mode 100644 index 0000000000..30fa2cb6d6 --- /dev/null +++ b/flower/include/rational.hh @@ -0,0 +1 @@ +#include diff --git a/flower/include/real.hh b/flower/include/real.hh new file mode 100644 index 0000000000..0533af2111 --- /dev/null +++ b/flower/include/real.hh @@ -0,0 +1,16 @@ +#ifndef REAL_HH +#define REAL_HH + + +#include +#include +#include + +typedef double Real; + +inline Real +distance(Real x,Real y) +{ + return abs(x-y); +} +#endif diff --git a/flower/include/scalar.hh b/flower/include/scalar.hh new file mode 100644 index 0000000000..08897ce50c --- /dev/null +++ b/flower/include/scalar.hh @@ -0,0 +1,34 @@ +/* + scalar.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef SCALAR_HH +#define SCALAR_HH +#include "string.hh" +#include "real.hh" + +/// Perl -like scalar type. +struct Scalar : public String { + + Scalar(Real r) : String(r) {} + Scalar(int i) : String(i) {} + Scalar(char c) : String(c) {} + Scalar(char const *c) : String(c) {} + Scalar(String s ):String(s) {} + Scalar(Rational ); + operator Rational(); + Scalar() {} + bool isnum(); + operator Real(); + operator int(); + + /** perl -like string to bool conversion. + */ + operator bool() const; + +}; + +#endif // SCALAR_HH + diff --git a/flower/include/smat.hh b/flower/include/smat.hh new file mode 100644 index 0000000000..05bdac464b --- /dev/null +++ b/flower/include/smat.hh @@ -0,0 +1,93 @@ +#ifndef SMAT_HH +#define SMAT_HH +#include "varray.hh" +#include "vsmat.hh" +#include "real.hh" +/// simplest matrix storage. refer to its baseclass for the doco. +class Full_storage : public virtual_smat +{ + /// height, width + int h,w; + /// maxima. + int maxh, maxw; + + /// the storage + Real** els; + void + init() { + els=0; + h=w=maxh=maxw=0; + + } + + bool valid(int i, int j) const { + return (i>=0 && i < h) + && (j < w && j >=0); + } + + + void resize_rows(int); + void resize_cols(int); + +public: + virtual int rows() const { + return h; + } + virtual int cols() const { + return w; + } + + + virtual void set_size(int i, int j) + { + resize(i,j); //this could be more efficient. + } + + virtual void set_size(int i) { + set_size(i,i); + } + virtual void resize(int i, int j); + virtual void resize(int i) { + resize(i,i); + } + + virtual Real& elem(int i,int j) { + assert(valid(i,j)); + return els[i][j]; + } + virtual Real const & elem(int i, int j) const { + assert(valid(i,j)); + return els[i][j]; + } + virtual Array row(int i) const; + virtual Array column(int j) const; + + Full_storage() { + init(); + } + Full_storage(int i, int j) { + init(); + set_size(i,j); + } + Full_storage(Full_storage&); + Full_storage(int i) { + init(); + set_size(i); + } + void OK() const; + void operator=(Full_storage const &); + + virtual void insert_row(int k); + virtual void delete_row(int k); + virtual void delete_column(int k); + + + ~Full_storage(); + virtual bool mult_ok(int i, int j)const; + virtual void mult_next(int &i, int &j) const ; + virtual bool trans_ok(int i, int j) const; + virtual void trans_next(int &i, int &j) const; + virtual virtual_smat * clone(); +}; + +#endif diff --git a/flower/include/string-convert.hh b/flower/include/string-convert.hh new file mode 100644 index 0000000000..9eb9869653 --- /dev/null +++ b/flower/include/string-convert.hh @@ -0,0 +1,45 @@ +/* + PROJECT: FlowerSoft C++ library + FILE : string-convert.hh + +*/ + +#ifndef STRING_CONVERT_HH +#define STRING_CONVERT_HH + +/* + ///a class which only has functions. +//#define functor class // cute. docxx fucks up +*/ + +/** + The functor String_convert handles all conversions to/from String (some + time, anyway). + The class is quite empty from data view. + */ +class String_convert { + static int hex2bin_i( String hex_str, String& bin_str_r ); + static int hex2nibble_i( Byte byte ); + static Byte nibble2hex_byte( Byte byte ); +public: + static String bin2dec_str( String bin_str ); + static String bin2hex_str( String bin_str ); + static String dec2bin_str( String str ); + static int bin2_i( String str ); + static String char_str(char c, int n); + static int dec2_i( String dec_str ); + static double dec2_f( String dec_str ); + static String double_str(double f, char const* fmt=0); + static int hex2_i( String str ); + static unsigned hex2_u( String str ); + static String hex2bin_str( String str ); + static String int_str(int i, char const *fmt=0 ); + static String i2hex_str( int i, int length_i, char ch ); + static String u2hex_str( unsigned u, int length_i, char ch ); + static String i2dec_str( int i, int length_i, char ch ); + static String rational_str(Rational); + static String pointer_str(void const *); + static String i64_str(I64, char const * fmt = 0); +}; + +#endif // __STRING_CONVERT_HH // diff --git a/flower/include/string-data.hh b/flower/include/string-data.hh new file mode 100644 index 0000000000..ecd7159074 --- /dev/null +++ b/flower/include/string-data.hh @@ -0,0 +1,95 @@ +/* + string-data.hh -- declare String_data + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef STRINGDATA_HH +#define STRINGDATA_HH + + +/**Internal String struct. + the data itself. Handles simple tasks (resizing, resetting) + */ +class String_data { + // GNU malloc: storage overhead is 8 bytes anyway. + +friend class String_handle; + int maxlen; // maxlen is arraysize-1 + + int length_i_; + Byte* data_byte_p_; + int references; + + /// init to "" + String_data(); + + /// init from src. Conservative allocation. + String_data(String_data const &src); + + ~String_data(); + + /** POST: maxlen >= j. + @param j, maximum stringlength_i_. + contents thrown away. + */ + void setmax(int j); + + /** POST: maxlen >= j. + @param j, maximum stringlength_i_. + contents are kept if it grows. + */ + void remax(int j); + + /// check if writeable. + void OKW(); + + /// check state. + void OK(); + + /// reduce memory usage. + void tighten(); + + // assignment. + void set( Byte const* byte_c_l, int length_i ); + + void set( char const* ch_c_l ); + + /// concatenation. + void append( Byte const* byte_c_l, int length_i ); + + void operator += ( char const* ch_c_l ); + + char const* ch_c_l() const; + + char* ch_l(); + + Byte const* byte_c_l() const; + + // idem, non const + Byte* byte_l(); + + void trunc(int j); + + /** access element. not really safe. Can alter length_i_ without + #String_data# knowing it. */ + Byte &operator [](int j); + Byte operator [](int j) const; + bool is_binary_bo()const; +}; + + + +#ifdef STRING_UTILS_INLINED +#ifndef INLINE +#define INLINE inline +#endif +#include "string-data.inl" + +#endif + + +#endif // STRING_DATA_HH diff --git a/flower/include/string-data.inl b/flower/include/string-data.inl new file mode 100644 index 0000000000..d2b925d0ce --- /dev/null +++ b/flower/include/string-data.inl @@ -0,0 +1,210 @@ +/* -*-C++-*- + String_data.inl -- implement String_data + + source file of Flower lib + + (c) 1997 Han-Wen Nienhuys +*/ + +#ifndef STRINGDATA_INL +#define STRINGDATA_INL + +#include +#include + +#include "string-data.hh" +const int INITIALMAX=8; + +#include + +INLINE void +String_data::OKW() +{ + assert (references == 1); +} + +INLINE void +String_data::OK() +{ + assert(maxlen >= length_i_); + assert(bool(data_byte_p_)); + assert(references >= 1); +} + + +INLINE +String_data::String_data() +{ + references=0; + maxlen = INITIALMAX; + data_byte_p_ = new Byte[maxlen + 1]; + data_byte_p_[0] = 0; + length_i_ = 0; +} + +INLINE +String_data::String_data(String_data const &src) +{ + references=0; + maxlen = length_i_ = src.length_i_; + data_byte_p_ = new Byte[maxlen+1]; // should calc GNU 8byte overhead. + memcpy( data_byte_p_, src.data_byte_p_, length_i_ + 1 ); +} + +INLINE +String_data::~String_data() +{ + assert(references == 0); + delete[] data_byte_p_; +} + +INLINE void +String_data::setmax(int j) +{ + OKW(); + if (j > maxlen) { + delete data_byte_p_; + maxlen = j; + data_byte_p_ = new Byte[maxlen + 1]; + + data_byte_p_[0] = 0; + length_i_ = 0; + } +} + +/* this is all quite hairy: + update of length_i_ + update of maxlen + alloc of buffer + copying of buffer + needs blondification: + split tasks + define change authority +*/ +INLINE void +String_data::remax(int j) +{ + OKW(); + if (j > maxlen) { + Byte *p = new Byte[j + 1]; + memcpy( p, data_byte_p_, ( maxlen = 0 && j <= length_i_); + data_byte_p_[j] = 0; + length_i_ = j; +} + +INLINE bool +String_data::is_binary_bo()const +{ +// return !memchr(data_byte_p_, length_i_, 0); + return ( (int)strlen( (char const*)data_byte_p_ ) != length_i_ ); +} + +INLINE Byte& +String_data::operator [](int j) +{ + assert(j >= 0 && j <= length_i_); + return data_byte_p_[j] ; +} + +INLINE Byte +String_data::operator [](int j) const +{ + assert(j >= 0 && j <= length_i_); + return data_byte_p_[j]; +} + + + + +#endif // __STRING_UTIL_CC // diff --git a/flower/include/string-handle.hh b/flower/include/string-handle.hh new file mode 100644 index 0000000000..5b7a12f648 --- /dev/null +++ b/flower/include/string-handle.hh @@ -0,0 +1,70 @@ +/* + string-handle.hh -- declare String_handle + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef STRINGHANDLE_HH +#define STRINGHANDLE_HH +#include "fproto.hh" + + +/** + Reference counting for strings. + + handles ref. counting, and provides a very thin interface using + Byte * + + */ +class String_handle { + String_data* data; + + /// decrease ref count. Named kind of like a Tanenbaum semafore + void down(); + + /// increase ref count + void up(String_data *d); + + /** make sure data has only one reference. + POST: data->references == 1 + */ + void copy(); + +public: + String_handle(); + ~String_handle(); + String_handle(String_handle const & src); + + Byte const* byte_c_l() const; + char const* ch_c_l() const; + Byte* byte_l(); + char* ch_l(); + bool is_binary_bo()const; + void operator =(String_handle const &src); + void operator += (char const *s); + Byte operator[](int j) const; + + /** Access elements. WARNING: NOT SAFE + don't use this for loops. Use byte_c_l() + */ + Byte &operator[](int j); + void append( Byte const* byte_c_l, int length_i ); + void set( Byte const* byte_c_l, int length_i ); + void operator = (char const *p); + void trunc(int j); + int length_i() const; +}; + +#ifdef STRING_UTILS_INLINED +#ifndef INLINE +#define INLINE inline +#endif +#include "string-handle.inl" +/* we should be resetting INLINE. oh well. */ +#endif + + +#endif // STRINGHANDLE_HH diff --git a/flower/include/string-handle.inl b/flower/include/string-handle.inl new file mode 100644 index 0000000000..1f1d44ab13 --- /dev/null +++ b/flower/include/string-handle.inl @@ -0,0 +1,156 @@ +/* -*-c++-*- + + stringhandle.inl -- implement String_handle + + source file of Flower lib + + (c) 1997 Han-Wen Nienhuys +*/ + +#ifndef STRINGHANDLE_INL +#define STRINGHANDLE_INL + +#include +#include + +#include "string-data.hh" +#include "string-handle.hh" + +INLINE void +String_handle::down() +{ + if (!(--data->references)) delete data; data = 0; +} + +/// increase ref count +INLINE void +String_handle::up(String_data *d) +{ + data=d; data->references ++; +} + +INLINE void +String_handle::copy() +{ + if (data->references !=1){ + String_data *newdata = new String_data(*data); + down(); + up(newdata); + } +} + +INLINE +String_handle::String_handle() +{ + up(new String_data); +} + +INLINE +String_handle::~String_handle() +{ + down(); +} + +INLINE +String_handle::String_handle(String_handle const & src) +{ + up(src.data); +} + +INLINE Byte* +String_handle::byte_l() +{ + copy(); + return data->byte_l(); +} + +INLINE char* +String_handle::ch_l() +{ + copy(); + return (char*)data->byte_l(); +} + +INLINE Byte +const* String_handle::byte_c_l() const +{ + return data->byte_c_l(); +} + +INLINE char const* +String_handle::ch_c_l() const +{ + return (char const*)data->byte_c_l(); +} + +INLINE void +String_handle::operator =(String_handle const &src) +{ + if (this == &src) + return; + down(); + up(src.data); +} + +INLINE void +String_handle::operator += (char const *s) +{ + copy(); + *data += s; +} + + +INLINE Byte +String_handle::operator[](int j) const +{ + return (*data)[j]; +} + +// !NOT SAFE! +// don't use this for loops. Use byte_c_l() +INLINE Byte & +String_handle::operator[](int j) +{ + copy(); // hmm. Not efficient + return data->byte_l()[j]; +} + +INLINE void +String_handle::append( Byte const* byte_c_l, int length_i ) +{ + copy(); + data->append( byte_c_l, length_i ); +} + +INLINE void +String_handle::set( Byte const* byte_c_l, int length_i ) +{ + copy(); + data->set( byte_c_l, length_i ); +} + +INLINE void +String_handle::operator = (char const *p) +{ + copy(); + data->set( p ); +} + +INLINE void +String_handle::trunc(int j) +{ + copy(); data->trunc(j); +} + +INLINE int +String_handle::length_i() const +{ + return data->length_i_; +} + +INLINE bool +String_handle::is_binary_bo() const { + return data->is_binary_bo(); +} + +#endif diff --git a/flower/include/string.hh b/flower/include/string.hh new file mode 100644 index 0000000000..8270e01e08 --- /dev/null +++ b/flower/include/string.hh @@ -0,0 +1,193 @@ +/* + + FILE : string.hh -- declare String + + Rehacked by HWN 3/nov/95 + removed String & 's + introduced Class String_handle + */ + +#ifndef STRING_HH +#define STRING_HH + + +#include +#include +#include + +#include "string-handle.hh" + +/** + + Intuitive string class. provides +\begin{itemize} +\item + ref counting through #String_handle# +\item + conversion from bool, int, double, char* , char. +\item + to be moved to String_convert: + conversion to int, upcase, downcase + +\item + printable. + +\item + indexing (index_i, index_any_i, last_index_i) + +\item + cutting (left_str, right_str, mid_str) + +\item + concat (+=, +) + +\item + signed comparison (<, >, ==, etc) + +\item + No operator[] is provided, since this would be enormously slow. If needed, + convert to char const* . +\end{itemize} + +*/ +class String +{ +protected: + String_handle strh_; + + bool null_terminated(); + +public: + + /** init to empty string. This is needed because other + constructors are provided.*/ + String() { } + String(Rational); + + /// String s = "abc"; + String( char const* source ); + String( Byte const* byte_c_l, int length_i ); + + /// "ccccc" + String( char c, int n = 1 ); + + String( int i , char const *fmt=0); + String ( double f , char const* fmt =0); + /// 'true' or 'false' + String(bool ); + + /// return a "new"-ed copy of contents + Byte* copy_byte_p() const; // return a "new"-ed copy of contents + + char const* ch_c_l() const; + Byte const* byte_c_l() const; + char* ch_l(); + Byte* byte_l(); + + /// deprecated; use ch_c_l() + operator char const* () const { return ch_c_l(); } + + String &operator =( String const & source ); + + /// concatenate s + void operator += (char const* s) { strh_ += s; } + void operator += (String s); + + void append(String); + void prepend(String); + + char operator []( int n ) const { return strh_[n]; } + + /// return n leftmost chars + String left_str( int n ) const; + + /// return n rightmost chars + String right_str( int n ) const; + + /// return uppercase of *this + String upper_str() const; + + /// return lowercase of *this + String lower_str() const; + + /// return the "esrever" of *this + String reversed_str() const; + + + /// return a piece starting at index_i (first char = index_i 0), length n + String mid_str(int index_i, int n ) const; + + /// cut out a middle piece, return remainder + String nomid_str(int index_i, int n ) const; + + /// signed comparison, analogous to memcmp; + static int compare_i(String const & s1,const String& s2); + + /// index of rightmost c + int index_last_i( char c) const; + + /// index of rightmost element of string + int index_last_i( char const* string ) const; + + int index_i(char c ) const; + int index_i(String ) const; + int index_any_i(String ) const; + + void to_upper(); + void to_lower(); + /// provide Stream output + void print_on(ostream& os) const; + + /// the length of the string + int length_i() const; + + // ***** depreciated + int len() const { + return length_i(); + } + + /// convert to an integer + int value_i() const; + + /// convert to a double + double value_f() const; +}; + +#include "compare.hh" + +instantiate_compare(String const &, String::compare_i); + +// because char const* also has an operator ==, this is for safety: +inline bool operator==(String s1, char const* s2){ + return s1 == String(s2); +} +inline bool operator==(char const* s1, String s2) +{ + return String(s1)==s2; +} +inline bool operator!=(String s1, char const* s2 ) { + return s1!=String(s2); +} +inline bool operator!=(char const* s1,String s2) { + return String(s2) !=s1; +} + + +inline String +operator + (String s1, String s2) +{ + s1 += s2; + return s1; +} + +inline ostream & +operator << ( ostream& os, String d ) +{ + d.print_on(os); + return os; +} + + +// String quoteString(String message, String quote); + +#endif diff --git a/flower/include/text-db.hh b/flower/include/text-db.hh new file mode 100644 index 0000000000..3535a84f8f --- /dev/null +++ b/flower/include/text-db.hh @@ -0,0 +1,55 @@ +#ifndef TEXTDB_HH +#define TEXTDB_HH + +#include "data-file.hh" + +/**a "const" Array. Contents can't be changed. do "#" comments, read quote enclosed fields */ + +class Text_record : Array +{ + int line_no; + String filename; + +public: + Text_record() { } // needed because of other ctor + + /// report an error in this line. + message(String s) { + cerr << '\n'<< filename << ": "<< line_no << s << "\n"; + } + String operator[](int j) { + return Array::operator[](j); + } + + Text_record(Array s, String fn, int j) : Array(s) { + filename = fn; line_no = j; + } + Array::size; +}; + +/** abstraction for a datafile. + add a subrec/fieldsep/record separator + */ + +class Text_db : private Data_file +{ + void gobble_leading_white(); +public: + /// get a line with records + Text_record get_record(); + + Text_db(String fn):Data_file(fn) { } + Data_file::error; + bool eof(); + + /// get next line. + Text_record operator++(int) { + return get_record(); + } + /// are we done yet? + operator bool() { + return !eof(); + } +}; + +#endif diff --git a/flower/include/text-stream.hh b/flower/include/text-stream.hh new file mode 100644 index 0000000000..437f8698c7 --- /dev/null +++ b/flower/include/text-stream.hh @@ -0,0 +1,74 @@ + +#ifndef TEXTSTR_HH +#define TEXTSTR_HH + +#include +#include +#include "string.hh" +#include "varray.hh" + +/** + line counting input stream. + a stream for textfiles. linecounting. Thin interface getchar and + ungetchar. (ungetc is unlimited) + + should protect get and unget against improper use +*/ + + +class Text_stream +{ + int line_no; + + // could just have used streams. + FILE *f; + Array pushback; + String name; + + public: + Text_stream(String fn); + String get_name() { return name; } + bool eof() { + return feof(f); + } + bool eol() { + return (peek() == '\n'); + } + char peek() { + char c = get(); + unget(c); + return c; + } + int line(){ + return line_no; + } + + char get() { + char c; + + if (pushback.empty()) + c = getc(f); + else + c = pushback.pop(); + + if (c =='\n') + line_no++; + return c; + } + void unget(char c) { + if (c =='\n') + line_no--; + pushback.push(c); + } + ~Text_stream (){ + if (!eof()) + cerr <<__FUNCTION__<< ": closing unended file"; + + fclose(f); + } + + /// GNU format message. + void message(String s); +}; + +#endif diff --git a/flower/include/unionfind.hh b/flower/include/unionfind.hh new file mode 100644 index 0000000000..fbaa51e731 --- /dev/null +++ b/flower/include/unionfind.hh @@ -0,0 +1,25 @@ +#ifndef UNIONFIND_HH +#define UNIONFIND_HH +#include "varray.hh" + +/* + which points of a graph are connected?. + Union find, a standard algorithm: + + Union_find represents an undirected graph of N points. You can + connect two points using #connect()#. #find(i)# finds a uniquely + determined representant of the equivalence class of points + connected to #i#. + + */ +struct Union_find { + void connect(int i, int j); + int find(int i); + bool equiv(int i, int j) { return find(i) == find(j); } + Union_find(int sz); + +private: + Array classes; + +}; +#endif diff --git a/flower/include/varray.hh b/flower/include/varray.hh new file mode 100644 index 0000000000..b7400bb501 --- /dev/null +++ b/flower/include/varray.hh @@ -0,0 +1,186 @@ +/* + (c) Han-Wen Nienhuys 1995,96 + + Distributed under GNU GPL +*/ + +#ifndef ARRAY_H +#define ARRAY_H +#include + +/// copy a bare (C-)array from #src# to #dest# sized #count# +template +inline void arrcpy(T*dest, T*src, int count) { + for (int i=0; i < count ; i++) + *dest++ = *src++; +} + + +/** + Scaleable array/stack template, for a type T with default constructor. + + + This template implements a scaleable vector. With (or without) range + checking. It may be flaky for objects with complicated con- and + destructors. The type T should have a default constructor. It is + best suited for simple types, such as int, double or String, it + provides a paranoidly safe replacement for the new T[int] construct. + + It uses stack terminology, (push, pop, top), and can be used as a stack. + + + */ +template +class Array { +protected: + /// maximum length of array. + int max; + + /// the data itself + T *thearray; + + /// stretch or shrink array. + void remax(int newmax) { + T* newarr = new T[newmax]; + size_ = (newmax < size_) ? newmax : size_; + arrcpy(newarr, thearray, size_); + + delete[] thearray; + thearray = newarr; + max = newmax; + } + int size_; + +public: + /// check invariants + void OK() const { + assert(max >= size_ && size_ >=0); + if (max) assert(thearray); + } + /** report the size_. + @see {setsize_} + */ + int size() const { return size_; } + + /// POST: size() == 0 + void clear() { size_ = 0; } + + Array() { thearray = 0; max =0; size_ =0; } + + + /** set the size_ to #s#. + POST: size() == s. + Warning: contents are unspecified */ + void set_size(int s) { + if (s >= max) remax(s); + size_ = s; + } + + ~Array() { delete[] thearray; } + + /// return a "new"ed copy of array + T* copy_array() const { + T* Tarray = new T[size_]; + arrcpy(Tarray, thearray, size_); + return Tarray; + } + // depracated + operator T* () const { + return copy_array(); + } + void operator=(Array const & src) { + set_size (src.size_); + arrcpy(thearray,src.thearray, size_); + } + Array(Array const & src) { + thearray = src.copy_array(); + max = size_ = src.size_; + } + + /// tighten array size_. + void precompute () { remax(size_); } + + /// this makes Array behave like an array + T &operator[] (const int i) const { + assert(i >=0&&i=0 && j<= size_); + set_size(size_+1); + for (int i=size_-1; i > j; i--) + thearray[i] = thearray[i-1]; + thearray[j] = k; + } + void del(int i) { + assert(i >=0&& i < size_); + arrcpy(thearray+i, thearray+i+1, size_-i-1); + size_--; + } + // quicksort. + void sort (int (*compare)( T const&,T const&), + int lower = -1, int upper = -1 ) { + if (lower < 0) { + lower = 0 ; + upper = size()-1; + } + if (lower >= upper) + return; + swap(lower, (lower+upper)/2); + int last = lower; + for (int i= lower +1; i <= upper; i++) + if (compare(thearray[i], thearray[lower]) < 0 ) + swap( ++last,i); + swap(lower, last); + sort(compare, lower, last-1); + sort(compare, last+1, upper); + } + void concat(Array const &src) { + int s = size_; + set_size(size_ + src.size_); + arrcpy(thearray+s,src.thearray, src.size_); + } + Array subvec(int lower, int upper) { + assert(lower >= 0 && lower <=upper&& upper <= size_); + Array r; + int s =upper-lower; + r.set_size(s); + arrcpy(r.thearray, thearray + lower, s); + return r; + } +}; + +#endif diff --git a/flower/include/vector.hh b/flower/include/vector.hh new file mode 100644 index 0000000000..323d03db88 --- /dev/null +++ b/flower/include/vector.hh @@ -0,0 +1,111 @@ +#ifndef VECTOR_HH +#define VECTOR_HH + +#include +#include "real.hh" +#include "varray.hh" + +class Dstream; +class String; +void set_matrix_debug(Dstream&ds); + +/** a row of numbers. + a vector. Storage is handled in Array, Vector only does the mathematics. + */ +class Vector { + Array dat; +public: + void OK() const { dat.OK();} + int dim() const { return dat.size(); } + Vector() { } + Vector(Array d ); + Vector(Vector const &n); + Vector(int n) { + dat.set_size(n); + fill(0); + } + void insert(Real v, int i) { + dat.insert(v,i); + } + void del(int i) { dat.del(i); } + operator String() const; + void fill(Real r) { + for (int i=0; i < dim(); i++) + dat[i] =r; + } + + void operator +=(Vector v) { + assert(v.dim() == dim()); + for (int i=0; i < dim(); i++) + dat[i] += v.dat[i]; + } + + void operator /=(Real a) { + (*this) *= 1/a; + } + + void operator *=(Real a) { + for (int i=0; i < dim(); i++) + dat[i] *= a; + } + + void operator -=(Vector v) { + assert(v.dim() == dim()); + for (int i=0; i < dim(); i++) + dat[i] -= v(i); + } + + Real &operator()(int i) { return dat[i]; } + Real operator()(int i) const { return dat[i]; } + Real elem(int i) { return dat[i]; } + Real operator *(Vector v) const { + Real ip=0; + assert(v.dim() == dim()); + for (int i=0; i < dim(); i++) + ip += dat[i] *v(i); + return ip; + } + Vector operator-() const; + Real norm() { + return sqrt(norm_sq() ); + } + Real norm_sq() { + return ((*this) * (*this)); + } + operator Array () { return dat; } + void print() const; + /// set to j-th element of unit-base + void set_unit(int j) ; +}; + +inline Vector +operator+(Vector a, Vector const &b) { + a += b; + return a; +} + +inline Vector +operator-(Vector a, Vector const &b) { + a -= b; + return a; +} + +inline Vector +operator*(Vector v, Real a) { + v *= a; + return v; +} + +inline Vector +operator*( Real a,Vector v) { + v *= a; + return v; +} + +inline Vector +operator/(Vector v,Real a) { + v *= 1/a; + return v; +} + +#endif diff --git a/flower/include/vsmat.hh b/flower/include/vsmat.hh new file mode 100644 index 0000000000..b9dcdadecb --- /dev/null +++ b/flower/include/vsmat.hh @@ -0,0 +1,141 @@ +#ifndef VSMAT_HH +#define VSMAT_HH +#include "varray.hh" +#include "real.hh" +/** base class for interface with matrix storageclasses. There are no + iterators for matrixclasses, since matrices are (like arrays) + explicitly int-indexed. + + Iteration is provided by *_next, *_ok, which update and check both + index variables simultaneously. + + TODO + determine type of product matrix. + +*/ +class virtual_smat { + + +public: + /// check invariants + virtual void OK() const=0; + + /// height of matrix + virtual int rows() const = 0; + + /// width of matrix + virtual int cols() const = 0; + + + /** set the size. contents lost. + PRE + i >=0, j>=0 + */ + virtual void set_size(int i, int j) = 0; + + /**set the size to square dimen. contents lost + PRE + i>=0 + */ + virtual void set_size(int i) = 0; + /**set the size to i. + + keep contents. If enlarged contents unspecified + + PRE + i>=0, j>=0 + + */ + virtual void resize(int i, int j) = 0; + + /** + set the size to square dimen. contents kept + Keep contents. If enlarged contents are unspecified + + PRE + i>=0 + */ + virtual void resize(int i) = 0; + + + /** + access an element. + + Generate an errormessage, if this happens + in the 0-part of a sparse matrix. + */ + + virtual Real& elem(int i,int j) = 0; + + /// access a element, no modify + virtual Real const & elem(int i, int j) const = 0; + +#if 1 + virtual Array row(int i) const = 0; + virtual Array column(int j) const = 0; +#endif + + + /** + add a row to the matrix before row k. Contents + of added row are unspecified + + 0 <= k <= rows() + */ + virtual void insert_row(int k)=0; + + + /** + delete a row from this matrix. + + PRE + 0 <= k < rows(); + */ + virtual void delete_row(int k)=0; + virtual void delete_column(int k)=0; + virtual ~virtual_smat() { } + virtual virtual_smat *clone()=0; + + + + /** + at end of matrix?. when doing loop + + for(i=0; i + */ +#include +#include +#include +#include "lgetopt.hh" + +long +Getopt_long::intarg() +{ + long l; + if (sscanf(optarg, "%ld", &l) != 1) + report(E_ILLEGALARG); + + return l; +} + +Long_option_init * +Getopt_long::parselong() +{ + char const *optnm = argv[optind] + 2 ; + assert(*optnm); + + char *endopt = strchr(optnm, '='); + int searchlen = (endopt) ? endopt - optnm : strlen(optnm); + + beet=0; + for (int i=0; i< table_len; i++) { + char const *ln = the_opts[i].longname; + + if (ln && !strncmp(ln, optnm, searchlen)) { + beet = the_opts+i; + break; + } + } + + if (!beet) { + report(E_UNKNOWNOPTION); + return 0; + } + optind++; + optindind = 0; + + + if (beet->take_arg) { + if (endopt) + optarg = endopt +1; // a '=' + else { + optarg = argv[optind]; + optind++; + } + if (!optarg) + report(E_ARGEXPECT); + + } else { + optarg = 0; + if (endopt) + report(E_NOARGEXPECT); + } + + return beet; +} + + +ostream & +Long_option_init::printon(ostream &errorout) +{ + if (shortname) + errorout <<"-" << shortname; + if (shortname && longname) + errorout << ", "; + if (longname) + errorout << "`--" << longname << "'"; + return errorout; +} + +// report an error, GNU style. +void +Getopt_long::report(Errorcod c) +{ + error = c; + if (!errorout) + return; + + *errorout << argv[0] << ": "; + switch (c) { + case E_ARGEXPECT: + *errorout<< "option "; + beet->printon(*errorout); + *errorout << "requires an argument"<longname << "' does not allow an argument"<printon(*errorout); + *errorout << '\n'; + default: + assert(false); + } + exit(2); +} + +Long_option_init * +Getopt_long::parseshort() +{ + char c=argv[optind][optindind]; + beet=0; + assert(c); + + for (int i=0; i < table_len; i++) + if (the_opts[i].shortname == c) { + beet = the_opts+i; + break; + } + + if (!beet){ + report(E_UNKNOWNOPTION); + return 0; + } + + optindind++; + if (!beet->take_arg){ + optarg = 0; + return beet; + } + optarg = argv[optind] + optindind; + + optind ++; + optindind = 0; + + if (!optarg[0]) { + optarg = argv[optind]; + optind ++; + } + if (!optarg) { + report(E_ARGEXPECT); + } + + return beet; +} + +Long_option_init * +Getopt_long::operator()() { + if (!next()) + return 0; + + if (optindind) + return parseshort(); + + if (argv[optind][0] != '-') + return 0; + + if (argv[optind][1] == '-') {// what to do with "command -- bla" + return parselong(); + } else { + optindind = 1; + return parseshort(); + } +} + +Getopt_long::Getopt_long(int c, char **v, Long_option_init *lo) +{ + the_opts = lo; + errorout = &cerr; + argv = v; + argc = c; + optind = 1; + optindind = 0; + + // reached end of option table? + int i; + for (i = 0; the_opts[i].longname ||the_opts[i].shortname; i++) + ; + table_len = i; +} + +bool +Getopt_long::next() +{ + + error = E_NOERROR; + while (optind < argc && !argv[optind][optindind]) { + optind++; + optindind = 0; + } + return (optind < argc); +} + +char * +Getopt_long::current_arg() +{ + if (optind >= argc) + return 0; + char * a = argv[optind]; + return a + optindind; +} + +char * +Getopt_long::get_next_arg() +{ + char * a = current_arg(); + if ( a) { + optind ++; + optindind = 0; + } + return a; +} diff --git a/flower/lib/Makefile b/flower/lib/Makefile deleted file mode 100644 index 0c1d299dca..0000000000 --- a/flower/lib/Makefile +++ /dev/null @@ -1,97 +0,0 @@ -# -# project LilyPond -- the musical typesetter -# title makefile for micro-lily-lib -# file lib/Makefile -# -# Copyright (c) 1997 by -# Jan Nieuwenhuizen -# Han-Wen Nienhuys -# - -# subdir level: -# -depth = ../.. -# - -# generic variables: -# -include ./$(depth)/make/Variables.make -# - -# identify module: -# -NAME = flower -MODULE_NAME = flower -include ./$(depth)/flower/.version -build = ./$(depth)/flower/$(outdir)/.build -# - -# descent order into subdirectories: -# -SUBDIRS = include -# - -# to be remade each build: -# -VERSION_DEPENDENCY =# -# - -# list of c++ header files: -# -HHFILES = $(shell ls *.hh $(ERROR_LOG)) -# - -# list of c++ source files: -# -CCFILES = $(shell ls *.cc $(ERROR_LOG)) -# - -# list of other source files: -# -EXTRA_SOURCE_FILES = $(shell ls *.y *.l $(ERROR_LOG)) -# - -# list of distribution files: -# -DISTFILES = Makefile $(HHFILES) $(CCFILES) $(EXTRA_SOURCE_FILES) -# - -# list of custom libraries: -# -# yes, i know about the -L and -l options, -# but these libraries get rebuild when needed. -CUSTOMLIBES = \ - -LOADLIBES += -# - -# main target of this module: -# -# MAINTARGET = $(EXECUTABLE) -# MAINTARGET = $(LIBRARY) -# MAINTARGET = $(bindir)/$(EXECUTABLE)# huh? -MAINTARGET = $(libdir)/$(LIBRARY)# huh? - -default: $(MAINTARGET) -# - -# # sic. -# $(include-flower)/flower-config.hh: -# touch $@ - -# generic targets and rules: -# -include ./$(depth)/make/Targets.make -include ./$(depth)/make/Rules.make -# - -# list of depend files: -# -DEPFILES = $(shell ls $(depdir)/*.dep $(ERROR_LOG)) -# - -# auto dependencies: -# --include /dev/null $(DEPFILES) -# - diff --git a/flower/lib/choleski.cc b/flower/lib/choleski.cc deleted file mode 100644 index 1d64f949ac..0000000000 --- a/flower/lib/choleski.cc +++ /dev/null @@ -1,91 +0,0 @@ -#include "choleski.hh" -const Real EPS = 1e-7; // so sue me. Hard coded - -Vector -Choleski_decomposition::solve(Vector rhs)const -{ - int n= rhs.dim(); - assert(n == L.dim()); - Vector y(n); - - // forward substitution - for (int i=0; i < n; i++) { - Real sum(0.0); - for (int j=0; j < i; j++) - sum += y(j) * L(i,j); - y(i) = (rhs(i) - sum)/L(i,i); - } - for (int i=0; i < n; i++) - y(i) /= D(i); - - // backward subst - Vector &x(rhs); // using input as return val. - for (int i=n-1; i >= 0; i--) { - Real sum(0.0); - for (int j=i+1; j < n; j++) - sum += L(j,i)*x(j); - x(i) = (y(i) - sum)/L(i,i); - } - return x; -} - -/* - Standard matrix algorithm. - */ - -Choleski_decomposition::Choleski_decomposition(Matrix P) - : L(P.dim()), D(P.dim()) -{ - int n = P.dim(); - assert((P-P.transposed()).norm()/P.norm() < EPS); - - L.unit(); - for (int k= 0; k < n; k++) { - for (int j = 0; j < k; j++){ - Real sum(0.0); - for (int l=0; l < j; l++) - sum += L(k,l)*L(j,l)*D(l); - L(k,j) = (P(k,j) - sum)/D(j); - } - Real sum=0.0; - - for (int l=0; l < k; l++) - sum += sqr(L(k,l))*D(l); - Real d = P(k,k) - sum; - D(k) = d; - } - -#ifdef NDEBUG - assert((original()-P).norm() / P.norm() < EPS); -#endif -} - -Matrix -Choleski_decomposition::original() const -{ - Matrix T(L.dim()); - T.set_diag(D); - return L*T*L.transposed(); -} - -Matrix -Choleski_decomposition::inverse() const -{ - int n=L.dim(); - Matrix invm(n); - Vector e_i(n); - for (int i = 0; i < n; i++) { - e_i.set_unit(i); - Vector inv(solve(e_i)); - for (int j = 0 ; j -#include - -#include "data-file.hh" - -void -Data_file::gobble_white() -{ - char c; - - while ((c=data_get()) == ' ' ||c == '\t') - if (eof()) - break; - - data_unget(c); -} - -String -Data_file::get_word() -{// should handle escape seq's - String s; - - while (1) - { - char c = data_get(); - - if (isspace(c) || eof()) - { - data_unget(c); - break; - } - - - if (c == '\"') - { - rawmode= true; - - while ((c = data_get()) != '\"') - if (eof()) - error("EOF in a string"); - else - s += c; - - - rawmode= false; - } - else - s += c; - } - - return s; -} - -/** get a char - Only class member who uses text_file::get - */ -char -Data_file::data_get() { - char c = get(); - if (!rawmode && c == '#') // gobble comment - { - while ((c = get()) != '\n' && !eof()) - ; - return '\n'; - } - - return c; -} - -/// read line, gobble '\n' -String Data_file::get_line() -{ - char c; - String s; - - while ((c = data_get()) != '\n' && !eof()) - s += c; - return s; -} - -/// gobble stuff before first entry on a line. -void -Data_file::gobble_leading_white() -{ - // eat blank lines. - while (!eof()) { - char c = data_get(); - if (!isspace(c)) { - data_unget(c); - break; - } - } -} - - diff --git a/flower/lib/dstream.cc b/flower/lib/dstream.cc deleted file mode 100644 index 1197dd79e7..0000000000 --- a/flower/lib/dstream.cc +++ /dev/null @@ -1,161 +0,0 @@ - - -#include -#include "assoc.hh" -#include "dstream.hh" -#include "scalar.hh" -#include "text-db.hh" -#include "string-convert.hh" - -/// indent of each level -const INDTAB = 2; - -/* - should use Regexp library. - */ -static String -strip_pretty(String pretty_str) -{ - int i = pretty_str.index_i('('); - if (i>=0) - pretty_str = pretty_str.left_str(i); - - int l = pretty_str.index_last_i(' '); // strip until last ' ' - if (l>=0) - pretty_str = pretty_str.nomid_str(0,l+1); - return pretty_str; -} - -static String -strip_member(String pret) -{ - int l=pret.index_last_i(':')-1; - if (l>=0) - pret = pret.left_str(l ); - return pret; -} - -Dstream& -Dstream::identify_as(String name) -{ - if (!os) - return *this; - - String mem(strip_pretty(name)); - String cl(strip_member(mem)); - String idx = cl; - - if (silent->elt_query(mem)) - idx = mem; - else if (silent->elt_query(cl)) - idx = cl; - else { - (*silent)[idx] = false; - } - local_silence = (*silent)[idx]; - if (classname != idx && !local_silence) { - classname=idx; - if (!(*silent)["Dstream"]) - *os << "[" << classname << ":]"; // messy. - } - return *this; -} - -bool -Dstream::silence(String s) -{ - if (!silent->elt_query(s)) - return false; - return (*silent)[s]; -} - -/** Output a string via the Dstream. This is the only output - interface. It delegates all conversion to String class. */ -Dstream & -Dstream::operator<<(String s) -{ - output(s); - return *this; -} - -Dstream & -Dstream::operator<<(const void *v_l) -{ - output(String_convert::pointer_str(v_l)); - return *this; -} - -Dstream & -Dstream::operator<<(const char *ch_l) -{ - output(ch_l); - return *this; -} - -void -Dstream::output(String s) -{ - if (local_silence|| !os) - return ; - - for (const char *cp = s ; *cp; cp++) - switch(*cp) { - case '{': - case '[': - case '(': indentlvl += INDTAB; - *os << *cp; - break; - - case ')': - case ']': - case '}': - indentlvl -= INDTAB; - *os << *cp ; - - assert (indentlvl>=0) ; - break; - - case '\n': - *os << '\n' << String (' ', indentlvl) << flush; - break; - default: - *os << *cp; - break; - } - return ; -} - - -Dstream::Dstream(ostream *r, const char * cfg_nm ) -{ - os = r; - silent = new Assoc; - indentlvl = 0; - if (!os) - return; - - const char * fn =cfg_nm ? cfg_nm : ".dstreamrc"; - { - ifstream ifs(fn); // can't open - if (!ifs) - return; - } - - Text_db cfg(fn); - while (! cfg.eof()){ - Text_record r( cfg++); - if (r.size() != 2) { - r.message("not enough fields in Dstream init."); - continue; - } - (*silent)[r[0]] = (bool)(int)(Scalar(r[1])); - } - -} - - -Dstream::~Dstream() -{ - delete silent; - assert(!indentlvl) ; -} diff --git a/flower/lib/flower-version.cc b/flower/lib/flower-version.cc deleted file mode 100644 index 83a69c0cef..0000000000 --- a/flower/lib/flower-version.cc +++ /dev/null @@ -1,16 +0,0 @@ -#include "../out/version.hh" // urg -#include - -static char *s = "FlowerLib " MAJOR_VERSION "." MINOR_VERSION "." PATCH_LEVEL MY_PATCH_LEVEL " #%d"; - -static const int build= -#include "../out/.build" -; - -const char * -flower_version_sz() -{ - static char v[1024]; - sprintf(v, s, build); - return v; -} diff --git a/flower/lib/include/Makefile b/flower/lib/include/Makefile deleted file mode 100644 index 1a7272a1d8..0000000000 --- a/flower/lib/include/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# flower/lib/include/Makefile - -# subdir level: -# -depth = ../../.. -# - -# generic stuff/Makefile -# -include ./$(depth)/make/Include.make -# - -# identify module: -# -MODULE_NAME = flower -include ./$(depth)/flower/.version -build = ./$(depth)/flower/$(outdir)/.build -# - diff --git a/flower/lib/include/assoc-iter.hh b/flower/lib/include/assoc-iter.hh deleted file mode 100644 index 34b88df22d..0000000000 --- a/flower/lib/include/assoc-iter.hh +++ /dev/null @@ -1,39 +0,0 @@ -/* - associter.hh -- part of flowerlib - - (c) 1996 Han-Wen Nienhuys -*/ - -#ifndef ASSOCITER_HH -#define ASSOCITER_HH - -#include "assoc.hh" - -/// an iterator for the #Assoc# class -template -struct Assoc_iter { - int i; - Assoc &assoc_; - /// we don't want to be bothered by const correctness - Assoc_iter(const Assoc &a) : - assoc_((Assoc &)a) - { - i= next(0); - } - int next(int j) { - while (j < assoc_.arr.size() && assoc_.arr[j].free) - j++; - return j; - } - bool ok() const { - return i < assoc_.arr.size(); - } - void OK()const { - assert(!ok() || !assoc_.arr[i].free); - } - void operator++(int) { i++; i = next(i); } - K key() { return assoc_.arr[i].key; } - V &val() { return assoc_.arr[i].val; } -}; - -#endif diff --git a/flower/lib/include/assoc.hh b/flower/lib/include/assoc.hh deleted file mode 100644 index 99e20914b7..0000000000 --- a/flower/lib/include/assoc.hh +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef ASSOC_HH -#define ASSOC_HH - -#include "varray.hh" -#include - -/** - A helper for Assoc - */ -template -struct Assoc_ent_ { - bool free; - K key; - V val; -}; - - -/** mindblowingly stupid Associative array implementation. - Hungarian: map - */ -template -struct Assoc { - Array< Assoc_ent_ > arr; - - /* ************** */ - - int find(K key) const { - for (int i = 0; i < arr.size(); i++) { - if (!arr[i].free && key == arr[i].key) - return i; - } - return -1; - } - int find_creat(K key) { - int free = -1; - for (int i = 0; i < arr.size(); i++) { - if (key == arr[i].key) { - return i; - } else if (arr[i].free ) { - free = i; - } - } - if (free >= 0){ - arr[free].free = false; - arr[free].key = key; - return free; - } - - Assoc_ent_ ae; - ae.free = false; - ae.key = key; - arr.push(ae); - return arr.size() -1; - } -public: - bool elt_query(K key) const { - return find(key) >= 0; - } - void del(K key) { - assert(elt_query(key)); - int i= find(key); - arr[i].free = true; - } - void - add(K key, V val) { - int i = find_creat(key); - arr[i].val = val; - } - V& operator[](K key) { - return arr[find_creat(key)].val; - } - const V& operator[](K key) const { - assert(elt_query(key)); - return arr[find(key)].val; - } -}; - -#endif diff --git a/flower/lib/include/choleski.hh b/flower/lib/include/choleski.hh deleted file mode 100644 index f5e9fb4f5a..0000000000 --- a/flower/lib/include/choleski.hh +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef CHOLESKI_HH -#define CHOLESKI_HH - -#include "matrix.hh" - -/** - Choleski decomposition of a matrix - structure for using the LU decomposition of a positive definite matrix. - - #P# is split into - - LD transpose(L) - */ -struct Choleski_decomposition { - - /// lower triangle of Choleski decomposition - Matrix L; - - /// diagonal - Vector D; - - /** Create decomposition of P. - PRE - P needs to be symmetric positive definite - */ - - Choleski_decomposition(Matrix P); - - /** - solve Px = rhs - */ - Vector solve(Vector rhs) const; - - Vector operator * (Vector rhs) const { return solve (rhs); } - /** - return the inverse of the matrix P. - */ - Matrix inverse() const; - /** - return P, calc'ed from L and D - */ - Matrix original() const; - - -}; -#endif diff --git a/flower/lib/include/compare.hh b/flower/lib/include/compare.hh deleted file mode 100644 index 203ba014e7..0000000000 --- a/flower/lib/include/compare.hh +++ /dev/null @@ -1,55 +0,0 @@ -/* - flowerlib - - (c) 1996 Han-Wen Nienhuys - */ -#ifndef COMPARE_HH -#define COMPARE_HH - -#define one_operator(type, function, op) \ -inline bool \ -operator op (type t1, type t2) {\ - return function(t1, t2) op 0;\ -}\ - -#define gpp_minmax_operator(type, op, opp) \ -inline type \ -operator op(type t1, type t2)\ -{\ - return (t1 opp t2) ? t1 : t2;\ -}\ - - -#if defined (__GNUG__) && ! defined (__STRICT_ANSI__) -#define gpp_minmax(type, prefix)\ - prefix gpp_minmax_operator(type, ?, >) -#else -#define gpp_minmax(type, prefix) -#endif - -/** handy notations for a signed comparison. - make the operators{<,<=,==,>=,>} and the MAX and MIN of two. - Please fill a & in the type argument if necessary. - */ -#define template_instantiate_compare(type, function, prefix) \ -prefix one_operator(type, function, >)\ -prefix one_operator(type, function, >=)\ -prefix one_operator(type, function, ==)\ -prefix one_operator(type, function, !=)\ -prefix one_operator(type, function, <)\ -prefix one_operator(type, function, <=)\ -gpp_minmax(type, prefix)\ -prefix inline type max(type t1, type t2) { return (t1 > t2 )? t1 : t2; }\ -prefix inline type min(type t1, type t2) { return (t1 < t2 )? t1 : t2; }\ - \ -prefix bool operator<(type t1, type t2) /* stupid fix to allow ; */ - - - -#define instantiate_compare(type, func) template_instantiate_compare(type,func, ) - - - -#endif - diff --git a/flower/lib/include/cursor.hh b/flower/lib/include/cursor.hh deleted file mode 100644 index 0ea99037f9..0000000000 --- a/flower/lib/include/cursor.hh +++ /dev/null @@ -1,113 +0,0 @@ -// cursor.hh - -#ifndef __CURSOR_HH -#define __CURSOR_HH - -#include "link.hh" -template class List; - -/** iterator to List. - add and insert extend the list - items are always stored as copies in List, but: - List : copies of String stored - List : copies of String* stored! - - the operations add and insert actually delegate the work to List class. - */ -template -class Cursor -{ - public: - /** create cursor, set at top. The const part isn't true, actually, #list# - surely isn't const, but I get tired of the warning messages. */ - Cursor( const List& list, Link* pointer = 0 ); - - Cursor( const Cursor& cursor ); - - T& thing(); - - /// return current T - T& operator *() { return thing(); } - operator T() { return thing(); } - Cursor operator =( const Cursor& c ); - - /// make cursor with #no# items back - Cursor operator -( int no) const; - - /// make cursor with #no# items further - Cursor operator +( int no) const; - int operator -(Cursor op) const; - Cursor operator -=(int); - Cursor operator +=(int); - - /// return current and move one down - Cursor operator ++( int ); - - /// return current and move one up - Cursor operator --( int ); - - /// point to link? - bool ok(); - - /// ++ items left? - bool forward(); - - /// -- items left? - bool backward(); - - /** put (copy) after me in List. - analogously to editor. ok() interpreted as at end - of line. - - PRE: !ok, POST: added to bottom() - - PRE: ok, POST: added after me - - cursor points to same object, cursor.next() is newly added - object. - */ - void add( const T& thing ); - - /** put (copy) before me in List. - analogously to editor. ok() interpreted as at begin of - line. - - PRE: !ok, POST: add to top() - - PRE: ok, POST: add before me - - cursor points to same object, cursor.previous() - is newly inserted object. - */ - - void insert( const T& thing ); - /// - void backspace(); - - /// - void del(); - - /// access the list this came from - List& list() const ; - Link* pointer(); - static int compare(Cursor a,Cursorb) { return a-b; } -private: - List& list_; - Link* pointer_; -}; - - -/* - comparisons. - */ -#include "compare.hh" - - -template_instantiate_compare(Cursor, Cursor::compare, template); - -#include "pcursor.hh" -#include "list.hh" -#include "cursor.inl" -#include "iterate.hh" - -#endif // CURSOR_HH diff --git a/flower/lib/include/cursor.inl b/flower/lib/include/cursor.inl deleted file mode 100644 index 54d3703e60..0000000000 --- a/flower/lib/include/cursor.inl +++ /dev/null @@ -1,113 +0,0 @@ - // cursor.inl -*-c++-*- -#ifndef CURSOR_INL -#define CURSOR_INL -#include - - -template -inline -Cursor::Cursor( const List& list, Link* pointer ) : - list_((List&) list ) -{ - if ( list.size() ) - pointer_ = pointer ? pointer : list.top_; - else - pointer_ = pointer; -} - -template -inline -Cursor::Cursor( const Cursor& cursor ) : - list_( cursor.list_ ) -{ - pointer_ = cursor.pointer_; -} - -template -inline T& -Cursor::thing() -{ - assert( pointer_ ); - return pointer_->thing(); -} - -template -Cursor -Cursor::operator =( const Cursor& c ) -{ - assert( &list_ == &c.list_ ); - pointer_ = c.pointer_; - return *this; -} - -template -inline void -Cursor::add( const T& th ) -{ - list_.add( th, *this ); -} - -template -inline void -Cursor::insert( const T& th ) -{ - list_.insert( th, *this ); -} - -template -inline List& -Cursor::list() const -{ - return list_; -} - -template -inline Link* -Cursor::pointer() -{ - return pointer_; -} - -template -inline bool -Cursor::backward() -{ - return ( pointer_ != 0 ); -} - -template -inline bool -Cursor::forward() -{ - return ( pointer_ != 0 ); -} - -template -inline bool -Cursor::ok() -{ - return ( pointer_ != 0 ); -} - - -template -inline Cursor -Cursor::operator ++( int ) -{ - Cursor r (*this); - assert( pointer_ ); - pointer_ = pointer_->next(); - return r; -} - -template -inline Cursor -Cursor::operator --( int ) -{ - Cursor r (*this); - assert( pointer_ ); - pointer_ = pointer_->previous(); - return r; -} - -#endif diff --git a/flower/lib/include/cursor.tcc b/flower/lib/include/cursor.tcc deleted file mode 100644 index 3be73fe5d2..0000000000 --- a/flower/lib/include/cursor.tcc +++ /dev/null @@ -1,109 +0,0 @@ -#ifndef CURSOR_CC -#define CURSOR_CC - -#include "cursor.hh" -#include - -template - void -Cursor::backspace() -{ - Cursor c(*this); - if ( c.ok() ) - c--; - list_.remove( *this ); -} - -template - void -Cursor::del() -{ - Cursor c(*this); - if ( c.ok() ) - c++; - list_.remove( *this ); - *this = c; -} - - -template -Cursor -Cursor::operator -=( int j ) -{ - while (j--) - (*this)--; - return *this; -} -template -Cursor -Cursor::operator +=( int j ) -{ - while (j++) - (*this)++; - return *this; -} - -template -Cursor -Cursor::operator +( int i ) const -{ - Cursor r = *this; - - if (i<0) - return r -(-i); - - while (i--) - r++; - - return r; -} - -template -Cursor -Cursor::operator -( int i ) const -{ - Cursor r = *this; - if (i<0) - return r +(-i); - - while (i--) - r--; - - return r; -} -/* - warning: can't use Cursor::operator == (Cursor), - since it uses Cursor::operator-(Cursor) - */ -template -int -Cursor::operator-(Cursor rhs) const -{ - assert(rhs.list == list); - int dif = 0; - - // search from *this on further up (positive difference) - Cursor c(*this); - while (c.ok() && c.pointer_ != rhs.pointer_) { - c--; - dif++; - } - - if (c.ok()) - goto gotcha; // so, sue me. - - // search in direction of bottom. (negative diff) - dif =0; - c=*this; - while (c.ok() && c.pointer_ !=rhs.pointer_) { - dif --; - c++; - } - assert(c.ok()); - -gotcha: - assert((*this - dif).pointer_ == c.pointer_); - return dif; -} - -#endif diff --git a/flower/lib/include/data-file.hh b/flower/lib/include/data-file.hh deleted file mode 100644 index dae9e56347..0000000000 --- a/flower/lib/include/data-file.hh +++ /dev/null @@ -1,59 +0,0 @@ -/* - data-file.hh -- declare Data_file - - source file of the LilyPond music typesetter - - (c) 1997 Han-Wen Nienhuys -*/ - - -#ifndef DATAFILE_HH -#define DATAFILE_HH - -#include "text-stream.hh" - -/// read a data file -class Data_file : private Text_stream -{ - - public: - bool rawmode; - - Text_stream::line; - Text_stream::eof; - Text_stream::get_name; - - char data_get(); - void data_unget(char c) { - unget(c); - } - - /// read line, eat #\n# - String get_line(); - - /// read a word till next space, leave space. Also does quotes - String get_word(); - - /// gobble horizontal white stuff. - void gobble_white(); - - /// gobble empty stuff before first field. - void gobble_leading_white(); - Data_file(String s) : Text_stream(s) { - //*mlog << "(" << s << flush; - rawmode= false; - } - - ~Data_file() { - // *mlog << ")"< -struct Assoc; - -/** debug stream. - a class for providing debug output of nested structures, - with indents according to \{\}()[]. - - One can turn on and off specific messages using the Assoc silent. - This can be done automatically: - - #define DEBUG dstream_.identify_as(__PRETTY_FUNCTION__) - - DEBUG << "a message\n"; - - Init for the class names which should be silent can be given in a rc file. - - */ -class Dstream -{ - ostream *os; - int indentlvl; - bool local_silence; - String classname; - void output(String s); - Assoc *silent; -public: - - bool silence(String); - - /** - if rcfile == 0, then do not read any rc file. - */ - - Dstream(ostream *r, const char * rcfile); - virtual ~Dstream(); - Dstream &identify_as(String s); - - Dstream &operator << (String s); - /** - Output memory locations. - */ - Dstream &operator << (void const *); - Dstream &operator << (char const *); -}; -#endif - diff --git a/flower/lib/include/fproto.hh b/flower/lib/include/fproto.hh deleted file mode 100644 index 01ebe64b6f..0000000000 --- a/flower/lib/include/fproto.hh +++ /dev/null @@ -1,54 +0,0 @@ -/* - fproto.hh -- typenames in flowerlib - - (c) 1996 Han-Wen Nienhuys -*/ - -#ifndef FPROTO_HH -#define FPROTO_HH - - -const char * flower_version_sz(); - -// what the F*** is "int" ? -// depreciate int, long, etc., use i32, i64, remember: linux-16/linux-64 ? -/// (i32) -typedef int i32; -/// (i64) -typedef long long I64; - -template struct Array; -template struct sstack; -template struct Assoc; -template struct List; -template struct PointerList; -template struct IPointerList; -template struct Cursor; -template struct PCursor; -template struct Link; -template struct Handle; -template struct Interval_t; -template struct PQueue; - -#include "real.hh" - -typedef Interval_t Interval; - -struct Choleski_decomposition; - -struct Long_option_init; -struct Getopt_long; -struct Matrix; -struct String_data; -struct String_handle; -struct String_convert; -struct String; -struct virtual_smat; -struct Vector ; -struct Text_stream; -struct Data_file; -struct Text_db; -struct Scalar; -typedef unsigned char Byte; -#endif // FPROTO_HH - diff --git a/flower/lib/include/handle.hh b/flower/lib/include/handle.hh deleted file mode 100644 index 63c17ef1d2..0000000000 --- a/flower/lib/include/handle.hh +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef HANDLE_HH -#define HANDLE_HH - -/// reference counting handle -template -class Handle { - T *obj; - int *refs; - - /// let go of ref. Delete if necessary - void down() { - if (!(*refs--)) { - delete obj; - delete refs; - } - obj = 0; - refs = 0; - } - /// point to new object. - void up(T *t, int *r) { - if (!r) { - refs = new int; - *refs = 1; - } else { - refs =r; - *refs++; - } - obj = t; - } - /// POST: *refs == 1 - void copy() { - if(*refs != 1){ - T * newobj = new T(*obj ); - down(); - up(newobj); - } - } - Handle(Handle const &src) { - up(src.obj, src.refs); - } - Handle(T & o) { - up (&o); - } - void operator=(Handle const& src) { - if (this == &src) - return; - down(); - up(src.o, src.refs); - } - operator const T&() { - return *obj; - } - operator T&() { - copy(); - return *obj; - } -} -#endif diff --git a/flower/lib/include/interval.hh b/flower/lib/include/interval.hh deleted file mode 100644 index aae16381db..0000000000 --- a/flower/lib/include/interval.hh +++ /dev/null @@ -1,125 +0,0 @@ -/* - interval.hh -- part of flowerlib - - (c) 1996 Han-Wen Nienhuys -*/ - -#ifndef INTERVAL_HH -#define INTERVAL_HH - -#include -#include "fproto.hh" -#include "real.hh" - - -/** a T interval. - this represents the closed interval [left,right]. - No invariants. T must be a totally ordered ring - */ -template -struct Interval_t { - T left, right; - - /* ************** */ - - T center() { return (left + right) / T(2);} - void translate(T t) { - left += t; - right += t; - } - T& idx(int j) { - if (j==-1) - return left; - else if (j==1) - return right; - else - assert(false); - return left; - } - T& operator[](int j) { - return idx(j); - } - T operator[](int j) const { - return ((Interval_t *)this)->idx(j); - } - T &max() { return right;} - T max()const { return right;} - T min()const{ return left; } - T &min(){ return left; } - /** - PRE - *this and h are comparable - */ - void unite(Interval_t h); - void intersect(Interval_t h); - - T length() const; - void set_empty() ; - bool empty() const { return left > right; } - Interval_t() { - set_empty(); - } - Interval_t(T m, T M) { - left =m; - right = M; - } - Interval_t &operator += (T r) { - left += r; - right +=r; - return *this; - } - String str() const; - bool elt_q(T r); -}; - - -/** - inclusion ordering. Crash if not comparable. - */ -template -int Interval__compare(const Interval_t&,Interval_t const&); - -/* - INLINE - */ - -#include "compare.hh" - -template_instantiate_compare(Interval_t&, Interval__compare, template); - - -template -inline Interval_t -intersection(Interval_t a, Interval_t const&b) -{ - a.intersect(b); - return a; - -} - - -template -inline -Interval_t operator +(T a,Interval_t i ) -{ - i += a; - return i; -} - -template -inline -Interval_t operator +(Interval_t i,T a ){ - return a+i; -} - -typedef Interval_t Interval; - - -#define Interval__instantiate(T) template struct Interval_t;\ - template int Interval__compare(const Interval_t&,Interval_t const&) - - -#endif // INTERVAL_HH - - - diff --git a/flower/lib/include/interval.tcc b/flower/lib/include/interval.tcc deleted file mode 100644 index 6e7b0b1279..0000000000 --- a/flower/lib/include/interval.tcc +++ /dev/null @@ -1,106 +0,0 @@ -#include -#include -#include "interval.hh" -#include "string.hh" - - -template -int -_Interval__compare(const Interval_t&a,Interval_t const&b) -{ - if (a.left == b.left && a.right == b.right) - return 0; - - if (a.left <= b.left && a.right >= b.right) - return 1; - - if (a.left >= b.left && a.right <= b.right) - return -1; - - return -2; -} - - -template -int -Interval__compare(const Interval_t&a,Interval_t const&b) -{ - int i = _Interval__compare(a,b); - if (i < -1) - assert(false); - return i; -} - -#ifdef AIX -const Real INFTY = 1e8; // ARGh. AIX sucks -#else -const Real INFTY = HUGE_VAL; -#endif - -template -void -Interval_t::set_empty() -{ - left = INFTY; - right = -INFTY; -} - -template -T -Interval_t::length() const { - assert(right >= left); - return right-left; -} - -template -void -Interval_t::unite(Interval_t h) -{ - if (h.leftright) - right = h.right; -} - -/** - smallest Interval which includes *this and #h# - */ - -template -void -Interval_t::intersect(Interval_t h) -{ -#if defined (__GNUG__) && ! defined (__STRICT_ANSI__) - left = h.left >? left; - right = h.right -Interval_t -intersect(Interval_t x, Interval_t const &y) -{ - x.intersect(y); - return x; -} - -template -String -Interval_t::str() const -{ - if (empty()) - return "[empty]"; - String s("["); - - return s + left + "," + right +"]"; -} - -template -bool -Interval_t::elt_q(T r) -{ - return r >= left && r <= right; -} diff --git a/flower/lib/include/iterate.hh b/flower/lib/include/iterate.hh deleted file mode 100644 index 1e924f0790..0000000000 --- a/flower/lib/include/iterate.hh +++ /dev/null @@ -1,22 +0,0 @@ -/* - iterate.hh -- define some list macros - - source file of the flowerlib - - (c) 1997 Han-Wen Nienhuys -*/ - - -#ifndef ITERATE_HH -#define ITERATE_HH - - - -#define iterator(set) typeof((set).top()) -#define iterator_bot(set) typeof((set).bottom()) - -// should use top() -#define iter_top(set,var) iterator(set) var(set) -#define iter_bot(set,var) iterator(set) var(set.bottom()) - -#endif // ITERATE_HH diff --git a/flower/lib/include/lgetopt.hh b/flower/lib/include/lgetopt.hh deleted file mode 100644 index 3b2b0348b3..0000000000 --- a/flower/lib/include/lgetopt.hh +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef LGETOPT_HH -#define LGETOPT_HH - -#include - - -class ostream; - -/** - a struct this for initialising the commandline options. - */ -struct Long_option_init { - bool take_arg; - const char* longname; - char shortname; - - ostream &printon(ostream &errorout); -}; - - -/** C++ for version of long_getopt. For processing GNU style command - line arguments. No pointer (return values, arguments) contents are - copied. */ -class Getopt_long { -public: - /** errorcodes: no error, argument expected, no argument expected, - unknown option, illegal argument (eg. int expected). */ - enum Errorcod { E_NOERROR = 0, E_ARGEXPECT, E_NOARGEXPECT, E_UNKNOWNOPTION, - E_ILLEGALARG } ; - - -private: - - /// the option info. - Long_option_init *the_opts; - int table_len; - - /// if doing short option, argv[optind][optindind] is processed next. - int optindind; - - /// the option found - Long_option_init *beet; - - /// get ready for processing next error. - bool next(); - Long_option_init *parselong(); - Long_option_init *parseshort(); - - ostream *errorout; - - /// report an error and abort - void report(Errorcod c); -public: - - /// argument. Set to 0 if not present - char* optarg; - - /// current error status - Errorcod error; - - /// return an integer (with err. detect) - long intarg(); - /// argv[optind] will be processed next. - int optind; - - /// the arguments - char **argv; - - /// the arg. count - int argc; - - /* *************** */ - - /** - What to do with errors. - report messages on #*os#, and abort. - if #os# is null, then do not report nor abort, just set #error# - */ - - void seterror(ostream *os); - - /// construct: pass arguments and option info. - Getopt_long(int c, char **v, Long_option_init *lo); - - /** get the next option. - @return pointer to next option found. - 0 if error occurred, or next argument is no option. - */ - Long_option_init *operator()(); - - char *current_arg(); - char * get_next_arg(); -}; -#endif diff --git a/flower/lib/include/libc-extension.hh b/flower/lib/include/libc-extension.hh deleted file mode 100644 index dec8f24bdc..0000000000 --- a/flower/lib/include/libc-extension.hh +++ /dev/null @@ -1,33 +0,0 @@ -/* - libc-extension.hh -- declare some string.h extensions - - source file of the flowerlib - - (c) 1997 Han-Wen Nienhuys -*/ - - -#ifndef LIBC_EXTENSION_HH -#define LIBC_EXTENSION_HH -#include "fproto.hh" -#include "config.hh" - -char* strnlwr( char* start_l ,int n); -char* strnupr( char* start_l, int n); - -#ifndef HAVE_MEMMEM // GNU extension. -char *memmem(const Byte * haystack, int haystack_len, - const Byte *needle, int needle_len); -#endif HAVE_MEMMEM - -#ifndef HAVE_SNPRINTF // GNU extension. -int snprintf (char *str, size_t n, - const char *format, ... ); -#endif - - -Byte *memrchr(const Byte * p, int n, char c); -Byte *strrev( Byte* byte_l, int length_i ); - - -#endif // LIBC_EXTENSION_HH diff --git a/flower/lib/include/link.hh b/flower/lib/include/link.hh deleted file mode 100644 index 6f9c75a411..0000000000 --- a/flower/lib/include/link.hh +++ /dev/null @@ -1,38 +0,0 @@ -// link.hh - -#ifndef __LINK_HH -#define __LINK_HH -template -class List; - - -/// class for List -template -class Link -{ -// friend class Cursor; -public: - Link( const T& thing ); - - Link* previous(); - Link* next(); - - /// put new Link item after me in list - void add( const T& thing ); - /// put new Link item before me in list - void insert( const T& thing ); - void remove(List &l); - - T& thing(); - void OK() const; -private: - Link( Link* previous, Link* next, const T& thing ); - - T thing_; - Link* previous_; - Link* next_; -}; - -#include "link.inl" - -#endif // __LINK_HH // diff --git a/flower/lib/include/link.inl b/flower/lib/include/link.inl deleted file mode 100644 index 3926d6bc2a..0000000000 --- a/flower/lib/include/link.inl +++ /dev/null @@ -1,102 +0,0 @@ -// link.inl -*-c++-*- -#ifndef LINK_INL -#define LINK_INL -#include -template -inline -void -Link::OK() const -{ -#ifndef NDEBUG - if (previous_) { - assert(previous_->next_ == this); - } - if (next_) { - assert(next_->previous_ == this); - } -#endif -} - -template -inline -Link::Link( const T& thing ) : - thing_( thing ) -{ - previous_ = next_ = 0; -} - -template -inline -Link::Link( Link* previous, Link* next, const T& thing ) : - thing_( thing ) -{ - previous_ = previous; - next_ = next; -} - -template -inline -Link* -Link::next() -{ - return next_; -} - -template -inline -Link* -Link::previous() -{ - return previous_; -} - -template -inline -void -Link::add( const T& thing ) -{ - - Link* l = new Link( this, next_, thing ); - if ( next_ ) - next_->previous_ = l; - next_ = l; -} - -template -inline void -Link::insert( const T& thing ) -{ - // Link* l = new Link( next_, this, thing ); - // bugfix hwn 16/9/96 - Link* l = new Link( previous_, this, thing ); - if ( previous_ ) - previous_->next_ = l; - previous_ = l; -} - -/* - don't forget to adjust #l#'s top_ and bottom_. - */ -template -inline void -Link::remove(List &l) -{ - if ( previous_ ) - previous_->next_ = next_; - else - l.top_ = next_; - - if ( next_ ) - next_->previous_ = previous_; - else - l.bottom_ = previous_; -} - -template -inline -T& -Link::thing() -{ - return thing_; -} -#endif diff --git a/flower/lib/include/list.hh b/flower/lib/include/list.hh deleted file mode 100644 index ec59fbff07..0000000000 --- a/flower/lib/include/list.hh +++ /dev/null @@ -1,98 +0,0 @@ -#ifndef __LIST_HH -#define __LIST_HH - -class ostream; -template class Cursor; -template class Link; - -/** all-purpose doubly linked list. - - List can be seen as all items written down on paper, - from top to bottom - - class Cursor is used to extend List - - items are always stored as copies in List, but: - #List# : copies of #String# stored - #List# : copies of #String*# stored! - (do not use, use \Ref{PointerList} ## instead.) - - {\bf note:} - retrieving "invalid" cursors, i.e. - #top()/bottom()# from empty list, #find()# without success, - results in a nonvalid Cursor ( #!ok()# ) - - - INVARIANTEN! -*/ - -template -class List -{ - public: - List(List const&src); - - /// construct empty list - List(); - virtual ~List(); - - int size() const; - - Cursor bottom() const; // const sucks. - Cursor top() const; - - void OK() const; // check list - - protected: - friend class Cursor; - friend class Link; - - void concatenate(List const &s); - - /** make *this empty. - - POST: - size == 0 - - WARNING: - contents lost, and not deleted. - */ - void set_empty(); - - void add( const T& thing, Cursor &after_me ); - - /// put thing before #before_me# - void insert( const T& thing, Cursor &before_me ); - - /** Remove link pointed to by me. Destructor of contents called - (nop for pointers) - - POST - none; - - - WARNING: do not use #me# after calling - */ - void remove( Cursor me ); - - - /* ************** */ - - int size_; - Link* top_; - Link* bottom_; -}; - -#include "list.inl" -#include "cursor.hh" - -// instantiate a template: explicit instantiation. -#define L_instantiate(a) template class List; template class Cursor; \ - template class Link - - -#endif // __LIST_HH // - - - - diff --git a/flower/lib/include/list.inl b/flower/lib/include/list.inl deleted file mode 100644 index df0687b7c8..0000000000 --- a/flower/lib/include/list.inl +++ /dev/null @@ -1,56 +0,0 @@ -// -*-c++-*- - -#ifndef LIST_INL -#define LIST_INL - -template -inline -List::List() -{ - set_empty(); -} - -template -inline void -List::set_empty() -{ - top_ = bottom_ = 0; - size_ = 0; -} - -template -inline void -List::remove( Cursor me ) -{ - if ( me.ok() ){ - Link *lp = me.pointer(); - lp->remove(*this); - delete lp; - size_--; - } -} - -template -inline int -List::size() const -{ - return size_; -} - -template -inline Cursor -List::top()const -{ - return Cursor( *this, top_ ); -} - - -template -inline Cursor -List::bottom()const -{ - return Cursor( *this, bottom_ ); -} - - -#endif diff --git a/flower/lib/include/list.tcc b/flower/lib/include/list.tcc deleted file mode 100644 index 16e12a31f1..0000000000 --- a/flower/lib/include/list.tcc +++ /dev/null @@ -1,112 +0,0 @@ -#ifndef LIST_CC -#define LIST_CC - -#include "list.hh" - -template -List::List(List const&src) -{ - set_empty(); - // probably el stupido - for (Cursor c(src); c.ok(); c++) - bottom().add(c); -} - -template -void -List::OK() const -{ - int i = size_; - Link *lp = top_; - while (i--) { - assert(lp); - lp->OK(); - lp = lp->next(); - } - assert(!lp); - i = size_; - lp = bottom_; - while (i--) { - assert(lp); - lp->OK(); - lp = lp->previous(); - } - assert(!lp); -} - - -template -List::~List() -{ - Cursor c(*this); - while (c.ok()) - c.del(); -} - -/** - - add after after_me. - - Procedure: - \begin{itemize} - \item if #after_me# is #ok()#, add after #after_me#, else - \item if list !empty simply add to bottom, else - \item list is empty: create first \Ref{Link} and initialize - #bottom_# and #top_#. - \end{itemize} -*/ -template -void -List::add( const T& thing, Cursor &after_me ) -{ - if (!size_) { // not much choice if list is empty - bottom_ = top_ = new Link( thing ); - if (!after_me.ok()) - after_me = bottom(); - } else { // add at aprioprate place - if (!after_me.ok()) - after_me = bottom(); - Link *p =after_me.pointer(); - p->add(thing); - if (p == bottom_) // adjust bottom_ if necessary. - bottom_ = p->next(); - } - - size_++; -} - -template -void -List::insert( const T& thing, Cursor &before_me ) -{ - if (!size_) { - bottom_ = top_ = new Link( thing ); - if (!before_me.ok()) - before_me = top(); - - } else { - if (!before_me.ok()) - before_me = top(); - - Link *p = before_me.pointer() ; - - p->insert(thing); - if (p == top_) - top_ = p->previous(); - } - - size_++; -} - - -template -void -List::concatenate(List const&s) -{ - Cursor b(bottom()); - for (Cursor c(s); c.ok(); c++) { - b.add(c); - b++; - } -} -#endif diff --git a/flower/lib/include/matrix.hh b/flower/lib/include/matrix.hh deleted file mode 100644 index a633d6657a..0000000000 --- a/flower/lib/include/matrix.hh +++ /dev/null @@ -1,135 +0,0 @@ -#ifndef MATRIX_HH -#define MATRIX_HH - - -#include "vsmat.hh" -#include "vector.hh" - -/** a Real matrix. This is a class for a nonsquare block of #Real#s. The - implementation of sparse matrices is done in the appropriate #smat# - class. Matrix only does the mathematical actions (adding, - multiplying, etc.) - - - TODO - implement ref counting? */ - - -class Matrix { - virtual_smat *dat; - -public: - void OK() const { dat->OK(); } - int cols() const { return dat->cols(); } - int rows() const { return dat->rows(); } - - /** return the size of a matrix. - PRE - the matrix needs to be square. - */ - int dim() const; - - // Matrix() { dat = 0; } - ~Matrix() { delete dat; } - - /// set entries to r - void fill(Real r); - - /// set diagonal to d - void set_diag(Real d); - - void set_diag(Vector d); - /// set unit matrix - void unit() { set_diag(1.0); } - - void operator+=(const Matrix&m); - void operator-=(const Matrix&m); - void operator*=(Real a); - void operator/=(Real a) { (*this) *= 1/a; } - - /** add a row. - add a row to the matrix before row k - - PRE - v.dim() == cols() - 0 <= k <= rows() - */ - void insert_row(Vector v,int k); - /** . - delete a row from this matrix. - - PRE - 0 <= k < rows(); - */ - void delete_row(int k) { dat->delete_row(k); } - void delete_column(int k) { dat->delete_column(k); } - - /** - square n matrix, initialised to null - */ - Matrix(int n); - - /** - n x m matrix, init to 0 - */ - Matrix(int n, int m); - Matrix(const Matrix &m); - - /// dyadic product: v * w.transpose - Matrix(Vector v, Vector w); - void operator=(const Matrix&m); - - /// access an element - Real operator()(int i,int j) const { return dat->elem(i,j); } - - /// access an element - Real &operator()(int i, int j) { return dat->elem(i,j); } - - /// Matrix multiply with vec (from right) - Vector operator *(const Vector &v) const; - - /// set this to m1*m2. - void set_product(const Matrix &m1, const Matrix &m2); - - - Vector left_multiply(Vector const &) const; - - Matrix operator-() const; - - /// transpose this. - void transpose(); - - /// return a transposed copy. - Matrix transposed() const ; - - Real norm() const; - /** swap. - PRE - 0 <= c1,c2 < cols() - */ - void swap_columns(int c1, int c2); - - /** swap. - PRE - 0 <= c1,c2 < rows() - */ - void swap_rows(int c1, int c2); - - - Vector row(int ) const; - Vector col(int) const; - - operator String() const; - void print() const; -}; - -inline Vector -operator *(Vector &v, const Matrix& m) { return m.left_multiply(v); } -Matrix operator *(const Matrix& m1,const Matrix &m2); -Matrix operator /(const Matrix &m1,Real a); -inline Matrix operator -(Matrix m1,const Matrix m2) -{ - m1 -= m2; - return m1; -} -#endif diff --git a/flower/lib/include/path.hh b/flower/lib/include/path.hh deleted file mode 100644 index bc4d9f3776..0000000000 --- a/flower/lib/include/path.hh +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef PATH_HH -#define PATH_HH -#include "string.hh" -#include "varray.hh" - - -/** searching directory for file. - - Abstraction of PATH variable. An interface for searching input files. - Search a number of dirs for a file. - - Should use kpathsea? - -*/ - -class File_path : private Array -{ -public: - /// locate a file in the search path - String find(String nm); - - /// construct using prefix. Normally argv[0]. - File_path(String); - - /// add to end of path. - Array::push; - void add(String str) { push(str); } -}; -/// split path into its components -void split_path(String path, String &drive, String &dirs, String &filebase, String &extension); - -#endif diff --git a/flower/lib/include/pcursor.tcc b/flower/lib/include/pcursor.tcc deleted file mode 100644 index ffb01bcfe8..0000000000 --- a/flower/lib/include/pcursor.tcc +++ /dev/null @@ -1,16 +0,0 @@ -#include "pcursor.hh" - -template -void -PCursor::junk() -{ -#if !defined(NDEBUG) && defined(PARANOID) - list().OK(); -#endif - - delete ptr(); -#if !defined(NDEBUG)&&defined(PARANOID) - thing() = 0; - list().OK(); -#endif -} diff --git a/flower/lib/include/plist.tcc b/flower/lib/include/plist.tcc deleted file mode 100644 index ac9daedf71..0000000000 --- a/flower/lib/include/plist.tcc +++ /dev/null @@ -1,21 +0,0 @@ -#include "plist.hh" - -template -IPointerList::~IPointerList() -{ - PCursor c( *this ); - while (c.ok()) { - delete c.remove_p(); - } -} - -template -PCursor -PointerList::find(T what ) const -{ - PCursor i(*this); - for (; i.ok(); i++) - if (i.ptr() == what) - break; - return i; -} diff --git a/flower/lib/include/pqueue.hh b/flower/lib/include/pqueue.hh deleted file mode 100644 index c8dfe1bea6..0000000000 --- a/flower/lib/include/pqueue.hh +++ /dev/null @@ -1,72 +0,0 @@ -/* - pqueue.hh -- declare - - source file of the LilyPond music typesetter - - (c) 1997 Han-Wen Nienhuys -*/ - - -#ifndef PQUEUE_HH -#define PQUEUE_HH - -#include "varray.hh" - -/** - Stupid Prioq. Should use Lists and STL. - Smallest is put at the front. - -Actually, this sux. Should use a template struct PQuee_ent - */ - -template -struct PQueue -{ - Array value_arr_; - Array indices_arr_; - void OK() const - { - - assert(value_arr_.size() == indices_arr_.size()); - } - - void enter(V v, I idx) { - int j=0; - for (; j < value_arr_.size(); j++) - if (indices_arr_[j] > idx) - break; - - insert(j,v,idx); - - } - int size() { return value_arr_.size(); } - V front_val() { return value_arr_[0]; } - I front_idx() { return indices_arr_[0]; } - void del(int i) - { - value_arr_.del(i); - indices_arr_.del(i); - } - int size() const - { - OK(); - return value_arr_.size(); - } - - - void insert(int j, V v, I idx) - { - value_arr_.insert(v, j); - indices_arr_.insert(idx, j); - } - - - - V get() { - V retval = front_val(); - del(0); - return retval; - } - -}; -#endif // PQUEUE_HH diff --git a/flower/lib/include/rational.hh b/flower/lib/include/rational.hh deleted file mode 100644 index 30fa2cb6d6..0000000000 --- a/flower/lib/include/rational.hh +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/flower/lib/include/real.hh b/flower/lib/include/real.hh deleted file mode 100644 index 0533af2111..0000000000 --- a/flower/lib/include/real.hh +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef REAL_HH -#define REAL_HH - - -#include -#include -#include - -typedef double Real; - -inline Real -distance(Real x,Real y) -{ - return abs(x-y); -} -#endif diff --git a/flower/lib/include/scalar.hh b/flower/lib/include/scalar.hh deleted file mode 100644 index 5cdfa427da..0000000000 --- a/flower/lib/include/scalar.hh +++ /dev/null @@ -1,34 +0,0 @@ -/* - scalar.hh -- part of LilyPond - - (c) 1996 Han-Wen Nienhuys -*/ - -#ifndef SCALAR_HH -#define SCALAR_HH -#include "string.hh" -#include "real.hh" - -/// Perl -like scalar type. -struct Scalar : public String { - - Scalar(Real r) : String(r) {} - Scalar(int i) : String(i) {} - Scalar(char c) : String(c) {} - Scalar(const char *c) : String(c) {} - Scalar(String s ):String(s) {} - Scalar(Rational ); - operator Rational(); - Scalar() {} - bool isnum(); - operator Real(); - operator int(); - - /** perl -like string to bool conversion. - */ - operator bool() const; - -}; - -#endif // SCALAR_HH - diff --git a/flower/lib/include/smat.hh b/flower/lib/include/smat.hh deleted file mode 100644 index 9b0987c8f4..0000000000 --- a/flower/lib/include/smat.hh +++ /dev/null @@ -1,93 +0,0 @@ -#ifndef SMAT_HH -#define SMAT_HH -#include "varray.hh" -#include "vsmat.hh" -#include "real.hh" -/// simplest matrix storage. refer to its baseclass for the doco. -class Full_storage : public virtual_smat -{ - /// height, width - int h,w; - /// maxima. - int maxh, maxw; - - /// the storage - Real** els; - void - init() { - els=0; - h=w=maxh=maxw=0; - - } - - bool valid(int i, int j) const { - return (i>=0 && i < h) - && (j < w && j >=0); - } - - - void resize_rows(int); - void resize_cols(int); - -public: - virtual int rows() const { - return h; - } - virtual int cols() const { - return w; - } - - - virtual void set_size(int i, int j) - { - resize(i,j); //this could be more efficient. - } - - virtual void set_size(int i) { - set_size(i,i); - } - virtual void resize(int i, int j); - virtual void resize(int i) { - resize(i,i); - } - - virtual Real& elem(int i,int j) { - assert(valid(i,j)); - return els[i][j]; - } - virtual const Real& elem(int i, int j) const { - assert(valid(i,j)); - return els[i][j]; - } - virtual Array row(int i) const; - virtual Array column(int j) const; - - Full_storage() { - init(); - } - Full_storage(int i, int j) { - init(); - set_size(i,j); - } - Full_storage(Full_storage&); - Full_storage(int i) { - init(); - set_size(i); - } - void OK() const; - void operator=(Full_storage const &); - - virtual void insert_row(int k); - virtual void delete_row(int k); - virtual void delete_column(int k); - - - ~Full_storage(); - virtual bool mult_ok(int i, int j)const; - virtual void mult_next(int &i, int &j) const ; - virtual bool trans_ok(int i, int j) const; - virtual void trans_next(int &i, int &j) const; - virtual virtual_smat * clone(); -}; - -#endif diff --git a/flower/lib/include/string-convert.hh b/flower/lib/include/string-convert.hh deleted file mode 100644 index f6bcfa7fae..0000000000 --- a/flower/lib/include/string-convert.hh +++ /dev/null @@ -1,45 +0,0 @@ -/* - PROJECT: FlowerSoft C++ library - FILE : string-convert.hh - -*/ - -#ifndef STRING_CONVERT_HH -#define STRING_CONVERT_HH - -/* - ///a class which only has functions. -//#define functor class // cute. docxx fucks up -*/ - -/** - The functor String_convert handles all conversions to/from String (some - time, anyway). - The class is quite empty from data view. - */ -class String_convert { - static int hex2bin_i( String hex_str, String& bin_str_r ); - static int hex2nibble_i( Byte byte ); - static Byte nibble2hex_byte( Byte byte ); -public: - static String bin2dec_str( String bin_str ); - static String bin2hex_str( String bin_str ); - static String dec2bin_str( String str ); - static int bin2_i( String str ); - static String char_str(char c, int n); - static int dec2_i( String dec_str ); - static double dec2_f( String dec_str ); - static String double_str(double f, char const* fmt=0); - static int hex2_i( String str ); - static unsigned hex2_u( String str ); - static String hex2bin_str( String str ); - static String int_str(int i, char const *fmt=0 ); - static String i2hex_str( int i, int length_i, char ch ); - static String u2hex_str( unsigned u, int length_i, char ch ); - static String i2dec_str( int i, int length_i, char ch ); - static String rational_str(Rational); - static String pointer_str(const void *); - static String i64_str(I64, char const * fmt = 0); -}; - -#endif // __STRING_CONVERT_HH // diff --git a/flower/lib/include/string-data.hh b/flower/lib/include/string-data.hh deleted file mode 100644 index ecd7159074..0000000000 --- a/flower/lib/include/string-data.hh +++ /dev/null @@ -1,95 +0,0 @@ -/* - string-data.hh -- declare String_data - - source file of the LilyPond music typesetter - - (c) 1997 Han-Wen Nienhuys -*/ - - -#ifndef STRINGDATA_HH -#define STRINGDATA_HH - - -/**Internal String struct. - the data itself. Handles simple tasks (resizing, resetting) - */ -class String_data { - // GNU malloc: storage overhead is 8 bytes anyway. - -friend class String_handle; - int maxlen; // maxlen is arraysize-1 - - int length_i_; - Byte* data_byte_p_; - int references; - - /// init to "" - String_data(); - - /// init from src. Conservative allocation. - String_data(String_data const &src); - - ~String_data(); - - /** POST: maxlen >= j. - @param j, maximum stringlength_i_. - contents thrown away. - */ - void setmax(int j); - - /** POST: maxlen >= j. - @param j, maximum stringlength_i_. - contents are kept if it grows. - */ - void remax(int j); - - /// check if writeable. - void OKW(); - - /// check state. - void OK(); - - /// reduce memory usage. - void tighten(); - - // assignment. - void set( Byte const* byte_c_l, int length_i ); - - void set( char const* ch_c_l ); - - /// concatenation. - void append( Byte const* byte_c_l, int length_i ); - - void operator += ( char const* ch_c_l ); - - char const* ch_c_l() const; - - char* ch_l(); - - Byte const* byte_c_l() const; - - // idem, non const - Byte* byte_l(); - - void trunc(int j); - - /** access element. not really safe. Can alter length_i_ without - #String_data# knowing it. */ - Byte &operator [](int j); - Byte operator [](int j) const; - bool is_binary_bo()const; -}; - - - -#ifdef STRING_UTILS_INLINED -#ifndef INLINE -#define INLINE inline -#endif -#include "string-data.inl" - -#endif - - -#endif // STRING_DATA_HH diff --git a/flower/lib/include/string-data.inl b/flower/lib/include/string-data.inl deleted file mode 100644 index d2b925d0ce..0000000000 --- a/flower/lib/include/string-data.inl +++ /dev/null @@ -1,210 +0,0 @@ -/* -*-C++-*- - String_data.inl -- implement String_data - - source file of Flower lib - - (c) 1997 Han-Wen Nienhuys -*/ - -#ifndef STRINGDATA_INL -#define STRINGDATA_INL - -#include -#include - -#include "string-data.hh" -const int INITIALMAX=8; - -#include - -INLINE void -String_data::OKW() -{ - assert (references == 1); -} - -INLINE void -String_data::OK() -{ - assert(maxlen >= length_i_); - assert(bool(data_byte_p_)); - assert(references >= 1); -} - - -INLINE -String_data::String_data() -{ - references=0; - maxlen = INITIALMAX; - data_byte_p_ = new Byte[maxlen + 1]; - data_byte_p_[0] = 0; - length_i_ = 0; -} - -INLINE -String_data::String_data(String_data const &src) -{ - references=0; - maxlen = length_i_ = src.length_i_; - data_byte_p_ = new Byte[maxlen+1]; // should calc GNU 8byte overhead. - memcpy( data_byte_p_, src.data_byte_p_, length_i_ + 1 ); -} - -INLINE -String_data::~String_data() -{ - assert(references == 0); - delete[] data_byte_p_; -} - -INLINE void -String_data::setmax(int j) -{ - OKW(); - if (j > maxlen) { - delete data_byte_p_; - maxlen = j; - data_byte_p_ = new Byte[maxlen + 1]; - - data_byte_p_[0] = 0; - length_i_ = 0; - } -} - -/* this is all quite hairy: - update of length_i_ - update of maxlen - alloc of buffer - copying of buffer - needs blondification: - split tasks - define change authority -*/ -INLINE void -String_data::remax(int j) -{ - OKW(); - if (j > maxlen) { - Byte *p = new Byte[j + 1]; - memcpy( p, data_byte_p_, ( maxlen = 0 && j <= length_i_); - data_byte_p_[j] = 0; - length_i_ = j; -} - -INLINE bool -String_data::is_binary_bo()const -{ -// return !memchr(data_byte_p_, length_i_, 0); - return ( (int)strlen( (char const*)data_byte_p_ ) != length_i_ ); -} - -INLINE Byte& -String_data::operator [](int j) -{ - assert(j >= 0 && j <= length_i_); - return data_byte_p_[j] ; -} - -INLINE Byte -String_data::operator [](int j) const -{ - assert(j >= 0 && j <= length_i_); - return data_byte_p_[j]; -} - - - - -#endif // __STRING_UTIL_CC // diff --git a/flower/lib/include/string-handle.hh b/flower/lib/include/string-handle.hh deleted file mode 100644 index 5b7a12f648..0000000000 --- a/flower/lib/include/string-handle.hh +++ /dev/null @@ -1,70 +0,0 @@ -/* - string-handle.hh -- declare String_handle - - source file of the LilyPond music typesetter - - (c) 1997 Han-Wen Nienhuys -*/ - - -#ifndef STRINGHANDLE_HH -#define STRINGHANDLE_HH -#include "fproto.hh" - - -/** - Reference counting for strings. - - handles ref. counting, and provides a very thin interface using - Byte * - - */ -class String_handle { - String_data* data; - - /// decrease ref count. Named kind of like a Tanenbaum semafore - void down(); - - /// increase ref count - void up(String_data *d); - - /** make sure data has only one reference. - POST: data->references == 1 - */ - void copy(); - -public: - String_handle(); - ~String_handle(); - String_handle(String_handle const & src); - - Byte const* byte_c_l() const; - char const* ch_c_l() const; - Byte* byte_l(); - char* ch_l(); - bool is_binary_bo()const; - void operator =(String_handle const &src); - void operator += (char const *s); - Byte operator[](int j) const; - - /** Access elements. WARNING: NOT SAFE - don't use this for loops. Use byte_c_l() - */ - Byte &operator[](int j); - void append( Byte const* byte_c_l, int length_i ); - void set( Byte const* byte_c_l, int length_i ); - void operator = (char const *p); - void trunc(int j); - int length_i() const; -}; - -#ifdef STRING_UTILS_INLINED -#ifndef INLINE -#define INLINE inline -#endif -#include "string-handle.inl" -/* we should be resetting INLINE. oh well. */ -#endif - - -#endif // STRINGHANDLE_HH diff --git a/flower/lib/include/string-handle.inl b/flower/lib/include/string-handle.inl deleted file mode 100644 index 1f1d44ab13..0000000000 --- a/flower/lib/include/string-handle.inl +++ /dev/null @@ -1,156 +0,0 @@ -/* -*-c++-*- - - stringhandle.inl -- implement String_handle - - source file of Flower lib - - (c) 1997 Han-Wen Nienhuys -*/ - -#ifndef STRINGHANDLE_INL -#define STRINGHANDLE_INL - -#include -#include - -#include "string-data.hh" -#include "string-handle.hh" - -INLINE void -String_handle::down() -{ - if (!(--data->references)) delete data; data = 0; -} - -/// increase ref count -INLINE void -String_handle::up(String_data *d) -{ - data=d; data->references ++; -} - -INLINE void -String_handle::copy() -{ - if (data->references !=1){ - String_data *newdata = new String_data(*data); - down(); - up(newdata); - } -} - -INLINE -String_handle::String_handle() -{ - up(new String_data); -} - -INLINE -String_handle::~String_handle() -{ - down(); -} - -INLINE -String_handle::String_handle(String_handle const & src) -{ - up(src.data); -} - -INLINE Byte* -String_handle::byte_l() -{ - copy(); - return data->byte_l(); -} - -INLINE char* -String_handle::ch_l() -{ - copy(); - return (char*)data->byte_l(); -} - -INLINE Byte -const* String_handle::byte_c_l() const -{ - return data->byte_c_l(); -} - -INLINE char const* -String_handle::ch_c_l() const -{ - return (char const*)data->byte_c_l(); -} - -INLINE void -String_handle::operator =(String_handle const &src) -{ - if (this == &src) - return; - down(); - up(src.data); -} - -INLINE void -String_handle::operator += (char const *s) -{ - copy(); - *data += s; -} - - -INLINE Byte -String_handle::operator[](int j) const -{ - return (*data)[j]; -} - -// !NOT SAFE! -// don't use this for loops. Use byte_c_l() -INLINE Byte & -String_handle::operator[](int j) -{ - copy(); // hmm. Not efficient - return data->byte_l()[j]; -} - -INLINE void -String_handle::append( Byte const* byte_c_l, int length_i ) -{ - copy(); - data->append( byte_c_l, length_i ); -} - -INLINE void -String_handle::set( Byte const* byte_c_l, int length_i ) -{ - copy(); - data->set( byte_c_l, length_i ); -} - -INLINE void -String_handle::operator = (char const *p) -{ - copy(); - data->set( p ); -} - -INLINE void -String_handle::trunc(int j) -{ - copy(); data->trunc(j); -} - -INLINE int -String_handle::length_i() const -{ - return data->length_i_; -} - -INLINE bool -String_handle::is_binary_bo() const { - return data->is_binary_bo(); -} - -#endif diff --git a/flower/lib/include/string.hh b/flower/lib/include/string.hh deleted file mode 100644 index 8cef141169..0000000000 --- a/flower/lib/include/string.hh +++ /dev/null @@ -1,193 +0,0 @@ -/* - - FILE : string.hh -- declare String - - Rehacked by HWN 3/nov/95 - removed String & 's - introduced Class String_handle - */ - -#ifndef STRING_HH -#define STRING_HH - - -#include -#include -#include - -#include "string-handle.hh" - -/** - - Intuitive string class. provides -\begin{itemize} -\item - ref counting through #String_handle# -\item - conversion from bool, int, double, char* , char. -\item - to be moved to String_convert: - conversion to int, upcase, downcase - -\item - printable. - -\item - indexing (index_i, index_any_i, last_index_i) - -\item - cutting (left_str, right_str, mid_str) - -\item - concat (+=, +) - -\item - signed comparison (<, >, ==, etc) - -\item - No operator[] is provided, since this would be enormously slow. If needed, - convert to char const* . -\end{itemize} - -*/ -class String -{ -protected: - String_handle strh_; - - bool null_terminated(); - -public: - - /** init to empty string. This is needed because other - constructors are provided.*/ - String() { } - String(Rational); - - /// String s = "abc"; - String( char const* source ); - String( Byte const* byte_c_l, int length_i ); - - /// "ccccc" - String( char c, int n = 1 ); - - String( int i , char const *fmt=0); - String ( double f , char const* fmt =0); - /// 'true' or 'false' - String(bool ); - - /// return a "new"-ed copy of contents - Byte* copy_byte_p() const; // return a "new"-ed copy of contents - - char const* ch_c_l() const; - Byte const* byte_c_l() const; - char* ch_l(); - Byte* byte_l(); - - /// deprecated; use ch_c_l() - operator char const* () const { return ch_c_l(); } - - String &operator =( const String & source ); - - /// concatenate s - void operator += (char const* s) { strh_ += s; } - void operator += (String s); - - void append(String); - void prepend(String); - - char operator []( int n ) const { return strh_[n]; } - - /// return n leftmost chars - String left_str( int n ) const; - - /// return n rightmost chars - String right_str( int n ) const; - - /// return uppercase of *this - String upper_str() const; - - /// return lowercase of *this - String lower_str() const; - - /// return the "esrever" of *this - String reversed_str() const; - - - /// return a piece starting at index_i (first char = index_i 0), length n - String mid_str(int index_i, int n ) const; - - /// cut out a middle piece, return remainder - String nomid_str(int index_i, int n ) const; - - /// signed comparison, analogous to memcmp; - static int compare_i(const String& s1,const String& s2); - - /// index of rightmost c - int index_last_i( char c) const; - - /// index of rightmost element of string - int index_last_i( char const* string ) const; - - int index_i(char c ) const; - int index_i(String ) const; - int index_any_i(String ) const; - - void to_upper(); - void to_lower(); - /// provide Stream output - void print_on(ostream& os) const; - - /// the length of the string - int length_i() const; - - // ***** depreciated - int len() const { - return length_i(); - } - - /// convert to an integer - int value_i() const; - - /// convert to a double - double value_f() const; -}; - -#include "compare.hh" - -instantiate_compare(const String &, String::compare_i); - -// because char const* also has an operator ==, this is for safety: -inline bool operator==(String s1, char const* s2){ - return s1 == String(s2); -} -inline bool operator==(char const* s1, String s2) -{ - return String(s1)==s2; -} -inline bool operator!=(String s1, char const* s2 ) { - return s1!=String(s2); -} -inline bool operator!=(char const* s1,String s2) { - return String(s2) !=s1; -} - - -inline String -operator + (String s1, String s2) -{ - s1 += s2; - return s1; -} - -inline ostream & -operator << ( ostream& os, String d ) -{ - d.print_on(os); - return os; -} - - -// String quoteString(String message, String quote); - -#endif diff --git a/flower/lib/include/text-db.hh b/flower/lib/include/text-db.hh deleted file mode 100644 index 3535a84f8f..0000000000 --- a/flower/lib/include/text-db.hh +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef TEXTDB_HH -#define TEXTDB_HH - -#include "data-file.hh" - -/**a "const" Array. Contents can't be changed. do "#" comments, read quote enclosed fields */ - -class Text_record : Array -{ - int line_no; - String filename; - -public: - Text_record() { } // needed because of other ctor - - /// report an error in this line. - message(String s) { - cerr << '\n'<< filename << ": "<< line_no << s << "\n"; - } - String operator[](int j) { - return Array::operator[](j); - } - - Text_record(Array s, String fn, int j) : Array(s) { - filename = fn; line_no = j; - } - Array::size; -}; - -/** abstraction for a datafile. - add a subrec/fieldsep/record separator - */ - -class Text_db : private Data_file -{ - void gobble_leading_white(); -public: - /// get a line with records - Text_record get_record(); - - Text_db(String fn):Data_file(fn) { } - Data_file::error; - bool eof(); - - /// get next line. - Text_record operator++(int) { - return get_record(); - } - /// are we done yet? - operator bool() { - return !eof(); - } -}; - -#endif diff --git a/flower/lib/include/text-stream.hh b/flower/lib/include/text-stream.hh deleted file mode 100644 index 437f8698c7..0000000000 --- a/flower/lib/include/text-stream.hh +++ /dev/null @@ -1,74 +0,0 @@ - -#ifndef TEXTSTR_HH -#define TEXTSTR_HH - -#include -#include -#include "string.hh" -#include "varray.hh" - -/** - line counting input stream. - a stream for textfiles. linecounting. Thin interface getchar and - ungetchar. (ungetc is unlimited) - - should protect get and unget against improper use -*/ - - -class Text_stream -{ - int line_no; - - // could just have used streams. - FILE *f; - Array pushback; - String name; - - public: - Text_stream(String fn); - String get_name() { return name; } - bool eof() { - return feof(f); - } - bool eol() { - return (peek() == '\n'); - } - char peek() { - char c = get(); - unget(c); - return c; - } - int line(){ - return line_no; - } - - char get() { - char c; - - if (pushback.empty()) - c = getc(f); - else - c = pushback.pop(); - - if (c =='\n') - line_no++; - return c; - } - void unget(char c) { - if (c =='\n') - line_no--; - pushback.push(c); - } - ~Text_stream (){ - if (!eof()) - cerr <<__FUNCTION__<< ": closing unended file"; - - fclose(f); - } - - /// GNU format message. - void message(String s); -}; - -#endif diff --git a/flower/lib/include/unionfind.hh b/flower/lib/include/unionfind.hh deleted file mode 100644 index fbaa51e731..0000000000 --- a/flower/lib/include/unionfind.hh +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef UNIONFIND_HH -#define UNIONFIND_HH -#include "varray.hh" - -/* - which points of a graph are connected?. - Union find, a standard algorithm: - - Union_find represents an undirected graph of N points. You can - connect two points using #connect()#. #find(i)# finds a uniquely - determined representant of the equivalence class of points - connected to #i#. - - */ -struct Union_find { - void connect(int i, int j); - int find(int i); - bool equiv(int i, int j) { return find(i) == find(j); } - Union_find(int sz); - -private: - Array classes; - -}; -#endif diff --git a/flower/lib/include/varray.hh b/flower/lib/include/varray.hh deleted file mode 100644 index febf3e7601..0000000000 --- a/flower/lib/include/varray.hh +++ /dev/null @@ -1,186 +0,0 @@ -/* - (c) Han-Wen Nienhuys 1995,96 - - Distributed under GNU GPL -*/ - -#ifndef ARRAY_H -#define ARRAY_H -#include - -/// copy a bare (C-)array from #src# to #dest# sized #count# -template -inline void arrcpy(T*dest, T*src, int count) { - for (int i=0; i < count ; i++) - *dest++ = *src++; -} - - -/** - Scaleable array/stack template, for a type T with default constructor. - - - This template implements a scaleable vector. With (or without) range - checking. It may be flaky for objects with complicated con- and - destructors. The type T should have a default constructor. It is - best suited for simple types, such as int, double or String, it - provides a paranoidly safe replacement for the new T[int] construct. - - It uses stack terminology, (push, pop, top), and can be used as a stack. - - - */ -template -class Array { -protected: - /// maximum length of array. - int max; - - /// the data itself - T *thearray; - - /// stretch or shrink array. - void remax(int newmax) { - T* newarr = new T[newmax]; - size_ = (newmax < size_) ? newmax : size_; - arrcpy(newarr, thearray, size_); - - delete[] thearray; - thearray = newarr; - max = newmax; - } - int size_; - -public: - /// check invariants - void OK() const { - assert(max >= size_ && size_ >=0); - if (max) assert(thearray); - } - /** report the size_. - @see {setsize_} - */ - int size() const { return size_; } - - /// POST: size() == 0 - void clear() { size_ = 0; } - - Array() { thearray = 0; max =0; size_ =0; } - - - /** set the size_ to #s#. - POST: size() == s. - Warning: contents are unspecified */ - void set_size(int s) { - if (s >= max) remax(s); - size_ = s; - } - - ~Array() { delete[] thearray; } - - /// return a "new"ed copy of array - T* copy_array() const { - T* Tarray = new T[size_]; - arrcpy(Tarray, thearray, size_); - return Tarray; - } - // depracated - operator T* () const { - return copy_array(); - } - void operator=(Array const & src) { - set_size (src.size_); - arrcpy(thearray,src.thearray, size_); - } - Array(const Array & src) { - thearray = src.copy_array(); - max = size_ = src.size_; - } - - /// tighten array size_. - void precompute () { remax(size_); } - - /// this makes Array behave like an array - T &operator[] (const int i) const { - assert(i >=0&&i=0 && j<= size_); - set_size(size_+1); - for (int i=size_-1; i > j; i--) - thearray[i] = thearray[i-1]; - thearray[j] = k; - } - void del(int i) { - assert(i >=0&& i < size_); - arrcpy(thearray+i, thearray+i+1, size_-i-1); - size_--; - } - // quicksort. - void sort (int (*compare)( T const&,T const&), - int lower = -1, int upper = -1 ) { - if (lower < 0) { - lower = 0 ; - upper = size()-1; - } - if (lower >= upper) - return; - swap(lower, (lower+upper)/2); - int last = lower; - for (int i= lower +1; i <= upper; i++) - if (compare(thearray[i], thearray[lower]) < 0 ) - swap( ++last,i); - swap(lower, last); - sort(compare, lower, last-1); - sort(compare, last+1, upper); - } - void concat(Array const &src) { - int s = size_; - set_size(size_ + src.size_); - arrcpy(thearray+s,src.thearray, src.size_); - } - Array subvec(int lower, int upper) { - assert(lower >= 0 && lower <=upper&& upper <= size_); - Array r; - int s =upper-lower; - r.set_size(s); - arrcpy(r.thearray, thearray + lower, s); - return r; - } -}; - -#endif diff --git a/flower/lib/include/vector.hh b/flower/lib/include/vector.hh deleted file mode 100644 index 4d91397cc6..0000000000 --- a/flower/lib/include/vector.hh +++ /dev/null @@ -1,111 +0,0 @@ -#ifndef VECTOR_HH -#define VECTOR_HH - -#include -#include "real.hh" -#include "varray.hh" - -class Dstream; -class String; -void set_matrix_debug(Dstream&ds); - -/** a row of numbers. - a vector. Storage is handled in Array, Vector only does the mathematics. - */ -class Vector { - Array dat; -public: - void OK() const { dat.OK();} - int dim() const { return dat.size(); } - Vector() { } - Vector(Array d ); - Vector(const Vector&n); - Vector(int n) { - dat.set_size(n); - fill(0); - } - void insert(Real v, int i) { - dat.insert(v,i); - } - void del(int i) { dat.del(i); } - operator String() const; - void fill(Real r) { - for (int i=0; i < dim(); i++) - dat[i] =r; - } - - void operator +=(Vector v) { - assert(v.dim() == dim()); - for (int i=0; i < dim(); i++) - dat[i] += v.dat[i]; - } - - void operator /=(Real a) { - (*this) *= 1/a; - } - - void operator *=(Real a) { - for (int i=0; i < dim(); i++) - dat[i] *= a; - } - - void operator -=(Vector v) { - assert(v.dim() == dim()); - for (int i=0; i < dim(); i++) - dat[i] -= v(i); - } - - Real &operator()(int i) { return dat[i]; } - Real operator()(int i) const { return dat[i]; } - Real elem(int i) { return dat[i]; } - Real operator *(Vector v) const { - Real ip=0; - assert(v.dim() == dim()); - for (int i=0; i < dim(); i++) - ip += dat[i] *v(i); - return ip; - } - Vector operator-() const; - Real norm() { - return sqrt(norm_sq() ); - } - Real norm_sq() { - return ((*this) * (*this)); - } - operator Array () { return dat; } - void print() const; - /// set to j-th element of unit-base - void set_unit(int j) ; -}; - -inline Vector -operator+(Vector a, Vector const &b) { - a += b; - return a; -} - -inline Vector -operator-(Vector a, Vector const &b) { - a -= b; - return a; -} - -inline Vector -operator*(Vector v, Real a) { - v *= a; - return v; -} - -inline Vector -operator*( Real a,Vector v) { - v *= a; - return v; -} - -inline Vector -operator/(Vector v,Real a) { - v *= 1/a; - return v; -} - -#endif diff --git a/flower/lib/include/vsmat.hh b/flower/lib/include/vsmat.hh deleted file mode 100644 index 283b1e567b..0000000000 --- a/flower/lib/include/vsmat.hh +++ /dev/null @@ -1,141 +0,0 @@ -#ifndef VSMAT_HH -#define VSMAT_HH -#include "varray.hh" -#include "real.hh" -/** base class for interface with matrix storageclasses. There are no - iterators for matrixclasses, since matrices are (like arrays) - explicitly int-indexed. - - Iteration is provided by *_next, *_ok, which update and check both - index variables simultaneously. - - TODO - determine type of product matrix. - -*/ -class virtual_smat { - - -public: - /// check invariants - virtual void OK() const=0; - - /// height of matrix - virtual int rows() const = 0; - - /// width of matrix - virtual int cols() const = 0; - - - /** set the size. contents lost. - PRE - i >=0, j>=0 - */ - virtual void set_size(int i, int j) = 0; - - /**set the size to square dimen. contents lost - PRE - i>=0 - */ - virtual void set_size(int i) = 0; - /**set the size to i. - - keep contents. If enlarged contents unspecified - - PRE - i>=0, j>=0 - - */ - virtual void resize(int i, int j) = 0; - - /** - set the size to square dimen. contents kept - Keep contents. If enlarged contents are unspecified - - PRE - i>=0 - */ - virtual void resize(int i) = 0; - - - /** - access an element. - - Generate an errormessage, if this happens - in the 0-part of a sparse matrix. - */ - - virtual Real& elem(int i,int j) = 0; - - /// access a element, no modify - virtual const Real& elem(int i, int j) const = 0; - -#if 1 - virtual Array row(int i) const = 0; - virtual Array column(int j) const = 0; -#endif - - - /** - add a row to the matrix before row k. Contents - of added row are unspecified - - 0 <= k <= rows() - */ - virtual void insert_row(int k)=0; - - - /** - delete a row from this matrix. - - PRE - 0 <= k < rows(); - */ - virtual void delete_row(int k)=0; - virtual void delete_column(int k)=0; - virtual ~virtual_smat() { } - virtual virtual_smat *clone()=0; - - - - /** - at end of matrix?. when doing loop - - for(i=0; i - */ -#include -#include -#include -#include "lgetopt.hh" - -long -Getopt_long::intarg() -{ - long l; - if (sscanf(optarg, "%ld", &l) != 1) - report(E_ILLEGALARG); - - return l; -} - -Long_option_init * -Getopt_long::parselong() -{ - const char *optnm = argv[optind] + 2 ; - assert(*optnm); - - char *endopt = strchr(optnm, '='); - int searchlen = (endopt) ? endopt - optnm : strlen(optnm); - - beet=0; - for (int i=0; i< table_len; i++) { - const char *ln = the_opts[i].longname; - - if (ln && !strncmp(ln, optnm, searchlen)) { - beet = the_opts+i; - break; - } - } - - if (!beet) { - report(E_UNKNOWNOPTION); - return 0; - } - optind++; - optindind = 0; - - - if (beet->take_arg) { - if (endopt) - optarg = endopt +1; // a '=' - else { - optarg = argv[optind]; - optind++; - } - if (!optarg) - report(E_ARGEXPECT); - - } else { - optarg = 0; - if (endopt) - report(E_NOARGEXPECT); - } - - return beet; -} - - -ostream & -Long_option_init::printon(ostream &errorout) -{ - if (shortname) - errorout <<"-" << shortname; - if (shortname && longname) - errorout << ", "; - if (longname) - errorout << "`--" << longname << "'"; - return errorout; -} - -// report an error, GNU style. -void -Getopt_long::report(Errorcod c) -{ - error = c; - if (!errorout) - return; - - *errorout << argv[0] << ": "; - switch (c) { - case E_ARGEXPECT: - *errorout<< "option "; - beet->printon(*errorout); - *errorout << "requires an argument"<longname << "' does not allow an argument"<printon(*errorout); - *errorout << '\n'; - default: - assert(false); - } - exit(2); -} - -Long_option_init * -Getopt_long::parseshort() -{ - char c=argv[optind][optindind]; - beet=0; - assert(c); - - for (int i=0; i < table_len; i++) - if (the_opts[i].shortname == c) { - beet = the_opts+i; - break; - } - - if (!beet){ - report(E_UNKNOWNOPTION); - return 0; - } - - optindind++; - if (!beet->take_arg){ - optarg = 0; - return beet; - } - optarg = argv[optind] + optindind; - - optind ++; - optindind = 0; - - if (!optarg[0]) { - optarg = argv[optind]; - optind ++; - } - if (!optarg) { - report(E_ARGEXPECT); - } - - return beet; -} - -Long_option_init * -Getopt_long::operator()() { - if (!next()) - return 0; - - if (optindind) - return parseshort(); - - if (argv[optind][0] != '-') - return 0; - - if (argv[optind][1] == '-') {// what to do with "command -- bla" - return parselong(); - } else { - optindind = 1; - return parseshort(); - } -} - -Getopt_long::Getopt_long(int c, char **v, Long_option_init *lo) -{ - the_opts = lo; - errorout = &cerr; - argv = v; - argc = c; - optind = 1; - optindind = 0; - - // reached end of option table? - int i; - for (i = 0; the_opts[i].longname ||the_opts[i].shortname; i++) - ; - table_len = i; -} - -bool -Getopt_long::next() -{ - - error = E_NOERROR; - while (optind < argc && !argv[optind][optindind]) { - optind++; - optindind = 0; - } - return (optind < argc); -} - -char * -Getopt_long::current_arg() -{ - if (optind >= argc) - return 0; - char * a = argv[optind]; - return a + optindind; -} - -char * -Getopt_long::get_next_arg() -{ - char * a = current_arg(); - if ( a) { - optind ++; - optindind = 0; - } - return a; -} diff --git a/flower/lib/libc-extension.cc b/flower/lib/libc-extension.cc deleted file mode 100644 index 3a89e81008..0000000000 --- a/flower/lib/libc-extension.cc +++ /dev/null @@ -1,113 +0,0 @@ -/* - libc-extension.cc -- implement some string.h extensions - - source file of the flowerlib - - (c) 1997 Han-Wen Nienhuys -*/ -#include -#include -#include -#include "libc-extension.hh" - -/* - compensate for lacking libc functions. - */ -char* -strnlwr( char* start_l ,int n) -{ - char * p = start_l + n; - while ( --p >= start_l) { - *p = tolower( *p ); /* a macro on some compilers */ - } - return start_l; -} - -char* -strnupr( char* start_l, int n) -{ - char * p = start_l + n; - while ( --p >= start_l) { - *p = toupper( *p ); /* a macro on some compilers */ - } - return start_l; -} - -#ifndef HAVE_MEMMEM - -/** locate a substring. #memmem# finds the first occurrence of - #needle# in #haystack# - */ - -char * -memmem(const Byte * haystack, int haystack_len, - const Byte *needle,int needle_len) -{ - const Byte * end_haystack = haystack + haystack_len - needle_len; - const Byte * end_needle = needle + needle_len ; - - /* Ahhh ... Some minimal lowlevel stuff. This *is* nice; Varation - is the spice of life */ - while (haystack < end_haystack) { - const Byte *subneedle_l = needle; - const Byte *subhaystack_l = haystack; - while (subneedle_l < end_needle) { - if (*subneedle_l++ != *subhaystack_l++) - goto next; // yeah. I should be prosecuted. - } - - // completed the needle. Gotcha. - return (char*) haystack; - next: - haystack++; - } - return 0; -} -#endif - -Byte * -memrchr(const Byte * p, int n, char c) -{ - const Byte * q = p+n; - while (q > p) { - if (*--q == c) - return (Byte*)q; - } - return 0; -} - - -template -inline void -my_swap(T &t1, T &t2, T &tmp) -{ - tmp = t1; - t1 = t2; - t2 = tmp; -} - -Byte* -strrev( Byte* byte_l, int length_i ) -{ - Byte tmp_byte; - - Byte* left_l = byte_l; - Byte* right_l = byte_l + length_i; - - while ( right_l > left_l ) { - my_swap(*right_l-- , *left_l++ , tmp_byte); - } - return byte_l; -} - -#ifndef HAVE_SNPRINTF -int snprintf ( char *str, size_t, - const char *format, ... ) -{ - va_list ap; - va_start(ap, format); - int i = vsprintf(str, format, ap); - va_end(ap); - return i; -} -#endif diff --git a/flower/lib/matdebug.cc b/flower/lib/matdebug.cc deleted file mode 100644 index bcc2843bca..0000000000 --- a/flower/lib/matdebug.cc +++ /dev/null @@ -1,63 +0,0 @@ -#include "dstream.hh" -#include "matrix.hh" - -static Dstream *dout = 0; - -/** - Set the debugging output. Will not delete/swallow argument. - */ -void set_matrix_debug(Dstream&ds) -{ - dout = &ds; -} - -Matrix::operator String() const -{ - String s; -#ifndef NPRINT - s="matrix {\n"; - for (int i=0; i< rows(); i++){ - for (int j = 0; j < cols(); j++) { - s+= String(dat->elem(i,j), "%6f "); - } - s+="\n"; - } - s+="}\n"; -#endif - return s; -} - - -void -Matrix::print() const -{ -#ifndef NPRINT - if (!dout) - return; - *dout << *this; -#endif -} - -Vector::operator String() const -{ - String s; -#ifndef NPRINT - s="vector ["; - for (int i=0; i < dim(); i++) { - s += String(dat[i], "%6f") + String(' '); - } - s+="]"; -#endif - return s; -} - - -void -Vector::print() const -{ -#ifndef NDEBUG - if (!dout) - return; - *dout << *this<<'\n'; -#endif -} diff --git a/flower/lib/matrix.cc b/flower/lib/matrix.cc deleted file mode 100644 index 63bd85a33c..0000000000 --- a/flower/lib/matrix.cc +++ /dev/null @@ -1,240 +0,0 @@ -#include "matrix.hh" - -Real -Matrix::norm() const -{ - Real r =0.0; - for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j)) - r += sqr(dat->elem(i,j)); - return sqrt(r); -} - -void -Matrix::fill(Real r) -{ - for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j)) - dat->elem(i,j)=r; -} - -void -Matrix::set_diag(Real r) -{ - for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j)) - dat->elem(i,j)=(i==j) ? r: 0.0; -} - -void -Matrix::set_diag(Vector d) -{ - for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j)) - dat->elem(i,j)=(i==j) ? d(i): 0.0; -} - -void -Matrix::operator+=(const Matrix&m) -{ - assert(m.cols() == cols()); - assert(m.rows() == rows()); - for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j)) - dat->elem(i,j) += m(i,j); -} - -void -Matrix::operator-=(const Matrix&m) -{ - assert(m.cols() == cols()); - assert(m.rows() == rows()); - for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j)) - dat->elem(i,j) -= m(i,j); -} - - -void -Matrix::operator*=(Real a) -{ - for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j)) - dat->elem(i,j) *= a; -} - -void -Matrix::operator=(const Matrix&m) -{ - if (&m == this) - return ; - delete dat; - dat = m.dat->clone(); -} - -Matrix::Matrix(const Matrix &m) -{ - m.OK(); - - dat = m.dat->clone(); -} - - -Matrix::Matrix(int n, int m) -{ - dat = virtual_smat::get_full(n,m); - fill(0); -} - -Matrix::Matrix(int n) -{ - dat = virtual_smat::get_full(n,n); - fill(0); -} - -Matrix::Matrix(Vector v, Vector w) -{ - dat = virtual_smat::get_full(v.dim(), w.dim()); - for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j)) - dat->elem(i,j)=v(i)*w(j); -} - - -Vector -Matrix::row(int k) const -{ - int n=cols(); - - - Vector v(n); - for(int i=0; i < n; i++) - v(i)=dat->elem(k,i); - - return v; -} - -Vector -Matrix::col(int k) const -{ - int n=rows(); - Vector v(n); - for(int i=0; i < n; i++) - v(i)=dat->elem(i,k); - return v; -} - -Vector -Matrix::left_multiply(const Vector& v) const -{ - Vector dest(v.dim()); - assert(dat->cols()==v.dim()); - for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j)) - dest(i)+= dat->elem(j,i)*v(j); - return dest; -} - -Vector -Matrix::operator *(const Vector& v) const -{ - Vector dest(rows()); - assert(dat->cols()==v.dim()); - for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j)) - dest(i)+= dat->elem(i,j)*v(j); - return dest; -} - -Matrix -operator /(Matrix const& m1,Real a) -{ - Matrix m(m1); - m /= a; - return m; -} - -void -Matrix::transpose() // delegate to storage? -{ - for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j)) { - if (i >= j) - continue; - Real r=dat->elem(i,j); - dat->elem(i,j) = dat->elem(j,i); - dat->elem(j,i)=r; - } -} - -Matrix -Matrix::operator-() const -{ - OK(); - Matrix m(*this); - m*=-1.0; - return m; -} - -Matrix -Matrix::transposed() const -{ - Matrix m(*this); - m.transpose(); - return m; -} - - -/* should do something smarter: bandmatrix * bandmatrix is also banded matrix. */ -Matrix -operator *(const Matrix &m1, const Matrix &m2) -{ - Matrix result(m1.rows(), m2.cols()); - result.set_product(m1,m2); - return result; -} - -void -Matrix::set_product(const Matrix &m1, const Matrix &m2) -{ - assert(m1.cols()==m2.rows()); - assert(cols()==m2.cols() && rows()==m1.rows()); - - for (int i=0, j=0; dat->mult_ok(i,j); - dat->mult_next(i,j)) { - Real r=0.0; - for (int k = 0; k < m1.cols(); k++) - r += m1(i,k)*m2(k,j); - dat->elem(i,j)=r; - } -} - -void -Matrix::insert_row(Vector v, int k) -{ - assert(v.dim()==cols()); - dat->insert_row(k); - for (int j=0; j < cols(); j++) - dat->elem(k,j)=v(j); -} - - -void -Matrix::swap_columns(int c1, int c2) -{ - assert(c1>=0&& c1 < cols()&&c2 < cols() && c2 >=0); - for (int i=0; i< rows(); i++) { - Real r=dat->elem(i,c1); - dat->elem(i,c1) = dat->elem(i,c2); - dat->elem(i,c2)=r; - } -} - -void -Matrix::swap_rows(int c1, int c2) -{ - assert(c1>=0&& c1 < rows()&&c2 < rows() && c2 >=0); - for (int i=0; i< cols(); i++) { - Real r=dat->elem(c1,i); - dat->elem(c1,i) = dat->elem(c2,i); - dat->elem(c2,i)=r; - } -} - - -int -Matrix::dim() const -{ - assert(cols() == rows()); - return rows(); -} - diff --git a/flower/lib/path.cc b/flower/lib/path.cc deleted file mode 100644 index c79962f00f..0000000000 --- a/flower/lib/path.cc +++ /dev/null @@ -1,77 +0,0 @@ -/* - path.cc - manipulation of paths and filenames. -*/ -#include -#include "path.hh" - -#ifndef PATHSEP -#define PATHSEP '/' -#endif - -/** - @param path the original full filename - @return 4 components of the path. They can be empty -*/ -void -split_path(String path, - String &drive, String &dirs, String &filebase, String &extension) -{ - // peel off components, one by one. - int di = path.index_i(':'); - if (di >= 0) - { - drive = path.left_str(di + 1); - path = path.right_str(path.len() - di -1); - } - else - drive = ""; - - di = path.index_last_i(PATHSEP); - if (di >=0) - { - dirs = path.left_str(di + 1); - path = path.right_str(path.len()-di -1); - } - else - dirs = ""; - - di = path.index_last_i('.'); - if (di >= 0) - { - filebase = path.left_str(di); - extension =path.right_str(path.len()-di); - } - else - { - extension = ""; - filebase = path; - } -} - -File_path::File_path(String pref) -{ - add("."); - add(pref); -} - - -/** find a file. - It will search in the current dir, in the construction-arg, and - in any other added path, in this order. - */ -String -File_path::find(String nm) -{ - for (int i=0; i < size(); i++) { - String path = (*this)[i]; - path+= "/"+nm; - - - FILE *f = fopen(path, "r"); // ugh! - if (f) { - fclose(f); - return path; - } - } - return ""; -} diff --git a/flower/lib/scalar.cc b/flower/lib/scalar.cc deleted file mode 100644 index 5edd9e997f..0000000000 --- a/flower/lib/scalar.cc +++ /dev/null @@ -1,57 +0,0 @@ -#include -#include -#include "scalar.hh" - -Scalar::Scalar(Rational r) - :String(r) -{ - -} - -Scalar::operator Rational() -{ - int p = index_i('/'); - if (p == -1) - return int(*this); - - String s2 = right_str(len()-p-1); - String s1 = left_str(p); - - return Rational(s1.value_i(), s2.value_i()); -} - -bool -Scalar::isnum() -{ - int conv = false; - if (len()) { - long l =0; - conv = sscanf(strh_.ch_c_l(), "%ld", &l); - } - return len() && conv; -} - -Scalar::operator Real() -{ - assert (isnum()); - return value_f(); -} - -Scalar::operator int() -{ - assert (isnum()); - return value_i(); -} - - -Scalar::operator bool() const -{ - if (!len()) - return false; - if (*this == "0") - return false; - String u (*this); - if ( u.upper_str() == "FALSE") - return false; - return true; -} diff --git a/flower/lib/smat.cc b/flower/lib/smat.cc deleted file mode 100644 index dcc61ce44e..0000000000 --- a/flower/lib/smat.cc +++ /dev/null @@ -1,181 +0,0 @@ -#include "smat.hh" - -void -Full_storage::operator=(Full_storage const &fs) -{ - resize(fs.h, fs.w); - OK(); - fs.OK(); - for (int i=0; i= h && maxw >= w); - assert(h >= 0 && w >= 0); - assert(els||!maxh); -#endif -} -void -Full_storage::resize_cols(int newh) -{ - if (newh <= maxh) { - h=newh; - return; - } - - Real ** newa=new Real*[newh]; - int j=0; - for (; j < h; j++) - newa[j] = els[j]; - for (; j < newh; j++) - newa[j] = new Real[maxw]; - delete[] els; - els=newa; - - h = maxh = newh; -} - -void -Full_storage::resize_rows(int neww) -{ - if (neww <= maxw) { - w=neww; - return; - } - for (int i=0; i < maxh ; i++) { - Real* newa = new Real[neww]; - for (int k=0; k < w; k++) - newa[k] = els[i][k]; - - delete[] els[i]; - els[i] = newa; - } - w = maxw = neww; -} - -Full_storage::~Full_storage() { - for (int i=0; i < maxh; i++) - delete [] els[i]; - delete[] els; -} - -void -Full_storage::resize(int rows, int cols) -{ - OK(); - resize_cols(rows); - resize_rows(cols); - -} - - -bool -Full_storage::mult_ok(int i, int j) const -{ - return valid(i,j); -} - -bool -Full_storage::trans_ok(int i, int j) const -{ - return valid(i,j); -} - - -void -Full_storage::trans_next(int &i, int &j) const -{ - assert(trans_ok(i,j)); - i++; - if (i >= h) { - i=0; - j ++; - } -} - -void -Full_storage::mult_next(int &i, int &j) const -{ - assert(mult_ok(i,j)); - j++; - if (j >= w) { - j=0; - i++; - } -} - -void -Full_storage::delete_column(int k) -{ - assert(0 <= k &&k k ; i--) - for (int j=0; j -Full_storage::row(int n) const -{ - Array r; - for (int j = 0; j < w; j++) - r.push(els[n][j]); - return r; -} - -Array -Full_storage::column(int n) const -{ - - Array r; - for (int i = 0; i -#include -#include "libc-extension.hh" -#include "string.hh" -#include "string-convert.hh" - -/** - a safe length for stringconversion buffers - - worst case would be %f printing HUGE (or 1/HUGE), which is approx - 2e318, this number would have approx 318 zero's in its string. - - Should enlarge buff dynamically. - @see - man 3 snprintf - */ -static const int STRING_BUFFER_LEN=1024; - -String -String_convert::bin2hex_str( String bin_str ) -{ - String str; - Byte const* byte_c_l = bin_str.byte_c_l(); - for ( int i = 0; i < bin_str.length_i(); i++ ) { - str += (char)nibble2hex_byte( *byte_c_l >> 4 ); - str += (char)nibble2hex_byte( *byte_c_l++ ); - } - return str; -} - -int -String_convert::bin2_i( String bin_str ) -{ - assert( bin_str.length_i() <= 4 ); - - int result_i = 0; - for ( int i = 0; i < bin_str.length_i(); i++ ) { - result_i <<= 8; - result_i += (Byte)bin_str[ i ]; - } - return result_i; -} - -// breendet imp from String -int -String_convert::dec2_i( String dec_str ) -{ - if ( !dec_str.length_i() ) - return 0; - - long l = 0; - int conv = sscanf( dec_str.ch_c_l(), "%ld", &l ); - assert( conv ); - - return (int)l; -} - -String -String_convert::i64_str( I64 i64, char const* fmt) -{ - char buffer[STRING_BUFFER_LEN]; - snprintf(buffer, STRING_BUFFER_LEN, - (fmt ? fmt : "%Ld"), i64 ); // assume radix 10 - return String(buffer); - -} -// breendet imp from String -double -String_convert::dec2_f( String dec_str ) -{ - if ( !dec_str.length_i() ) - return 0; - double d = 0; - int conv = sscanf( dec_str.ch_c_l(), "%lf", &d ); - assert( conv ); - return d; -} - -int -String_convert::hex2bin_i( String hex_str, String& bin_str_r ) -{ - if ( hex_str.length_i() % 2 ) - hex_str = "0" + hex_str; - - bin_str_r = ""; - Byte const* byte_c_l= hex_str.byte_c_l(); - int i = 0; - while ( i < hex_str.length_i() ) { - int high_i = hex2nibble_i( *byte_c_l++ ); - int low_i = hex2nibble_i( *byte_c_l++ ); - if ( high_i < 0 || low_i < 0 ) - return 1; // illegal char - bin_str_r += String( (char)( high_i << 4 | low_i ), 1 ); - i += 2; - } - return 0; -} - -String -String_convert::hex2bin_str( String hex_str ) -{ - String str; -// silly, asserts should alway be "on"! -// assert( !hex2bin_i( hex_str, str ) ); - int error_i = hex2bin_i( hex_str, str ); - assert( !error_i ); - return str; -} - -int -String_convert::hex2nibble_i( Byte byte ) -{ - if ( byte >= '0' && byte <= '9' ) - return byte - '0'; - if ( byte >= 'A' && byte <= 'F' ) - return byte - 'A' + 10; - if ( byte >= 'a' && byte <= 'f') - return byte - 'a' + 10; - return -1; -} - -// stupido. Should use int_str() -String -String_convert::i2dec_str( int i, int length_i, char ch ) -{ - char fill_ch = ch; - if ( fill_ch) - fill_ch = '0'; - - // ugh - String dec_str( i ); - - // ugh - return String( fill_ch, length_i - dec_str.length_i() ) + dec_str; -} - - -// stupido. Should use int_str() -String -String_convert::u2hex_str( unsigned u, int length_i, char fill_ch ) -{ - String str; - if ( !u ) - str = "0"; - -#if 1 // both go... - while ( u ) { - str = String( (char)( ( u % 16 )["0123456789abcdef"] ) ) + str; - u /= 16; - } -#else - str += int_str( u, "%x" ); -#endif - - str = String( fill_ch, length_i - str.length_i() ) + str; - while ( ( str.length_i() > length_i ) && ( str[ 0 ] == 'f' ) ) - str = str.mid_str( 2, INT_MAX ); - - return str; -} - -String -String_convert::i2hex_str( int i, int length_i, char fill_ch ) -{ - return u2hex_str( (unsigned)i, length_i, fill_ch ); -} - -Byte -String_convert::nibble2hex_byte( Byte byte ) -{ - if ( ( byte & 0x0f ) <= 9 ) - return ( byte & 0x0f ) + '0'; - else - return ( byte & 0x0f ) - 10 + 'a'; -} -/** - Convert an integer to a string - - @param - #fmt# is a printf style format, default assumes "%d" as format. - */ -String -String_convert::int_str(int i, char const* fmt) -{ - char buffer[STRING_BUFFER_LEN]; - snprintf(buffer, STRING_BUFFER_LEN, - (fmt ? fmt : "%d"), i ); // assume radix 10 - return String(buffer); -} - -/** - Convert a double to a string. - - @param #fmt# is a printf style format, default assumes "%lf" as format - */ -String -String_convert::double_str(double f, char const* fmt) -{ - char buf[STRING_BUFFER_LEN]; - - snprintf(buf, STRING_BUFFER_LEN, fmt ? fmt : "%f", f); - return buf; -} - -/** - Make a string from a single character. - - @param - #n# is a repetition count, default value is 1 - */ -String -String_convert::char_str(char c, int n) -{ - n = n >= 0 ? n : 0; - char* ch_p = new char[ n ]; - memset( ch_p, c, n ); - String s((Byte*)ch_p, n); - delete ch_p; - return s; -} - -String -String_convert::rational_str(Rational r) -{ - char * n = Itoa(r.numerator()); // LEAK???? - - String s = n; - if (r.denominator() != 1) { - char * d = Itoa(r.denominator()); - s += String( '/' ) + String(d); - //delete d; - } -/* delete n; - */ - return s; -} - -String -String_convert::pointer_str(const void *l) -{ - I64 i64 = (I64)l; - return String_convert::i64_str(i64, "0x%0Lx"); -} diff --git a/flower/lib/stringtest.cc b/flower/lib/stringtest.cc deleted file mode 100644 index 0bbde77c99..0000000000 --- a/flower/lib/stringtest.cc +++ /dev/null @@ -1,118 +0,0 @@ -#ifdef STRING_TEST -/* - stupid test program to verify stringlib - stringtest.cc - */ -#include -#include "string.hh" -#include "varray.hh" -#include "string-convert.hh" - -void -ctors() -{ - cout << "constructors"< a; - a.push("abcd"); - a.push("zxy"); - a.push("abc"); - a.push(""); - a.sort(String::compare_i); - cout << "compares: "< -*/ - -#ifdef STRING_DEBUG -#include -#include -void* -mymemmove( void* dest, void const* src, size_t n ) -{ - return memcpy( dest, src, n ); // wohltempererit: 69006 -} -#define memmove mymemmove -#endif - -#ifdef STRING_UTILS_INLINED -#undef STRING_UTILS_INLINED -#endif - -#ifdef INLINE -#undef INLINE -#endif - -#define INLINE - -#include "string-handle.hh" -#include "string-data.hh" -#include "string-data.inl" -#include "string-handle.inl" diff --git a/flower/lib/text-db.cc b/flower/lib/text-db.cc deleted file mode 100644 index ebfc992ff2..0000000000 --- a/flower/lib/text-db.cc +++ /dev/null @@ -1,48 +0,0 @@ -#include "text-db.hh" -bool -Text_db::eof() -{ - Data_file::gobble_leading_white(); - return Data_file::eof(); -} - -void -Text_db::gobble_leading_white() -{ - while (1) { - Data_file::gobble_leading_white(); - if (eof()) - return ; - char c; - if ((c = data_get()) !='\n'){ - data_unget (c); - return ; - } - } -} - - -Text_record -Text_db::get_record() -{ - while (1) { - String s; - Array fields; - assert(!eof()); - - while ((s = get_word()) != "") - { - fields.push(s); - gobble_white(); - } - - - if (get_line() != "") - assert(false); - - assert (fields.size()); - return Text_record(fields, get_name(), line()); - } -} - - diff --git a/flower/lib/text-stream.cc b/flower/lib/text-stream.cc deleted file mode 100644 index a2d3e4b119..0000000000 --- a/flower/lib/text-stream.cc +++ /dev/null @@ -1,31 +0,0 @@ -#include "text-stream.hh" - -Text_stream::Text_stream(String fn) -{ - ios::sync_with_stdio(); - if (fn == "") - { - name = ""; - f = stdin; - } - - else - { - name = fn; - f = fopen(fn, "r"); - } - - if (!f) { - cerr <<__FUNCTION__<< ": can't open `" << fn << "'\n"; - exit(1); - } - - line_no = 1; - } - -void -Text_stream::message(String s) -{ - cerr << "\n"< d) - : dat(d) -{ - -} -Vector::Vector(const Vector&n) - : dat(n.dat) -{ -} - -Vector -Vector::operator-() const -{ - Vector v(*this); - v*=-1; - return v; -} - -void -Vector::set_unit(int j) -{ - fill(0.0); - dat[j] = 1.0; -} diff --git a/flower/libc-extension.cc b/flower/libc-extension.cc new file mode 100644 index 0000000000..6e9a9b77a6 --- /dev/null +++ b/flower/libc-extension.cc @@ -0,0 +1,112 @@ +/* + libc-extension.cc -- compensate for lacking libc functions. + + + source file of the flowerlib + + (c) 1997 Han-Wen Nienhuys +*/ +#include +#include +#include +#include "libc-extension.hh" + + +char* +strnlwr( char* start_l ,int n) +{ + char * p = start_l + n; + while ( --p >= start_l) { + *p = tolower( *p ); /* a macro on some compilers */ + } + return start_l; +} + +char* +strnupr( char* start_l, int n) +{ + char * p = start_l + n; + while ( --p >= start_l) { + *p = toupper( *p ); /* a macro on some compilers */ + } + return start_l; +} + +#if !HAVE_MEMMEM + +/** locate a substring. #memmem# finds the first occurrence of + #needle# in #haystack# + */ + +char * +memmem(Byte const * haystack, int haystack_len, + Byte const *needle,int needle_len) +{ + Byte const * end_haystack = haystack + haystack_len - needle_len; + Byte const * end_needle = needle + needle_len ; + + /* Ahhh ... Some minimal lowlevel stuff. This *is* nice; Varation + is the spice of life */ + while (haystack < end_haystack) { + Byte const *subneedle_l = needle; + Byte const *subhaystack_l = haystack; + while (subneedle_l < end_needle) { + if (*subneedle_l++ != *subhaystack_l++) + goto next; // yeah. I should be prosecuted. + } + + // completed the needle. Gotcha. + return (char*) haystack; + next: + haystack++; + } + return 0; +} +#endif + +Byte * +memrchr(Byte const * p, int n, char c) +{ + const Byte * q = p+n; + while (q > p) { + if (*--q == c) + return (Byte*)q; + } + return 0; +} + + +template +inline void +my_swap(T &t1, T &t2, T &tmp) +{ + tmp = t1; + t1 = t2; + t2 = tmp; +} + +Byte* +strrev( Byte* byte_l, int length_i ) +{ + Byte tmp_byte; + + Byte* left_l = byte_l; + Byte* right_l = byte_l + length_i; + + while ( right_l > left_l ) { + my_swap(*right_l-- , *left_l++ , tmp_byte); + } + return byte_l; +} + +#if ! HAVE_SNPRINTF +int snprintf ( char *str, size_t, + char const *format, ... ) +{ + va_list ap; + va_start(ap, format); + int i = vsprintf(str, format, ap); + va_end(ap); + return i; +} +#endif diff --git a/flower/matdebug.cc b/flower/matdebug.cc new file mode 100644 index 0000000000..bcc2843bca --- /dev/null +++ b/flower/matdebug.cc @@ -0,0 +1,63 @@ +#include "dstream.hh" +#include "matrix.hh" + +static Dstream *dout = 0; + +/** + Set the debugging output. Will not delete/swallow argument. + */ +void set_matrix_debug(Dstream&ds) +{ + dout = &ds; +} + +Matrix::operator String() const +{ + String s; +#ifndef NPRINT + s="matrix {\n"; + for (int i=0; i< rows(); i++){ + for (int j = 0; j < cols(); j++) { + s+= String(dat->elem(i,j), "%6f "); + } + s+="\n"; + } + s+="}\n"; +#endif + return s; +} + + +void +Matrix::print() const +{ +#ifndef NPRINT + if (!dout) + return; + *dout << *this; +#endif +} + +Vector::operator String() const +{ + String s; +#ifndef NPRINT + s="vector ["; + for (int i=0; i < dim(); i++) { + s += String(dat[i], "%6f") + String(' '); + } + s+="]"; +#endif + return s; +} + + +void +Vector::print() const +{ +#ifndef NDEBUG + if (!dout) + return; + *dout << *this<<'\n'; +#endif +} diff --git a/flower/matrix.cc b/flower/matrix.cc new file mode 100644 index 0000000000..9d229c0ae1 --- /dev/null +++ b/flower/matrix.cc @@ -0,0 +1,240 @@ +#include "matrix.hh" + +Real +Matrix::norm() const +{ + Real r =0.0; + for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j)) + r += sqr(dat->elem(i,j)); + return sqrt(r); +} + +void +Matrix::fill(Real r) +{ + for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j)) + dat->elem(i,j)=r; +} + +void +Matrix::set_diag(Real r) +{ + for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j)) + dat->elem(i,j)=(i==j) ? r: 0.0; +} + +void +Matrix::set_diag(Vector d) +{ + for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j)) + dat->elem(i,j)=(i==j) ? d(i): 0.0; +} + +void +Matrix::operator+=(Matrix const &m) +{ + assert(m.cols() == cols()); + assert(m.rows() == rows()); + for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j)) + dat->elem(i,j) += m(i,j); +} + +void +Matrix::operator-=(Matrix const &m) +{ + assert(m.cols() == cols()); + assert(m.rows() == rows()); + for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j)) + dat->elem(i,j) -= m(i,j); +} + + +void +Matrix::operator*=(Real a) +{ + for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j)) + dat->elem(i,j) *= a; +} + +void +Matrix::operator=(Matrix const &m) +{ + if (&m == this) + return ; + delete dat; + dat = m.dat->clone(); +} + +Matrix::Matrix(Matrix const &m) +{ + m.OK(); + + dat = m.dat->clone(); +} + + +Matrix::Matrix(int n, int m) +{ + dat = virtual_smat::get_full(n,m); + fill(0); +} + +Matrix::Matrix(int n) +{ + dat = virtual_smat::get_full(n,n); + fill(0); +} + +Matrix::Matrix(Vector v, Vector w) +{ + dat = virtual_smat::get_full(v.dim(), w.dim()); + for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j)) + dat->elem(i,j)=v(i)*w(j); +} + + +Vector +Matrix::row(int k) const +{ + int n=cols(); + + + Vector v(n); + for(int i=0; i < n; i++) + v(i)=dat->elem(k,i); + + return v; +} + +Vector +Matrix::col(int k) const +{ + int n=rows(); + Vector v(n); + for(int i=0; i < n; i++) + v(i)=dat->elem(i,k); + return v; +} + +Vector +Matrix::left_multiply(Vector const & v) const +{ + Vector dest(v.dim()); + assert(dat->cols()==v.dim()); + for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j)) + dest(i)+= dat->elem(j,i)*v(j); + return dest; +} + +Vector +Matrix::operator *(Vector const & v) const +{ + Vector dest(rows()); + assert(dat->cols()==v.dim()); + for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j)) + dest(i)+= dat->elem(i,j)*v(j); + return dest; +} + +Matrix +operator /(Matrix const& m1,Real a) +{ + Matrix m(m1); + m /= a; + return m; +} + +void +Matrix::transpose() // delegate to storage? +{ + for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j)) { + if (i >= j) + continue; + Real r=dat->elem(i,j); + dat->elem(i,j) = dat->elem(j,i); + dat->elem(j,i)=r; + } +} + +Matrix +Matrix::operator-() const +{ + OK(); + Matrix m(*this); + m*=-1.0; + return m; +} + +Matrix +Matrix::transposed() const +{ + Matrix m(*this); + m.transpose(); + return m; +} + + +/* should do something smarter: bandmatrix * bandmatrix is also banded matrix. */ +Matrix +operator *(Matrix const &m1, Matrix const &m2) +{ + Matrix result(m1.rows(), m2.cols()); + result.set_product(m1,m2); + return result; +} + +void +Matrix::set_product(Matrix const &m1, Matrix const &m2) +{ + assert(m1.cols()==m2.rows()); + assert(cols()==m2.cols() && rows()==m1.rows()); + + for (int i=0, j=0; dat->mult_ok(i,j); + dat->mult_next(i,j)) { + Real r=0.0; + for (int k = 0; k < m1.cols(); k++) + r += m1(i,k)*m2(k,j); + dat->elem(i,j)=r; + } +} + +void +Matrix::insert_row(Vector v, int k) +{ + assert(v.dim()==cols()); + dat->insert_row(k); + for (int j=0; j < cols(); j++) + dat->elem(k,j)=v(j); +} + + +void +Matrix::swap_columns(int c1, int c2) +{ + assert(c1>=0&& c1 < cols()&&c2 < cols() && c2 >=0); + for (int i=0; i< rows(); i++) { + Real r=dat->elem(i,c1); + dat->elem(i,c1) = dat->elem(i,c2); + dat->elem(i,c2)=r; + } +} + +void +Matrix::swap_rows(int c1, int c2) +{ + assert(c1>=0&& c1 < rows()&&c2 < rows() && c2 >=0); + for (int i=0; i< cols(); i++) { + Real r=dat->elem(c1,i); + dat->elem(c1,i) = dat->elem(c2,i); + dat->elem(c2,i)=r; + } +} + + +int +Matrix::dim() const +{ + assert(cols() == rows()); + return rows(); +} + diff --git a/flower/path.cc b/flower/path.cc new file mode 100644 index 0000000000..c79962f00f --- /dev/null +++ b/flower/path.cc @@ -0,0 +1,77 @@ +/* + path.cc - manipulation of paths and filenames. +*/ +#include +#include "path.hh" + +#ifndef PATHSEP +#define PATHSEP '/' +#endif + +/** + @param path the original full filename + @return 4 components of the path. They can be empty +*/ +void +split_path(String path, + String &drive, String &dirs, String &filebase, String &extension) +{ + // peel off components, one by one. + int di = path.index_i(':'); + if (di >= 0) + { + drive = path.left_str(di + 1); + path = path.right_str(path.len() - di -1); + } + else + drive = ""; + + di = path.index_last_i(PATHSEP); + if (di >=0) + { + dirs = path.left_str(di + 1); + path = path.right_str(path.len()-di -1); + } + else + dirs = ""; + + di = path.index_last_i('.'); + if (di >= 0) + { + filebase = path.left_str(di); + extension =path.right_str(path.len()-di); + } + else + { + extension = ""; + filebase = path; + } +} + +File_path::File_path(String pref) +{ + add("."); + add(pref); +} + + +/** find a file. + It will search in the current dir, in the construction-arg, and + in any other added path, in this order. + */ +String +File_path::find(String nm) +{ + for (int i=0; i < size(); i++) { + String path = (*this)[i]; + path+= "/"+nm; + + + FILE *f = fopen(path, "r"); // ugh! + if (f) { + fclose(f); + return path; + } + } + return ""; +} diff --git a/flower/scalar.cc b/flower/scalar.cc new file mode 100644 index 0000000000..5edd9e997f --- /dev/null +++ b/flower/scalar.cc @@ -0,0 +1,57 @@ +#include +#include +#include "scalar.hh" + +Scalar::Scalar(Rational r) + :String(r) +{ + +} + +Scalar::operator Rational() +{ + int p = index_i('/'); + if (p == -1) + return int(*this); + + String s2 = right_str(len()-p-1); + String s1 = left_str(p); + + return Rational(s1.value_i(), s2.value_i()); +} + +bool +Scalar::isnum() +{ + int conv = false; + if (len()) { + long l =0; + conv = sscanf(strh_.ch_c_l(), "%ld", &l); + } + return len() && conv; +} + +Scalar::operator Real() +{ + assert (isnum()); + return value_f(); +} + +Scalar::operator int() +{ + assert (isnum()); + return value_i(); +} + + +Scalar::operator bool() const +{ + if (!len()) + return false; + if (*this == "0") + return false; + String u (*this); + if ( u.upper_str() == "FALSE") + return false; + return true; +} diff --git a/flower/smat.cc b/flower/smat.cc new file mode 100644 index 0000000000..dcc61ce44e --- /dev/null +++ b/flower/smat.cc @@ -0,0 +1,181 @@ +#include "smat.hh" + +void +Full_storage::operator=(Full_storage const &fs) +{ + resize(fs.h, fs.w); + OK(); + fs.OK(); + for (int i=0; i= h && maxw >= w); + assert(h >= 0 && w >= 0); + assert(els||!maxh); +#endif +} +void +Full_storage::resize_cols(int newh) +{ + if (newh <= maxh) { + h=newh; + return; + } + + Real ** newa=new Real*[newh]; + int j=0; + for (; j < h; j++) + newa[j] = els[j]; + for (; j < newh; j++) + newa[j] = new Real[maxw]; + delete[] els; + els=newa; + + h = maxh = newh; +} + +void +Full_storage::resize_rows(int neww) +{ + if (neww <= maxw) { + w=neww; + return; + } + for (int i=0; i < maxh ; i++) { + Real* newa = new Real[neww]; + for (int k=0; k < w; k++) + newa[k] = els[i][k]; + + delete[] els[i]; + els[i] = newa; + } + w = maxw = neww; +} + +Full_storage::~Full_storage() { + for (int i=0; i < maxh; i++) + delete [] els[i]; + delete[] els; +} + +void +Full_storage::resize(int rows, int cols) +{ + OK(); + resize_cols(rows); + resize_rows(cols); + +} + + +bool +Full_storage::mult_ok(int i, int j) const +{ + return valid(i,j); +} + +bool +Full_storage::trans_ok(int i, int j) const +{ + return valid(i,j); +} + + +void +Full_storage::trans_next(int &i, int &j) const +{ + assert(trans_ok(i,j)); + i++; + if (i >= h) { + i=0; + j ++; + } +} + +void +Full_storage::mult_next(int &i, int &j) const +{ + assert(mult_ok(i,j)); + j++; + if (j >= w) { + j=0; + i++; + } +} + +void +Full_storage::delete_column(int k) +{ + assert(0 <= k &&k k ; i--) + for (int j=0; j +Full_storage::row(int n) const +{ + Array r; + for (int j = 0; j < w; j++) + r.push(els[n][j]); + return r; +} + +Array +Full_storage::column(int n) const +{ + + Array r; + for (int i = 0; i +#include +#include "libc-extension.hh" +#include "string.hh" +#include "string-convert.hh" + +/** + a safe length for stringconversion buffers + + worst case would be %f printing HUGE (or 1/HUGE), which is approx + 2e318, this number would have approx 318 zero's in its string. + + Should enlarge buff dynamically. + @see + man 3 snprintf + */ +static const int STRING_BUFFER_LEN=1024; + +String +String_convert::bin2hex_str( String bin_str ) +{ + String str; + Byte const* byte_c_l = bin_str.byte_c_l(); + for ( int i = 0; i < bin_str.length_i(); i++ ) { + str += (char)nibble2hex_byte( *byte_c_l >> 4 ); + str += (char)nibble2hex_byte( *byte_c_l++ ); + } + return str; +} + +int +String_convert::bin2_i( String bin_str ) +{ + assert( bin_str.length_i() <= 4 ); + + int result_i = 0; + for ( int i = 0; i < bin_str.length_i(); i++ ) { + result_i <<= 8; + result_i += (Byte)bin_str[ i ]; + } + return result_i; +} + +// breendet imp from String +int +String_convert::dec2_i( String dec_str ) +{ + if ( !dec_str.length_i() ) + return 0; + + long l = 0; + int conv = sscanf( dec_str.ch_c_l(), "%ld", &l ); + assert( conv ); + + return (int)l; +} + +String +String_convert::i64_str( I64 i64, char const* fmt) +{ + char buffer[STRING_BUFFER_LEN]; + snprintf(buffer, STRING_BUFFER_LEN, + (fmt ? fmt : "%Ld"), i64 ); // assume radix 10 + return String(buffer); + +} +// breendet imp from String +double +String_convert::dec2_f( String dec_str ) +{ + if ( !dec_str.length_i() ) + return 0; + double d = 0; + int conv = sscanf( dec_str.ch_c_l(), "%lf", &d ); + assert( conv ); + return d; +} + +int +String_convert::hex2bin_i( String hex_str, String& bin_str_r ) +{ + if ( hex_str.length_i() % 2 ) + hex_str = "0" + hex_str; + + bin_str_r = ""; + Byte const* byte_c_l= hex_str.byte_c_l(); + int i = 0; + while ( i < hex_str.length_i() ) { + int high_i = hex2nibble_i( *byte_c_l++ ); + int low_i = hex2nibble_i( *byte_c_l++ ); + if ( high_i < 0 || low_i < 0 ) + return 1; // illegal char + bin_str_r += String( (char)( high_i << 4 | low_i ), 1 ); + i += 2; + } + return 0; +} + +String +String_convert::hex2bin_str( String hex_str ) +{ + String str; +// silly, asserts should alway be "on"! +// assert( !hex2bin_i( hex_str, str ) ); + int error_i = hex2bin_i( hex_str, str ); + assert( !error_i ); + return str; +} + +int +String_convert::hex2nibble_i( Byte byte ) +{ + if ( byte >= '0' && byte <= '9' ) + return byte - '0'; + if ( byte >= 'A' && byte <= 'F' ) + return byte - 'A' + 10; + if ( byte >= 'a' && byte <= 'f') + return byte - 'a' + 10; + return -1; +} + +// stupido. Should use int_str() +String +String_convert::i2dec_str( int i, int length_i, char ch ) +{ + char fill_ch = ch; + if ( fill_ch) + fill_ch = '0'; + + // ugh + String dec_str( i ); + + // ugh + return String( fill_ch, length_i - dec_str.length_i() ) + dec_str; +} + + +// stupido. Should use int_str() +String +String_convert::u2hex_str( unsigned u, int length_i, char fill_ch ) +{ + String str; + if ( !u ) + str = "0"; + +#if 1 // both go... + while ( u ) { + str = String( (char)( ( u % 16 )["0123456789abcdef"] ) ) + str; + u /= 16; + } +#else + str += int_str( u, "%x" ); +#endif + + str = String( fill_ch, length_i - str.length_i() ) + str; + while ( ( str.length_i() > length_i ) && ( str[ 0 ] == 'f' ) ) + str = str.mid_str( 2, INT_MAX ); + + return str; +} + +String +String_convert::i2hex_str( int i, int length_i, char fill_ch ) +{ + return u2hex_str( (unsigned)i, length_i, fill_ch ); +} + +Byte +String_convert::nibble2hex_byte( Byte byte ) +{ + if ( ( byte & 0x0f ) <= 9 ) + return ( byte & 0x0f ) + '0'; + else + return ( byte & 0x0f ) - 10 + 'a'; +} +/** + Convert an integer to a string + + @param + #fmt# is a printf style format, default assumes "%d" as format. + */ +String +String_convert::int_str(int i, char const* fmt) +{ + char buffer[STRING_BUFFER_LEN]; + snprintf(buffer, STRING_BUFFER_LEN, + (fmt ? fmt : "%d"), i ); // assume radix 10 + return String(buffer); +} + +/** + Convert a double to a string. + + @param #fmt# is a printf style format, default assumes "%lf" as format + */ +String +String_convert::double_str(double f, char const* fmt) +{ + char buf[STRING_BUFFER_LEN]; + + snprintf(buf, STRING_BUFFER_LEN, fmt ? fmt : "%f", f); + return buf; +} + +/** + Make a string from a single character. + + @param + #n# is a repetition count, default value is 1 + */ +String +String_convert::char_str(char c, int n) +{ + n = n >= 0 ? n : 0; + char* ch_p = new char[ n ]; + memset( ch_p, c, n ); + String s((Byte*)ch_p, n); + delete ch_p; + return s; +} + +String +String_convert::rational_str(Rational r) +{ + char * n = Itoa(r.numerator()); // LEAK???? + + String s = n; + if (r.denominator() != 1) { + char * d = Itoa(r.denominator()); + s += String( '/' ) + String(d); + //delete d; + } +/* delete n; + */ + return s; +} + +String +String_convert::pointer_str(void const *l) +{ + I64 i64 = (I64)l; + return String_convert::i64_str(i64, "0x%0Lx"); +} diff --git a/flower/stringtest.cc b/flower/stringtest.cc new file mode 100644 index 0000000000..0bbde77c99 --- /dev/null +++ b/flower/stringtest.cc @@ -0,0 +1,118 @@ +#ifdef STRING_TEST +/* + stupid test program to verify stringlib + stringtest.cc + */ +#include +#include "string.hh" +#include "varray.hh" +#include "string-convert.hh" + +void +ctors() +{ + cout << "constructors"< a; + a.push("abcd"); + a.push("zxy"); + a.push("abc"); + a.push(""); + a.sort(String::compare_i); + cout << "compares: "< +*/ + +#ifdef STRING_DEBUG +#include +#include +void* +mymemmove( void* dest, void const* src, size_t n ) +{ + return memcpy( dest, src, n ); // wohltempererit: 69006 +} +#define memmove mymemmove +#endif + +#ifdef STRING_UTILS_INLINED +#undef STRING_UTILS_INLINED +#endif + +#ifdef INLINE +#undef INLINE +#endif + +#define INLINE + +#include "string-handle.hh" +#include "string-data.hh" +#include "string-data.inl" +#include "string-handle.inl" diff --git a/flower/test/Makefile b/flower/test/Makefile index 14bf4b9916..5b6affe77e 100644 --- a/flower/test/Makefile +++ b/flower/test/Makefile @@ -19,12 +19,13 @@ NAME =stringtest # include ./$(depth)/$(NAME)/.version MODULE_NAME = flower include ./$(depth)/flower/.version -build = ./$(depth)/flower/test/$(outdir)/.build + # # generic variables: # -include ./$(depth)/make/Variables.make +include ./$(depth)/make/Variables.make +include ./$(depth)/make/Files.make # # descent order into subdirectories: @@ -40,29 +41,12 @@ VERSION_DEPENDENCY = # # module compile settings: (not generally needed! # EXTRA_CFLAGS = -DSTRING_TEST -EXTRA_CXXFLAGS = -EXTRA_LDFLAGS = -# - -# list of c++ header files: -# -# HHFILES = $(shell ls *.hh $(ERROR_LOG)) -# - -# list of c++ source files: -# -CCFILES = $(shell ls *.cc $(ERROR_LOG)) # -# list of other source files: -# -EXTRA_SOURCE_FILES = $(shell ls *.y *.l $(ERROR_LOG)) -# # list of distribution files: # -DISTFILES = Makefile $(HHFILES) $(CCFILES) $(EXTRA_SOURCE_FILES) -# +EXTRA_DISTFILES = result # list of custom libraries: # @@ -82,9 +66,11 @@ MAINTARGET = $(lily_bindir)/$(EXECUTABLE)# huh? #default: $(MAINTARGET) BUILDSTRINGTEST=$(MAINTARGET) EXECSTRINGTEST=$(EXECUTABLE) + default: $(BUILDSTRINGTEST) do-stringtest do-stringtest: - $(EXECSTRINGTEST) # should cmp with a 'standard result' + $(EXECSTRINGTEST) > $(outdir)/result # should cmp with a 'standard result' + cmp $(outdir)/result result dummy: @@ -96,7 +82,7 @@ include ./$(depth)/make/Rules.make # list of depend files: # -DEPFILES = $(shell ls $(depdir)/*.dep $(ERROR_LOG)) +DEPFILES = $(wildcard $(depdir)/*.dep ) # # auto dependencies: diff --git a/flower/test/result b/flower/test/result new file mode 100644 index 0000000000..1351b5b0cc --- /dev/null +++ b/flower/test/result @@ -0,0 +1,40 @@ +constructors +hai + +10 +c +0.0132 +compares: + +abc +abcd +zxy +hay = "foobarbazblub" len=13 +index_i('b') b= 3 +last_index_i('b') b= 12 +index_i("bar"): 3 +index_any("bar"): b: 3 + left_str(-1): + right_str( -1): + left_str(0): + right_str( 0): + left_str(1): h + right_str( 1): i + left_str(2): ha + right_str( 2): ai + left_str(3): hai + right_str( 3): hai + left_str(4): hai + right_str( 4): hai +blonde haren +mid(2,6)=onde h +nomid(2,6)=blaren +hai +left +hai daar +Hallo daaR! +up: HALLO DAAR! down: hallo daar! +`Hallo daaR!' is not empty +`' is empty +ff +-1:ff diff --git a/flower/text-db.cc b/flower/text-db.cc new file mode 100644 index 0000000000..ebfc992ff2 --- /dev/null +++ b/flower/text-db.cc @@ -0,0 +1,48 @@ +#include "text-db.hh" +bool +Text_db::eof() +{ + Data_file::gobble_leading_white(); + return Data_file::eof(); +} + +void +Text_db::gobble_leading_white() +{ + while (1) { + Data_file::gobble_leading_white(); + if (eof()) + return ; + char c; + if ((c = data_get()) !='\n'){ + data_unget (c); + return ; + } + } +} + + +Text_record +Text_db::get_record() +{ + while (1) { + String s; + Array fields; + assert(!eof()); + + while ((s = get_word()) != "") + { + fields.push(s); + gobble_white(); + } + + + if (get_line() != "") + assert(false); + + assert (fields.size()); + return Text_record(fields, get_name(), line()); + } +} + + diff --git a/flower/text-stream.cc b/flower/text-stream.cc new file mode 100644 index 0000000000..a2d3e4b119 --- /dev/null +++ b/flower/text-stream.cc @@ -0,0 +1,31 @@ +#include "text-stream.hh" + +Text_stream::Text_stream(String fn) +{ + ios::sync_with_stdio(); + if (fn == "") + { + name = ""; + f = stdin; + } + + else + { + name = fn; + f = fopen(fn, "r"); + } + + if (!f) { + cerr <<__FUNCTION__<< ": can't open `" << fn << "'\n"; + exit(1); + } + + line_no = 1; + } + +void +Text_stream::message(String s) +{ + cerr << "\n"< d) + : dat(d) +{ + +} +Vector::Vector(Vector const &n) + : dat(n.dat) +{ +} + +Vector +Vector::operator-() const +{ + Vector v(*this); + v*=-1; + return v; +} + +void +Vector::set_unit(int j) +{ + fill(0.0); + dat[j] = 1.0; +} diff --git a/init/Makefile b/init/Makefile index 04fb51197d..c8fee3cd50 100644 --- a/init/Makefile +++ b/init/Makefile @@ -1,5 +1,6 @@ # init/Makefile + # subdir level: # depth = .. @@ -9,12 +10,12 @@ build = ./$(depth)/lily/$(outdir)/.build # generic stuff/Makefile # -include ./$(depth)/make/Stuff.make +include ./$(depth)/make/Include.make # # list of distribution files: # -INIFILES = $(shell ls *.ini) +INIFILES = $(wildcard *.ini) DISTFILES = Makefile $(INIFILES) # diff --git a/init/dutch.ini b/init/dutch.ini index 884dfd0df7..a44eaca96b 100644 --- a/init/dutch.ini +++ b/init/dutch.ini @@ -2,41 +2,41 @@ % common dutch names for notes. "es" means flat, "is" means sharp % -ceses = melodic { 0 0 -2 0 } -ces = melodic { 0 0 -1 0 } -c = melodic { 0 0 0 0 } -cis = melodic { 0 0 1 0 } -cisis = melodic { 0 0 2 0 } -deses = melodic { 0 1 -2 0 } -des = melodic { 0 1 -1 0 } -d = melodic { 0 1 0 0 } -dis = melodic { 0 1 1 0 } -disis = melodic { 0 1 2 0 } -eses = melodic { 0 2 -2 0 } -es = melodic { 0 2 -1 0 } -e = melodic { 0 2 0 0 } -eis = melodic { 0 2 1 0 } -eisis = melodic { 0 2 2 0 } -feses = melodic { 0 3 -2 0 } -fes = melodic { 0 3 -1 0 } -f = melodic { 0 3 0 0 } -fis = melodic { 0 3 1 0 } -fisis = melodic { 0 3 2 0 } -geses = melodic { 0 4 -2 0 } -ges = melodic { 0 4 -1 0 } -g = melodic { 0 4 0 0 } -gis = melodic { 0 4 1 0 } -gisis = melodic { 0 4 2 0 } -ases = melodic { 0 5 -2 0 } -as = melodic { 0 5 -1 0 } -a = melodic { 0 5 0 0 } -ais = melodic { 0 5 1 0 } -aisis = melodic { 0 5 2 0 } -beses = melodic { 0 6 -2 0 } -bes = melodic { 0 6 -1 0 } -b = melodic { 0 6 0 0 } -bis = melodic { 0 6 1 0 } -bisis = melodic { 0 6 2 0 } +ceses = \melodic { 0 0 -2 } +ces = \melodic { 0 0 -1 } +c = \melodic { 0 0 0 } +cis = \melodic { 0 0 1 } +cisis = \melodic { 0 0 2 } +deses = \melodic { 0 1 -2 } +des = \melodic { 0 1 -1 } +d = \melodic { 0 1 0 } +dis = \melodic { 0 1 1 } +disis = \melodic { 0 1 2 } +eses = \melodic { 0 2 -2 } +es = \melodic { 0 2 -1 } +e = \melodic { 0 2 0 } +eis = \melodic { 0 2 1 } +eisis = \melodic { 0 2 2 } +feses = \melodic { 0 3 -2 } +fes = \melodic { 0 3 -1 } +f = \melodic { 0 3 0 } +fis = \melodic { 0 3 1 } +fisis = \melodic { 0 3 2 } +geses = \melodic { 0 4 -2 } +ges = \melodic { 0 4 -1 } +g = \melodic { 0 4 0 } +gis = \melodic { 0 4 1 } +gisis = \melodic { 0 4 2 } +ases = \melodic { 0 5 -2 } +as = \melodic { 0 5 -1 } +a = \melodic { 0 5 0 } +ais = \melodic { 0 5 1 } +aisis = \melodic { 0 5 2 } +beses = \melodic { 0 6 -2 } +bes = \melodic { 0 6 -1 } +b = \melodic { 0 6 0 } +bis = \melodic { 0 6 1 } +bisis = \melodic { 0 6 2 } % @@ -44,40 +44,40 @@ bisis = melodic { 0 6 2 0 } % -Ceses = melodic { -1 0 -2 0 } -Ces = melodic { -1 0 -1 0 } -C = melodic { -1 0 0 0 } -Cis = melodic { -1 0 1 0 } -Cisis = melodic { -1 0 2 0 } -Deses = melodic { -1 1 -2 0 } -Des = melodic { -1 1 -1 0 } -D = melodic { -1 1 0 0 } -Dis = melodic { -1 1 1 0 } -Disis = melodic { -1 1 2 0 } -Eses = melodic { -1 2 -2 0 } -Es = melodic { -1 2 -1 0 } -E = melodic { -1 2 0 0 } -Eis = melodic { -1 2 1 0 } -Eisis = melodic { -1 2 2 0 } -Feses = melodic { -1 3 -2 0 } -Fes = melodic { -1 3 -1 0 } -F = melodic { -1 3 0 0 } -Fis = melodic { -1 3 1 0 } -Fisis = melodic { -1 3 2 0 } -Geses = melodic { -1 4 -2 0 } -Ges = melodic { -1 4 -1 0 } -G = melodic { -1 4 0 0 } -Gis = melodic { -1 4 1 0 } -Gisis = melodic { -1 4 2 0 } -Ases = melodic { -1 5 -2 0 } -As = melodic { -1 5 -1 0 } -A = melodic { -1 5 0 0 } -Ais = melodic { -1 5 1 0 } -Aisis = melodic { -1 5 2 0 } -Beses = melodic { -1 6 -2 0 } -Bes = melodic { -1 6 -1 0 } -B = melodic { -1 6 0 0 } -Bis = melodic { -1 6 1 0 } -Bisis = melodic { -1 6 2 0 } +Ceses = \melodic { -1 0 -2 } +Ces = \melodic { -1 0 -1 } +C = \melodic { -1 0 0 } +Cis = \melodic { -1 0 1 } +Cisis = \melodic { -1 0 2 } +Deses = \melodic { -1 1 -2 } +Des = \melodic { -1 1 -1 } +D = \melodic { -1 1 0 } +Dis = \melodic { -1 1 1 } +Disis = \melodic { -1 1 2 } +Eses = \melodic { -1 2 -2 } +Es = \melodic { -1 2 -1 } +E = \melodic { -1 2 0 } +Eis = \melodic { -1 2 1 } +Eisis = \melodic { -1 2 2 } +Feses = \melodic { -1 3 -2 } +Fes = \melodic { -1 3 -1 } +F = \melodic { -1 3 0 } +Fis = \melodic { -1 3 1 } +Fisis = \melodic { -1 3 2 } +Geses = \melodic { -1 4 -2 } +Ges = \melodic { -1 4 -1 } +G = \melodic { -1 4 0 } +Gis = \melodic { -1 4 1 } +Gisis = \melodic { -1 4 2 } +Ases = \melodic { -1 5 -2 } +As = \melodic { -1 5 -1 } +A = \melodic { -1 5 0 } +Ais = \melodic { -1 5 1 } +Aisis = \melodic { -1 5 2 } +Beses = \melodic { -1 6 -2 } +Bes = \melodic { -1 6 -1 } +B = \melodic { -1 6 0 } +Bis = \melodic { -1 6 1 } +Bisis = \melodic { -1 6 2 } diff --git a/init/dynamic.ini b/init/dynamic.ini index da3725b2ed..c8d5985f7e 100644 --- a/init/dynamic.ini +++ b/init/dynamic.ini @@ -1,10 +1,10 @@ -ppp = dynamic {7 } -pp = dynamic { 6 } -p = dynamic { 5 } -mp = dynamic { 4 } -mf = dynamic { 3 } -df = dynamic { 2 } % f is a notename too. -ff = dynamic { 1 } -fff = dynamic { 0 } +ppp = \dynamic {7 } +pp = \dynamic { 6 } +p = \dynamic { 5 } +mp = \dynamic { 4 } +mf = \dynamic { 3 } +df = \dynamic { 2 } % f is a notename too. +ff = \dynamic { 1 } +fff = \dynamic { 0 } diff --git a/init/script.ini b/init/script.ini index aeee0b01ac..f800923fdc 100644 --- a/init/script.ini +++ b/init/script.ini @@ -1,16 +1,15 @@ -% name = script { +% name = \script { % indexstring same_dir_as_stem above_below_staff symbol_can_beinverted } % -accent = script { "sforzato" -1 0 0 } -marcato = script { "marcato" -1 0 1 } -staccatissimo = script { "staccatissimo" -1 0 1 } -portato= script { "portato" -1 0 1 } -fermata = script { "fermata" 1 0 1 } -stopped = script { "stopped" 0 1 0 } -staccato = script { "staccato" -1 0 0 } -tenuto = script {"tenuto" -1 0 0 } -portato = script { "portato" -1 0 0 } -upbow = script { "upbow" 0 1 0 } -downbow = script { "downbow" 0 1 0 } +accent = \script { "sforzato" -1 0 0 } +marcato = \script { "marcato" -1 0 1 } +staccatissimo = \script { "staccatissimo" -1 0 1 } +portato= \script { "portato" -1 0 1 } +fermata = \script { "fermata" 1 0 1 } +stopped = \script { "stopped" 0 1 0 } +staccato = \script { "staccato" -1 0 0 } +tenuto = \script {"tenuto" -1 0 0 } +upbow = \script { "upbow" 0 1 0 } +downbow = \script { "downbow" 0 1 0 } diff --git a/init/swedish.ini b/init/swedish.ini index f120a6a701..fd7333a3ad 100644 --- a/init/swedish.ini +++ b/init/swedish.ini @@ -4,38 +4,38 @@ % by Mats Bengtsson. -cessess = melodic { 0 0 -2 0 } -cess = melodic { 0 0 -1 0 } -c = melodic { 0 0 0 0 } -ciss = melodic { 0 0 1 0 } -cississ = melodic { 0 0 2 0 } -dessess = melodic { 0 1 -2 0 } -dess = melodic { 0 1 -1 0 } -d = melodic { 0 1 0 0 } -diss = melodic { 0 1 1 0 } -dississ = melodic { 0 1 2 0 } -essess = melodic { 0 2 -2 0 } -ess = melodic { 0 2 -1 0 } -e = melodic { 0 2 0 0 } -eiss = melodic { 0 2 1 0 } -eississ = melodic { 0 2 2 0 } -fessess = melodic { 0 3 -2 0 } -fess = melodic { 0 3 -1 0 } -f = melodic { 0 3 0 0 } -fiss = melodic { 0 3 1 0 } -fississ = melodic { 0 3 2 0 } -gessess = melodic { 0 4 -2 0 } -gess = melodic { 0 4 -1 0 } -g = melodic { 0 4 0 0 } -giss = melodic { 0 4 1 0 } -gississ = melodic { 0 4 2 0 } -assess = melodic { 0 5 -2 0 } -ass = melodic { 0 5 -1 0 } -a = melodic { 0 5 0 0 } -aiss = melodic { 0 5 1 0 } -aississ = melodic { 0 5 2 0 } -hessess = melodic { 0 6 -2 0 } -b = melodic { 0 6 -1 0 } -h = melodic { 0 6 0 0 } -hiss = melodic { 0 6 1 0 } -hississ = melodic { 0 6 2 0 } +cessess = \melodic { 0 0 -2 } +cess = \melodic { 0 0 -1 } +c = \melodic { 0 0 0 } +ciss = \melodic { 0 0 1 } +cississ = \melodic { 0 0 2 } +dessess = \melodic { 0 1 -2 } +dess = \melodic { 0 1 -1 } +d = \melodic { 0 1 0 } +diss = \melodic { 0 1 1 } +dississ = \melodic { 0 1 2 } +essess = \melodic { 0 2 -2 } +ess = \melodic { 0 2 -1 } +e = \melodic { 0 2 0 } +eiss = \melodic { 0 2 1 } +eississ = \melodic { 0 2 2 } +fessess = \melodic { 0 3 -2 } +fess = \melodic { 0 3 -1 } +f = \melodic { 0 3 0 } +fiss = \melodic { 0 3 1 } +fississ = \melodic { 0 3 2 } +gessess = \melodic { 0 4 -2 } +gess = \melodic { 0 4 -1 } +g = \melodic { 0 4 0 } +giss = \melodic { 0 4 1 } +gississ = \melodic { 0 4 2 } +assess = \melodic { 0 5 -2 } +ass = \melodic { 0 5 -1 } +a = \melodic { 0 5 0 } +aiss = \melodic { 0 5 1 } +aississ = \melodic { 0 5 2 } +hessess = \melodic { 0 6 -2 } +b = \melodic { 0 6 -1 } +h = \melodic { 0 6 0 } +hiss = \melodic { 0 6 1 } +hississ = \melodic { 0 6 2 } diff --git a/init/symbol.ini b/init/symbol.ini index cc0f13d399..7ed0e0c99a 100644 --- a/init/symbol.ini +++ b/init/symbol.ini @@ -1,6 +1,6 @@ include "dynamic.ini" -include "dutch.ini" # do not include init/ path +include "dutch.ini" % do not include init/ path include "script.ini" include "table_sixteen.ini" diff --git a/init/table_sixteen.ini b/init/table_sixteen.ini index 240eae0b8b..dfd036f741 100644 --- a/init/table_sixteen.ini +++ b/init/table_sixteen.ini @@ -3,36 +3,36 @@ % It has a lot of hard-wired stringconstants % -table_sixteen= -symboltables { +tablesixteen= +\symboltables { - texid "\musixsixteendefs" + \texid "\musixsixteendefs" % index TeXstring, xmin xmax ymin ymax - "scripts" = table { - "fermata" "\fermata" 0pt 0pt 0pt 6pt - "-fermata" "\ifermata" 0pt 0pt -6pt 0pt + "scripts" = \table { + "fermata" "\fermata" 0\pt 0\pt 0\pt 6\pt + "-fermata" "\ifermata" 0\pt 0\pt -6\pt 0\pt "portato" "\portato" "-portato" "\iportato" "tenuto" "\tenuto" "-tenuto" "\itenuto" - "sforzato" "\sforzato" -0.8pt 4.8pt -1.92pt 1.92pt - "marcato" "\marcato" 0pt 4.8pt 0pt 4pt - "-marcato" "\imarcato" 0pt 4.8pt -4pt 0pt - "staccato" "\staccato" 0pt 0pt 0pt 5pt - "staccatissimo" "\staccatissimo" 0pt 0pt 0pt 7.5pt - "-staccatissimo" "\istaccatissimo" 0pt 0pt -7.5pt 0pt - "upbow" "\upbow" -1pt 6pt 0pt 5pt - "downbow" "\downbow" 0pt 5pt 0pt 7.5pt + "sforzato" "\sforzato" -0.8\pt 4.8\pt -1.92\pt 1.92\pt + "marcato" "\marcato" 0\pt 4.8\pt 0\pt 4\pt + "-marcato" "\imarcato" 0\pt 4.8\pt -4\pt 0\pt + "staccato" "\staccato" 0\pt 0\pt 0\pt 5\pt + "staccatissimo" "\staccatissimo" 0\pt 0\pt 0\pt 7.5\pt + "-staccatissimo" "\istaccatissimo" 0\pt 0\pt -7.5\pt 0\pt + "upbow" "\upbow" -1\pt 6\pt 0\pt 5\pt + "downbow" "\downbow" 0\pt 5\pt 0\pt 7.5\pt } - "style" = table { - "roman" "\settext{%}" 0pt 0pt 0pt 8pt - "italic" "\setitalic{%}" 0pt 0pt 0pt 8pt - "dynamic" "\setdynamic{%}" 0pt 0pt 0pt 8pt + "style" = \table { + "roman" "\settext{%}" 0\pt 0\pt 0\pt 8\pt + "italic" "\setitalic{%}" 0\pt 0\pt 0\pt 8\pt + "dynamic" "\setdynamic{%}" 0\pt 0\pt 0\pt 8\pt } - "dynamics" = table { + "dynamics" = \table { "mf" "\dynmf" "fff" "\dynfff" @@ -44,99 +44,99 @@ symboltables { "ppp" "\dynppp" } - "align" = table { + "align" = \table { "-1" "\leftalign{%}" "0" "\centeralign{%}" "1" "\rightalign{%}" } - "clefs" = table { - "violin" "\violinclef" 0pt 12.8pt -10pt 18pt - "bass" "\bassclef" 0pt 12.8pt 0pt 16pt - "alto" "\altoclef" 0pt 12.8pt 0pt 16pt - "tenor" "\altoclef" 0pt 12.8pt 0pt 16pt - "violin_change" "\cviolinclef" 0pt 11.2pt -12pt 12pt - "bass_change" "\cbassclef" 0pt 11.2pt 0pt 16pt - "alto_change" "\caltoclef" 0pt 11.2pt 0pt 16pt - "tenor_change" "\caltoclef" 0pt 11.2pt 0pt 16pt + "clefs" = \table { + "violin" "\violinclef" 0\pt 12.8\pt -10\pt 18\pt + "bass" "\bassclef" 0\pt 12.8\pt 0\pt 16\pt + "alto" "\altoclef" 0\pt 12.8\pt 0\pt 16\pt + "tenor" "\altoclef" 0\pt 12.8\pt 0\pt 16\pt + "violin_change" "\cviolinclef" 0\pt 11.2\pt -12\pt 12\pt + "bass_change" "\cbassclef" 0\pt 11.2\pt 0\pt 16\pt + "alto_change" "\caltoclef" 0\pt 11.2\pt 0\pt 16\pt + "tenor_change" "\caltoclef" 0\pt 11.2\pt 0\pt 16\pt } - "balls" = table { - "1" "\wholeball" 0pt 6pt -2 pt 2pt - "2" "\halfball" 0pt 5pt -2 pt 2pt - "4" "\quartball" 0pt 5pt -2 pt 2pt + "balls" = \table { + "1" "\wholeball" 0\pt 6\pt -2 \pt 2\pt + "2" "\halfball" 0\pt 5\pt -2 \pt 2\pt + "4" "\quartball" 0\pt 5\pt -2 \pt 2\pt } - "slur" = table { + "slur" = \table { "whole" "\slurchar%{%}" "half" "\hslurchar%{%}" } - "accidentals" = table { - "-2" "\flatflat" 0pt 10.2pt -2.5pt 7.5pt - "-1" "\flat" 0pt 6pt -2.5pt 7.5pt - "0" "\natural" 0pt 6pt -7.5pt 7.5pt - "1" "\sharp" 0pt 6pt -7.5pt 7.5pt - "2" "\sharpsharp" 0pt 6pt -2.5pt 7.5pt + "accidentals" = \table { + "-2" "\flatflat" 0\pt 10.2\pt -2.5\pt 7.5\pt + "-1" "\flat" 0\pt 6\pt -2.5\pt 7.5\pt + "0" "\natural" 0\pt 6\pt -7.5\pt 7.5\pt + "1" "\sharp" 0\pt 6\pt -7.5\pt 7.5\pt + "2" "\sharpsharp" 0\pt 6\pt -2.5\pt 7.5\pt } - "streepjes" = table { - "toplines" "\toplines{%}" -3pt 9pt 0pt 0pt - "botlines" "\botlines{%}" -3pt 9pt 0pt 0pt + "streepjes" = \table { + "toplines" "\toplines{%}" -3\pt 9\pt 0\pt 0\pt + "botlines" "\botlines{%}" -3\pt 9\pt 0\pt 0\pt } - "bars" = table { + "bars" = \table { "empty" "\emptybar" - "|" "\maatstreep" 0pt 0.4pt -8pt 8pt - "||" "\finishbar" 0pt 2pt -8pt 8pt - ":|" "\repeatbar" -4pt 0pt -8pt 8pt - "|:" "\startrepeat" 0pt 4pt -8pt 8pt - ":|:" "\repeatbarstartrepeat" 0pt 16pt -8pt 8pt + "|" "\maatstreep" 0\pt 0.4\pt -8\pt 8\pt + "||" "\finishbar" 0\pt 2\pt -8\pt 8\pt + ":|" "\repeatbar" -4\pt 0\pt -8\pt 8\pt + "|:" "\startrepeat" 0\pt 4\pt -8\pt 8\pt + ":|:" "\repeatbarstartrepeat" 0\pt 16\pt -8\pt 8\pt } - "rests" = table { - "1" "\wholerest" -5pt 1pt -1pt 1pt - "2" "\halfrest" -5pt 1pt -1pt 1pt - "4" "\quartrest" -5pt 2pt -5pt 5pt - "8" "\eighthrest" 0pt 5pt 0pt 8pt - "16" "\sixteenthrest" 0pt 6pt 0pt 12pt - "32" "\thirtysecondrest" 0pt 6pt 0pt 16pt + "rests" = \table { + "1" "\wholerest" -5\pt 1\pt -1\pt 1\pt + "2" "\halfrest" -5\pt 1\pt -1\pt 1\pt + "4" "\quartrest" -5\pt 2\pt -5\pt 5\pt + "8" "\eighthrest" 0\pt 5\pt 0\pt 8\pt + "16" "\sixteenthrest" 0\pt 6\pt 0\pt 12\pt + "32" "\thirtysecondrest" 0\pt 6\pt 0\pt 16\pt } - "meters" = table { - "C" "\fourfourmeter" 0pt 10pt -5pt 5pt - "C2" "\allabreve" 0pt 10pt -5pt 5pt + "meters" = \table { + "C" "\fourfourmeter" 0\pt 10\pt -5\pt 5\pt + "C2" "\allabreve" 0\pt 10\pt -5\pt 5\pt } % dims ignored for this table - "param" = table { - "meter" "\generalmeter{%}{%}" 0pt 10pt -5pt 5pt + "param" = \table { + "meter" "\generalmeter{%}{%}" 0\pt 10\pt -5\pt 5\pt "linestaf" "\linestafsym{%}{%}" "stem" "\stem{%}{%}" "fill" "\hbox{}" - "crescendo" "\crescendosym{%}" 0pt 0pt -3pt 3pt - "decrescendo" "\decrescendosym{%}" 0pt 0pt -3pt 3pt + "crescendo" "\crescendosym{%}" 0\pt 0\pt -3\pt 3\pt + "decrescendo" "\decrescendosym{%}" 0\pt 0\pt -3\pt 3\pt } - "dots" = table { - "1" "\lsingledot" 0pt 2pt -1pt 1pt - "2" "\ldoubledot" 0pt 5pt -1pt 1pt - "3" "\ltripledot" 0pt 8pt -1pt 1pt + "dots" = \table { + "1" "\lsingledot" 0\pt 2\pt -1\pt 1\pt + "2" "\ldoubledot" 0\pt 5\pt -1\pt 1\pt + "3" "\ltripledot" 0\pt 8\pt -1\pt 1\pt } - "flags" = table { - "8" "\eigthflag" 0pt 4pt 0pt 0pt - "16" "\sixteenthflag" 0pt 4pt 0pt 0pt - "32" "\thirtysecondflag" 0pt 4pt 0pt 0pt - "-8" "\deigthflag" 0pt 4pt 0pt 0pt - "-16" "\dsixteenthflag" 0pt 4pt 0pt 0pt - "-32" "\dthirtysecondflag" 0pt 4pt 0pt 0pt + "flags" = \table { + "8" "\eigthflag" 0\pt 4\pt 0\pt 0\pt + "16" "\sixteenthflag" 0\pt 4\pt 0\pt 0\pt + "32" "\thirtysecondflag" 0\pt 4\pt 0\pt 0\pt + "-8" "\deigthflag" 0\pt 4\pt 0\pt 0\pt + "-16" "\dsixteenthflag" 0\pt 4\pt 0\pt 0\pt + "-32" "\dthirtysecondflag" 0\pt 4\pt 0\pt 0\pt } - "beamslopes" = table { + "beamslopes" = \table { "slope" "\beamslope{%}{%}" "horizontal" "\rulesym{%}{%}" } } -default_table = symboltables { table_sixteen } +defaulttable = \symboltables { tablesixteen } diff --git a/init/table_twenty.ini b/init/table_twenty.ini index 6e2b8836a3..e4a5f78001 100644 --- a/init/table_twenty.ini +++ b/init/table_twenty.ini @@ -3,15 +3,15 @@ % It has a lot of hard-wired stringconstants % -table_twenty = symboltables { +table_twenty = \symboltables { texid "\musixtwentydefs" - "style" = table { + "style" = \table { "roman" "\settext{%}" 0pt 0pt 0pt 0pt "italic" "\setitalic{%}" 0pt 0pt 0pt 0pt } - "align" = table { + "align" = \table { "-1" "\leftalign{%}" 0pt 0pt 0pt 0pt "0" "\centeralign{%}" 0pt 0pt 0pt 0pt "1" "\rightalign{%}" 0pt 0pt 0pt 0pt @@ -22,7 +22,7 @@ table_twenty = symboltables { % be careful with editing this: % the "index" entry is hardwired into lilypond. - "clefs" = table { + "clefs" = \table { "violin" "\violinclef" 0pt 16pt -12.5pt 22.5pt "bass" "\bassclef" 0pt 16pt 0pt 20pt "alto" "\altoclef" 0pt 16pt 0pt 20pt @@ -33,17 +33,17 @@ table_twenty = symboltables { "tenor_change" "\caltoclef" 0pt 16pt 0pt 20pt } - "balls" = table { + "balls" = \table { "1" "\wholeball" 0pt 7.5pt -2.5pt 2.5pt "2" "\halfball" 0pt 6pt -2.5pt 2.5pt "4" "\quartball" 0pt 6pt -2.5pt 2.5pt } - "slur" = table { + "slur" = \table { "whole" "\slurchar%{%}" 0pt 0pt 0pt 0pt "half" "\hslurchar%{%}" 0pt 0pt 0pt 0pt } - "accidentals" = table { + "accidentals" = \table { "-2" "\flatflat" 0pt 10.2pt -2.5pt 7.5pt "-1" "\flat" 0pt 6pt -2.5pt 7.5pt "0" "\natural" 0pt 6pt -7.5pt 7.5pt @@ -51,18 +51,18 @@ table_twenty = symboltables { "2" "\sharpsharp" 0pt 6pt -2.5pt 7.5pt } - "streepjes" = table { + "streepjes" = \table { "toplines" "\toplines{%}" -3pt 9pt 0pt 0pt "botlines" "\botlines{%}" -3pt 9pt 0pt 0pt } - "bars" = table { + "bars" = \table { "empty" "\emptybar" 0pt 0pt 0pt 0pt "|" "\maatstreep" 0pt 5pt -12pt 12pt "||" "\finishbar" 0pt 2pt -12pt 12pt } - "rests" = table { + "rests" = \table { "1" "\wholerest" -5pt 1pt -1pt 1pt "2" "\halfrest" -5pt 1pt -1pt 1pt "4" "\quartrest" -5pt 2pt -5pt 5pt @@ -71,26 +71,26 @@ table_twenty = symboltables { "32" "\thirtysecondrest" 0pt 6pt 0pt 16pt } - "meters" = table { + "meters" = \table { "C" "\fourfourmeter" 0pt 10pt -5pt 5pt "C2" "\allabreve" 0pt 10pt -5pt 5pt } % dims ignored for this table - "param" = table { + "param" = \table { "meter" "\generalmeter{%}{%}" -3pt 10pt -5pt 5pt "linestaf" "\linestafsym{%}{%}" "stem" "\stem{%}{%}" "fill" "\hbox{}" } - "dots" = table { + "dots" = \table { "1" "\lsingledot" 0pt 8pt -1pt 1pt "2" "\ldoubledot" 0pt 12pt -1pt 1pt "3" "\ltripledot" 0pt 16pt -1pt 1pt } - "flags" = table { + "flags" = \table { "8" "\eigthflag" 0pt 5pt 0pt 0pt "16" "\sixteenthflag" 0pt 5pt 0pt 0pt "32" "\thirtysecondflag" 0pt 5pt 0pt 0pt @@ -99,10 +99,10 @@ table_twenty = symboltables { "-32" "\dthirtysecondflag" 0pt 5pt 0pt 0pt } - "beamslopes" = table { + "beamslopes" = \table { "slope" "\beamslope{%}{%}" "horizontal" "\rulesym{%}{%}" } } -default_table = symboltables { table_twenty } +default_table = \symboltables { table_twenty } diff --git a/input/Makefile b/input/Makefile index 94970aa5c0..d2e1363371 100644 --- a/input/Makefile +++ b/input/Makefile @@ -9,7 +9,7 @@ build = ./$(depth)/lily/$(outdir)/.build # generic stuff/Makefile # -include ./$(depth)/make/Stuff.make +include ./$(depth)/make/Include.make # # list of distribution files: diff --git a/input/cadenza.ly b/input/cadenza.ly index ecfda88354..b1fe77a160 100644 --- a/input/cadenza.ly +++ b/input/cadenza.ly @@ -4,17 +4,17 @@ % author: unknown. Copyright: none % -cad = music { $ +cad = \music { \duration { 8} \textstyle "italic" \clef \violin - 'c4.\mf g8 + c'4.\mf g8 \textstyle "roman" - ['e^"accel" ()'d 'c b] - [b()'c] g-\fermata + [e'^"accel" ()d' c' b] + [b()c'] g-\fermata \bar \empty - c [c_"rubato" e g 'c] + c [c_"rubato" e g c'] \octave{'} e4. e [g ()f_"rit" e d] @@ -33,26 +33,26 @@ cad = music { $ \duration{16} [d cis d e] f4()[f e d c] `b4 - \octave{} ['d8 'c8 a8]2/3 + \octave{} [d'8 c'8 a8]2/3 g2 \bar \empty - [g c e g] ['c e g 'c]\octave{'} + [g c e g] [c' e g c']\octave{'} [e `g c e] g4^\fermata %()% BUG! \bar \empty - [g8.(_"a tempo" e g8. )e] + [g8.(_"a \tempo" e g8. )e] a4. g8 [f8 e8 d8 c8] `g2 d2^"tr" c4 - $} + } score { - staff { melodic - music { cad } + \staff { \melodic + \music { cad } } - commands { - cadenza {1} + \co\mmands { + \cadenza {1} grouping{1*4} } - paper {} - midi { tempo 4:80 } + \paper {} + \midi { \tempo 4:80 } } diff --git a/input/coriolan-alto.ly b/input/coriolan-alto.ly index 2037580f13..29a7b38c02 100644 --- a/input/coriolan-alto.ly +++ b/input/coriolan-alto.ly @@ -3,16 +3,17 @@ % Opus 62 % Ouverture zu Collins Trauerspiel "Coriolan" % -% a 5 bar fragment of the alto part +% a 5 \bar fragment of the alto part % % Copyright (c) 1997 Jan Nieuwenhuizen % -% when lily can handle this, i-ll type the other 304 bars +% when lily can handle this, i-ll type the other 304 \bars % (maybe even sooner :-) % -alto = music { - $ +alto = \music { + + \meter {4/4} \grouping {4*4} \duration{ 8 } \key {bes es as} @@ -21,8 +22,8 @@ alto = music { % that-s why i-d rather type chords, % but how to type slurs? %30 - { - \music{ + < + { [ c c-. ] c2.( | %31 [ ) c c-. ] c2.( | @@ -32,10 +33,10 @@ alto = music { [ ) c c-. ] c4. c-. c4 } %30:2 - \music{ + { \octave{ ` } \textstyle "italic" - % this should be a dynamic, rather than text + % this should be a \dynamic, rather than text [ c c_"cresc. \ \ - \ \ \ \ - \ \ \ \ - \ \ \ \ - \ \ \ \ - \ \ \ \ - \ \ \ \ - \ \ \ \ - \ \ \ \ - \ \ \ \ - \ \ \ \ - \ \ \ \ @@ -49,34 +50,32 @@ alto = music { [ ) c c-. ] c4. c-. c4 | \octave{ } } - } %34 - % these are two voices (i.e. divisi) + > + % these are two \voices (i.e. divisi) % the c4 and c2, however are really 16th... % e.g.: c16*4 and c16*8 or % [ c4 c2 ]*16 ? % we-ll say "simile" for now... % - { \multivoice - \music{ \stem{ 1 }[ c16^"div." c16 c16 c16 ] c4 c2 } - \music { + < \multivoice + { \stem{ 1 }[ c16^"div." c16 c16 c16 ] c4 c2 } + { \octave{ ` } \textstyle "italic" \stem{ -1 } [ as16_"\ff" as16 as16 as16 ] as4_"simile" as2 \textstyle "roman" } - } - $ + > + } score { - staff { melodic music { alto }} + \staff { \melodic \music { alto }} - commands { - meter {4*4} grouping {4*4} } - paper { - unitspace 14mm - geometric 1.4 + \paper { + \unitspace 14\mm + \geometric 1.4 } } diff --git a/input/error.ly b/input/error.ly index 283f48922d..66b3760844 100644 --- a/input/error.ly +++ b/input/error.ly @@ -1,29 +1,29 @@ include "this-is-hopefully-a-nonexisting-file" -mwa = music { - $ +mwa = \music { + [ a8 a8 a8 a8 a8 ] % [ a8 ] % % segfault - { \music{ [ bes^"1"( )a bes-. g-. ] a4-.^"4" } \music{ [ e ] } \music{ [ c ] } } | + { \\music{ [ bes^"1"( )a bes-. g-. ] a4-.^"4" } \\music{ [ e ] } \\music{ [ c ] } } | a ) b ] c % warning & % ok; error a b ) ] % ok; error % a......... % fatal error -- assert a b c ||| % - abc % ok; print error, no output + abc % ok; print error, no \output \bla % no warning-> this STRING, reduced to lyric_elt. - a [ b % warning, still output - { a( b } % warning, still output + a [ b % warning, still \output + { a( b } % warning, still \output a b ,c a b c-* a b c& { a-. b-. } - $ + } -bla = music { +bla = \music { @ These Gates will open just like windows. % ok; warning @ @@ -33,13 +33,13 @@ bla = music { include "this-is-hopefully-a-nonexisting-file" score { - staff { - lyric music { bla } + \staff { + lyric \music { bla } } - staff { - melodic music { mwa } + \staff { + \melodic \music { mwa } } - commands { - meter {3*4} + \co\mmands { + \meter {3/4} } } diff --git a/input/fugue1.midi.ly b/input/fugue1.midi.ly index 1c730a6783..c42cc42775 100644 --- a/input/fugue1.midi.ly +++ b/input/fugue1.midi.ly @@ -1,147 +1,144 @@ % Creator: This is mi2mu 0.0.11.2 #14/FlowerLib 1.1.7 #1 of Mar 12 1997 02:11:21 % Automatically generated, at Wed Mar 12 02:22:22 1997 -% from input file: fugue1.midi +% from input file: fugue1.\midi -track0 = music { $ - % midi copyright: +track0 = \music { + % \midi copyright: % instrument: -$} % track0 +} % track0 -track1 = music { $ - % midi copyright: +track1 = \music { + % \midi copyright: % instrument: - g8 a8 b8 'c8. { \music{ 'd16 } } { \music{ 'c16 } } - { \music{ b8 } } 'e8 a8 { \music{ 'd8. } } 'e16 - 'd16 'c16 b16 g16 a16 b16 'c16 b16 'c16 'd16 'e16 - 'd16 'e16 'fis16 'g8 b8 'c8 a8 'd16 'c16 b16 a16 { - \music{ g8. } } g16 f16 e16 f16 g16 a16 g16 a16 b16 - 'c2 b4 'c8 'd8 'e8 'f8. { \music{ 'f16 } \music{ - 'g16 } } 'e8 'a8 'd8 'g8. 'a16 'g16 'f16 'e8 'a8. - 'b16 'a16 'g16 'f2 'e8. 'fis16 'g2 'fis4 'g16 'f16 - 'e16 'd16 'c16 'd16 'c16 b16 a16 'c16 b16 a16 'c16 - a16 gis8 'e8 'd8 'c16 b16 a16 gis16 a16 b16 'c16 - fis16 gis16 a16 b8 a16 b16 'c8 'f8 'e8 'd4 'c16 b16 - { \music{ 'c16 } } { \music{ b16 } } { \music{ b16 - b16 } \music{ 'c16 'c16 } \music{ b16 } \music{ - 'c16 'c16 } } { } { \music{ b16 } } { \music{ a16 } - } a4 g8 a8 b8 'c8. { \music{ 'd16 } } { \music{ - 'c16 } } { \music{ b8 } } 'c8 'd8 'e8 'f8. { \music{ - 'g16 } } { \music{ 'f16 } } { \music{ 'e8 } } 'a8 - 'd8 'g8. 'a16 'g16 'f16 'e8 'a8 'd8 'ais8 'a8 'g16 - 'f16 'g16 'f16 'g16 'e16 'f16 { \music{ 'g16 } } { - \music{ 'g16 } } { \music{ 'a16 } } { \music{ 'g16 } - } { } { } { \music{ 'f16 } } { \music{ 'g16 } } { - \music{ 'a16 } } 'cis16 'd16 'g16 { \music{ 'f16 } - } { \music{ 'e16 } } { \music{ 'f16 } } { \music{ - 'e16 } } { } { \music{ 'f16 } } { } { } { } { - \music{ 'e8 } } { } 'd16 'd8 g8 a8 b8 'c8 'd16 { - \music{ 'c16 } } { \music{ b8 } } 'e8 a8 { \music{ - 'd8. } } 'e16 'd16 'c16 b16 'c16 'd16 'e16 'f16 - 'g16 'a16 'g16 'f16 'e16 'd16 'c16 { \music{ 'c16 } - } { \music{ b16 } } { \music{ 'c16 } } { } { } { - \music{ b8. } } 'c8 'd8 g8 { \music{ 'c4 } } b8 'c4 - b8 ais8 a8 { \music{ 'd4 } } 'c8 'd8 'e8 'f4 'a16 { - \music{ 'g16 } } 'f16 'e16 { \music{ 'f16 } } { - \music{ 'e16 } } 'd16 'c2 g16 { \music{ a16 } } b16 - 'c16 'd16 'e16 { \music{ 'f8. } } { \music{ 'd16 } - \music{ 'c16 'e16 } } 'f16 { \music{ 'g16 } } { - \music{ 'a8. } } 'b16 ''c2 -$} % track1 + g8 a8 b8 c'8. { \\music{ d'16 } } { \\music{ c'16 } } + { \\music{ b8 } } e'8 a8 { \\music{ d'8. } } e'16 + d'16 c'16 b16 g16 a16 b16 c'16 b16 c'16 d'16 e'16 + d'16 e'16 fis'16 g'8 b8 c'8 a8 d'16 c'16 b16 a16 { + \\music{ g8. } } g16 f16 e16 f16 g16 a16 g16 a16 b16 + c'2 b4 c'8 d'8 e'8 f'8. { \\music{ f'16 } \\music{ + g'16 } } e'8 a'8 d'8 g'8. a'16 g'16 f'16 e'8 a'8. + b'16 a'16 g'16 f'2 e'8. fis'16 g'2 fis'4 g'16 f'16 + e'16 d'16 c'16 d'16 c'16 b16 a16 c'16 b16 a16 c'16 + a16 gis8 e'8 d'8 c'16 b16 a16 gis16 a16 b16 c'16 + fis16 gis16 a16 b8 a16 b16 c'8 f'8 e'8 d'4 c'16 b16 + { \\music{ c'16 } } { \\music{ b16 } } { \\music{ b16 + b16 } \\music{ c'16 c'16 } \\music{ b16 } \\music{ + c'16 c'16 } } { } { \\music{ b16 } } { \\music{ a16 } + } a4 g8 a8 b8 c'8. { \\music{ d'16 } } { \\music{ + c'16 } } { \\music{ b8 } } c'8 d'8 e'8 f'8. { \\music{ + g'16 } } { \\music{ f'16 } } { \\music{ e'8 } } a'8 + d'8 g'8. a'16 g'16 f'16 e'8 a'8 d'8 ais'8 a'8 g'16 + f'16 g'16 f'16 g'16 e'16 f'16 { \\music{ g'16 } } { + \\music{ g'16 } } { \\music{ a'16 } } { \\music{ g'16 } + } { } { } { \\music{ f'16 } } { \\music{ g'16 } } { + \\music{ a'16 } } cis'16 d'16 g'16 { \\music{ f'16 } + } { \\music{ e'16 } } { \\music{ f'16 } } { \\music{ + e'16 } } { } { \\music{ f'16 } } { } { } { } { + \\music{ e'8 } } { } d'16 d'8 g8 a8 b8 c'8 d'16 { + \\music{ c'16 } } { \\music{ b8 } } e'8 a8 { \\music{ + d'8. } } e'16 d'16 c'16 b16 c'16 d'16 e'16 f'16 + g'16 a'16 g'16 f'16 e'16 d'16 c'16 { \\music{ c'16 } + } { \\music{ b16 } } { \\music{ c'16 } } { } { } { + \\music{ b8. } } c'8 d'8 g8 { \\music{ c'4 } } b8 c'4 + b8 ais8 a8 { \\music{ d'4 } } c'8 d'8 e'8 f'4 a'16 { + \\music{ g'16 } } f'16 e'16 { \\music{ f'16 } } { + \\music{ e'16 } } d'16 c'2 g16 { \\music{ a16 } } b16 + c'16 d'16 e'16 { \\music{ f'8. } } { \\music{ d'16 } + \\music{ c'16 e'16 } } f'16 { \\music{ g'16 } } { + \\music{ a'8. } } b'16 c''2 +} % track1 -track2 = music { $ - % midi copyright: +track2 = \music { + % \midi copyright: % instrument: - c8 d8 e8 f8. { \music{ g16 } } { \music{ f16 } } { - \music{ e8 } } a8 d8 { \music{ g8. } } a16 g16 f16 - e16 f16 e16 d16 c16 d16 c16 `b16 `a8 fis8 { \music{ + c8 d8 e8 f8. { \\music{ g16 } } { \\music{ f16 } } { + \\music{ e8 } } a8 d8 { \\music{ g8. } } a16 g16 f16 + e16 f16 e16 d16 c16 d16 c16 `b16 `a8 fis8 { \\music{ g4. } } f16 e16 f8 d8 g8 f8 e8 d8 g4 f16 e16 f4 f16 e8 d4 c8 f8 g16 f16 e16 f8 d8 g4.. g8 a8 b8 { - \music{ 'c8. } } { \music{ 'd16 } } { \music{ 'c16 } - } { \music{ b8 } } 'e8 a8 { \music{ 'd8. } } 'e16 - 'd16 'c16 b8 d8 e8 fis8 { \music{ g8. } } { \music{ - a16 } } { \music{ g16 } } { \music{ f8 } } b8 e8 + \\music{ c'8. } } { \\music{ d'16 } } { \\music{ c'16 } + } { \\music{ b8 } } e'8 a8 { \\music{ d'8. } } e'16 + d'16 c'16 b8 d8 e8 fis8 { \\music{ g8. } } { \\music{ + a16 } } { \\music{ g16 } } { \\music{ f8 } } b8 e8 a8. b16 a16 gis16 fis8 f8 e8 d8. e16 fis16 gis16 a16 gis16 a16 b16 gis16 fis16 gis16 a16 b8 c8 d8 e8 - { \music{ f8. } } { \music{ g16 } } { \music{ f16 } - } { \music{ e8 } } a8 d8 g8. a16 g16 f16 e16 e16 - fis16 g4 fis8 gis8 { \music{ a4 } } g8 a8 b8 { - \music{ 'c8. } } { \music{ 'd16 } } { \music{ 'c16 } - } { \music{ b8 } } 'e8 a8 'd8. 'e16 'd16 'c16 b8 - 'g8 'cis8 'd8 'e8 'cis8 'd8 'e8 a8 e8 fis8 g8 { - \music{ a8. } } { \music{ b16 } } { \music{ a16 } } - { \music{ g8 } } 'c8 fis8 { \music{ b8. } } 'c16 + { \\music{ f8. } } { \\music{ g16 } } { \\music{ f16 } + } { \\music{ e8 } } a8 d8 g8. a16 g16 f16 e16 e16 + fis16 g4 fis8 gis8 { \\music{ a4 } } g8 a8 b8 { + \\music{ c'8. } } { \\music{ d'16 } } { \\music{ c'16 } + } { \\music{ b8 } } e'8 a8 d'8. e'16 d'16 c'16 b8 + g'8 cis'8 d'8 e'8 cis'8 d'8 e'8 a8 e8 fis8 g8 { + \\music{ a8. } } { \\music{ b16 } } { \\music{ a16 } } + { \\music{ g8 } } c'8 fis8 { \\music{ b8. } } c'16 b16 a16 g16 fis16 e16 d16 e4 d4 a16 g16 f16 e16 g16 - f16 a16 g4 a16 ais8 { \music{ 'c4 } } 'd8 g8 { - \music{ g4. } } f4 e8 d4 e16 a4 g4 f8 g8 a8 { - \music{ ais8. } } { \music{ 'c16 } } { \music{ - ais16 } } { \music{ a8 } } 'd8 g8 { \music{ 'c8. } - } 'd16 'c16 ais16 a16 ais16 a16 g16 f16 g16 f16 e16 - g16 a4 'f16 'd8 { \music{ 'e2 } \music{ 'g2 } } -$} % track2 + f16 a16 g4 a16 ais8 { \\music{ c'4 } } d'8 g8 { + \\music{ g4. } } f4 e8 d4 e16 a4 g4 f8 g8 a8 { + \\music{ ais8. } } { \\music{ c'16 } } { \\music{ + ais16 } } { \\music{ a8 } } d'8 g8 { \\music{ c'8. } + } d'16 c'16 ais16 a16 ais16 a16 g16 f16 g16 f16 e16 + g16 a4 f'16 d'8 { \\music{ e'2 } \\music{ g'2 } } +} % track2 -track3 = music { $ - % midi copyright: +track3 = \music { + % \midi copyright: % instrument: - `g8 `a8 `b8 c8. { \music{ d16 } } { \music{ c16 } } - { \music{ `b8 } } e8 `a8 { \music{ d8. } } e16 d16 + `g8 `a8 `b8 c8. { \\music{ d16 } } { \\music{ c16 } } + { \\music{ `b8 } } e8 `a8 { \\music{ d8. } } e16 d16 c16 `b8 c4 `ais8 `a8 d8 `g8 c8 `a16 `b16 c16 d4 `g4 - `g8 `a8 `b8 c8. { \music{ d16 } } { \music{ c16 } } + `g8 `a8 `b8 c8. { \\music{ d16 } } { \\music{ c16 } } { } `b8 e8 `a8 d8. e16 d16 c16 `b8 e4. d4 `b16 c16 `a16 e16 d16 c16 `b16 c16 `a16 `b16 c16 d16 c16 - `b16 `a16 `g4 `e8 `fis8 `gis8 `a8. { \music{ `b16 } - } { \music{ `a16 } } { \music{ `g8 } } c8 `fis8 - `b8. c16 `b16 `a16 `gis8 { \music{ `a4 } } `gis8 - `a4 `g8 `a8 `b8 c8. { \music{ d16 } } { \music{ c16 - } } { \music{ `b8 } } e8 `a8 d4 `g8 d4 c8 `a8 e4 d8 - `a8 `b8 cis8 d8. { \music{ e16 } } { \music{ d16 } - } { \music{ c8 } } f8 `b8 e8. f16 e16 d16 cis8 `a8 - `b8 cis8 d8. { \music{ e16 } } { \music{ d16 } } { - \music{ c8 } } fis8 `b8 e8. fis16 e16 d16 c4.. d16 - c16 `b16 `a16 `g16 `a16 `fis16 `g8 `b8 c8 { \music{ - d8 } } e8. { \music{ f16 } } { \music{ e16 } } { - \music{ d8 } } g8 c8 f8. g16 f16 e16 d4 e8 d4 { - \music{ `g8 } } `g4. `c8 `d8 `e8 `f8. { \music{ - `g16 } } { \music{ `f16 } } { \music{ `e8 } } `a8 - `d8 { \music{ `g8. } } `a16 `g16 `f16 `e16 `d16 + `b16 `a16 `g4 `e8 `fis8 `gis8 `a8. { \\music{ `b16 } + } { \\music{ `a16 } } { \\music{ `g8 } } c8 `fis8 + `b8. c16 `b16 `a16 `gis8 { \\music{ `a4 } } `gis8 + `a4 `g8 `a8 `b8 c8. { \\music{ d16 } } { \\music{ c16 + } } { \\music{ `b8 } } e8 `a8 d4 `g8 d4 c8 `a8 e4 d8 + `a8 `b8 cis8 d8. { \\music{ e16 } } { \\music{ d16 } + } { \\music{ c8 } } f8 `b8 e8. f16 e16 d16 cis8 `a8 + `b8 cis8 d8. { \\music{ e16 } } { \\music{ d16 } } { + \\music{ c8 } } fis8 `b8 e8. fis16 e16 d16 c4.. d16 + c16 `b16 `a16 `g16 `a16 `fis16 `g8 `b8 c8 { \\music{ + d8 } } e8. { \\music{ f16 } } { \\music{ e16 } } { + \\music{ d8 } } g8 c8 f8. g16 f16 e16 d4 e8 d4 { + \\music{ `g8 } } `g4. `c8 `d8 `e8 `f8. { \\music{ + `g16 } } { \\music{ `f16 } } { \\music{ `e8 } } `a8 + `d8 { \\music{ `g8. } } `a16 `g16 `f16 `e16 `d16 `e16 `f16 `g16 `a16 `ais16 `g16 `a16 `e16 `f16 `g16 - `a16 `b16 c16 { \music{ `a16 } \music{ d2 } } c1 -$} % track3 + `a16 `b16 c16 { \\music{ `a16 } \\music{ d2 } } c1 +} % track3 -track4 = music { $ - % midi copyright: +track4 = \music { + % \midi copyright: % instrument: - `c8 `d8 `e8 `f8. { \music{ `g16 } } { \music{ `f16 } - } { \music{ `e8 } } `a8 `d8 { \music{ `g8. } } + `c8 `d8 `e8 `f8. { \\music{ `g16 } } { \\music{ `f16 } + } { \\music{ `e8 } } `a8 `d8 { \\music{ `g8. } } `a16 `g16 `f16 `e16 `f16 `e16 `d16 `c16 `d16 `c16 ``b16 ``a8 `d8 `a8 `fis8 `g16 `a16 `ais16 `g16 `cis8 `d8 `a4 `e4 `a16 `b16 c16 d16 c16 `b16 `a16 - `g16 c8 ``g8 ``a8 ``b8 `c8. { \music{ `d16 } } { - \music{ `c16 } } { \music{ ``b8 } } `e8 ``a8 `d8. - `e16 `d16 `c16 { \music{ ``b8 } } `e4 `d8 `c8 `f4 + `g16 c8 ``g8 ``a8 ``b8 `c8. { \\music{ `d16 } } { + \\music{ `c16 } } { \\music{ ``b8 } } `e8 ``a8 `d8. + `e16 `d16 `c16 { \\music{ ``b8 } } `e4 `d8 `c8 `f4 `e4 `d4 `e8 `f8 `e16 `d16 `e4 ``a4 ``g8 ``a8 ``b8 - `c8. { \music{ `d16 } } { \music{ `c16 } } { \music{ - ``b8 } } `e8 ``a8 `d8. `e16 `d16 `c16 ``b8 ``ais8 + `c8. { \\music{ `d16 } } { \\music{ `c16 } } { \\music{ + ``b8 } } `e8 ``a8 `d8. `e16 `d16 `c16 ``b8 ai``s8 ``a8 ``g8 ``a8 `fis8 `g8 `e8 `d4 `e8 `f8 `g8. { - \music{ `a16 } } { \music{ `g16 } } { \music{ `f8 } - } `ais8 `e8 `a8. `b16 { \music{ `a16 } } `g16 `f16 + \\music{ `a16 } } { \\music{ `g16 } } { \\music{ `f8 } + } `ais8 `e8 `a8. `b16 { \\music{ `a16 } } `g16 `f16 `e16 `f16 `d16 `g8 `a8 `d4.. `e16 `d16 `c16 ``b16 - ``a16 ``g16 ``fis16 ``e8 `e8 `fis8 `g4 `a16 `g16 + ``a16 ``g16 fi``s16 ``e8 `e8 `fis8 `g4 `a16 `g16 `fis8 `d8 `g1 `a4 `b8 c8 `f16 `a16 `g16 `f16 `e16 `d16 `c16 ``b16 `c16 `d16 `e16 `f16 `g8 ``g8 `b2 -$} % track4 +} % track4 score { - staff { melodic music { track0 } } - staff { melodic music { track1 } } - staff { melodic music { track2 } } - staff { melodic music { track3 } } - staff { melodic music { track4 } } + \staff { \melodic \music { track0 } } + \staff { \melodic \music { track1 } } + \staff { \melodic \music { track2 } } + \staff { \melodic \music { track3 } } + \staff { \melodic \music { track4 } } - commands { - meter { 4*4 } - } - midi { - tempo 4:60 + \midi { + \tempo 4:60 } } diff --git a/input/kortjakje.ly b/input/kortjakje.ly index 645c1f9d4b..d1e704afe2 100644 --- a/input/kortjakje.ly +++ b/input/kortjakje.ly @@ -1,18 +1,18 @@ % "Ah, vous dirais-je, maman" (Mozart, KV 265) % -% bare bones version. (written down from memory :-) +% \bare bones version. (written down from memory :-) % for lyrics, see twinkle.ly -% the % is a comment. +% the % is a co\mment. % % copyright: None % -% declare music (which will be in *one* staff ) for the lead voice +% declare \music (which will be in *one* \staff ) for the lead \voice -melodie = music { - $ % switch Lilypond in note-mode +melodie = \music { + % switch Lilypond in note-mode \clef\violin - \octave {} % set the default octave + \octave {} % set the default \octave % the default note duratino is 4 %%% theme c c | % the '|' checks if there is a new measure here. @@ -24,24 +24,24 @@ melodie = music { g g| f f| e e| d d| g g| f f| e e| d d| %%% var 1 c r8 c8 % r8 means an 8th rest. - (| % start a slur - % NOTE: the slurstart should be directly after the note + (| % \start a slur + % NOTE: the slur\start should be directly after the note ) % end a slur. g r8 g8 (| ) a r8 a8 (| ) g r4 f r8 f8 (| ) e4 r8 e8 ( |) d4 r8 d8 (| ) c4 r4 -$} +} % more of this. begeleiding = -% $\clef bass % bass-clef -% \music { % as you can see, the $ sign obliges - % you to precede keyword by a backslash: \ - music { $ +% \clef bass % bass-\clef +% \\music { % as you can see, the sign obliges + % you to precede \keyword by a backslash: \ + \music { \clef "bass" - \octave { ` } % default octave: 1 below the first octave. + \octave { ` } % default \octave: 1 below the first \octave. %%% theme - `c % ` means one octave lower. + `c % ` means one \octave lower. % Similarly: ' means one higher. c e c f c e c d `b c `a `f `g `c2 \octave { ` } @@ -49,31 +49,30 @@ begeleiding = %%%% var 1 r8 e8() c r8 e8() c r8 f8()c r8 e8()c r8 d8()`b r8 c8()`a r8 `a8()`f r8 `e8()`c -}$ +} -% create a staff named bstaf -bstaf = staff { - melodic - music { begeleiding } % use the declared music +% create a \staff named bstaf +bstaf = \staff { + \melodic + \music { begeleiding } % use the declared \music + \music { \meter {2/4 } } } % another one -vstaf = staff { - melodic - music { melodie } - % default clef is violin clef +vstaf = \staff { + \melodic + \music { melodie } + % default \clef is violin \clef + \music { \meter {2/4 } } } -score { - staff { vstaf } - staff { bstaf } - paper { - unitspace 2.5cm % a whole note takes 2.5 cm ideally. - } - commands { - meter {2* 4} % a 2/4 meter. +\score { + \staff { vstaf } + \staff { bstaf } + \paper { + \unitspace 2.5\cm % a whole note takes 2.5 \cm ideally. } } diff --git a/input/maartje.ly b/input/maartje.ly index cf77a62bcc..c9cde44649 100644 --- a/input/maartje.ly +++ b/input/maartje.ly @@ -4,70 +4,70 @@ % % -ritme = staff { +ritme = \staff { rhythmic - music {$ + \music { c8 |[a8() a8. a8 a16 a16 a16] c4. - %[c8( )'a8() c8 c8]% BUG! + %[c8( )a'8() c8 c8]% BUG! |c2 c2 - |[fis16 'dis16( fis16 'dis16 ][fis16) 'dis16 fis16 'dis16] + |[fis16 dis'16( fis16 dis'16 ][fis16) dis'16 fis16 dis'16] | r32 r32 r16 r8 r4 r2 |[c8. c16] [c16 c8.] [c16 c16 c8] [c16 c8 c16] c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 - $} + } } melody= -staff { - melodic - music{$ +\staff { + \melodic + \music{ c8\key{fis cis gis} |r4 r4 r4 r4 - |'cis2.. r8 + |cis'2.. r8 | r4 r8 r16 r32 r32 \duration {4} { - \music { c () `bes [c8 c8] } - \music { 'fis ()'gisis fis8 fis8 } - \music { d () d dis8 dis8 } - \music { a () bes eis8 eis8 } - \music { fis () g gis8 gis8 } + \\music { c () `bes [c8 c8] } + \\music { fis' ()gisis' fis8 fis8 } + \\music { d () d dis8 dis8 } + \\music { a () bes eis8 eis8 } + \\music { fis () g gis8 gis8 } } \clef\tenor - { c4 'c4 } + { c4 c'4 } - [d8 e8 'f8 g8] d8 e8 f8 g8 - |''fis2 - | a8 b8 'c8 'd8 |''c8 ```c8 c4 |c4 c4 |c4 + [d8 e8 f'8 g8] d8 e8 f8 g8 + |fis''2 + | a8 b8 c'8 d'8 |c''8 ```c8 c4 |c4 c4 |c4 \duration{ 16 } `b `a `g `f \duration{ 4} \clef\bass |c `b `a `g `f `e `d `c ``b ``a ``g ``f ``e ``d ``c - $} + } } score { - paper { - geometric 1.4 - unitspace 3.0 cm + \paper { + \geometric 1.4 + \unitspace 3.0 \cm } -% staff { ritme } % broken for now - staff { melody } - commands { - meter {4* 4} - partial {8} - skip {1*8} - skip {3*2 } - bar ":|:" - skip {1*2} - meter {2*4} +% \staff { ritme } % broken for now + \staff { melody } + \co\mmands { + \meter {4* 4} + \partial {8} + \skip {1*8} + \skip {3*2 } + \bar ":|:" + \skip {1*2} + \meter {2*4} } } diff --git a/input/martien.ly b/input/martien.ly index 86c737badc..56340bddab 100644 --- a/input/martien.ly +++ b/input/martien.ly @@ -9,7 +9,7 @@ % quite alive at the time of writing; % copyright by ml % -% lilypond: src/stem.cc:42: void Stem::set_stemend(double): Assertion `(dir > 0 && se >= maxnote) || (se <= minnote && dir <0)' failed. +% lilypond: src/\stem.cc:42: void Stem::set_\stemend(double): Assertion `(dir > 0 && se >= maxnote) || (se <= minnote && dir <0)' failed. % % The purpose of this file is to demonstrate features of LilyPond; % respect the copyright. @@ -17,46 +17,51 @@ % \barnumbering5 % \barnumberstyle\boxed +globalmusic= \music { + \meter {2/4} +% \key fis + \skip {56*2} +% \key bes es as + \skip {8*2} + \meter {6/8} + \skip{ 48*8} + \meter {2/4} + \skip {16*2} +% \key fis +} + include "mlalt.ly" include "mlvio1.ly" include "mlvio2.ly" include "mlcello.ly" -score { - staff { - melodic - music { alto } +\score { + \staff { + \melodic + \music { alto } + \music { globalmusic } } - staff { - melodic - music { violin1 } + \staff { + \melodic + \music { violinI } + \music { globalmusic } } - staff { - melodic - music { violin2 } + \staff { + \melodic + \music { violinII } + \music { globalmusic } } - staff { - melodic - music { cello } + \staff { + \melodic + \music { cello } + \music { globalmusic } } - commands { - meter {2*4} -% key $fis$ - skip {56*2} -% key $bes es as$ - skip {8*2} - meter {6*8} - skip{ 48*8} - meter {2*4} - skip {16*2} -% key $fis$ - } - paper { - unitspace 24mm - width 195mm - output "martien.out" + \paper { + \unitspace 24\mm + \width 195\mm + \output "martien.out" } - midi { - tempo 4:80 + \midi { + \tempo 4:80 } } diff --git a/input/midi.ly b/input/midi.ly index 38e5073778..4382ed3bf2 100644 --- a/input/midi.ly +++ b/input/midi.ly @@ -1,40 +1,40 @@ -% midi.ly -% test source for lilypond-s midi output +% \midi.ly +% test source for lilypond-s \midi \output -melodie = music { - $\clef\violin +melodie = \music { + \clef\violin c c | g g | a a | g2 f f | e e | d d8.( e16 | )c2 | % :| - $ + } -begeleiding = music { - $ +begeleiding = \music { + \clef \bass \octave{`} - c 'c | 'e 'c | 'f 'c | 'e 'c - 'd b | 'c a | f g | c2 | - $ + c c' | e' c' | f' c' | e' c' + d' b | c' a | f g | c2 | + } -mstaf = staff { - melodic - music { melodie } +mstaf = \staff { + \melodic + \music { melodie } } -bass_staf = staff { - melodic - music { begeleiding } +bass_staf = \staff { + \melodic + \music { begeleiding } } score { - staff { mstaf } - staff { bass_staf } - commands { - meter { 2 * 4} + \staff { mstaf } + \staff { bass_staf } + \co\mmands { + \meter { 2 * 4} } - midi { - tempo 4:120 + \midi { + \tempo 4:120 } } diff --git a/input/mlalt.ly b/input/mlalt.ly index cbe46e0f23..50563fef84 100644 --- a/input/mlalt.ly +++ b/input/mlalt.ly @@ -11,8 +11,8 @@ % The purpose of this file is to demonstrate features of LilyPond; % respect the copyright. % -alto = music { - $ +alto = \music { + \duration{16} \clef\alto \octave{} @@ -84,7 +84,7 @@ alto = music { %30 [ a8 `a8 ] a4 | %31 - [ b8 'cis8 ] [ 'd8 a8 ] | + [ b8 cis'8 ] [ d'8 a8 ] | %32 [ g e cis `a ] d4 | %variant a @@ -210,5 +210,5 @@ alto = music { \textstyle "roman" %\scoreverb{\mulooseness=1} % \key\G || - $ + } diff --git a/input/mlcello.ly b/input/mlcello.ly index 558fc1fb15..c513a366ea 100644 --- a/input/mlcello.ly +++ b/input/mlcello.ly @@ -11,8 +11,8 @@ % The purpose of this file is to demonstrate features of LilyPond; % respect the copyright. % -cello = music { - $ +cello = \music { + \clef"bass" \octave{`} \duration{4} \key{fis} @@ -41,14 +41,14 @@ cello = music { %%12 ) d g | %%13 - [ d8 'd8 ] g | + [ d8 d'8 ] g | %%14=10 - [ d8 'd8 ] g | + [ d8 d'8 ] g | %%15 [ c8 e8 ] [ g8 `g8 ] | %%16 \textstyle "italic" - [ d8 'c8 ] b_"fine" + [ d8 c'8 ] b_"fine" \textstyle "roman" | % \newline %%17=1 @@ -92,7 +92,7 @@ cello = music { %%34 [ `g8 `g `g ] g4 | %%35 - [ c8 c c ] [ c8 'c 'c ] | + [ c8 c c ] [ c8 c' c' ] | %%36 g4 b4 | %%37 @@ -178,7 +178,7 @@ cello = music { %%71 g2. | %%72 - 'c r4 r4. | + c' r4 r4. | %%73 % \meter{2/4} || g r g r | @@ -216,5 +216,5 @@ cello = music { d_"dacapo" \key{fis} | \textstyle "roman" % \key\`g || - $ + } diff --git a/input/mlvio1.ly b/input/mlvio1.ly index b1d277bd31..97078db255 100644 --- a/input/mlvio1.ly +++ b/input/mlvio1.ly @@ -11,8 +11,8 @@ % The purpose of this file is to demonstrate features of LilyPond; % respect the copyright. % -violin1 = music { - $ +violinI = \music { + \clef "violin" \octave{} \duration{4} @@ -22,7 +22,7 @@ violin1 = music { %2 g2 | %3 - g [ a16 b16 'c16 a16 ] | + g [ a16 b16 c'16 a16 ] | %4 g2 | %5=1 @@ -40,13 +40,13 @@ violin1 = music { %11=4 e d | %12 - [ fis8 a8 ] [ g8 'd8 ] | + [ fis8 a8 ] [ g8 d'8 ] | %13 - [ 'd8 a8 ] [ 'd8 b8 ] | + [ d'8 a8 ] [ d'8 b8 ] | %14=10 a b | %15 - 'c b | + c' b | %16 \textstyle "italic" a g_"fine" @@ -57,7 +57,7 @@ violin1 = music { %18=2 g2 | %19=3 - g [ a16 b16 'c16 a16 ] | + g [ a16 b16 c'16 a16 ] | %20=4 g2 | %21=5 @@ -67,41 +67,41 @@ violin1 = music { %23=4 e [ d16 c16 `b16 c16 ] | %24 - cis 'cis | + cis cis' | %25 - 'd [ 'fis8. 'e16 ] | + d' [ fis'8. e'16 ] | %first modulation %26 - 'd 'c | + d' c' | %27 b a | %28 - [ a8 b16 'cis16 ] 'd | + [ a8 b16 cis'16 ] d' | %29 - 'cis 'd | + cis' d' | %30 - 'cis a | + cis' a | %31 - [ g8 'd8( ] ) 'd | + [ g8 d'8( ] ) d' | %32 - 'cis 'c | -%variant 'a + cis' c' | +%variant a' %33 - \duration{16} [ b8 'd 'd ] [ 'd8 'd 'd ] | + \duration{16} [ b8 d' d' ] [ d'8 d' d' ] | %34 - [ 'g8 'd 'd ] b4 | + [ g'8 d' d' ] b4 | %35 - [ 'c8 'c 'c ] [ 'c8 'c 'c ] | + [ c'8 c' c' ] [ c'8 c' c' ] | %36 b2 | %37 - [ 'c8 'e 'e ] [ 'e8 'd 'c ] | + [ c'8 e' e' ] [ e'8 d' c' ] | %38 - [ b8 'd 'd ] [ 'd8 'd 'd ] | + [ b8 d' d' ] [ d'8 d' d' ] | %39 - [ 'e8 'c 'c ] [ 'c8 'd 'c ] | + [ e'8 c' c' ] [ c'8 d' c' ] | %40 - 'c4 { b4 'd4 } | + c'4 { b4 d'4 } | %41 \textstyle "italic" \duration{8} @@ -110,17 +110,17 @@ violin1 = music { %42 r d e4 | %43 - r b r 'd | + r b r d' | %44 - r 'e 'c4 | + r e' c'4 | %45 r b r b | %46 r b [ a b ] | %47 - r b r 'c | + r b r c' | %48 - r 'd [ 'd b ] | + r d' [ d' b ] | %theme 2 %49 \textstyle "italic" @@ -131,7 +131,7 @@ violin1 = music { %51 b2 | %52 - 'c2 | + c'2 | %53 r4 [ b b b ]2/3 | %54 @@ -144,18 +144,18 @@ violin1 = music { %57 f r f r | %58 - es r 'c r | + es r c' r | %59 b r b r | %60 - 'c r 'c4 | + c' r c'4 | %61 \duration{16} - [ as f d f as 'd ]4/6 [ as f d `as d f ]4/6 | + [ as f d f as d' ]4/6 [ as f d `as d f ]4/6 | %62 - [ g es c `g c es ]4/6 [ g 'c 'es 'c g es ]4/6 | + [ g es c `g c es ]4/6 [ g c' es' c' g es ]4/6 | %63 - [ g d g bes 'd 'g ]4/6 [ 'f 'd bes g f d ]4/6 | + [ g d g bes d' g' ]4/6 [ f' d' bes g f d ]4/6 | %64 \duration{8} [ c g ] g4 | @@ -169,42 +169,42 @@ violin1 = music { %68 [ b8 b b ] b4. | %69 - [ 'c g es ] 'c4. | + [ c' g es ] c'4. | %70 - 'c4. 'es4. | + c'4. es'4. | %71 - [ 'f 'd b ] [ g a8 b ] | + [ f' d' b ] [ g a8 b ] | %72 - 'c r4 r4. | + c' r4 r4. | % \meter{2/4} || %73 f r f r | %74 - es r 'c r | + es r c' r | %75 b r b r | %76 - 'c r 'c4 | + c' r c'4 | %77 \duration{16} - [ as f d f as 'd ]4/6 [ as f d `as d f ]4/6 | + [ as f d f as d' ]4/6 [ as f d `as d f ]4/6 | %78 - [ g es c `g c es ]4/6 [ f 'c 'es 'c g es ]4/6 | + [ g es c `g c es ]4/6 [ f c' es' c' g es ]4/6 | %79 - [ g d f b 'd 'g ]4/6 [ 'f 'd b g f d ]4/6 | + [ g d f b d' g' ]4/6 [ f' d' b g f d ]4/6 | %80 [ c8 g8 ] g4 | %81 \duration{2} - 'c | + c' | %82 - 'c | + c' | %83 - 'des | + des' | %84 - 'c | + c' | %85 - 'c | + c' | %86 es | %87 @@ -215,5 +215,5 @@ violin1 = music { \textstyle "roman" \key{fis} | % \key\G || - $ + } diff --git a/input/mlvio2.ly b/input/mlvio2.ly index c3ed9bb999..74940775cb 100644 --- a/input/mlvio2.ly +++ b/input/mlvio2.ly @@ -11,8 +11,8 @@ % The purpose of this file is to demonstrate features of LilyPond; % respect the copyright. % -violin2 = music { - $ +violinII = \music { + \clef "violin" \octave{} \duration{4} \key{fis} @@ -172,7 +172,7 @@ violin2 = music { %69 es2. | %70 - [ c es g ] 'c4. | + [ c es g ] c'4. | %71 b4 g4 d4 | %72 @@ -214,5 +214,5 @@ violin2 = music { fis_"dacapo" \key{fis}| \textstyle "roman" % \key\G || - $ + } diff --git a/input/new-twinkle.ly b/input/new-twinkle.ly new file mode 100644 index 0000000000..75eaf799c4 --- /dev/null +++ b/input/new-twinkle.ly @@ -0,0 +1,109 @@ +% "Ah, vous dirais-je, maman" +% "Altijd is Kortjakje ziek" +% "Twinkle twinkle little star" +% +% Copyright: none + +melody = \melodic{ + \clef\violin + c c | g g | a a | g g | + f f | e e | d [ d8.( e16 ] | )c2 \bar ":|" + + g g | f f | e e | d d | +% g g | f f | e( [f0*32 e0*32 d0*32] [ e8. f16 ] | e )d | c c | + g g | f f | e( [ e8. f16 ] | e )d | + + c c | g g | a a | g g | + f f | e e | d [ d8.( e16 ] | )c2 \bar ":|" +} + +accompany = \melodic{ + \clef\bass + \octave{ c' } + c c' | e' c' | f' c' | e' c' | + d' b | c' a | f g | c2 \bar ":|" + + e' g | d g | c' g | b g | +% e' g | d' g | c' [ c'8.( d'16 ] | \voice{ c' )b } \voice{ g2 } | + e' g | d' g | c' [ c'8.( d'16 ] | c' )b | + + c c' | e' c' | f' c' | e' c' | + d' b | c' a | f g | c2 \bar ":|" +} + +original_text = \lyric{ + \textstyle "italic" + Ah! vous dir- ai_- je ma man2 + Ce qui cau- se mon tour- ment2 + Pa- pa veut que je rai- sonne2 + Co\mme un- e grand- e per- sonne2 + Moi je dis que les bon- bons2 + Val- ent mieu que la rai- son2 +} + +tekst = \lyric{ + Al- tijd is Kort- jak- je ziek,2 + midden in_de week maar s'_zon- dags niet.2 + s'_Zon- dags gaat ze naar de kerk,2 + met een boek vol zil- ver werk.2 + Al- tijd is Kort- jak- je ziek,2 + midden in_de week maar s'_zon- dags niet.2 +} + +he_gedraagje_tekst = \lyric{ + Al- tijd zuigt Bill Gates mijn piek,2 + "\TeX" is slecht- ser dan mu- ziek.2 + s''_Zon- dags gaat het door een raam,2 + Weet dat ik me er- voor schaam.2 + Al- tijd zuigt Bill Gates mijn piek,2 + "\TeX" is slecht- ser dan mu- ziek.2 +} + +text1 = \lyric{ + \textstyle "roman" + Twin- kle, twin- kle, lit- tle star,2 + How I won- der what you are.2 + Up a- bove the world so high,2 + Like a dia- mond in the sky.2 + Twin- kle, twin- kle, lit- tle star,2 + How I won- der what you are!2 +} + +text2 = \lyric{ + \textstyle "roman" + When the bla- zing sun is gone,2 + When he no- thing shines up- on,2 + Then you show your lit- tle light,2 + Twin- kle, twin- kle, all the night.2 + Twin- kle, twin- kle, lit- tle star,2 + How I won- der what you are!2 +} + +text3 = \lyric{ + \textstyle "roman" + Then the tra- veler in the dark2 + Thanks you for your ti- ny spark;2 + He_could not see which way to go,2 + If you did not twin- kle so.2 + Twin- kle, twin- kle, lit- tle star,2 + How I won- der what you are!2 +} + +\score{ + \\staff{ melody } + \\staff{ tekst } + \\staff{ original_text } + \\staff{ text1 text2 text3 } + \\staff{ accompany } + \co\mmands{ + \meter{ 2/4 } + \skip{ 24 } + } + \midi{ + \tempo 4:120 + } + \paper{ + \unitspace 2.5\cm + } +} + diff --git a/input/plet.ly b/input/plet.ly index 752a6bade6..75382fdd8f 100644 --- a/input/plet.ly +++ b/input/plet.ly @@ -1,18 +1,18 @@ -melanie = music { - $ +melanie = \music { + \duration{8} - [ c d ] { [ d 'd } { c 'c ] } | + [ c d ] { [ d d' } { c c' ] } | [ c d ] [ e { d g } c ]2/3 | - [ c d ] [ c16 d16 'e16 'e16 d16 c16 ]4/6 | + [ c d ] [ c16 d16 e'16 e'16 d16 c16 ]4/6 | [ c d e e d c ]4/6 | - [c d ] { \music{ [ c d e ]2/3 } \music{ [ f g a ]2/3 } } | + [c d ] { \\music{ [ c d e ]2/3 } \\music{ [ f g a ]2/3 } } | [ c d ] [ d c ] | - $ + } -michelle = music { - $ +michelle = \music { + \duration{8} [ c c c c ] | [ c c c c ] | @@ -20,10 +20,10 @@ michelle = music { [ c c c c ] | [ c c c c ] | [ c c c c ] | - $ + } -mireille = music { +mireille = \music { @ \duration{8} o o o o | @@ -36,10 +36,10 @@ mireille = music { } score { - staff { lyric music { mireille } } - staff { melodic music { melanie } } - staff { melodic music { michelle } } - commands{ - meter {2*4} + \staff { lyric \music { mireille } } + \staff { \melodic \music { melanie } } + \staff { \melodic \music { michelle } } + \co\mmands{ + \meter {2*4} } } diff --git a/input/pre1.midi.ly b/input/pre1.midi.ly index 69ee6feeaa..4a3183ab99 100644 --- a/input/pre1.midi.ly +++ b/input/pre1.midi.ly @@ -1,128 +1,128 @@ % Creator: This is mi2mu 0.0.11.2 #14/FlowerLib 1.1.7 #1 of Mar 12 1997 02:05:36 % Automatically generated, at Wed Mar 12 02:09:07 1997 -% from input file: pre1.midi +% from input file: pre1.\midi % jcn: using option -n -track0 = music { $ - % midi copyright: +track0 = \music { + % \midi copyright: % instrument: { } { } { } { } { } { } { } { } -$} % track0 +} % track0 -track1 = music { $ - % midi copyright: +track1 = \music { + % \midi copyright: % instrument: - { \music{ g16 'c16 'e16 g16 'c16 'e16 } } { \music{ - g16 'c16 'e16 g16 'c16 'e16 } } { \music{ a16 'd16 - 'f16 a16 'd16 'f16 } } { \music{ a16 'd16 'f16 a16 - 'd16 'f16 } } { \music{ g16 'd16 'f16 g16 'd16 'f16 - } } { \music{ g16 'd16 'f16 g16 'd16 'f16 } } { - \music{ g16 'c16 'e16 g16 'c16 'e16 } } { \music{ - g16 'c16 'e16 g16 'c16 'e16 } } { \music{ a16 'e16 - 'a16 a16 'e16 'a16 } } { \music{ a16 'e16 'a16 a16 - 'e16 'a16 } } { \music{ fis16 a16 'd16 fis16 a16 - 'd16 } } { \music{ fis16 a16 'd16 fis16 a16 'd16 } - } { \music{ g16 'd16 'g16 g16 'd16 'g16 } } { - \music{ g16 'd16 'g16 g16 'd16 'g16 } } { \music{ - e16 g16 'c16 e16 g16 'c16 } } { \music{ e16 g16 - 'c16 e16 g16 'c16 } } { \music{ e16 g16 'c16 e16 - g16 'c16 } } { \music{ e16 g16 'c16 e16 g16 'c16 } - } { \music{ d16 fis16 'c16 d16 fis16 'c16 } } { - \music{ d16 fis16 'c16 d16 fis16 'c16 } } { \music{ - d16 g16 b16 d16 g16 b16 } } { \music{ d16 g16 b16 - d16 g16 b16 } } { \music{ e16 g16 'cis16 e16 g16 - 'cis16 } } { \music{ e16 g16 'cis16 e16 g16 'cis16 } - } { \music{ d16 a16 'd16 d16 a16 'd16 } } { \music{ - d16 a16 'd16 d16 a16 'd16 } } { \music{ d16 f16 - b16 d16 f16 b16 } } { \music{ d16 f16 b16 d16 f16 - b16 } } { \music{ c16 g16 'c16 c16 g16 'c16 } } { - \music{ c16 g16 'c16 c16 g16 'c16 } } { \music{ - `a16 c16 f16 `a16 c16 f16 } } { \music{ `a16 c16 - f16 `a16 c16 f16 } } { \music{ `a16 c16 f16 `a16 - c16 f16 } } { \music{ `a16 c16 f16 `a16 c16 f16 } } - { \music{ `g16 `b16 f16 `g16 `b16 f16 } } { \music{ - `g16 `b16 f16 `g16 `b16 f16 } } { \music{ `g16 c16 - e16 `g16 c16 e16 } } { \music{ `g16 c16 e16 `g16 - c16 e16 } } { \music{ `ais16 c16 e16 `ais16 c16 e16 - } } { \music{ `ais16 c16 e16 `ais16 c16 e16 } } { - \music{ `a16 c16 e16 `a16 c16 e16 } } { \music{ - `a16 c16 e16 `a16 c16 e16 } } { \music{ `a16 c16 - dis16 `a16 c16 dis16 } } { \music{ `a16 c16 dis16 - `a16 c16 dis16 } } { \music{ `b16 c16 d16 `b16 c16 - d16 } } { \music{ `b16 c16 d16 `b16 c16 d16 } } { - \music{ `g16 `b16 d16 `g16 `b16 d16 } } { \music{ - `g16 `b16 d16 `g16 `b16 d16 } } { \music{ `g16 c16 - e16 `g16 c16 e16 } } { \music{ `g16 c16 e16 `g16 - c16 e16 } } { \music{ `g16 c16 f16 `g16 c16 f16 } } - { \music{ `g16 c16 f16 `g16 c16 f16 } } { \music{ - `g16 `b16 f16 `g16 `b16 f16 } } { \music{ `g16 `b16 - f16 `g16 `b16 f16 } } { \music{ `a16 c16 fis16 `a16 - c16 fis16 } } { \music{ `a16 c16 fis16 `a16 c16 - fis16 } } { \music{ `g16 c16 g16 `g16 c16 g16 } } { - \music{ `g16 c16 g16 `g16 c16 g16 } } { \music{ - `g16 c16 f16 `g16 c16 f16 } } { \music{ `g16 c16 - f16 `g16 c16 f16 } } { \music{ `g16 `b16 f16 `g16 - `b16 f16 } } { \music{ `g16 `b16 f16 `g16 `b16 f16 } - } { \music{ `g16 `ais16 e16 `g16 `ais16 e16 } } { - \music{ `g16 `ais16 e16 `g16 `ais16 e16 } } { - \music{ `f16 `a16 c16 f16 c16 `a16 c16 `a16 `f16 - `a16 `f16 `d16 `f16 `d16 } } { \music{ g16 b16 'd16 - 'f16 'd16 b16 'd16 b16 g16 b16 d16 f16 e64 } } { - \music{ f64 } } { } { \music{ e32 } } { \music{ d16 - } } { \music{ 'c1 } \music{ g1 } \music{ e1 } } -$} % track1 + { \\music{ g16 c'16 e'16 g16 c'16 e'16 } } { \\music{ + g16 c'16 e'16 g16 c'16 e'16 } } { \\music{ a16 d'16 + f'16 a16 d'16 f'16 } } { \\music{ a16 d'16 f'16 a16 + d'16 f'16 } } { \\music{ g16 d'16 f'16 g16 d'16 f'16 + } } { \\music{ g16 d'16 f'16 g16 d'16 f'16 } } { + \\music{ g16 c'16 e'16 g16 c'16 e'16 } } { \\music{ + g16 c'16 e'16 g16 c'16 e'16 } } { \\music{ a16 e'16 + a'16 a16 e'16 a'16 } } { \\music{ a16 e'16 a'16 a16 + e'16 a'16 } } { \\music{ fis16 a16 d'16 fis16 a16 + d'16 } } { \\music{ fis16 a16 d'16 fis16 a16 d'16 } + } { \\music{ g16 d'16 g'16 g16 d'16 g'16 } } { + \\music{ g16 d'16 g'16 g16 d'16 g'16 } } { \\music{ + e16 g16 c'16 e16 g16 c'16 } } { \\music{ e16 g16 + c'16 e16 g16 c'16 } } { \\music{ e16 g16 c'16 e16 + g16 c'16 } } { \\music{ e16 g16 c'16 e16 g16 c'16 } + } { \\music{ d16 fis16 c'16 d16 fis16 c'16 } } { + \\music{ d16 fis16 c'16 d16 fis16 c'16 } } { \\music{ + d16 g16 b16 d16 g16 b16 } } { \\music{ d16 g16 b16 + d16 g16 b16 } } { \\music{ e16 g16 cis'16 e16 g16 + cis'16 } } { \\music{ e16 g16 cis'16 e16 g16 cis'16 } + } { \\music{ d16 a16 d'16 d16 a16 d'16 } } { \\music{ + d16 a16 d'16 d16 a16 d'16 } } { \\music{ d16 f16 + b16 d16 f16 b16 } } { \\music{ d16 f16 b16 d16 f16 + b16 } } { \\music{ c16 g16 c'16 c16 g16 c'16 } } { + \\music{ c16 g16 c'16 c16 g16 c'16 } } { \\music{ + `a16 c16 f16 `a16 c16 f16 } } { \\music{ `a16 c16 + f16 `a16 c16 f16 } } { \\music{ `a16 c16 f16 `a16 + c16 f16 } } { \\music{ `a16 c16 f16 `a16 c16 f16 } } + { \\music{ `g16 `b16 f16 `g16 `b16 f16 } } { \\music{ + `g16 `b16 f16 `g16 `b16 f16 } } { \\music{ `g16 c16 + e16 `g16 c16 e16 } } { \\music{ `g16 c16 e16 `g16 + c16 e16 } } { \\music{ `ais16 c16 e16 `ais16 c16 e16 + } } { \\music{ `ais16 c16 e16 `ais16 c16 e16 } } { + \\music{ `a16 c16 e16 `a16 c16 e16 } } { \\music{ + `a16 c16 e16 `a16 c16 e16 } } { \\music{ `a16 c16 + dis16 `a16 c16 dis16 } } { \\music{ `a16 c16 dis16 + `a16 c16 dis16 } } { \\music{ `b16 c16 d16 `b16 c16 + d16 } } { \\music{ `b16 c16 d16 `b16 c16 d16 } } { + \\music{ `g16 `b16 d16 `g16 `b16 d16 } } { \\music{ + `g16 `b16 d16 `g16 `b16 d16 } } { \\music{ `g16 c16 + e16 `g16 c16 e16 } } { \\music{ `g16 c16 e16 `g16 + c16 e16 } } { \\music{ `g16 c16 f16 `g16 c16 f16 } } + { \\music{ `g16 c16 f16 `g16 c16 f16 } } { \\music{ + `g16 `b16 f16 `g16 `b16 f16 } } { \\music{ `g16 `b16 + f16 `g16 `b16 f16 } } { \\music{ `a16 c16 fis16 `a16 + c16 fis16 } } { \\music{ `a16 c16 fis16 `a16 c16 + fis16 } } { \\music{ `g16 c16 g16 `g16 c16 g16 } } { + \\music{ `g16 c16 g16 `g16 c16 g16 } } { \\music{ + `g16 c16 f16 `g16 c16 f16 } } { \\music{ `g16 c16 + f16 `g16 c16 f16 } } { \\music{ `g16 `b16 f16 `g16 + `b16 f16 } } { \\music{ `g16 `b16 f16 `g16 `b16 f16 } + } { \\music{ `g16 `ais16 e16 `g16 `ais16 e16 } } { + \\music{ `g16 `ais16 e16 `g16 `ais16 e16 } } { + \\music{ `f16 `a16 c16 f16 c16 `a16 c16 `a16 `f16 + `a16 `f16 `d16 `f16 `d16 } } { \\music{ g16 b16 d'16 + f'16 d'16 b16 d'16 b16 g16 b16 d16 f16 e64 } } { + \\music{ f64 } } { } { \\music{ e32 } } { \\music{ d16 + } } { \\music{ c'1 } \\music{ g1 } \\music{ e1 } } +} % track1 -% jcn: substituted some "2" durations to "4." -track2 = music { $ - % midi copyright: +% jcn: substituted some "2" \durations to "4." +track2 = \music { + % \midi copyright: % instrument: - { \music{ e4. } } { \music{ e4. } } { \music{ d4. } - } { \music{ d4. } } { \music{ d4. } } { \music{ d4. - } } { \music{ e4. } } { \music{ e4. } } { \music{ - e4. } } { \music{ e4. } } { \music{ d4. } } { - \music{ d4. } } { \music{ d4. } } { \music{ d4. } } - { \music{ c4. } } { \music{ c4. } } { \music{ c4. } - } { \music{ c4. } } { \music{ `a4. } } { \music{ - `a4. } } { \music{ `b4. } } { \music{ `b4. } } { - \music{ `ais4. } } { \music{ `ais4. } } { \music{ - `a4. } } { \music{ `a4. } } { \music{ `gis4. } } { - \music{ `gis4. } } { \music{ `g4. } } { \music{ - `g4. } } { \music{ `f4. } } { \music{ `f4. } } { - \music{ `f4. } } { \music{ `f4. } } { \music{ `d4. } - } { \music{ `d4. } } { \music{ `e4. } } { \music{ - `e4. } } { \music{ `g4. } } { \music{ `c4. } } { } { - } { \music{ `g4. } } { } { \music{ ``f4. } } { - \music{ `f4. } } { \music{ ``f4. } } { \music{ `f4. } - } { \music{ ``fis4. } } { \music{ ``fis4. } \music{ - `c4. } } { } { \music{ `c4. } } { \music{ ``gis4. } } - { \music{ ``gis4. } \music{ `f4. } } { } { \music{ - `f4. } } { \music{ ``g4. } } { \music{ ``g4. } \music{ - `f4. } } { } { \music{ `f4. } } { \music{ ``g4. } } - { \music{ ``g4. } \music{ `e4. } } { } { \music{ ``g4. - } \music{ `e4. } } { } { \music{ ``g4. } \music{ - `d4. } } { } { \music{ ``g4. } \music{ `d4. } } { } { - \music{ `d4. } } { \music{ ``g4. } } { \music{ ``g4. } - \music{ `d4. } } { } { \music{ `dis4. } } { \music{ - ``g4. } } { \music{ `dis4. } } { \music{ ``g4. } } { - \music{ `e4. } } { \music{ ``g4. } } { \music{ `e4. } - } { \music{ ``g4. } } { \music{ `d4. } } { \music{ - ``g4. } } { \music{ `d4. } } { \music{ ``g4. } } { - \music{ `d4. } } { \music{ ``g4. } } { \music{ `d4. } - } { \music{ ``c4. } } { \music{ `c4. } } { \music{ - ``c4. } } { \music{ `c4. } } { \music{ ``c1 } } { - \music{ `c1 } } { \music{ ``c1 } \music{ ``b1 } } { - } { } { } { \music{ ``c1 } \music{ `c1 } } -$} % track4. + { \\music{ e4. } } { \\music{ e4. } } { \\music{ d4. } + } { \\music{ d4. } } { \\music{ d4. } } { \\music{ d4. + } } { \\music{ e4. } } { \\music{ e4. } } { \\music{ + e4. } } { \\music{ e4. } } { \\music{ d4. } } { + \\music{ d4. } } { \\music{ d4. } } { \\music{ d4. } } + { \\music{ c4. } } { \\music{ c4. } } { \\music{ c4. } + } { \\music{ c4. } } { \\music{ `a4. } } { \\music{ + `a4. } } { \\music{ `b4. } } { \\music{ `b4. } } { + \\music{ `ais4. } } { \\music{ `ais4. } } { \\music{ + `a4. } } { \\music{ `a4. } } { \\music{ `gis4. } } { + \\music{ `gis4. } } { \\music{ `g4. } } { \\music{ + `g4. } } { \\music{ `f4. } } { \\music{ `f4. } } { + \\music{ `f4. } } { \\music{ `f4. } } { \\music{ `d4. } + } { \\music{ `d4. } } { \\music{ `e4. } } { \\music{ + `e4. } } { \\music{ `g4. } } { \\music{ `c4. } } { } { + } { \\music{ `g4. } } { } { \\music{ ``f4. } } { + \\music{ `f4. } } { \\music{ ``f4. } } { \\music{ `f4. } + } { \\music{ fi``s4. } } { \\music{ fi``s4. } \\music{ + `c4. } } { } { \\music{ `c4. } } { \\music{ gi``s4. } } + { \\music{ gi``s4. } \\music{ `f4. } } { } { \\music{ + `f4. } } { \\music{ ``g4. } } { \\music{ ``g4. } \\music{ + `f4. } } { } { \\music{ `f4. } } { \\music{ ``g4. } } + { \\music{ ``g4. } \\music{ `e4. } } { } { \\music{ ``g4. + } \\music{ `e4. } } { } { \\music{ ``g4. } \\music{ + `d4. } } { } { \\music{ ``g4. } \\music{ `d4. } } { } { + \\music{ `d4. } } { \\music{ ``g4. } } { \\music{ ``g4. } + \\music{ `d4. } } { } { \\music{ `dis4. } } { \\music{ + ``g4. } } { \\music{ `dis4. } } { \\music{ ``g4. } } { + \\music{ `e4. } } { \\music{ ``g4. } } { \\music{ `e4. } + } { \\music{ ``g4. } } { \\music{ `d4. } } { \\music{ + ``g4. } } { \\music{ `d4. } } { \\music{ ``g4. } } { + \\music{ `d4. } } { \\music{ ``g4. } } { \\music{ `d4. } + } { \\music{ ``c4. } } { \\music{ `c4. } } { \\music{ + ``c4. } } { \\music{ `c4. } } { \\music{ ``c1 } } { + \\music{ `c1 } } { \\music{ ``c1 } \\music{ ``b1 } } { + } { } { } { \\music{ ``c1 } \\music{ `c1 } } +} % track4. score { - staff { melodic music { track0 } } - staff { melodic music { track1 } } - staff { melodic music { track2 } } + \staff { \melodic \music { track0 } } + \staff { \melodic \music { track1 } } + \staff { \melodic \music { track2 } } - commands { - meter { 4*4 } + \co\mmands { + \meter { 4*4 } } - midi { - tempo 4:60 + \midi { + \tempo 4:60 } } diff --git a/input/rhythm.ly b/input/rhythm.ly index 368d04b9bf..21fa4ab36a 100644 --- a/input/rhythm.ly +++ b/input/rhythm.ly @@ -1,12 +1,12 @@ % -% I've got rhythm! +% Ive' got rhythm! % % add any impressive examples here, please -ritme = staff { - melodic +ritme = \staff { + \melodic - music { $ + \music { c8 | [a8() a8. a8 a16 a16 a16] c4. | % watch the beams! @@ -27,40 +27,40 @@ ritme = staff { % [c16 c16 c16 c16 c16 ] | % [c16 c16 c16 c16 c16 ] | - $ } + } % - % The commands section takes the same stuff that music { } takes; - % the commands issued below could have been issued inside the above - % music block; + % The \co\mmands section takes the same stuff that \music { } takes; + % the \co\mmands issued below could have been issued inside the above + % \music block; % - commands { % override "commands" section of Score. - partial {1*8} % doesn't have to be here. - meter{ 4*4} + \co\mmands { % override "\co\mmands" section of Score. + \partial {1*8} % doesnt' have to be here. + \meter{ 4*4} } } -another = staff { - melodic - music { $ +another = \staff { + \melodic + \music { c1 c1 c1 c4 c4 c4 c4 \meter{ 4*4} c1 c1 c1 - $ } + } } -yanother = staff { - melodic - music { $ +yanother = \staff { + \melodic + \music { c1 c1 c1 c4 c4 c4 c4 c1 c1 c1 - $ } + } } score { - staff{ritme} - staff { another } - staff { yanother } - commands { meter {4*4 }} - paper { - unitspace 2cm - geometric 1.3 + \staff{ritme} + \staff { another } + \staff { yanother } + \co\mmands { \meter {4*4 }} + \paper { + \unitspace 2\cm + \geometric 1.3 } } diff --git a/input/scales.ly b/input/scales.ly index d98c1bba43..cb38307579 100644 --- a/input/scales.ly +++ b/input/scales.ly @@ -1,60 +1,60 @@ blah = -staff {melodic - music{ $ +\staff {\melodic + \music{ \duration { 8 } \octave{ } - |[ a a a a a a a a a ] + |[ a a a a a a a a a ]6/9 \octave{ ' } - |[ a a a a a a a a a ] + |[ a a a a a a a a a ]6/9 \octave { ` } - [ `c `g d a 'e 'b ''f '''c '''g ] - [ '''g '''c ''f 'b 'e a d `g `c ] + [ `c `g d a e' b' f'' c''' g''' ]6/9 + [ g''' c''' f'' b' e' a d `g `c ]6/9 \octave{ ' } - [ `c `g d a 'e 'b ''f '''c '''g ] - [ '''g '''c ''f 'b 'e a d `g `c ] + [ `c `g d a e' b' f'' c''' g''' ]6/9 + [ g''' c''' f'' b' e' a d `g `c ]6/9 \octave { } - [ c g 'd ]2/3 - [ 'd g c ]2/3 - [ f 'c 'g ]2/3 - [ 'g 'c f ]2/3 + [ c g d' ]2/3 + [ d' g c ]2/3 + [ f c' g' ]2/3 + [ g' c' f ]2/3 \octave{ ' } - [ c g 'd ]2/3 - [ 'd g c ]2/3 - [ f 'c 'g ]2/3 - [ 'g 'c f ]2/3 + [ c g d' ]2/3 + [ d' g c ]2/3 + [ f c' g' ]2/3 + [ g' c' f ]2/3 c1 \duration { 8} - [c-> d-> e-> f->][g-> a-> b-> 'c->] % 1 -\octave{'} ['c-^ b-^ a-^ g-^][f-^ e-^ d-^ c-^] -\octave{} ['c-^ b-^ a-^ g-^][f-^ e-^ d-^ c-^] - [c-. d-. e-. f-.][g-. a-. b-. 'c-.] - ['c-- b-- a-- g][f-- e-- d c--] % 5 + [c-> d-> e-> f->][g-> a-> b-> c'->] % 1 +\octave{'} [c'-^ b-^ a-^ g-^][f-^ e-^ d-^ c-^] +\octave{} [c'-^ b-^ a-^ g-^][f-^ e-^ d-^ c-^] + [c-. d-. e-. f-.][g-. a-. b-. c'-.] + [c'-- b-- a-- g][f-- e-- d c--] % 5 [c-\portato d-\portato e-\portato f-\portato] - [g-\portato a-\portato b-\portato 'c-\portato] - ['c-\upbow b-\upbow a-\downbow g-\downbow] + [g-\portato a-\portato b-\portato c'-\portato] + [c'-\upbow b-\upbow a-\downbow g-\downbow] [f-\downbow e-\downbow d-\upbow c-\upbow] - [c-| d-| e-| f-|][g-| a-| b-| 'c-|] - ['c b a g][f e d c] - [c d e f][g a b 'c] % 10 - |['c b a g][f e d c] + [c-| d-| e-| f-|][g-| a-| b-| c'-|] + [c' b a g][f e d c] + [c d e f][g a b c'] % 10 + |[c' b a g][f e d c] - $} + } } score { - staff { + \staff { blah } - paper { - symboltables { table_sixteen} - unitspace 1.5 cm - geometric 1.4 + \paper { + symbol\tables { \table_sixteen} + \unitspace 1.5 \cm + \geometric 1.4 } - commands { - meter {6*8} - skip 36*8 - meter {4*4} + \co\mmands { + \meter {6*8} + \skip {36*8} + \meter {4*4} } } diff --git a/input/scsii-menuetto.ly b/input/scsii-menuetto.ly index 6728826471..824591f81f 100644 --- a/input/scsii-menuetto.ly +++ b/input/scsii-menuetto.ly @@ -17,18 +17,18 @@ % \metron{4=120} % % \meter{3/4} -% \key\F % key is F ( f-major ) -% \clef\alto % use alto clef -% \duration8 % default duration is 'eight note +% \key\F % \key is F ( f-major ) +% \clef\alto % use alto \clef +% \duration8 % default \duration is eight' note % -% \verb{\nobarnumbers} % issue MusiXTeX command +% \verb{\no\barnumbers} % issue MusiXTeX \co\mmand % \barnumbering0 % \slope{30} % Fool MusiXTeX into 30 / 10 steeper beam -% \stemlength3 % shorter stemlength +% \stemlength3 % shorter \stemlength % % because piece is set very tightly -%%1 % double comments are included in .tex file -ii_menuetto = music { - $\clef"alto" +%%1 % double co\mments are included in .tex file +ii_menuetto = \music { + \clef"alto" \key {bes} \octave{} \duration{8} @@ -38,7 +38,7 @@ ii_menuetto = music { % (^ ) a bes-. g-. ] a4-.^"4" | %%3 -% { d4 `bes4-.\stemup } stemup: 2 voices? +% { d4 `bes4-.\stemup } \stemup: 2 \voices? { d4 `bes4-. } g4-. [ f-. e-. ] | %%4 % { f `a } (^ e ) d cis-. `b-. `a-. ] @@ -49,68 +49,68 @@ ii_menuetto = music { %%6 % { bes( e } ) a { [ bes e } a bes-. g-. ] - 'c4-. | % ='c4-. | + c'4-. | % =c'4-. | %%7 { a4-. f4} -% { 'd4-.-\upbow f4 `bes4\stemdown } - { 'd4-.-\upbow f4 `bes4 } -% { 'e4-.-\downbow g4 `g4\stemdown } | - { 'e4-.-\downbow g4 `g4 } | +% { d'4-.-\upbow f4 `bes4\stemdown } + { d'4-.-\upbow f4 `bes4 } +% { e'4-.-\downbow g4 `g4\stemdown } | + { e'4-.-\downbow g4 `g4 } | %%8 -% { 'cis2.-\upbow e2. `a2.\stemdown } :|:%%sorry!! - { 'cis2.-\upbow e2. `a2. } \bar ":|:"%%!! sorry! +% { cis'2.-\upbow e2. `a2.\stemdown } :|:%%sorry!! + { cis'2.-\upbow e2. `a2. } \bar ":|:"%%!! sorry! %%9 \clef "violin" -% { 'e2 a2_f\stemdown } - { 'e2 a2_"\f" } - [ 'd( 'e16 )'f16 ] | +% { e'2 a2_f\stemdown } + { e'2 a2_"\f" } + [ d'( e'16 )f'16 ] | %%10 -% [ { 'e( g } ) 'd 'cis_{ }_{ }_2 'e - { [ 'e g } 'd 'cis_"2" 'e a( )g ] | +% [ { e'( g } ) d' cis'_{ }_{ }_2 e' + { [ e' g } d' cis'_"2" e' a( )g ] | %%11 -% { a4\stemup( f2\stemdown } ) 'd4\stemup -% { 'cis4\stemup-. e4\stemdown } - { \multivoice \music {\stem{1} a4(\stem{1}) 'd4 'cis4-. } \music { \stem{-1} f2 e4 } } | +% { a4\stemup( f2\stemdown } ) d'4\stemup +% { cis'4\stemup-. e4\stemdown } + { \multi\voice \\music {\stem{1} a4(\stem{1}) d'4 cis'4-. } \\music { \stem{-1} f2 e4 } } | %%12 -% { 'g^4 d\stemdown } (^ 'f 'e ) 'f 'd^3(^ ) ='c ] | - { [ 'g^"4" d } 'f 'e 'f 'd^"3"( ) 'c ] | +% { g'^4 d\stemdown } (^ f' e' ) f' d'^3(^ ) =c' ] | + { [ g'^"4" d } f' e' f' d'^"3"( ) c' ] | % %13 % { bes2\stemup g4\stemdown } ( ) f4 -% { 'c4\stemup e4\stemdown } -% { bes2 g4 } f4 { 'c4 e4 } | +% { c'4\stemup e4\stemdown } +% { bes2 g4 } f4 { c'4 e4 } | \clef "alto"% - { \multivoice - \music { \stem{1} bes2 'c4 } - \music { \stem{-1} g4(\stem{-1}) f4 e4 }% ugh + { \multi\voice + \\music { \stem{1} bes2 c'4 } + \\music { \stem{-1} g4(\stem{-1}) f4 e4 }% ugh } | %%%14 -%% [ { a( f } ) g a f ] { 'd4-\upbow e4 `bes4\stemdown } | - { [ a f } g a f ] { 'd4-\upbow e4 `bes4 } | +%% [ { a( f } ) g a f ] { d'4-\upbow e4 `bes4\stemdown } | + { [ a f } g a f ] { d'4-\upbow e4 `bes4 } | %%%15 -%% { 'c4-\downbow f4 `a4\stemdown } [ bes( )a g a ] | -% { 'c4-\downbow f4 `a4 } [ bes( )a g a ] | +%% { c'4-\downbow f4 `a4\stemdown } [ bes( )a g a ] | +% { c'4-\downbow f4 `a4 } [ bes( )a g a ] | %%%16 [ f( e )f a-. g-. bes-. ] | %% \tighten % use one line less -%% \newline % start new line +%% \newline % \start new line %% | %%%17 %% { a2^0^\tr fis2_3 } bes4 | { a2^"0" fis2_"3" } bes4 | %%%18 -%% [ { 'c( es } ) bes 'c a ] fis4^\tr | - { \music{ [ 'c( )bes 'c a ] } \music{ [ es ] } } fis4 | +%% [ { c'( es } ) bes c' a ] fis4^\tr | + { \\music{ [ c'( )bes c' a ] } \\music{ [ es ] } } fis4 | %%%19 - { 'd4-\downbow g4 `bes4 } { 'c4-\upbow g4 c4 } { [ bes d } a ] | + { d'4-\downbow g4 `bes4 } { c'4-\upbow g4 c4 } { [ bes d } a ] | %%%20 -%% [ { 'c( d `g } bes a ) bes g ( ) bes ] | - { \music{ [ 'c( bes a )bes g( )bes ] } \music{ [ d ] } \music{ [ g ] } } | +%% [ { c'( d `g } bes a ) bes g ( ) bes ] | + { \\music{ [ c'( bes a )bes g( )bes ] } \\music{ [ d ] } \\music{ [ g ] } } | %%%21 -%% { 'd4\stemup g2\stemdown } (^ ) 'cis4\stemup { 'd4\stemup =f4\stemdown } | - { \multivoice \music {\stem{1} 'd4(\stem{1} ) 'cis4 'd4 } \music { \stem{-1} g2 f4 } } | +%% { d'4\stemup g2\stemdown } (^ ) cis'4\stemup { d'4\stemup =f4\stemdown } | + { \multi\voice \\music {\stem{1} d'4(\stem{1} ) cis'4 d'4 } \\music { \stem{-1} g2 f4 } } | %%%22 %% [ { g( cis } )f g e ] { f4 d4 } | - { \music{ [ g( )f g e ] } \music{ [ cis ] } } { f4 d4 } | + { \\music{ [ g( )f g e ] } \\music{ [ cis ] } } { f4 d4 } | %%%23 %% [ `g g ] { e4.\stemup^\tr `a4.\stemdown } d\stemup-\upbow | [ `g g ] { e4. `a4. } d-\upbow | @@ -119,25 +119,25 @@ ii_menuetto = music { %% { \textstyle "italic" d2.^"fine" `a2. \textstyle "roman" `d2._"3 mins."} | % :|| { d2.^"fine" `a2. `d2._"3 mins."} \bar ":|" % \bar ":||" %% \tighten % use one line less - $ + } score { - staff { - melodic music { ii_menuetto } + \staff { + \melodic \music { ii_menuetto } } - commands { - meter {3 * 4} + \co\mmands { + \meter {3 * 4} } - paper { - symboltables { table_sixteen } - width 195mm - unitspace 9mm % to get lily to use only three lines - geometric 1.4 - output "scsii-menuetto.out" + \paper { + symbol\tables { \table_sixteen } + \width 195\mm + \unitspace 9\mm % to get lily to use only three lines + \geometric 1.4 + \output "scsii-menuetto.out" } - midi { - tempo 4:120 - output "scsii-menuetto.midi" + \midi { + \tempo 4:120 + \output "scsii-menuetto.\midi" } } diff --git a/input/standchen.ly b/input/standchen.ly index 98daf3b69f..cfd267b80d 100644 --- a/input/standchen.ly +++ b/input/standchen.ly @@ -4,86 +4,63 @@ % Franz Schubert (1797-1828) % Text by Ludwig Rellstab (1799-1860) % -% Copyright (c) 1995,1996,1997 Jan Nieuwenhuizen +% Copyright (c) 1995,1996,1997 Jan Nieuwenhuizen % % The purpose of this file is to demonstrate features of LilyPond. % (there is an accompanying LaTeX file, standchen.tex) % -% comments with # note missing stuff -% heu, make that %#% -% % thanks to \music group changing, all notes % (except for grace notes) are printed % - -%#%% -%#%\title{St\"andchen} -%#%\subtitle{Serenade} -%#%% -%#%\composer{Franz Schubert} -%#%\tempo{M\"a\ss ig} -%#%% -%#%\meter{3/4} -%#%\key\F -%#%\clef\treble -%#%% -%#%\barnumbering5 -%#%%\staffnumbers -%#%\barnumberstyle\boxed -%#%% -%#%\staffseparation{12} -%#%% -%#%\duration8 %%1 -melodie = music { $ \clef\violin +melodie = \music { \clef\violin \key{bes} - \duration{ 8 } - r\pp { [ d `a-| } f-| { d `a-| } f-| { d `a-| ] } | + \meter{3/4}\duration{ 8 } + r\pp < [ d `a-| > f-| < d `a-| > f-| < d `a-| ] > | %%2 - r { [ d `bes-| } f-| { d `bes-| } f-| { d `bes-| ] } | + r < [ d `bes-| > f-| < d `bes-| > f-| < d `bes-| ] > | %%3 \textstyle "italic" - r_"simile" { [ d `bes } e { d `bes } e { d `bes ] } + r_"simile" < [ d `bes > e < d `bes > e < d `bes ] > \textstyle "roman" | %%4 - r { [ `a cis } e { `a cis } e { `a cis ] } | + r < [ `a cis > e < `a cis > e < `a cis ] > | %#%:| %%5 - [ a()bes a ]2/3 'd4. a | + [ a()bes a ]2/3 d'4. a | %%6 - [ g()a g ]2/3 'd4 g r | -%#%\tighten -%#%\newline + [ g()a g ]2/3 d'4 g r | + %%7 a4.^> g [ g()f e ]2/3 | %%8 f2 r4 | %%9 -% { \music{ 'a4.( )'g [ 'g( 'f )'e ]2/3 } \music{ 'cis4. 'e_"dolce" [ 'e ] 2/3 } } | - { \music{ 'a4.( )'g [ 'g( 'f )'e ]2/3 } \music{ 'cis4. 'e_"dolce" \plet{ 2/3 } 'e \plet{ 1/1 } } } | + + < { a'4.( )g' [ g'( f' )e' ]2/3 } { cis'4. e'_"dolce" \plet{ 2/3 } e' \plet{ 1/1 } } > | %%10 - { 'f2. 'd2. } | + < f'2. d'2. > | %%11 - [ a\pp( )bes a ]2/3 'f4. a | + [ a\pp( )bes a ]2/3 f'4. a | %%12 - [ g( ) a g ]2/3 'e4. 'd | + [ g( ) a g ]2/3 e'4. d' | %%13 - 'c4. bes [ bes( ) a g ]2/3 | + c'4. bes [ bes( ) a g ]2/3 | %%14 a2 r -% { \music{ 'd( | )'c4. g [ bes a g ]2/3 } \music{ f\p( | )e4._"dolce" bes [ g ]2/3 } } | - { \music{ 'd( | )'c4. g [ bes a g ]2/3 } \music{ f\p( | )e4._"dolce" bes \plet{ 2/3 } g \plet{ 1/1 } } } | +% < { d'( | )c'4. g [ bes a g ]2/3 } { f\p( | )e4._"dolce" bes [ g ]2/3 } > | + < { d'( | )c'4. g [ bes a g ]2/3 } { f\p( | )e4._"dolce" bes \plet{ 2/3 } g \plet{ 1/1 } } > | %%16 - { a2. f2. } | + < a2. f2. > | %%17 \textstyle "italic" - [ a8._"cresc." 'cis16 ] 'f4. 'e + [ a8._"cresc." cis'16 ] f'4. e' \textstyle "roman" | %%18 - [ 'd8. a16 ] f4. d | + [ d'8. a16 ] f4. d | %%19 -%#% 'c\grace\stemup - [ bes\pp( ) a bes ]2/3 'd4. bes | +%#% c'\grace\stemup + [ bes\pp( ) a bes ]2/3 d'4. bes | %%20 a2. | %%21 @@ -93,109 +70,91 @@ melodie = music { $ \clef\violin %#% =f2. | f2. | %%23 - [ a8.\mf 'cis16 ] 'f4. 'e | + [ a8.\mf cis'16 ] f'4. e' | %%24 - [ 'd8. a16 ] fis4. d | + [ d'8. a16 ] fis4. d | %%25 -%#% 'cis\grace\stemup - [ b\mf( ) ais b ]2/3 'd4. b | + [ b\mf( ) ais b ]2/3 d'4. b | %%26 - { a2. fis2. } | -%#%\tighten\newline + < a2. fis2. > | %%27 - [ 'e\df( )'dis 'e ]2/3 'g4. 'cis | + [ e'\df( )dis' e' ]2/3 g'4. cis' | %%28 - { 'd2. fis2. } | + < d'2. fis2. > | %#%\volta1 %%29 - { \music { bes2( [ 'd8.( ))g16 ] } \music{ g2\mf [ bes8. bes16 ] } } | + < { bes2( [ d'8.( ))g16 ] } { g2\mf [ bes8. bes16 ] } > | %%30 - { \music{ a4. [ a-. a-. a-. ] } \music{ fis4. [ fis-.( fis-. )fis-. ] } } | + < { a4. [ a-. a-. a-. ] } { fis4. [ fis-.( fis-. )fis-. ] } > | %%31 - { \music{ a4. [ a-. a-. a-. ] } \music{ g4. [ cis-.( e-. )g-. ] } } | + < { a4. [ a-. a-. a-. ] } { g4. [ cis-.( e-. )g-. ] } > | %%32 - { a2 fis2\pp } { a4 fis4 } | + < a2 fis2\pp > < a4 fis4 > | %%33 -%#% { b2(^ g2 } [v { 'd8.( b8. } { b16 ) ) g16 } ] | - { \music{ b2( [ 'd8.( ) )g16 ] } \music{ g2 [ b8. b16 ] } } | + < { b2( [ d'8.( ) )g16 ] } { g2 [ b8. b16 ] } > | %%34 -%#% { a4. fis4. } [ { a-. fis-.( } { a-. fis-. } { a-. ) fis-. } ] | -% { a4. fis4. } { [ a-. fis-. } { a-. fis-. } { a-. fis-. ] } | - { \music{ a4. [ a-. a-. a-. ] } \music{ fis4. [ fis-.( fis-. )fis-. ] } } | + < { a4. [ a-. a-. a-. ] } { fis4. [ fis-.( fis-. )fis-. ] } > | %%35 -%#% { a4. g4. } [ { a cis-.( } { a e-. } { a )- g-. } ] | -% { a4. g4. } { [ a cis-. } { a e-. } { a g-. ] } | - { \music{ a4. [ a-. a-. a-. ] } \music{ g4. [ cis-.( e-. )g-. ] } } | + < { a4. [ a-. a-. a-. ] } { g4. [ cis-.( e-. )g-. ] } > | %%36 - { a2. fis2. } | + < a2. fis2. > | %#%\volta2 %#%:| %%37 - [ a8. a16 ] [ 'cis8. 'cis16 ] [ 'e8. 'e16 ] | + [ a8. a16 ] [ cis'8. cis'16 ] [ e'8. e'16 ] | %%38 - 'd4( )'cis4 r4 | + d'4( )cis'4 r4 | %%39 -%#% > a4. [ 'cis 'e8. >! 'd16 ] | - a4. [ 'cis 'e8. 'd16 ] | +%#% > a4. [ cis' e'8. >! d'16 ] | + a4. [ cis' e'8. d'16 ] | %%40 - 'cis2 r4 | + cis'2 r4 | %%41 -%#% { > 'fis4. 'cis4._f } 'e [ 'e( ) 'd >! 'cis ] | - { 'fis4. 'cis4.\df } 'e [ 'e( )'d 'cis ]2/3 | + < fis'4. cis'4.\df > e' [ e'( )d' cis' ]2/3 | %%42 - [ b8. 'cis16 ] 'd4^> b r | + [ b8. cis'16 ] d'4^> b r | %%43 -%#% [^ { b8._{ }_{ }_{ }_{ }_{ }_f g2. } 'cis16 ] 'd4^> b r | - [ b8.\df 'cis16 ] 'd4^> b r | + + [ b8.\df cis'16 ] d'4^> b r | %%44 -%#% [^ { > b8. fis2 } 'cis16 ] 'd4^> b >! r | - [ b8. 'cis16 ] 'd4^> b r | + [ b8. cis'16 ] d'4^> b r | %%45 -%#% 'cis\grace\stemup - [ b\p( )ais b ]2/3 'd4. b | + [ b\p( )ais b ]2/3 d'4. b | %%46 %#% { =a2. fis2. } | - { a2. fis2. } | + < a2. fis2. > | %%47 - [ 'e\df( )'dis 'e ]2/3 'g4.^> 'cis | + [ e'\df( )dis' e' ]2/3 g'4.^> cis' | %%48 -%#% { fis2.(v ='d2.\stemup(^ } -% { fis2. 'd2. } | -%%49 -%#% { ) 'd4 ) =f2._> } { r4 s4_{decr} } 'd4\stemup \textstyle "italic" - { \multivoice \music{ \stem{ 1 } fis2.( | \stem{ -1 } )f2. } \music { \stem{ 1 } 'd2.( | \stem{ 1 } )'d4 r4_"decresc." 'd4 } } + < \multivoice { \stem{ 1 } fis2.( | \stem{ -1 } )f2. } { \stem{ 1 } d'2.( | \stem{ 1 } )d'4 r4_"decresc." d'4 } > \textstyle "roman" | %%50 - { bes2. e2. } | + < bes2. e2. > | %%51 - { a2. cis2. } | + < a2. cis2. > | %%52 - { fis2 d2 } { a4 fis4\pp } | + < fis2 d2 > < a4 fis4\pp > | %%53 -%#% { bes2 g2 } [ { 'd8.^>( bes8. } { ) bes16 g16 } ] | - { bes2 g2 } { [ 'd8.^> bes8. } { bes16 g16 ] } | + + < bes2 g2 > < [ d'8.^> bes8. > < bes16 g16 ] > | %%54 -%#% { a4. fis4. } [ { a-. fis-.( } { a-. fis-. } { a-. ) fis-. } ] | -% { a4. fis4. } { [ a-. fis-. } { a-. fis-. } { a-. fis-. ] } | - { \music{ a4. [ a-. a-. a-. ] } \music{ fis4. [ fis-.( fis-. )fis-.] } } | + < { a4. [ a-. a-. a-. ] } { fis4. [ fis-.( fis-. )fis-.] } > | %%55 -%#% { a4. g4. } [ { a cis-.( } { a e-. } { a )- g-. } ] | -% { a4. g4. } { [ a cis-. } { a e-. } { a g-. ] } | - { \music{ a4. [ a-. a-. a-. ] } \music{ g4. [ cis-.( e-. )g-. ] } } | + < { a4. [ a-. a-. a-. ] } { g4. [ cis-.( e-. )g-. ] } > | %%56 \textstyle "italic" - { a2. fis2._"dim." } + < a2. fis2._"dim." > \textstyle "roman" | %%57 - { a2. fis2. } | + < a2. fis2. > | %%58 - { a2.^\fermata fis2. } | + < a2.^\fermata fis2. > | %#%\tighten -$ } + } -begeleiding = music { $ - \key{bes} +begeleiding = \music { + \key{bes}\meter{3/4} \clef\bass \duration{2} `d r4 | @@ -209,60 +168,55 @@ begeleiding = music { $ ``a r4 | %#%:| %%5 -%#%\stemlength2 \duration{ 8 } -%#% { =`f `d2 } `a d `a { d r4 } `a - { \multivoice \music{ \stem{ 1 } [ `f `a d `a d `a ] } \music { \stem{ -1 } `d2 r4 } } | + < \multivoice { \stem{ 1 } [ `f `a d `a d `a ] } { \stem{ -1 } `d2 r4 } > | %%6 - { \multivoice \music{ \stem{ 1 } [ `d `e `g `e `g `e ] } \music { \stem{ -1 } ``bes2 r4 } } | + < \multivoice { \stem{ 1 } [ `d `e `g `e `g `e ] } { \stem{ -1 } ``bes2 r4 } > | %%7 - { \multivoice \music{ \stem{ 1 } [ `cis `e `g `e `g e ] } \music { \stem{ -1 } ``a2 r4 } } | + < \multivoice { \stem{ 1 } [ `cis `e `g `e `g e ] } { \stem{ -1 } ``a2 r4 } > | %%8 - { \multivoice \music{ \stem{ 1 } [ `d `a d `a d `a ] } \music { \stem{ -1 } `d2 r4 } } | + < \multivoice { \stem{ 1 } [ `d `a d `a d `a ] } { \stem{ -1 } `d2 r4 } > | %%9 [ `a e g e g e ] | %%10 [ `d `a d `a d `a ] | %%11 - { \multivoice \music{ \stem{ 1 } [ `f `a d `a d `a ] } \music { \stem{ -1 } `d2 r4 } } | + < \multivoice { \stem{ 1 } [ `f `a d `a d `a ] } { \stem{ -1 } `d2 r4 } > | %%12 == 6 - { \multivoice \music{ \stem{ 1 } [ `d `e `g `e `g `e ] } \music { \stem{ -1 } ``bes2 r4 } } | + < \multivoice { \stem{ 1 } [ `d `e `g `e `g `e ] } { \stem{ -1 } ``bes2 r4 } > | %13 - { \multivoice \music{ [ `e `g `bes `g `bes `g ] } \music { \stem{ -1 } `c2 r4 } } | + < \multivoice { [ `e `g `bes `g `bes `g ] } { \stem{ -1 } `c2 r4 } > | %%14 - { \multivoice \music{ \stem{ 1 } [ `a c f c f c ] } \music { \stem{ -1 } `f2 r4 } } | + < \multivoice { \stem{ 1 } [ `a c f c f c ] } { \stem{ -1 } `f2 r4 } > | %%15 [ `c `g `bes `g `bes `g ] | %%16 [ ``f `c `f `c `f `c ] | %%17 - { \multivoice \music{ \stem{ 1 } [ ``a `e `g `e `g `e ] } \music { \stem{ -1 } ``a2 r4 } } | + < \multivoice { \stem{ 1 } [ ``a `e `g `e `g `e ] } { \stem{ -1 } ``a2 r4 } > | %%18 - { \multivoice \music{ \stem{ 1 } [ `d `a d `a d `a ] } \music { \stem{ -1 } `d2 r4 } } | + < \multivoice { \stem{ 1 } [ `d `a d `a d `a ] } { \stem{ -1 } `d2 r4 } > | %%19 - { \multivoice \music{ \stem{ 1 } [ ``bes `f `bes `f `bes `f ] } \music { \stem{ -1 } ``bes2 r4 } } | + < \multivoice { \stem{ 1 } [ ``bes `f `bes `f `bes `f ] } { \stem{ -1 } ``bes2 r4 } > | %%20 - { \multivoice \music{ \stem{ 1 } [ ``f `c `f `c `f `c ] } \music { \stem{ -1 } ``f2 r4 } } | + < \multivoice { \stem{ 1 } [ ``f `c `f `c `f `c ] } { \stem{ -1 } ``f2 r4 } > | %%21 -%#% s8 % skip space of grace note - { [ `e `c } `g c `g c `g ] | + < [ `e `c > `g c `g c `g ] | %%22 [ `f `a c `a `f `c ] | %%23 - { \multivoice \music{ \stem{ 1 } [ ``a `e `g `e `g `e ] } \music { \stem{ -1 } ``a2 r4 } } | + < \multivoice { \stem{ 1 } [ ``a `e `g `e `g `e ] } { \stem{ -1 } ``a2 r4 } > | %%24 - { \multivoice \music{ \stem{ 1 } [ `d `fis `a `fis `a `fis ] } \music { \stem{ -1 } `d2 r4 } } | + < \multivoice { \stem{ 1 } [ `d `fis `a `fis `a `fis ] } { \stem{ -1 } `d2 r4 } > | %%25 -%#% s8 % skip space of grace note - { \multivoice \music{ \stem{ 1 } [ ``g `d `b `d `b `d ] } \music { \stem{ -1 } ``g2 r4 } } | + < \multivoice { \stem{ 1 } [ ``g `d `b `d `b `d ] } { \stem{ -1 } ``g2 r4 } > | %%26 - { \multivoice \music{ \stem{ 1 } [ `d `a d `a d `a ] } \music { \stem{ -1 } `d2 r4 } } | + < \multivoice { \stem{ 1 } [ `d `a d `a d `a ] } { \stem{ -1 } `d2 r4 } > | %%27 - { [ `cis ``a } `e `a `e `a `e ] | + < [ `cis ``a > `e `a `e `a `e ] | %%28 [ `d `a d `a d `a ] | %%29 -%#% [ `d `g @ `bes `g `bes `g ] | [ `d `g `bes `g `bes `g ] | %#%\volta1 %%30 @@ -284,26 +238,25 @@ begeleiding = music { $ %%37 [ ``a `e `g `e ``bes^> `e ] | %%38 - [ ``a { e cis `a } { e cis `a } { e cis `a } { e cis `a } { e cis `a ] } | + [ ``a < e cis `a > < e cis `a > < e cis `a > < e cis `a > < e cis `a ] > | %%39 [ ``a `e `g `e ``bes^> `e ] | %%40 - [ ``a { e cis `a } { e cis `a } { e cis `a } { e cis `a } { e cis `a ] } | + [ ``a < e cis `a > < e cis `a > < e cis `a > < e cis `a > < e cis `a ] > | %%41 [ ``ais `e `fis `e `fis `e ] | %%42 - { [ `d ``b } `fis `b `fis `b `fis ] | + < [ `d ``b > `fis `b `fis `b `fis ] | %%43 - { [ `e ``b } `g `b `g `b `g ] | + < [ `e ``b > `g `b `g `b `g ] | %%44 - { [ `d ``b } `fis `b `fis `b `fis ] | + < [ `d ``b > `fis `b `fis `b `fis ] | %%45 -%#% s8 % skip space of grace note - { \multivoice \music{ \stem{ 1 } [ ``g `d `b `d `b `d ] } \music { \stem{ -1 } ``g2 r4 } } | + < \multivoice { \stem{ 1 } [ ``g `d `b `d `b `d ] } { \stem{ -1 } ``g2 r4 } > | %%46 - { \multivoice \music{ \stem{ 1 } [ `d `a d `a d `a ] } \music { \stem{ -1 } `d2 r4 } } | + < \multivoice { \stem{ 1 } [ `d `a d `a d `a ] } { \stem{ -1 } `d2 r4 } > | %%47 - { [ `cis ``a } `e `a `e `a `e ] | + < [ `cis ``a > `e `a `e `a `e ] | %%48 [ `d `fis `a `fis `a `fis ] | %%49 @@ -325,12 +278,12 @@ begeleiding = music { $ %%57 [ ``d ``a `d ``a `d ``a ] %%58 - { `d2.^\fermata ``d2. } | -$ } + < `d2.^\fermata ``d2. > | + } -tekst1 = music { - @ +tekstI = \lyrics { + \meter{3/4} \duration{4} _ _ _ _ _ _ @@ -393,11 +346,11 @@ tekst1 = music { _ _ _ _ _ _ % 57 _ _ _ _ _ _ - @ + } -tekst2 = music { - @ +tekstII= \lyrics { + \meter{3/4} \duration{4} _ _ _ _ _ _ @@ -457,36 +410,35 @@ tekst2 = music { % _ _ _ _ _ _ % 57 % _ _ _ _ _ _ - @ + } -score { - staff { +\score { + \staff { lyric - music { tekst1 } - music { tekst2 } - } - staff { - melodic - music { melodie } - } - staff { - melodic - music { begeleiding } + \music { tekstI } + \music { tekstII } } - commands { - meter {3*4} +% Setting up music ...lilypond: ../flower/include/cursor.inl:98: class Cursor Cursor::operator ++(int): Assertion `pointer_' failed. +%IOT trap/Abort +% \music { melodie } + \staff { + \melodic + \music { begeleiding } + } + \staff { + \melodic + \music { begeleiding } } - paper { - symboltables { table_sixteen } - width 195mm + \paper { + \width 195\mm % on two pages... - unitspace 9mm - geometric 1.2 - output "standchen.out" + \unitspace 9\mm + \geometric 1.2 + \output "standchen.out" } - midi { - tempo 4:54 + \midi { + \tempo 4:54 } } diff --git a/input/twinkle.ly b/input/twinkle.ly index 035854e846..c54fdea039 100644 --- a/input/twinkle.ly +++ b/input/twinkle.ly @@ -4,73 +4,71 @@ % % Copyright: none -melodie = music { - $\clef\violin +melodie = \music { + \clef\violin c c | g g | a a | g g | f f | e e | d d8.( e16 | )c2 | % :| g g | f f | e e | d d | -% g g | f f | e( [f0*32 e0*32 d0*32] e8. f16 | e )d | c c | g g | f f | e( e8. f16 | e )d | c c | g g | a a | g g | f f | e e | d d8.( e16 | )c2 % :| \bar ":|" - $ + } -begeleiding = music { - $\clef \bass +begeleiding = \music { + \clef \bass \octave{`} - c 'c | 'e 'c | 'f 'c | 'e 'c | - 'd b | 'c a | f g | c2 | + c c' | e' c' | f' c' | e' c' | + d' b | c' a | f g | c2 | - 'e g | d g | 'c g | b g | -% 'e g | 'd g | 'c 'c8.( 'd16 | \voice{ 'c )b } \voice{ g2 } | - 'e g | 'd g | 'c 'c8.( 'd16 | 'c )b | + e' g | d g | c' g | b g | + e' g | d' g | c' c'8.( d'16 | c' )b | - c 'c | 'e 'c | 'f 'c | 'e 'c | - 'd b | 'c a | f g | c2 + c c' | e' c' | f' c' | e' c' | + d' b | c' a | f g | c2 \bar ":|" - $ + } - -tekst = music { - @ +globalmusic=\music{ + \meter {2 / 4} + \skip {24*2} + \bar "||" + } +tekst = \lyrics { Al- tijd is Kort- jak- je ziek,2 - midden in_de week maar 's_zon- dags niet.2 - 's_Zon- dags gaat ze naar de kerk,2 + midden in_de week maar s'_zon- dags niet.2 + s'_Zon- dags gaat ze naar de kerk,2 met een boek vol zil- ver werk.2 Al- tijd is Kort- jak- je ziek,2 - midden in_de week maar 's_zon- dags niet.2 - @ + midden in_de week maar s'_zon- dags niet.2 } -he_gedraagje_tekst = music { - @ +hegedraagjetekst = \lyrics { Al- tijd zuigt Bill Gates mijn piek,2 "\TeX" is slecht- ser dan mu- ziek.2 - 's_Zon- dags gaat het door een raam,2 + s'_Zon- dags gaat het door een raam,2 Weet dat ik me er- voor schaam.2 Al- tijd zuigt Bill Gates mijn piek,2 "\TeX" is slecht- ser dan mu- ziek.2 - @ } -texte = music { - @ +texte = \lyrics { + \textstyle "italic" Ah! vous dir- ai_- je ma man2 Ce qui cau- se mon tour- ment2 Pa- pa veut que je rai- sonne2 - Comme un- e grand- e per- sonne2 + Co\mme un- e grand- e per- sonne2 Moi je dis que les bon- bons2 Val- ent mieux que la rai- son2 - @ + } -text1 = music { - @ +textI = \lyrics { + \textstyle "roman" Twin- kle, twin- kle, lit- tle star,2 How I won- der what you are.2 @@ -78,11 +76,11 @@ text1 = music { Like a dia- mond in the sky.2 Twin- kle, twin- kle, lit- tle star,2 How I won- der what you are!2 - @ + } -text2 = music { - @ +textII = \music { + \textstyle "roman" When the bla- zing sun is gone,2 When he no- thing shines up- on,2 @@ -90,11 +88,11 @@ text2 = music { Twin- kle, twin- kle, all the night.2 Twin- kle, twin- kle, lit- tle star,2 How I won- der what you are!2 - @ + } -text3 = music { - @ +textIII = \lyrics{ + \textstyle "roman" Then the tra- veler in the dark2 Thanks you for your ti- ny spark;2 @@ -102,61 +100,63 @@ text3 = music { If you did not twin- kle so.2 Twin- kle, twin- kle, lit- tle star,2 How I won- der what you are!2 - @ + } -mstaf = staff { - melodic - music { melodie } +mstaf = \staff { + \melodic + \music { melodie } + \music { globalmusic } } -bass_staf = staff { - melodic - music { begeleiding } +bassstaf = \staff { + \melodic + \music { begeleiding } + \music { globalmusic } } -dutch_staf = staff { +dutchstaf = \staff { lyric - music { tekst } - music {he_gedraagje_tekst} + \music { tekst } + \music {hegedraagjetekst} + \music { globalmusic } } -french_staf = staff { +frenchstaf = \staff { lyric - music { texte } + \music { texte } + \music { globalmusic } } -english_staf = staff { +englishstaf = \staff { lyric - music { text1 } - music { text2 } - music { text3 } + \music { textI } + \music { textII } + \music { textIII } + \music { globalmusic } } -tstaf = staff { +tstaf = \staff { lyric - music { tekst } - music { texte } + \music { tekst } + \music { texte } + \music { globalmusic } } -score { - staff { mstaf } - staff { dutch_staf } - staff { french_staf } - staff { english_staf } - staff { bass_staf } - paper { - unitspace 2.5cm - } - commands { - meter {2 * 4} - skip {24*2} -% bar "||" +\score { + \staff { mstaf } + \staff { dutchstaf } + \staff { frenchstaf } + \staff { englishstaf } + \staff { bassstaf } + \paper { + \unitspace 2.5\cm } - midi { - tempo 4:120 + + \midi { + \tempo 4:120 } } diff --git a/input/wohltemperirt.ly b/input/wohltemperirt.ly index 32de885acf..921cdbb983 100644 --- a/input/wohltemperirt.ly +++ b/input/wohltemperirt.ly @@ -1,26 +1,29 @@ % JS Bach, Das Wohltemperirtes Clavier I, Fuga II (c-minor) % -% a 7 bar fragment +% a 7 \bar fragment % % Public Domain -- typed by by HWN % +global=\music{\meter {4/4} + \grouping {2*2} + \key {bes es as}} -dux = music { $ +dux = \music { \clef \violin \duration { \last } r8-"dux" \stem{-1} - ['c16 b] ['c8 g] [as 'c16 b] ['c8 'd] | - [g 'c16 b] ['c8 'd] [f16 g] as4 [g16 f] | - [es 'c b a] [ g f es d] [c8 'es 'd 'c] | - [bes a bes 'c] [fis g a fis] | + [c'16 b] [c'8 g] [as c'16 b] [c'8 d'] | + [g c'16 b] [c'8 d'] [f16 g] as4 [g16 f] | + [es c' b a] [ g f es d] [c8 es' d' c'] | + [bes a bes c'] [fis g a fis] | g4 r16 [c d es] [f g as8(] [)as16 d es f ]| - [g a bes8(] [)bes16 es f g ] [as g f es] [d8 'c16 b]| - 'c4 r4 r8 ['f 'es 'd] + [g a bes8(] [)bes16 es f g ] [as g f es] [d8 c'16 b]| + c'4 r4 r8 [f' es' d'] r8 [as g f] [g f16 es] [f8 d] | -$} +} -comes = music { $ +comes = \music { \octave {'} r1 \stem{1} | @@ -32,9 +35,9 @@ comes = music { $ [) f8 es16 d] [c16 `bes `as `g] [`f8 as g f] [es d es f] [`b c d `b] | -$} +} -bassdux = music { $ +bassdux = \music { \clef \bass \octave { } r1 | @@ -45,31 +48,26 @@ bassdux = music { $ r1 | r8 [c16 B] [c8 G] [As c16 B] [c8 d] | [G c16 B] [c8 d] [F16 G] As4 [G16 F] | -$} +} -trebstaf = staff { melodic - % every "music {} " in a staff has its own "voicegroup" - music { dux } - music { comes } - +trebstaf = \staff { \melodic + % every "\music {} " in a \staff has its own "\voicegroup" + \music { dux } + \music { comes } + \music{global} } -basstaf = staff { melodic - music { bassdux } +basstaf = \staff { \melodic + \music { bassdux } + \music{global} } - -score { - staff { trebstaf } - staff { basstaf } +\score { + \staff { trebstaf } + \staff { basstaf } - commands { - meter {4*4} - grouping {2*2} - key {$bes es as$} - } - paper {} - midi { - tempo 4:90 + \paper {} + \midi { + \tempo 4:90 } } diff --git a/lib/Makefile b/lib/Makefile index 8676c37760..497b93d8a8 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -16,17 +16,13 @@ depth = .. # generic variables: # include ./$(depth)/make/Variables.make +include ./$(depth)/make/Files.make +include ./$(depth)/make/Version.make # # identify module: # NAME = lily -MAJOR_VERSION = $(TOPLEVEL_MAJOR_VERSION) -MINOR_VERSION = $(TOPLEVEL_MINOR_VERSION) -PATCH_LEVEL = $(TOPLEVEL_PATCH_LEVEL) -# use to send patches, always empty for released version: -MY_PATCH_LEVEL = $(TOPLEVEL_MY_PATCH_LEVEL) -build = $(lily-dir)/$(outdir)/.build # # descent order into subdirectories: @@ -39,24 +35,9 @@ SUBDIRS = include VERSION_DEPENDENCY =# # -# list of c++ header files: -# -HHFILES = $(shell ls *.hh $(ERROR_LOG)) -# - -# list of c++ source files: -# -CCFILES = $(shell ls *.cc $(ERROR_LOG)) -# - -# list of other source files: -# -EXTRA_SOURCE_FILES = # $(shell ls *.y *.l $(ERROR_LOG)) -# - # list of distribution files: # -DISTFILES = Makefile $(HHFILES) $(CCFILES) $(EXTRA_SOURCE_FILES) +DISTFILES = Makefile $(ALL_SOURCES) # # list of custom libraries: @@ -86,7 +67,7 @@ include ./$(depth)/make/Rules.make # list of depend files: # -DEPFILES = $(shell ls $(depdir)/*.dep $(ERROR_LOG)) + # # auto dependencies: diff --git a/lib/include/Makefile b/lib/include/Makefile index 7477d7a316..43a98084f3 100644 --- a/lib/include/Makefile +++ b/lib/include/Makefile @@ -8,16 +8,10 @@ depth = ../.. # identify module: # MODULE_NAME = lilypond -MAJOR_VERSION = $(TOPLEVEL_MAJOR_VERSION) -MINOR_VERSION = $(TOPLEVEL_MINOR_VERSION) -PATCH_LEVEL = $(TOPLEVEL_PATCH_LEVEL) -# use to send patches, always empty for released version: -MY_PATCH_LEVEL = $(TOPLEVEL_MY_PATCH_LEVEL) -build = ./$(depth)/lily/$(outdir)/.build -# # generic stuff/Makefile # + include ./$(depth)/make/Include.make -# + diff --git a/lily/.version b/lily/.version index 10eeb0d37d..04e19c9ac8 100644 --- a/lily/.version +++ b/lily/.version @@ -1,4 +1,8 @@ MAJOR_VERSION = 0 MINOR_VERSION = 0 -PATCH_LEVEL = 41 -MY_PATCH_LEVEL= \ No newline at end of file +PATCH_LEVEL = 42 +# use to send patches, always empty for released version: +# include separator: ".postfix", "-pl" makes rpm barf + +MY_PATCH_LEVEL =.2 +# diff --git a/lily/Makefile b/lily/Makefile index 96a523cb95..1bc1595cc5 100644 --- a/lily/Makefile +++ b/lily/Makefile @@ -1,4 +1,3 @@ -# # project LilyPond -- the musical typesetter # title makefile for lilypond # file lily/Makefile @@ -15,18 +14,16 @@ depth = .. # generic variables: # -include ./$(depth)/make/Variables.make +include ./$(depth)/make/Variables.make +include ./$(depth)/make/Files.make +include .version + # # identify module: # NAME = lilypond -MAJOR_VERSION = $(TOPLEVEL_MAJOR_VERSION) -MINOR_VERSION = $(TOPLEVEL_MINOR_VERSION) -PATCH_LEVEL = $(TOPLEVEL_PATCH_LEVEL) -# use to send patches, always empty for released version: -MY_PATCH_LEVEL = $(TOPLEVEL_MY_PATCH_LEVEL) -build = $(lily-dir)/$(outdir)/.build + # # descent order into subdirectories: @@ -39,30 +36,16 @@ SUBDIRS = include VERSION_DEPENDENCY = $(lily-version) # -# list of c++ header files: -# -HHFILES := $(wildcard *.hh) #$(shell ls *.hh $(ERROR_LOG)) -# - -# list of c++ source files: -# -CCFILES := $(wildcard *.cc) #$(shell ls *.cc $(ERROR_LOG)) -# - -# list of other source files: -# -EXTRA_SOURCE_FILES = $(shell ls *.y *.l $(ERROR_LOG)) -# # list of distribution files: # -DISTFILES = .version Makefile $(HHFILES) $(CCFILES) $(EXTRA_SOURCE_FILES) +DISTFILES = .version Makefile $(ALL_SOURCES) # # list of custom libraries: # # yes, i know about the -L and -l options, -# but these libraries get rebuild when needed. +# but these libraries get rebuilt when needed. CUSTOMLIBES = $(LIBLILY) $(LIBFLOWER) LOADLIBES += @@ -84,19 +67,15 @@ include ./$(depth)/make/Targets.make include ./$(depth)/make/Rules.make # -# explicit dependencies: (how to do auto?) -# -# ugh -#$(outdir)/version.cc: check-flower-version $(lily-version) - - -mylexer.cc: $(outdir)/parser.hh # sic +# force these: Make can't know these have to be generated in advance +mylexer.cc: $(outdir)/parser.hh lexer.l: $(outdir)/parser.hh + # # list of depend files: # -DEPFILES = $(shell ls $(depdir)/*.dep $(ERROR_LOG)) +DEPFILES = $(wildcard $(depdir)/*.dep) # # auto dependencies: diff --git a/lily/beam.cc b/lily/beam.cc index 87e9114caf..9a07bcc614 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -24,10 +24,10 @@ struct Stem_info { Stem_info(){} - Stem_info(const Stem*); + Stem_info(Stem const *); }; -Stem_info::Stem_info(const Stem*s) +Stem_info::Stem_info(Stem const *s) { x = s->hindex(); int dir = s->dir; diff --git a/lily/clef-reg.cc b/lily/clef-reg.cc index 791b724083..b4775721bb 100644 --- a/lily/clef-reg.cc +++ b/lily/clef-reg.cc @@ -65,7 +65,7 @@ Clef_register::try_request(Request * r_l) void Clef_register::process_requests() { - const Time_description *time_l = get_staff_info().time_c_l_; + Time_description const *time_l = get_staff_info().time_c_l_; if (!clef_req_l_ && (!time_l->whole_in_measure_|| !time_l->when_)) { clef_p_ = new Clef_item; clef_p_->change = false; diff --git a/lily/command-request.cc b/lily/command-request.cc index 769d522ba5..7e33d78a9d 100644 --- a/lily/command-request.cc +++ b/lily/command-request.cc @@ -25,7 +25,7 @@ Cadenza_req::Cadenza_req(bool b) int -Bar_req::compare(const Bar_req &c1)const +Bar_req::compare(Bar_req const &c1)const { return type_str_ == c1.type_str_; } diff --git a/lily/dimen.cc b/lily/dimen.cc index 9489ae9a1e..9e5fc2cea0 100644 --- a/lily/dimen.cc +++ b/lily/dimen.cc @@ -7,7 +7,7 @@ Real parse_dimen(String dim) { int i=dim.length_i()-1; - const char *s = dim; + char const *s = dim; while (i > 0 && (isspace(s[i]) || isalpha(s[i])) ){ i--; } diff --git a/lily/idealspacing.cc b/lily/idealspacing.cc index 805cb3bebb..8437aabe22 100644 --- a/lily/idealspacing.cc +++ b/lily/idealspacing.cc @@ -14,7 +14,7 @@ Idealspacing::print() const #endif } -Idealspacing::Idealspacing(const PCol * l,const PCol * r) +Idealspacing::Idealspacing(PCol const * l,PCol const * r) { space = 0.0; hooke = 0.0; diff --git a/lily/identifier.cc b/lily/identifier.cc index e4712f8a5a..c3de1d3987 100644 --- a/lily/identifier.cc +++ b/lily/identifier.cc @@ -12,6 +12,14 @@ #include "lexer.hh" #include "debug.hh" +#include "input-score.hh" +#include "symtable.hh" +#include "input-staff.hh" +#include "input-music.hh" +#include "lookup.hh" +#include "script-def.hh" +#include "request.hh" + void Identifier::error(String expect) { @@ -42,6 +50,7 @@ DEFAULT_PRINT(Staff_id, Input_staff, staff); DEFAULT_PRINT(M_chord_id, Music_general_chord, mchord); DEFAULT_PRINT(M_voice_id, Music_voice, mvoice); DEFAULT_PRINT(Request_id, Request, request); +DEFAULT_PRINT(Score_id, Input_score, score); void Real_id::do_print() const { @@ -49,3 +58,28 @@ Real_id::do_print() const mtor << *((Real_id*)this)->real(false)<< "\n"; } +#define implement_id_class(Idclass, Class, accessor) \ +char const * Idclass::classname() const\ +{\ + return #Class;\ +}\ +Class*\ +Idclass::accessor(bool copy) {\ + if (copy)\ + return new Class(* (Class*) data);\ + else\ + return (Class*) data;\ + }\ +Idclass::~Idclass() { delete accessor(false); }\ +Idclass::Idclass(String s, Class*st, int code):Identifier(s,code) { data = st; }\ + + +implement_id_class(Real_id, Real, real) +implement_id_class(Script_id, Script_def, script) +implement_id_class(Lookup_id, Lookup, lookup) +implement_id_class(Symtables_id, Symtables, symtables) +implement_id_class(Staff_id, Input_staff, staff) +implement_id_class(M_chord_id, Music_general_chord, mchord) +implement_id_class(M_voice_id, Music_voice, mvoice) +implement_id_class(Score_id, Input_score, score) +implement_id_class(Request_id, Request, request) diff --git a/lily/include/Makefile b/lily/include/Makefile index 89f5b189e5..da392fe30f 100644 --- a/lily/include/Makefile +++ b/lily/include/Makefile @@ -8,16 +8,5 @@ depth = ../.. # identify module: # MODULE_NAME = lilypond -MAJOR_VERSION = $(TOPLEVEL_MAJOR_VERSION) -MINOR_VERSION = $(TOPLEVEL_MINOR_VERSION) -PATCH_LEVEL = $(TOPLEVEL_PATCH_LEVEL) -# use to send patches, always empty for released version: -MY_PATCH_LEVEL = $(TOPLEVEL_MY_PATCH_LEVEL) -build = ./$(depth)/lily/$(outdir)/.build -# - -# generic stuff/Makefile -# include ./$(depth)/make/Include.make -# diff --git a/lily/include/class-name.hh b/lily/include/class-name.hh index 26da52dc0e..643959d620 100644 --- a/lily/include/class-name.hh +++ b/lily/include/class-name.hh @@ -12,8 +12,8 @@ /// a macro to declare the classes name as a static and virtual function. #define NAME_MEMBERS(c) \ -static const char *static_name(){ return #c; }\ -virtual const char *name() const{ return c::static_name(); } \ +static char const *static_name(){ return #c; }\ +virtual char const *name() const{ return c::static_name(); } \ int a_stupid_nonexistent_function_to_allow_the_semicolon_come_out() #endif // CLASS-NAME_HH diff --git a/lily/include/idealspacing.hh b/lily/include/idealspacing.hh index 05f58ba9c8..6b6f40c01a 100644 --- a/lily/include/idealspacing.hh +++ b/lily/include/idealspacing.hh @@ -18,11 +18,11 @@ struct Idealspacing { Real hooke; /// the two columns - const PCol *left, *right; + PCol const *left, *right; void print()const; void OK() const ; - Idealspacing(const PCol *left,const PCol *right); + Idealspacing(PCol const *left,PCol const *right); }; diff --git a/lily/include/identifier.hh b/lily/include/identifier.hh index 6312582bf0..812d1fe71f 100644 --- a/lily/include/identifier.hh +++ b/lily/include/identifier.hh @@ -1,4 +1,3 @@ - /* identifier.hh -- part of LilyPond @@ -8,36 +7,61 @@ #ifndef IDENTIFIER_HH #define IDENTIFIER_HH -#include "identparent.hh" -#include "symtable.hh" -#include "input-staff.hh" -#include "input-music.hh" -#include "lookup.hh" -#include "script-def.hh" -#include "request.hh" +#include "proto.hh" +#include "string.hh" + +/* boolean argument to accesor is copy_b..*/ +#define IDACCESSOR( Input_staff, staff)\ + virtual Input_staff * staff(bool) { error(#Input_staff); return 0; } + + +struct Identifier { + void *data; + String name; + int token_code_i_; -#define make_id_class(Idclass, Class, accessor) \ + Identifier(String n, int code) : name(n) { token_code_i_ = code; } + virtual ~Identifier() {} + + void print()const; + virtual char const *classname() const{ return "new Identifier"; } + void error(String); + IDACCESSOR(Input_staff, staff) + IDACCESSOR(Input_music, music) + IDACCESSOR(Music_voice, mvoice) + IDACCESSOR(Script_def, script) + IDACCESSOR(Symtables, symtables) + IDACCESSOR(Music_general_chord, mchord) + IDACCESSOR(Lookup,lookup) + IDACCESSOR(Real,real) + IDACCESSOR(Request, request) + IDACCESSOR(Input_score, score) + +protected: + virtual void do_print()const=0; +private: + Identifier(Identifier const&){} +}; + +#define declare_id_class(Idclass, Class, accessor) \ struct Idclass : Identifier {\ - virtual const char *classname() { return #Class; }\ - Idclass(String s, Class*st, int code):Identifier(s,code) { data = st; }\ - virtual Class* accessor(bool copy) {\ - if (copy)\ - return new Class(* (Class*) data);\ - else\ - return (Class*) data;\ - }\ - ~Idclass() { delete accessor(false); }\ - virtual void do_print()const; \ + virtual char const *classname()const;\ + Idclass(String s, Class*st, int code);\ + virtual Class* accessor(bool copy);\ + ~Idclass();\ + virtual void do_print()const; \ }\ -make_id_class(Real_id, Real, real); -make_id_class(Script_id, Script_def, script); -make_id_class(Lookup_id, Lookup, lookup); -make_id_class(Symtables_id, Symtables, symtables); -make_id_class(Staff_id, Input_staff, staff); -make_id_class(M_chord_id, Music_general_chord, mchord); -make_id_class(M_voice_id, Music_voice, mvoice); -make_id_class(Request_id, Request, request); -#endif // IDENTIFIER_HH +declare_id_class(Real_id, Real, real); +declare_id_class(Script_id, Script_def, script); +declare_id_class(Lookup_id, Lookup, lookup); +declare_id_class(Symtables_id, Symtables, symtables); +declare_id_class(Staff_id, Input_staff, staff); +declare_id_class(M_chord_id, Music_general_chord, mchord); +declare_id_class(M_voice_id, Music_voice, mvoice); +declare_id_class(Score_id, Input_score, score); +declare_id_class(Request_id, Request, request); + +#endif // IDENTIFIER_ diff --git a/lily/include/identparent.hh b/lily/include/identparent.hh index a8b75b0fd3..09c7cfafd0 100644 --- a/lily/include/identparent.hh +++ b/lily/include/identparent.hh @@ -1,48 +1 @@ -/* - identparent.hh -- part of LilyPond - - (c) 1996,97 Han-Wen Nienhuys -*/ - -#ifndef IDENTPARENT_HH -#define IDENTPARENT_HH - -#include "proto.hh" -#include "string.hh" - -/* boolean argument to accesor is copy_b..*/ -#define IDACCESSOR( Input_staff, staff)\ - virtual Input_staff * staff(bool) { error(#Input_staff); return 0; } - - -struct Identifier { - void *data; - String name; - int token_code_i_; - - Identifier(String n, int code) : name(n) { token_code_i_ = code; } - virtual ~Identifier() {} - - void print()const; - virtual const char*classname() { return "new Identifier"; } - void error(String); - IDACCESSOR(Input_staff, staff) - IDACCESSOR(Input_music, music) - IDACCESSOR(Music_voice, mvoice) - IDACCESSOR(Script_def, script) - IDACCESSOR(Symtables, symtables) - IDACCESSOR(Music_general_chord, mchord) - IDACCESSOR(Lookup,lookup) - IDACCESSOR(Real,real) - IDACCESSOR(Request, request) - -protected: - virtual void do_print()const=0; -private: - Identifier(Identifier const&){} - -}; -#endif // IDENTPARENT_HH - - - +#error diff --git a/lily/include/input-score.hh b/lily/include/input-score.hh index 4286f4b60b..a7468e03fa 100644 --- a/lily/include/input-score.hh +++ b/lily/include/input-score.hh @@ -19,7 +19,7 @@ /// the total music def of one movement struct Input_score { /// defined where? - const char* defined_ch_c_l_; + char const * defined_ch_c_l_; int errorlevel_i_; /// paper_, staffs_ and commands_ form the problem definition. @@ -27,7 +27,6 @@ struct Input_score { Midi_def* midi_p_; IPointerList staffs_; - Input_music * score_wide_music_p_; /* *************************************************************** */ Input_score(); @@ -40,7 +39,6 @@ struct Input_score { void set(Midi_def* midi_p); void print() const; Score*parse(); - void set(Input_music*); }; #endif diff --git a/lily/include/input-staff.hh b/lily/include/input-staff.hh index 3b874a1b39..23495bd744 100644 --- a/lily/include/input-staff.hh +++ b/lily/include/input-staff.hh @@ -14,19 +14,17 @@ struct Input_staff { - const char * defined_ch_c_l_; + char const * defined_ch_c_l_; String type; IPointerList music_; - Input_music * score_wide_music_p_; /* *************** */ ~Input_staff(); void add(Input_music*m); Input_staff(Input_staff const&); Input_staff(String); - void set_score_wide(Input_music*m); - Staff* parse(Score*, Input_music *score_wide); + Staff* parse(Score*); void print() const; }; diff --git a/lily/include/keyword.hh b/lily/include/keyword.hh index 152d9dc15d..88ab9ffbe0 100644 --- a/lily/include/keyword.hh +++ b/lily/include/keyword.hh @@ -10,7 +10,7 @@ /* for the keyword table */ struct Keyword_ent { - const char *name; + char const *name; int tokcode; }; @@ -19,7 +19,7 @@ struct Keyword_table Keyword_ent *table; int maxkey; Keyword_table(Keyword_ent *); - int lookup(const char *s) const; + int lookup(char const *s) const; }; diff --git a/lily/include/lexer.hh b/lily/include/lexer.hh index 266ee22a56..08faa553f8 100644 --- a/lily/include/lexer.hh +++ b/lily/include/lexer.hh @@ -15,7 +15,7 @@ #include "string.hh" int yylex(); -void yyerror(const char *s); +void yyerror(char const *s); bool busy_parsing(); void kill_lexer(); void set_lexer(); @@ -51,7 +51,11 @@ struct My_flex_lexer : yyFlexLexer { char const* here_ch_c_l(); int lookup_keyword(String); void lookup_notename(int &large, int &small, String s); - void LexerError(const char *); + + void push_note_state(); + void push_lyric_state(); + void pop_state(); + void LexerError(char const *); String spot() const; Identifier*lookup_identifier(String s); My_flex_lexer(); diff --git a/lily/include/linespace.hh b/lily/include/linespace.hh index 1479d1e936..2a9e655479 100644 --- a/lily/include/linespace.hh +++ b/lily/include/linespace.hh @@ -9,8 +9,8 @@ /// helper struct for #Spacing_problem# struct Colinfo { - const PCol *pcol_; - const Real* fixpos; + PCol const *pcol_; + Real const * fixpos; Interval width; /* *************** */ @@ -18,7 +18,7 @@ struct Colinfo { void operator=(Colinfo const&); Colinfo(Colinfo const&); ~Colinfo(); - Colinfo(const PCol*,const Real*); + Colinfo(PCol const *,Real const *); void print() const; bool fixed() const { return fixpos;} Real fixed_position()const { return *fixpos; } @@ -47,11 +47,11 @@ struct Colinfo { springs. The lower the energy, the better the configuration. */ class Spacing_problem { - Array ideals; + Array ideals; Array cols; /// the index of #c# in #cols# - int col_id(const PCol *c) const; + int col_id(PCol const *c) const; /// generate an (nonoptimal) solution Vector find_initial_solution() const; @@ -60,7 +60,7 @@ class Spacing_problem { bool check_feasible() const; /// does #this# contain the column #w#? - bool contains(const PCol *w); + bool contains(PCol const *w); /// make the energy function void make_matrices(Matrix &quad, Vector &lin,Real&) const; @@ -84,13 +84,13 @@ public: since they can be "summed" if the columns to which #i# refers are not in this problem, the spacing is ignored. */ - void add_ideal(const Idealspacing *i); + void add_ideal(Idealspacing const *i); /** add a col to the problem. columns have to be added left to right. The column contains info on it's minimum width. */ - void add_column(const PCol *, bool fixed=false, Real fixpos=0.0); + void add_column(PCol const *, bool fixed=false, Real fixpos=0.0); @@ -99,7 +99,7 @@ public: Vector try_initial_solution() const; void OK() const; void print() const; - void print_ideal(const Idealspacing*)const; + void print_ideal(Idealspacing const *)const; }; diff --git a/lily/include/local-key-reg.hh b/lily/include/local-key-reg.hh index d0a2867a87..9611449383 100644 --- a/lily/include/local-key-reg.hh +++ b/lily/include/local-key-reg.hh @@ -13,7 +13,7 @@ struct Local_key_register : Request_register { Local_key local_key_; Local_key_item* key_item_p_; - const Key *key_c_l_; + Key const *key_c_l_; /* *************** */ virtual void process_requests(); virtual void acknowledge_element(Staff_elem_info); diff --git a/lily/include/musical-request.hh b/lily/include/musical-request.hh index 6d96117ff2..1ad791de40 100644 --- a/lily/include/musical-request.hh +++ b/lily/include/musical-request.hh @@ -96,8 +96,6 @@ struct Melodic_req :virtual Musical_req /// 0 natural, 1 sharp, etc int accidental_i_; - /// force/supress printing of accidental. - bool forceacc_b_; /// return height from central c (in halflines) int height()const; @@ -111,7 +109,9 @@ struct Melodic_req :virtual Musical_req /// Put a note of specified type, height, and with accidental on the staff. struct Note_req : Rhythmic_req, virtual Melodic_req { - + /// force/supress printing of accidental. + bool forceacc_b_; + Note_req(); Rhythmic_req* rhythmic() { return Rhythmic_req::rhythmic(); } REQUESTMETHODS(Note_req, note); }; @@ -214,7 +214,7 @@ struct Subtle_req : virtual Musical_req { struct Dynamic_req : Subtle_req { /// for absolute dynamics enum Loudness { - FFF, FF, F, MF, MP, P, PP, PPP + FFF, FF, F, MF, MP, P, PP, PPP }; static String loudness_str(Loudness); REQUESTMETHODS(Dynamic_req, dynamic); diff --git a/lily/include/p-col.hh b/lily/include/p-col.hh index 2641e64008..48d6c62a19 100644 --- a/lily/include/p-col.hh +++ b/lily/include/p-col.hh @@ -21,8 +21,8 @@ */ struct PCol { - PointerList its; - PointerList stoppers, starters; + PointerList its; + PointerList stoppers, starters; @@ -40,7 +40,7 @@ struct PCol { PCol *daddy_l_; /// if lines are broken then this column is in #line# - const Line_of_score *line_l_; + Line_of_score const *line_l_; /// if lines are broken then this column x-coord #hpos# Real hpos; diff --git a/lily/include/p-score.hh b/lily/include/p-score.hh index eeec67e2fb..3177613ec5 100644 --- a/lily/include/p-score.hh +++ b/lily/include/p-score.hh @@ -67,7 +67,7 @@ struct PScore { /** @return argument as a cursor of the list */ - PCursor find_col(const PCol *)const; + PCursor find_col(PCol const *)const; /* MAIN ROUTINES */ void process(); diff --git a/lily/include/p-staff.hh b/lily/include/p-staff.hh index 50a7f0c719..c95834c2fb 100644 --- a/lily/include/p-staff.hh +++ b/lily/include/p-staff.hh @@ -11,7 +11,7 @@ struct PStaff { PScore * pscore_l_; - PointerList spans; + PointerList spans; PointerList its; /* *************** */ diff --git a/lily/include/paper-def.hh b/lily/include/paper-def.hh index fba93580cb..5086a0ff0c 100644 --- a/lily/include/paper-def.hh +++ b/lily/include/paper-def.hh @@ -47,7 +47,7 @@ public: Real standard_height()const; Real note_width() const; void print() const; - const Lookup* lookup_l(); // TODO naming + Lookup const * lookup_l(); // TODO naming Real duration_to_dist(Moment); }; diff --git a/lily/include/qlpsolve.hh b/lily/include/qlpsolve.hh index 7c9b8da341..3423951452 100644 --- a/lily/include/qlpsolve.hh +++ b/lily/include/qlpsolve.hh @@ -32,7 +32,7 @@ class Active_constraints { Matrix A,H; Array active; Array inactive; // actually this is a set, not an array. - const Ineq_constrained_qp *opt; + Ineq_constrained_qp const *opt; public: String status()const; diff --git a/lily/include/score.hh b/lily/include/score.hh index a865ed02f3..4f10a7f95f 100644 --- a/lily/include/score.hh +++ b/lily/include/score.hh @@ -28,7 +28,7 @@ struct Score { IPointerList cols_; PScore *pscore_p_; - const char *defined_ch_c_l_; + char const *defined_ch_c_l_; int errorlevel_i_; /* *************************************************************** */ diff --git a/lily/include/scoreline.hh b/lily/include/scoreline.hh index f4e1987033..9196a96ab3 100644 --- a/lily/include/scoreline.hh +++ b/lily/include/scoreline.hh @@ -26,7 +26,7 @@ Line_of_score { String TeXstring() const; // is #c# contained in #*this#? - bool element(const PCol *c); + bool element(PCol const *c); }; #endif diff --git a/lily/include/staff-elem-info.hh b/lily/include/staff-elem-info.hh index c07f242e31..4e3392027d 100644 --- a/lily/include/staff-elem-info.hh +++ b/lily/include/staff-elem-info.hh @@ -17,7 +17,7 @@ struct Staff_elem_info { Staff_elem * elem_p_; Request*req_l_; - const Voice * voice_l_; + Voice const * voice_l_; Array origin_reg_l_arr_; /* *** */ @@ -28,8 +28,8 @@ struct Staff_elem_info { struct Staff_info { int *c0_position_i_; Staff_walker *walk_l_; - const Time_description *time_c_l_; - const Rhythmic_grouping *rhythmic_c_l_; + Time_description const *time_c_l_; + Rhythmic_grouping const *rhythmic_c_l_; bool break_allowed_b_; }; diff --git a/lily/include/staffelem.hh b/lily/include/staffelem.hh deleted file mode 100644 index 3928c994e9..0000000000 --- a/lily/include/staffelem.hh +++ /dev/null @@ -1,84 +0,0 @@ -/* - staffelem.hh -- part of LilyPond - - (c) 1996,97 Han-Wen Nienhuys -*/ - -#ifndef STAFFELEM_HH -#define STAFFELEM_HH -#include "varray.hh" -#include "proto.hh" -#include "offset.hh" -#include "molecule.hh" - -/** Both Spanner and Item are Staff_elem's. Most Staff_elem's depend - on other Staff_elem's, eg, Beam needs to know and set direction of - Stem. So the Beam has to be calculated *before* Stem. This is - accomplished with the dependencies field of struct Staff_elem. - - */ -struct Staff_elem { - enum Status { - ORPHAN, // not yet added to pstaff - VIRGIN, // added to pstaff - PRECALCING, - PRECALCED, // calcs before spacing done - POSTCALCING, - POSTCALCED, // after spacing calcs done - OUTPUT, // molecule has been output - } status; - - /// the pstaff it is in - PStaff *pstaff_l_; - - /* *************** */ - Staff_elem(Staff_elem const&); - String TeXstring () const ; - virtual void print() const; - virtual Interval width() const; - virtual Interval height() const; - Paperdef *paper() const; - virtual ~Staff_elem(); - Staff_elem(); - - void translate(Offset); - void add_processing(); - void pre_processing(); - void post_processing(); - void molecule_processing(); - virtual const char *name() const; // to find out derived classes. - virtual Spanner* spanner() { return 0; } - virtual Item * item() { return 0; } - void add_depedency(Staff_elem* ); - void substitute_dependency(Staff_elem* old, Staff_elem * newdep); -protected: - - /// do printing of derived info. - virtual void do_print() const=0; - /// generate the molecule - virtual Molecule* brew_molecule_p()const=0; - ///executed directly after the item is added to the PScore - virtual void do_add_processing(); - /// do calculations before determining horizontal spacing - virtual void do_pre_processing(); - - /// do calculations after determining horizontal spacing - virtual void do_post_processing(); - - Array dependants; - -private: - /// member: the symbols - Molecule *output; // should scrap, and use temp var? - - - /** - This is needed, because #output# may still be - NULL. - */ - Offset offset_; - Array dependencies; -}; -#define NAME_METHOD(c) const char *c::name()const{ return #c; } struct c -#endif // STAFFELEM_HH - diff --git a/lily/include/staffeleminfo.hh b/lily/include/staffeleminfo.hh index b8af8aeb22..14652899d4 100644 --- a/lily/include/staffeleminfo.hh +++ b/lily/include/staffeleminfo.hh @@ -16,7 +16,7 @@ struct Staff_elem_info { Staff_elem * elem_p_; Request*req_l_; - const Voice * voice_l_; + Voice const * voice_l_; Voice_group_registers * group_regs_l_; Request_register * origin_reg_l_; diff --git a/lily/include/voice-element.hh b/lily/include/voice-element.hh index 0c5b6b1328..be54ac401b 100644 --- a/lily/include/voice-element.hh +++ b/lily/include/voice-element.hh @@ -19,7 +19,7 @@ struct Voice_element { Moment duration; char const* defined_ch_c_l_; - const Voice *voice_l_; + Voice const *voice_l_; IPointerList reqs; /* *************** */ diff --git a/lily/include/voice.hh b/lily/include/voice.hh index 06e6e1da27..ccdff1f626 100644 --- a/lily/include/voice.hh +++ b/lily/include/voice.hh @@ -22,7 +22,7 @@ struct Voice { Voice(); Voice(Voice const&); - Moment when(const Voice_element*)const; + Moment when(Voice_element const *)const; Moment last() const; void add(Voice_element*); diff --git a/lily/input-score.cc b/lily/input-score.cc index f39d47a4b1..d68dd10959 100644 --- a/lily/input-score.cc +++ b/lily/input-score.cc @@ -42,8 +42,6 @@ Input_score::Input_score(Input_score const&s) midi_p_ = (s.midi_p_)? new Midi_def(*s.midi_p_) : 0; defined_ch_c_l_ = s.defined_ch_c_l_; errorlevel_i_ = s.errorlevel_i_; - score_wide_music_p_ = (s.score_wide_music_p_) ? - s.score_wide_music_p_->clone():0; } Score* @@ -55,34 +53,25 @@ Input_score::parse() if (midi_p_) s_p->set(new Midi_def(*midi_p_)); if (paper_p_) - s_p->set( new Paper_def(*paper_p_)); + s_p->set(new Paper_def(*paper_p_)); for (iter_top(staffs_,i); i.ok(); i++) { - Staff* staf_p=i->parse(s_p, score_wide_music_p_); + Staff* staf_p=i->parse(s_p); s_p->add(staf_p); } return s_p; } -void -Input_score::set(Input_music *m_p) -{ - delete score_wide_music_p_; - score_wide_music_p_ =m_p; -} - Input_score::~Input_score() { delete paper_p_; - delete score_wide_music_p_; delete midi_p_; } Input_score::Input_score() { - score_wide_music_p_ =0; defined_ch_c_l_=0; paper_p_= 0; midi_p_ = 0; diff --git a/lily/input-staff.cc b/lily/input-staff.cc index 8305a094a9..678ff2f16b 100644 --- a/lily/input-staff.cc +++ b/lily/input-staff.cc @@ -19,7 +19,6 @@ Input_staff::Input_staff(String s) { - score_wide_music_p_ =0; type= s; defined_ch_c_l_ = 0; } @@ -31,7 +30,7 @@ Input_staff::add(Input_music*m) } Staff* -Input_staff::parse(Score*score_l, Input_music *default_score_wide) +Input_staff::parse(Score*score_l) { Staff *p=0; if (type == "melodic") @@ -49,9 +48,6 @@ Input_staff::parse(Score*score_l, Input_music *default_score_wide) Voice_list vl = i->convert(); p->add(vl); } - Voice_list vl = (score_wide_music_p_) ? score_wide_music_p_->convert() - : default_score_wide->convert(); - p->add(vl); return p; } @@ -61,8 +57,6 @@ Input_staff::Input_staff(Input_staff const&s) add(i->clone()); defined_ch_c_l_ = s.defined_ch_c_l_; type = s.type; - score_wide_music_p_ = (s.score_wide_music_p_) ? - s.score_wide_music_p_->clone() : 0; } void @@ -75,14 +69,6 @@ Input_staff::print() const mtor << "}\n"; #endif } -void -Input_staff::set_score_wide(Input_music *m_p) -{ - delete score_wide_music_p_; - score_wide_music_p_ = m_p; -} - Input_staff::~Input_staff() { - delete score_wide_music_p_; } diff --git a/lily/key-item.cc b/lily/key-item.cc index 089eab126f..726af8cb30 100644 --- a/lily/key-item.cc +++ b/lily/key-item.cc @@ -18,7 +18,7 @@ Key_item::Key_item(int c) } void -Key_item::read(const Key_register& key_reg_r) +Key_item::read(Key_register const & key_reg_r) { const Array &idx_arr =key_reg_r.accidental_idx_arr_; for (int i = 0 ; i< idx_arr.size(); i++) { diff --git a/lily/key-reg.cc b/lily/key-reg.cc index 24189a532b..865eea264e 100644 --- a/lily/key-reg.cc +++ b/lily/key-reg.cc @@ -49,7 +49,7 @@ Key_register::acknowledge_element(Staff_elem_info info) void Key_register::process_requests() { - const Time_description *time_l = get_staff_info().time_c_l_; + Time_description const *time_l = get_staff_info().time_c_l_; if (!keyreq_l_ && (!time_l->whole_in_measure_|| !time_l->when_)) { diff --git a/lily/keyword.cc b/lily/keyword.cc index 14903cfb61..2ccb446e27 100644 --- a/lily/keyword.cc +++ b/lily/keyword.cc @@ -12,7 +12,7 @@ /* for the keyword table */ struct Keyword_ent { - const char *name; + char const *name; int tokcode; }; @@ -21,16 +21,16 @@ struct Keyword_table Keyword_ent *table; int maxkey; Keyword_table(Keyword_ent *); - int lookup(const char *s) const; + int lookup(char const *s) const; }; /* for qsort */ int - tabcmp(const void * p1, const void * p2) + tabcmp(void const * p1, void const * p2) { - return strcmp(((const Keyword_ent *) p1)->name, - ((const Keyword_ent *) p2)->name); + return strcmp(((Keyword_ent const *) p1)->name, + ((Keyword_ent const *) p2)->name); } Keyword_table::Keyword_table(Keyword_ent *tab) @@ -48,7 +48,7 @@ Keyword_table::Keyword_table(Keyword_ent *tab) lookup with binsearch, return tokencode. */ int -Keyword_table::lookup(const char *s)const +Keyword_table::lookup(char const *s)const { int lo, hi, diff --git a/lily/lexer.l b/lily/lexer.l index 29738a70aa..8e9d503536 100644 --- a/lily/lexer.l +++ b/lily/lexer.l @@ -11,7 +11,7 @@ #include "input-score.hh" #include "parseconstruct.hh" #include "main.hh" -#include "identparent.hh" +#include "identifier.hh" #define start_quote() \ yy_push_state(quote);\ @@ -49,22 +49,27 @@ ALPHAWORD {A}+ INT -?{N}+ REAL {INT}?(\.{N}*)? -OPTSIGN !? -PITCHMOD ['`]*{OPTSIGN} RESTNAME r|s|p NOTECOMMAND \\{WORD} DOTS \.+ LYRICS {TEX}+ -COMMENT [%#].*\n +COMMENT %.*\n %% -\$ { - yy_push_state(notes); -} -\@ { - yy_push_state(lyrics); + + +include { + yy_push_state(incl); +} +[ \t]* { /* eat the whitespace */ } +\"[^"]*\"+ { /* got the include file name */ + String s (YYText()+1); + s = s.left_str(s.length_i()-1); + defined_ch_c_l = here_ch_c_l() - String( YYText() ).length_i() - 1; + new_input(s); + yy_pop_state(); } {RESTNAME} { @@ -73,9 +78,9 @@ COMMENT [%#].*\n mtor << "rest:"<< yylval.string; return RESTNAME; } -{ALPHAWORD} { +{ALPHAWORD} { String str = YYText(); - mtor << "word: " << str<< eol; + mtor << "word: `" << str<< "'\n"; Identifier * id = lookup_identifier(str); if (id) { yylval.id = id; @@ -85,17 +90,13 @@ COMMENT [%#].*\n yylval.string=new String( str ); return STRING; } -{NOTECOMMAND} { +{NOTECOMMAND} { String c = YYText() +1; - mtor << "\\word: " << YYText()+1<token_code_i_; - } + String *sp = new String( c); yylval.string=sp; return STRING; @@ -114,8 +115,8 @@ COMMENT [%#].*\n [ \t\n]+ { } -\$ { - yy_pop_state(); +\+\+ { + return CONCAT; } \" { start_quote(); @@ -150,7 +151,7 @@ COMMENT [%#].*\n } {NOTECOMMAND} { String c = YYText() +1; - mtor << "\\word: " << YYText()+1<[ \t\n]+ { } -@ { - yy_pop_state(); -} <> { mtor << "<>"; @@ -213,38 +211,6 @@ COMMENT [%#].*\n if (! close_input()) yyterminate(); // can't move this, since it actually rets a YY_NULL } - - -include { - yy_push_state(incl); -} -[ \t]* { /* eat the whitespace */ } -\"[^"]*\"+ { /* got the include file name */ - String s (YYText()+1); - s = s.left_str(s.length_i()-1); - defined_ch_c_l = here_ch_c_l() - String( YYText() ).length_i() - 1; - new_input(s); - yy_pop_state(); -} - - -{WORD} { - mtor << "word: " << YYText()<left; - const PCol *r= i->right; + PCol const *l =i->left; + PCol const *r= i->right; if (!contains(l) || !contains(r)) { return; @@ -213,7 +213,7 @@ Spacing_problem::add_ideal(const Idealspacing *i) } void -Spacing_problem::print_ideal(const Idealspacing*id)const +Spacing_problem::print_ideal(Idealspacing const *id)const { #ifndef NPRINT int l = col_id(id->left); @@ -261,7 +261,7 @@ Colinfo::Colinfo(Colinfo const&c) width = c.width; } -Colinfo::Colinfo(const PCol*col_p, const Real*fixed_r_p ) +Colinfo::Colinfo(PCol const *col_p, Real const *fixed_r_p ) { fixpos = (fixed_r_p)? new Real(*fixed_r_p) : 0; pcol_ = col_p; diff --git a/lily/local-key-reg.cc b/lily/local-key-reg.cc index ddbd8dc5f8..bf7eb9c352 100644 --- a/lily/local-key-reg.cc +++ b/lily/local-key-reg.cc @@ -30,12 +30,12 @@ Local_key_register::pre_move_processing() void Local_key_register::acknowledge_element(Staff_elem_info info) { - if (info.req_l_->melodic()) { - Melodic_req * melodic_l_ = info.req_l_->melodic(); + if (info.req_l_->note()) { + Note_req * note_l_ = info.req_l_->note(); - if( melodic_l_->forceacc_b_ || - local_key_.oct(melodic_l_->octave_i_).acc(melodic_l_->notename_i_) - != melodic_l_->accidental_i_) { + if( note_l_->forceacc_b_ || + local_key_.oct(note_l_->octave_i_).acc(note_l_->notename_i_) + != note_l_->accidental_i_) { Item * support_l_ = info.elem_p_->item(); @@ -43,10 +43,10 @@ Local_key_register::acknowledge_element(Staff_elem_info info) key_item_p_ = new Local_key_item(*get_staff_info().c0_position_i_); } - key_item_p_->add(melodic_l_); + key_item_p_->add(note_l_); key_item_p_->add(support_l_); - local_key_.oct(melodic_l_->octave_i_) - .set(melodic_l_->notename_i_, melodic_l_->accidental_i_); + local_key_.oct(note_l_->octave_i_) + .set(note_l_->notename_i_, note_l_->accidental_i_); } } else if (info.elem_p_->name()==Key_item::static_name()) { Key_register * key_reg_l = @@ -59,7 +59,7 @@ Local_key_register::acknowledge_element(Staff_elem_info info) void Local_key_register::process_requests() { - const Time_description * time_c_l_ = get_staff_info().time_c_l_; + Time_description const * time_c_l_ = get_staff_info().time_c_l_; if (! time_c_l_->whole_in_measure_){ if (key_c_l_) local_key_.reset(*key_c_l_); diff --git a/lily/molecule.cc b/lily/molecule.cc index bfd298bfac..94d94cfd13 100644 --- a/lily/molecule.cc +++ b/lily/molecule.cc @@ -71,7 +71,7 @@ Molecule::translate(Offset o) } void -Molecule::add(const Molecule &m) +Molecule::add(Molecule const &m) { for (iter_top(m.ats,c); c.ok(); c++) { add(**c); @@ -79,7 +79,7 @@ Molecule::add(const Molecule &m) } void -Molecule::add_right(const Molecule &m) +Molecule::add_right(Molecule const &m) { if (!ats.size()) { add(m); @@ -92,7 +92,7 @@ Molecule::add_right(const Molecule &m) } void -Molecule::add_left(const Molecule &m) +Molecule::add_left(Molecule const &m) { if (!ats.size()) { add(m); @@ -106,7 +106,7 @@ Molecule::add_left(const Molecule &m) void -Molecule::add_top(const Molecule &m) +Molecule::add_top(Molecule const &m) { if (!ats.size()) { add(m); @@ -119,7 +119,7 @@ Molecule::add_top(const Molecule &m) } void -Molecule::add_bottom(const Molecule &m) +Molecule::add_bottom(Molecule const &m) { if (!ats.size()) { add(m); @@ -132,12 +132,12 @@ Molecule::add_bottom(const Molecule &m) } void -Molecule::operator = (const Molecule&) +Molecule::operator = (Molecule const &) { assert(false); } -Molecule::Molecule(const Molecule&s) +Molecule::Molecule(Molecule const &s) { add(s); } diff --git a/lily/musical-request.cc b/lily/musical-request.cc index be9667c1a0..bf1b56c44c 100644 --- a/lily/musical-request.cc +++ b/lily/musical-request.cc @@ -36,9 +36,11 @@ void Request::do_print() const{} void Request::print() const { +#ifndef NPRINT mtor << name() << " {"; do_print(); mtor << "}\n"; +#endif } @@ -87,13 +89,14 @@ Melodic_req::Melodic_req() notename_i_ = 0; octave_i_ = 0; accidental_i_ = 0; - forceacc_b_ = false; } void Melodic_req::do_print() const { - mtor << "notename: " << notename_i_ << " acc: " <compare(*d2.scriptdef_p_); @@ -247,7 +262,7 @@ Script_req::~Script_req() } /* *************** */ int -Text_req:: compare(const Text_req &r1, const Text_req &r2) +Text_req:: compare(Text_req const &r1, Text_req const &r2) { bool b1 = (r1.dir_i_ == r2.dir_i_); bool b2 = (r1.tdef_p_ ->compare(*r2.tdef_p_)); @@ -274,8 +289,11 @@ Text_req::Text_req(int dir_i, Text_def* tdef_p) void Text_req::do_print() const { +#ifndef NPRINT + mtor << " dir " << dir_i_ ; tdef_p_->print(); +#endif } /* *************** */ @@ -289,7 +307,10 @@ Skip_req::duration() const void Skip_req::do_print() const { +#ifndef NPRINT + mtor << "duration: " << duration(); +#endif } Voice * @@ -305,7 +326,9 @@ Request::voice_l() void Subtle_req::do_print() const { - mtor << " subtime " << subtime_; +#ifndef NPRINT + mtor << " subtime " << subtime_; +#endif } void diff --git a/lily/mylexer.cc b/lily/mylexer.cc index 2907a33965..265e02b126 100644 --- a/lily/mylexer.cc +++ b/lily/mylexer.cc @@ -1,7 +1,7 @@ #include #include "interval.hh" -#include "identparent.hh" +#include "identifier.hh" #include "assoc-iter.hh" #include "lexer.hh" #include "input-file.hh" @@ -26,6 +26,7 @@ static Keyword_ent the_key_tab[]={ "geometric", GEOMETRIC, "goto", GOTO, "in", IN_T, + "lyrics", LYRICS, "key", KEY, "melodic" , MELODIC, "meter", METER, @@ -119,7 +120,7 @@ My_flex_lexer::spot()const } void -My_flex_lexer::LexerError(const char *s) +My_flex_lexer::LexerError(char const *s) { if (lexer->include_stack_.empty()) { *mlog << "error at EOF" << s << '\n'; diff --git a/lily/note.cc b/lily/note.cc index 267a0de696..543ef6130c 100644 --- a/lily/note.cc +++ b/lily/note.cc @@ -10,7 +10,7 @@ #include "command-request.hh" #include "voice.hh" -#include "identparent.hh" +#include "identifier.hh" #include "varray.hh" #include "text-def.hh" #include "parseconstruct.hh" diff --git a/lily/p-col.cc b/lily/p-col.cc index 2bfa097431..caaf264766 100644 --- a/lily/p-col.cc +++ b/lily/p-col.cc @@ -52,7 +52,7 @@ PCol::print() const } int -PCol::compare(const PCol &c1, const PCol &c2) +PCol::compare(PCol const &c1, PCol const &c2) { PScore*ps_l = c1.pscore_l_; PCursor ac(ps_l->find_col(&c1)); diff --git a/lily/p-score.cc b/lily/p-score.cc index 582a3148ef..9e31523da1 100644 --- a/lily/p-score.cc +++ b/lily/p-score.cc @@ -137,7 +137,7 @@ PScore::select_items(PStaff*ps, PCol*pc) assert(ps && pc); for (iter_top(pc->its,i); i.ok(); i++){ if (i->pstaff_l_ == ps) - ret.push((Item*)(const Item*)i); + ret.push((Item*)(Item const *)i); } return ret; } @@ -204,9 +204,9 @@ PScore::postprocess() } PCursor -PScore::find_col(const PCol *c)const +PScore::find_col(PCol const *c)const { - const PCol*what = c; + PCol const *what = c; if (what->daddy_l_ ) what = what->daddy_l_; diff --git a/lily/paper-def.cc b/lily/paper-def.cc index 6063347e88..1b3a74b2a5 100644 --- a/lily/paper-def.cc +++ b/lily/paper-def.cc @@ -89,7 +89,7 @@ Paper_def::print() const mtor << "}\n"; #endif } -const Lookup* +Lookup const * Paper_def::lookup_l() { return lookup_p_; diff --git a/lily/parser.y b/lily/parser.y index e30f2da400..a5110d97ca 100644 --- a/lily/parser.y +++ b/lily/parser.y @@ -1,13 +1,16 @@ %{ // -*-Fundamental-*- #include - +#include "script-def.hh" +#include "symtable.hh" #include "lookup.hh" #include "misc.hh" #include "lexer.hh" #include "paper-def.hh" #include "midi-def.hh" -#include "input-score.hh" #include "main.hh" +#include "input-score.hh" +#include "input-staff.hh" +#include "input-music.hh" #include "keyword.hh" #include "debug.hh" #include "parseconstruct.hh" @@ -71,6 +74,7 @@ int fatal_error_i = 0; %token CM_T %token COMMAND %token COMMANDS +%token CONCAT %token DURATIONCOMMAND %token DYNAMIC %token END @@ -78,6 +82,7 @@ int fatal_error_i = 0; %token GOTO %token GROUPING %token IN_T +%token LYRICS %token KEY %token MELODIC %token METER @@ -113,8 +118,13 @@ int fatal_error_i = 0; %token INT %token IDENTIFIER %token MELODIC_REQUEST_IDENTIFIER +%token CHORD_IDENTIFIER +%token VOICE_IDENTIFIER %token POST_REQUEST_IDENTIFIER +%token SCRIPT_IDENTIFIER +%token STAFF_IDENTIFIER %token REAL_IDENTIFIER +%token SCORE_IDENTIFIER %token REQUEST_IDENTIFIER %token REAL %token DURATION RESTNAME @@ -122,7 +132,7 @@ int fatal_error_i = 0; %type box %type open_request_parens close_request_parens close_plet_parens -%type music_chord music_chord_body +%type music_chord music_chord_body init_music_chord %type voice_elt full_element lyrics_elt command_elt %type int %type octave_quotes octave_quote @@ -138,8 +148,8 @@ int fatal_error_i = 0; %type pitch_list %type midi_block midi_body %type duration_length -%type music -%type music_voice_body music_voice +%type music init_music +%type music_voice_body music_voice init_music_voice init_lyrics_voice %type paper_block paper_body %type dim real @@ -154,6 +164,11 @@ int fatal_error_i = 0; %type symtable symtable_body %type mudela_text + +%left PRIORITY + +%expect 2 /* have to fix this. */ + %% mudela: /* empty */ @@ -182,20 +197,28 @@ declarable_identifier: ; declaration: - declarable_identifier '=' staff_block { - $$ = new Staff_id(*$1, $3, IDENTIFIER); + declarable_identifier '=' score_block { + $$ = new Score_id(*$1, $3, SCORE_IDENTIFIER); + delete $1; + } + | declarable_identifier '=' staff_block { + $$ = new Staff_id(*$1, $3, STAFF_IDENTIFIER); delete $1; } - | declarable_identifier '=' music_voice { - $$ = new M_voice_id(*$1, $3, IDENTIFIER); + | declarable_identifier '=' init_music_voice { + $$ = new M_voice_id(*$1, $3, VOICE_IDENTIFIER); + delete $1; + } + | declarable_identifier '=' init_lyrics_voice { + $$ = new M_voice_id(*$1, $3, VOICE_IDENTIFIER); delete $1; } | declarable_identifier '=' script_definition { - $$ = new Script_id(*$1, $3, IDENTIFIER); + $$ = new Script_id(*$1, $3, SCRIPT_IDENTIFIER); delete $1; } - | declarable_identifier '=' music_chord { - $$ = new M_chord_id(*$1, $3, IDENTIFIER); + | declarable_identifier '=' init_music_chord { + $$ = new M_chord_id(*$1, $3, CHORD_IDENTIFIER); delete $1; } | declarable_identifier '=' symtables { @@ -235,20 +258,16 @@ score_block: $$->errorlevel_i_ = lexer->errorlevel_i_; lexer->errorlevel_i_ = 0; - /* unbarf score without global music. */ - if (!$$-> score_wide_music_p_) { - $$-> score_wide_music_p_ = new Music_voice; - } } ; score_body: { $$ = new Input_score; } - | score_body staff_block { $$->add($2); } - | score_body COMMANDS '{' music_voice_body '}' { - $$->set($4); + | SCORE_IDENTIFIER { + $$ = $1->score(true); } + | score_body staff_block { $$->add($2); } | score_body paper_block { $$->set($2); } | score_body midi_block { $$->set($2); } | score_body error { @@ -269,7 +288,6 @@ intastint_list: */ paper_block: PAPER - '{' paper_body '}' { $$ = $3; } ; @@ -327,7 +345,7 @@ staff_block: staff_init: - IDENTIFIER { $$ = $1->staff(true); } + STAFF_IDENTIFIER { $$ = $1->staff(true); } | STRING { $$ = new Input_staff(*$1); delete $1; @@ -339,10 +357,7 @@ staff_init: staff_body: staff_init - | staff_body COMMANDS '{' music_voice_body '}' { - $$->set_score_wide($4); - } - | staff_body music { + | staff_body init_music { $2->set_default_group( "staff_music" + String($$->music_.size())); $$->add($2); } @@ -350,6 +365,30 @@ staff_body: } ; +/* + let the lexer switch mode. +*/ +init_music: + init_music_voice { $$ = $1; } + | init_music_chord { $$ = $1; } + | init_lyrics_voice { $$ = $1; } + ; + +init_lyrics_voice: + LYRICS { lexer->push_lyric_state(); } + music_voice { $$ = $3; lexer->pop_state(); } + ; + +init_music_voice: + MUSIC { lexer->push_note_state(); } + /* cont*/ music_voice + { $$=$3; lexer->pop_state(); } + ; +init_music_chord: + MUSIC { lexer->push_note_state(); } + /* cont*/ music_chord + { $$=$3; lexer->pop_state(); } + ; /* MUSIC */ @@ -358,19 +397,16 @@ music: | music_chord { $$ = $1; } ; -music_voice: MUSIC '{' music_voice_body '}' { $$ = $3; } +music_voice: '{' music_voice_body '}' { $$ = $2; } ; music_voice_body: - IDENTIFIER { + VOICE_IDENTIFIER { $$ = $1->mvoice(true); } | /* */ { $$ = new Music_voice; } - | music_voice_body '+' IDENTIFIER { - $$->concatenate($3->mvoice(true)); - } | music_voice_body full_element { $$->add_elt($2); } @@ -381,13 +417,15 @@ music_voice_body: } | music_voice_body error { } - ; + | music_voice_body '>' { + error("Confused by earlier errors: bailing out"); + }; -music_chord: '{' music_chord_body '}' { $$ = $2; } +music_chord: '<' music_chord_body '>' { $$ = $2; } ; music_chord_body: - IDENTIFIER { + CHORD_IDENTIFIER { $$=$1->mchord(true); } | /* */ { @@ -396,15 +434,15 @@ music_chord_body: | MULTIVOICE { $$ = new Multi_voice_chord; } - | music_chord_body '+' IDENTIFIER { - $$->concatenate($3->mchord(true)); - } | music_chord_body music { $$->add($2); } | music_chord_body full_element { $$ ->add_elt($2); } + | music_chord_body '}' { + error("Confused by earlier errors: bailing out"); + } | music_chord_body error { } ; @@ -446,11 +484,13 @@ command_req: $$ = new Bar_req(*$2); delete $2; } - | METER '{' int '*' int '}' { + | METER '{' int '/' int '}' { Meter_change_req *m = new Meter_change_req; m->set($3,$5); // sorry hw, i need meter at output of track, // but don-t know where to get it... statics should go. + // HW : default: 4/4, meterchange reqs may change it. + Midi_def::num_i_s = $3; Midi_def::den_i_s = $5; $$ = m; @@ -520,7 +560,7 @@ pure_post_request: octave_quote: '\'' { $$ = 1; } - | '`' { $$ = -1; } + | '`' { $$ = -1 ; } ; octave_quotes: @@ -537,30 +577,32 @@ steno_note_req: * (Melodic_req *) $$ = *$1->request(false)->melodic(); $$->octave_i_ += lexer->prefs.default_octave_i_; } - | octave_quote steno_note_req { - $2-> octave_i_ += $1; - $$ = $2; //ugh!! + | steno_note_req '\'' { + $$-> octave_i_ ++; } - | '!' steno_note_req { + | '`' steno_note_req { $$ = $2; - $2->forceacc_b_ = ! $2->forceacc_b_; + $2-> octave_i_ --; + } + + | steno_note_req '!' { + $$->forceacc_b_ = ! $$->forceacc_b_; } ; melodic_request: - MELODIC '{' int int int int '}' {/* ugh */ + MELODIC '{' int int int '}' {/* ugh */ $$ = new Melodic_req; $$->octave_i_ = $3; $$->notename_i_ = $4; $$->accidental_i_ = $5; - $$->forceacc_b_ = $6; } ; dynamic_req: DYNAMIC '{' int '}' { Absolute_dynamic_req *ad_p = new Absolute_dynamic_req; - ad_p ->loudness_ = $3; + ad_p ->loudness_ = (Dynamic_req::Loudness)$3; $$ =ad_p; } ; @@ -620,7 +662,7 @@ script_req: ; mudela_script: - IDENTIFIER { $$ = $1->script(true); } + SCRIPT_IDENTIFIER { $$ = $1->script(true); } | script_definition { $$ = $1; } | '^' { $$ = get_scriptdef('^'); } | '+' { $$ = get_scriptdef('+'); } @@ -909,7 +951,7 @@ Paper_def* default_paper() { return new Paper_def( - lexer->lookup_identifier("default_table")->lookup(true)); + lexer->lookup_identifier("defaulttable")->lookup(true)); } diff --git a/lily/stem-beam-reg.cc b/lily/stem-beam-reg.cc index 67c7b5b54d..de09bb0940 100644 --- a/lily/stem-beam-reg.cc +++ b/lily/stem-beam-reg.cc @@ -124,7 +124,7 @@ Stem_beam_register::pre_move_processing() stem_p_ = 0; } if (beam_p_ && end_beam_b_) { - const Rhythmic_grouping * rg_c_l = get_staff_info().rhythmic_c_l_; + Rhythmic_grouping const * rg_c_l = get_staff_info().rhythmic_c_l_; rg_c_l->extend(current_grouping->interval()); beam_p_->set_grouping(*rg_c_l, *current_grouping); typeset_element(beam_p_); diff --git a/lily/tex-stream.cc b/lily/tex-stream.cc index 2125593ab6..4157f08563 100644 --- a/lily/tex-stream.cc +++ b/lily/tex-stream.cc @@ -43,7 +43,7 @@ Tex_stream & Tex_stream::operator<<(String s) { - for (const char *cp = s; *cp; cp++) { + for (char const *cp = s; *cp; cp++) { if (outputting_comment) { *os << *cp; if (*cp == '\n') { diff --git a/lily/text-def.cc b/lily/text-def.cc index b440003fd2..cd2961b65e 100644 --- a/lily/text-def.cc +++ b/lily/text-def.cc @@ -11,7 +11,7 @@ Text_def::Text_def() defined_ch_c_l_ = 0; } bool -Text_def::compare(const Text_def&def) +Text_def::compare(Text_def const &def) { return align_i_ == def.align_i_ && text_str_ == def.text_str_ && style_str_ == def.style_str_; diff --git a/lily/version.cc b/lily/version.cc index 5b24591c5b..eed3e39ca8 100644 --- a/lily/version.cc +++ b/lily/version.cc @@ -2,7 +2,7 @@ #include "string.hh" -extern const char* lily_version_sz(); +extern char const * lily_version_sz(); String get_version_str() diff --git a/lily/warn.cc b/lily/warn.cc index ad548c6f58..0db10f848e 100644 --- a/lily/warn.cc +++ b/lily/warn.cc @@ -30,7 +30,7 @@ error(String s) } void -error_t(const String& s, const Moment& r) +error_t(String const & s, Moment const & r) { String t_mom = String(trunc(r)) + String(r - Moment(trunc(r))); String e=s+ " (t = " + t_mom + ")"; @@ -38,7 +38,7 @@ error_t(const String& s, const Moment& r) } void -error_t(const String& s, Time_description const &t_tdes) +error_t(String const & s, Time_description const &t_tdes) { String e=s+ " (at t=" + String(t_tdes.bars_i_) + ": " + String(t_tdes.whole_in_measure_) + ")\n"; error(e); @@ -47,7 +47,7 @@ error_t(const String& s, Time_description const &t_tdes) void message( String message_str, char const* context_ch_c_l ) { - String str = "lilypond: "; + String str = ""; //"lilypond: ";// GNU format messages! Source_file* sourcefile_l = source_l_g->sourcefile_l( context_ch_c_l ); if ( sourcefile_l ) { str += sourcefile_l->file_line_no_str(context_ch_c_l) + String(": "); diff --git a/make/Builtin-rules.make b/make/Builtin-rules.make deleted file mode 100644 index b5fd253b0a..0000000000 --- a/make/Builtin-rules.make +++ /dev/null @@ -1,41 +0,0 @@ -# -# project LilyPond -- the musical typesetter -# title cancel all built-in rules -# file make/Builtin-rules.make -# -# Copyright (c) 1997 by -# Jan Nieuwenhuizen -# Han-Wen Nienhuys - -# no assembly sources -%.o : %.s - -# no c sources -%.o : %.c - -# not using RCS -% :: RCS/%,v -$(outdir)/% :: $(outdir)/RCS/%,v -% : RCS/%,v -$(outdir)/% : $(outdir)/RCS/%,v -%.c : RCS/%,v -%.cc : RCS/%,v -%.hh : RCS/%,v -%.make : RCS/%,v -$(outdir)/%.dep : $(outdir)/RCS/%,v -%.dep : RCS/%.dep,v -$(outdir)/%.dep : $(outdir)/RCS/%.dep,v - -# lily knows better -%.tab.c %.tab.h : %.y - -# fine suffixes: -Makefile : -%.cc : -%.dep : -$(outdir)/%.dep: -%.hh : -%.make : -%.p : - - diff --git a/make/Configure_variables.make.in b/make/Configure_variables.make.in index 22d1becc05..e38c13d9b0 100644 --- a/make/Configure_variables.make.in +++ b/make/Configure_variables.make.in @@ -3,7 +3,7 @@ # @configure_input@ INSTALL = @INSTALL@ -CXXFLAGS = @CXXFLAGS@ +USER_CXXFLAGS = @CXXFLAGS@ #CXX = @CXX@ prefix = @prefix@ diff --git a/make/Files.make b/make/Files.make new file mode 100644 index 0000000000..ba1d2e3762 --- /dev/null +++ b/make/Files.make @@ -0,0 +1,35 @@ +# list of c++ header files: +# +HHFILES = $(wildcard *.hh) +# + +# list of c++ inline files: +# +INLFILES = $(wildcard *.inl) +# + +# list of c++ template files: +# + +TCCFILES = $(wildcard *.tcc) + +# +# list of other source files: +# + +EXTRA_SOURCE_FILES = $(wildcard *.y *.l) + +# +PODFILES = $(wildcard *.pod) + +CCFILES = $(wildcard *.cc) +MAKEFILES = $(wildcard *.make) + +ALL_SOURCES=$(HHFILES) $(CCFILES) $(EXTRA_SOURCE_FILES) $(INLFILES) \ + $(TCCFILES) $(PODFILES) $(MAKEFILES) + +DEPFILES = $(wildcard $(depdir)/*.dep) + +build = $(outdir)/.build + +all-tag-sources=$(CCFILES) $(HHFILES) diff --git a/make/Include.make b/make/Include.make index b8f1255cf2..0416201c78 100644 --- a/make/Include.make +++ b/make/Include.make @@ -1,4 +1,4 @@ -# + # project LilyPond -- the musical typesetter # title generic red tape for include/Makefile # file make/Include.make @@ -9,43 +9,10 @@ # identify module: # -NAME = generic-include -MAJOR_VERSION = $(TOPLEVEL_MAJOR_VERSION) -MINOR_VERSION = $(TOPLEVEL_MINOR_VERSION) -PATCH_LEVEL = $(TOPLEVEL_PATCH_LEVEL) -# use to send patches, always empty for released version: -MY_PATCH_LEVEL = $(TOPLEVEL_MY_PATCH_LEVEL) -build = ./$(depth)/lily/$(outdir)/.build -# -# generic variables: -# -include ./$(depth)/make/Variables.make -# - -# list of c++ header files: -# -HHFILES = $(shell ls *.hh $(ERROR_LOG)) -# - -# list of c++ inline files: -# -INLFILES = $(shell ls *.inl $(ERROR_LOG)) -# -# list of c++ template files: -# -TCCFILES = $(shell ls *.tcc $(ERROR_LOG)) -# - -# list of distribution files: -# -DISTFILES = Makefile $(HHFILES) $(INLFILES) $(TCCFILES) -# - -# generic targets and rules: -# +include ./$(depth)/make/Variables.make +include ./$(depth)/make/Version.make +include ./$(depth)/make/Files.make include ./$(depth)/make/Targets.make include ./$(depth)/make/Rules.make -# - diff --git a/make/Makefile b/make/Makefile index 30fbad011d..1f8f6ca8c7 100644 --- a/make/Makefile +++ b/make/Makefile @@ -16,27 +16,17 @@ depth = .. # identify module: # NAME = make -MAJOR_VERSION = $(TOPLEVEL_MAJOR_VERSION) -MINOR_VERSION = $(TOPLEVEL_MINOR_VERSION) -PATCH_LEVEL = $(TOPLEVEL_PATCH_LEVEL) -# use to send patches, always empty for released version: -MY_PATCH_LEVEL = $(TOPLEVEL_MY_PATCH_LEVEL) -build = ./$(depth)/lily/$(outdir)/.build -# -# list of generic make files: -# -MAKEFILES = $(shell ls *.make) -# # list of distribution files: # -DISTFILES = Configure_variables.make.in Makefile lilypond.spec.in $(MAKEFILES) +EXTRA_DISTFILES = Configure_variables.make.in lilypond.spec.in # # generic variables: # -include ./$(depth)/make/Variables.make +include ./$(depth)/make/Variables.make +include ./$(depth)/make/Files.make # # generic targets and rules: @@ -45,5 +35,5 @@ include ./$(depth)/make/Targets.make include ./$(depth)/make/Rules.make # -lilypond.spec: lilypond.spec.in - sed 's/@TOPLEVEL_VERSION@/${TOPLEVEL_VERSION}/g'< $< > $@ \ No newline at end of file +lilypond.spec: lilypond.spec.in $(depth)/.version + sed 's/@TOPLEVEL_VERSION@/${TOPLEVEL_VERSION}/g'< $< > $@ diff --git a/make/Rules.make b/make/Rules.make index 1389ef4bd7..0e06b46cac 100644 --- a/make/Rules.make +++ b/make/Rules.make @@ -22,8 +22,10 @@ # compile rules: # $(outdir)/%.o: %.cc - $(DODEP)\ - $(CXX) -c $(CXXFLAGS) $(CXX_OUTPUT_OPTION) + $(DO_CXX_COMPILE) + +$(outdir)/%.o: $(outdir)/%.cc + $(DO_CXX_COMPILE) $(outdir)/%.cc: %.y # $(BISON) -d $< @@ -67,14 +69,16 @@ $(outdir)/%.1: %.pod # specific stuff: # $(LIBFLOWER): check-flower-deps - $(MAKE) ./$(outdir)/$(@F) -C $(depth)/flower/lib check-flower-deps: - $(MAKE) -C $(depth)/flower/lib + $(MAKE) -C $(depth)/flower/ $(outdir)/$(notdir $(LIBFLOWER)) check-lily-deps: check-flower-deps $(MAKE) -C $(depth)/lib +check-doc-deps: + $(MAKE) -C $(depth)/Documentation + $(LIBLILY): dummy $(MAKE) ./$(outdir)/$(@F) -C $(depth)/lib # diff --git a/make/Stuff.make b/make/Stuff.make deleted file mode 100644 index 6a71b90848..0000000000 --- a/make/Stuff.make +++ /dev/null @@ -1,30 +0,0 @@ -# -# project LilyPond -- the musical typesetter -# title generic red tape for stuff/Makefile -# file make/Stuff.make -# -# Copyright (c) 1997 by -# Jan Nieuwenhuizen -# Han-Wen Nienhuys -# identify module: -# - -NAME = generic-stuff -MAJOR_VERSION = $(TOPLEVEL_MAJOR_VERSION) -MINOR_VERSION = $(TOPLEVEL_MINOR_VERSION) -PATCH_LEVEL = $(TOPLEVEL_PATCH_LEVEL) -# use to send patches, always empty for released version: -MY_PATCH_LEVEL = $(TOPLEVEL_MY_PATCH_LEVEL) -# - -# generic variables: -# -include ./$(depth)/make/Variables.make -# - -# generic targets and rules: -# -include ./$(depth)/make/Targets.make -include ./$(depth)/make/Rules.make -# - diff --git a/make/Targets.make b/make/Targets.make index 8173b9e079..9859802a58 100644 --- a/make/Targets.make +++ b/make/Targets.make @@ -38,7 +38,7 @@ $(EXECUTABLE): $(build) $(OFILES) $(CUSTOMLIBES) exe: $(EXECUTABLE) # -$(build): +$(build): $(depth)/.version echo 0 > $@ # dependency list of library: @@ -112,6 +112,8 @@ doc++: $(progdocs) dist: -mkdir $(distdir) $(MAKE) localdist + chmod -Rf a+rX $(distdir) + (cd ./$(depth); tar cfz $(DIST_NAME).tar.gz $(DIST_NAME)) rm -rf $(distdir)/ # should be trapped @@ -119,8 +121,8 @@ localdist: $(DISTFILES) if [ -d out ]; then mkdir $(distdir)/$(localdir)/out; fi ln $(DISTFILES) $(distdir)/$(localdir) ifdef SUBDIRS - set -e; for i in $(SUBDIRS); do mkdir $(distdir)/$(localdir)/$$i; done - set -e; for i in $(SUBDIRS); do $(MAKE) localdir=$(localdir)/$$i -C $$i localdist; done + set -e; for i in $(SUBDIRS); do mkdir $(distdir)/$(localdir)/$$i; \ + $(MAKE) localdir=$(localdir)/$$i -C $$i localdist; done endif moduledist: @@ -141,9 +143,10 @@ ifdef SUBDIRS set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i all-tags; done endif -TAGS: $(allcc) - etags -CT $(allcc) - +TAGS: $(all-tag-sources) +ifdef all-tag-sources + -etags -CT $(all-tag-sources) /dev/null +endif # version stuff: # diff --git a/make/Template.make b/make/Template.make index 2d6397f5e8..f9246f92e3 100644 --- a/make/Template.make +++ b/make/Template.make @@ -24,13 +24,9 @@ include ./$(depth)/make/Variables.make # NAME = ... MODULE_NAME = -# include ./$(depth)/$(NAME)/.version -MAJOR_VERSION = 0 -MINOR_VERSION = 0 -PATCH_LEVEL = 0 -# use to send patches, always empty for released version: -MY_PATCH_LEVEL = # include separator: "-1" or ".a" -build = $(lily-dir)/$(outdir)/.build #????! +include ./$(depth)/$(NAME)/.version + +build = $(outdir)/.build #????! # # descent order into subdirectories: @@ -38,37 +34,17 @@ build = $(lily-dir)/$(outdir)/.build #????! SUBDIRS = # -# to be remade each build: -# -VERSION_DEPENDENCY = $(lily-version) -# - -# module compile settings: (not generally needed! +# module compile settings: (not generally needed!) # EXTRA_CFLAGS = EXTRA_CXXFLAGS = EXTRA_LDFLAGS = # +include ./$(depth)/make/Files.make -# list of c++ header files: -# -HHFILES = $(shell ls *.hh $(ERROR_LOG)) -# - -# list of c++ source files: -# -CCFILES = $(shell ls *.cc $(ERROR_LOG)) -# - -# list of other source files: -# -EXTRA_SOURCE_FILES = $(shell ls *.y *.l $(ERROR_LOG)) -# - -# list of distribution files: -# -DISTFILES = Makefile $(HHFILES) $(CCFILES) $(EXTRA_SOURCE_FILES) -# +# list of extra distribution files: +# Makefile, C++ and pod are dist'ed automatically +EXTRA_DISTFILES = # list of custom libraries: # @@ -91,11 +67,6 @@ include ./$(depth)/make/Targets.make include ./$(depth)/make/Rules.make # -# list of depend files: -# -DEPFILES = $(shell ls $(depdir)/*.dep $(ERROR_LOG)) -# - # auto dependencies: # -include $(DEPFILES) diff --git a/make/Variables.make b/make/Variables.make index 3c74750c92..7e8ff5a830 100644 --- a/make/Variables.make +++ b/make/Variables.make @@ -27,19 +27,19 @@ lily_bindir = ./$(depth)/bin distdir = ./$(depth)/$(DIST_NAME) module-distdir = ./$(depth)/$(MODULE_DIST_NAME) depdir = $(outdir) -flowerout = ./$(depth)/flower/lib/$(outdir) +flowerout = ./$(depth)/flower/$(outdir) libout = ./$(depth)/lib/$(outdir) libdir = $(outdir) lilyout = ./$(depth)/lily/$(outdir) mi2muout = ./$(depth)/mi2mu/$(outdir) makeout = ./$(depth)/make/$(outdir) -flower-dir = ./$(depth)/flower/lib +flower-dir = ./$(depth)/flower lib-dir = ./$(depth)/lib lily-dir = ./$(depth)/lily mi2mu-dir = ./$(depth)/mi2mu make-dir = ./$(depth)/make include-lib = ./$(depth)/lib/include -include-flower = ./$(depth)/flower/lib/include +include-flower = ./$(depth)/flower/include # # user settings: @@ -106,7 +106,7 @@ mi2mu-version = $(mi2muout)/version.hh # custom libraries: # -LIBFLOWER = $(depth)/flower/lib/$(outdir)/$(LIB_PREFIX)flower$(LIB_SUFFIX) +LIBFLOWER = $(depth)/flower/$(outdir)/$(LIB_PREFIX)flower$(LIB_SUFFIX) LIBLILY = $(depth)/lib/$(outdir)/$(LIB_PREFIX)lily$(LIB_SUFFIX) # @@ -129,6 +129,9 @@ AR_COMMAND = $(AR) $(ARFLAGS) $@ RANLIB_COMMAND=$(RANLIB) $@ # compiler: # + +DO_CXX_COMPILE=$(DODEP)\ + $(CXX) -c $(CXXFLAGS) $(CXX_OUTPUT_OPTION) # "CC = $(CC)" # "CXX = $(CXX)" # @@ -161,3 +164,4 @@ LIBRARY = $(LIB_PREFIX)$(NAME)$(LIB_SUFFIX) STRIPDEBUG=true #replace to do stripping of certain objects +DISTFILES=$(EXTRA_DISTFILES) Makefile $(ALL_SOURCES) diff --git a/make/Version.make b/make/Version.make new file mode 100644 index 0000000000..9ee357173b --- /dev/null +++ b/make/Version.make @@ -0,0 +1,7 @@ + +MAJOR_VERSION = $(TOPLEVEL_MAJOR_VERSION) +MINOR_VERSION = $(TOPLEVEL_MINOR_VERSION) +PATCH_LEVEL = $(TOPLEVEL_PATCH_LEVEL) +# use to send patches, always empty for released version: +MY_PATCH_LEVEL = $(TOPLEVEL_MY_PATCH_LEVEL) +build = $(outdir)/.build diff --git a/make/lilypond.spec.in b/make/lilypond.spec.in index 18d469b45e..887c92075a 100644 --- a/make/lilypond.spec.in +++ b/make/lilypond.spec.in @@ -22,18 +22,18 @@ configure --enable-checking --enable-optimise --enable-printing --prefix=/usr make all %install make install - +strip /usr/bin/lilypond /usr/bin/mi2mu %files %doc Documentation/out/index.text Documentation/out/CodingStyle.text %doc Documentation/out/lilygut.text Documentation/out/lilyinput.text %doc Documentation/out/error.text Documentation/out/faq.text %doc Documentation/out/INSTALL.text -%doc Documentation/out/language.text Documentation/out/lelie_logo.png +%doc Documentation/out/language.text Documentation/lelie_logo.gif /usr/bin/lilypond /usr/bin/mi2mu /usr/man/man1/lilypond.1 -/usr/lib/texmf/texmf/tex/lilypond/* -/usr/share/lilypond/* +/usr/lib/texmf/texmf/tex/lilypond/ +/usr/share/lilypond/ %post texhash diff --git a/mi2mu/Makefile b/mi2mu/Makefile index 10a7f1ef53..235504e660 100644 --- a/mi2mu/Makefile +++ b/mi2mu/Makefile @@ -15,7 +15,8 @@ depth = .. # generic variables: # -include ./$(depth)/make/Variables.make +include ./$(depth)/make/Variables.make +include ./$(depth)/make/Files.make # # identify module: @@ -36,24 +37,11 @@ SUBDIRS = include VERSION_DEPENDENCY = $(mi2mu-version) # -# list of c++ header files: -# -HHFILES := $(wildcard *.hh ) -# - -# list of c++ source files: -# -CCFILES := $(wildcard *.cc ) -# - -# list of other source files: -# -EXTRA_SOURCE_FILES := $(wildcard *.y *.l ) -# # list of distribution files: # -DISTFILES = Makefile .version $(HHFILES) $(CCFILES) $(EXTRA_SOURCE_FILES) +DISTFILES = Makefile .version $(ALL_SOURCES) + # # list of custom libraries: @@ -87,7 +75,7 @@ midi-lexer.l: $(outdir)/midi-parser.hh # list of depend files: # -DEPFILES = $(shell ls $(depdir)/*.dep $(ERROR_LOG)) +DEPFILES = $(wildcard $(depdir)/*.dep) # # auto dependencies: diff --git a/mi2mu/include/Makefile b/mi2mu/include/Makefile index 6860a29536..1cfdc7b22a 100644 --- a/mi2mu/include/Makefile +++ b/mi2mu/include/Makefile @@ -8,12 +8,6 @@ depth = ../.. # identify module: # MODULE_NAME = lilypond -MAJOR_VERSION = $(TOPLEVEL_MAJOR_VERSION) -MINOR_VERSION = $(TOPLEVEL_MINOR_VERSION) -PATCH_LEVEL = $(TOPLEVEL_PATCH_LEVEL) -# use to send patches, always empty for released version: -MY_PATCH_LEVEL = $(TOPLEVEL_MY_PATCH_LEVEL) -build = ./$(depth)/mi2mu/$(outdir)/.build # # generic stuff/Makefile diff --git a/tex/Makefile b/tex/Makefile index 35004f0f6d..adcbcdd157 100644 --- a/tex/Makefile +++ b/tex/Makefile @@ -4,17 +4,13 @@ # depth = .. # - -build = ./$(depth)/lily/$(outdir)/.build - -# generic stuff/Makefile # -include ./$(depth)/make/Stuff.make +include ./$(depth)/make/Include.make # # list of distribution files: # -TEXFILES = $(shell ls *.tex) +TEXFILES = $(wildcard *.tex) DISTFILES = Makefile $(TEXFILES) # @@ -24,4 +20,4 @@ localinstall: localuninstall: for i in $(TEXFILES) ; do rm -f $(TEXPREFIX)/lilypond/$$i; done - -rmdir $(TEXPREFIX)/lilypond/ \ No newline at end of file + -rmdir $(TEXPREFIX)/lilypond/