From daee8243ff1c66bc714455a2d265ab02f03546ec Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Thu, 6 Mar 1997 19:16:55 +0100 Subject: [PATCH] release: 0.0.39-1 --- .dstreamrc | 54 --- .version | 6 + Documentation/CodingStyle.pod | 35 +- Documentation/Makefile | 73 ++-- Documentation/README.pod | 18 +- Documentation/faq.pod | 50 +-- Documentation/language.pod | 27 +- Generate.make | 30 -- INSTALL | 50 +++ Initial.make | 12 - Makefile | 115 +++-- NEWS | 50 +++ README | 3 - Sources.make | 135 ------ TODO | 9 +- Variables.make | 130 ------ bin/Makefile | 20 + clearlily => bin/clearlily | 0 bin/configure | 85 ++++ bin/cpgento | 49 +++ genheader => bin/genheader | 0 bin/make_fversion | 11 + make_patch => bin/make_patch | 0 bin/make_version | 11 + {Documentation => bin}/make_website | 2 +- configure | 59 +-- deps/Makefile | 13 - flower/.version | 6 + flower/Makefile | 23 +- flower/NEWS | 5 +- flower/Sources.make | 23 +- flower/TODO | 12 +- flower/Variables.make | 12 +- flower/assoc.hh | 9 +- flower/choleski.cc | 2 +- flower/dstream.cc | 62 ++- flower/dstream.hh | 9 +- flower/fproto.hh | 24 +- flower/lgetopt.cc | 30 +- flower/lgetopt.hh | 37 +- flower/lib/Makefile | 92 ++++ flower/lib/choleski.cc | 91 ++++ flower/{datafile.cc => lib/data-file.cc} | 2 +- flower/lib/dstream.cc | 158 +++++++ flower/lib/include/Makefile | 19 + .../include/assoc-iter.hh} | 0 flower/lib/include/assoc.hh | 78 ++++ flower/lib/include/choleski.hh | 46 ++ flower/lib/include/compare.hh | 55 +++ flower/lib/include/cursor.hh | 113 +++++ flower/lib/include/cursor.inl | 113 +++++ flower/lib/include/cursor.tcc | 109 +++++ .../{datafile.hh => lib/include/data-file.hh} | 4 +- flower/lib/include/dstream.hh | 54 +++ .../lib/include/flower-config.hh | 0 flower/lib/include/fproto.hh | 44 ++ flower/lib/include/handle.hh | 58 +++ flower/lib/include/interval.hh | 125 ++++++ flower/lib/include/interval.tcc | 106 +++++ flower/lib/include/iterate.hh | 22 + flower/lib/include/lgetopt.hh | 94 +++++ flower/lib/include/libc-extension.hh | 32 ++ flower/lib/include/link.hh | 38 ++ flower/lib/include/link.inl | 102 +++++ flower/lib/include/list.hh | 98 +++++ flower/lib/include/list.inl | 56 +++ flower/lib/include/list.tcc | 112 +++++ flower/lib/include/matrix.hh | 135 ++++++ flower/lib/include/path.hh | 32 ++ flower/lib/include/pcursor.tcc | 16 + flower/lib/include/plist.tcc | 21 + flower/lib/include/pqueue.hh | 46 ++ flower/lib/include/rational.hh | 1 + flower/lib/include/real.hh | 16 + flower/lib/include/scalar.hh | 34 ++ flower/lib/include/smat.hh | 93 ++++ flower/lib/include/string-convert.hh | 43 ++ .../include/string-data.hh} | 5 +- .../include/string-data.inl} | 31 +- .../include/string-handle.hh} | 8 +- .../include/string-handle.inl} | 9 +- flower/lib/include/string.hh | 193 +++++++++ flower/{textdb.hh => lib/include/text-db.hh} | 2 +- .../include/text-stream.hh} | 0 flower/lib/include/unionfind.hh | 25 ++ flower/lib/include/varray.hh | 186 ++++++++ flower/lib/include/vector.hh | 111 +++++ flower/lib/include/vsmat.hh | 141 +++++++ flower/lib/lgetopt.cc | 222 ++++++++++ flower/lib/libc-extension.cc | 113 +++++ flower/lib/matdebug.cc | 63 +++ flower/lib/matrix.cc | 240 +++++++++++ flower/lib/path.cc | 77 ++++ flower/lib/scalar.cc | 57 +++ flower/lib/smat.cc | 181 ++++++++ flower/lib/string-convert.cc | 235 +++++++++++ flower/lib/stringtest.cc | 118 ++++++ flower/lib/stringutil.cc | 33 ++ flower/{textdb.cc => lib/text-db.cc} | 2 +- flower/{textstream.cc => lib/text-stream.cc} | 2 +- flower/lib/unionfind.cc | 35 ++ flower/lib/vector.cc | 25 ++ flower/matdebug.cc | 1 + flower/pcursor.hh | 4 +- flower/plist.tcc | 2 +- flower/smat.cc | 12 +- flower/string-convert.cc | 95 ++++- flower/string-convert.hh | 41 +- flower/string.cc | 396 ++++++++---------- flower/string.hh | 47 +-- flower/stringtest.cc | 105 ++++- flower/stringutil.cc | 8 +- flower/varray.hh | 11 +- hdr/Makefile | 13 - hdr/duration.hh | 111 ----- hdr/lily-stream.hh | 27 -- hdr/lyric-item.hh | 19 - hdr/midi-event.hh | 85 ---- hdr/midi-item.hh | 85 ---- hdr/midi-main.hh | 27 -- hdr/midi-score.hh | 27 -- hdr/midi-stream.hh | 32 -- hdr/midi-track.hh | 26 -- hdr/my-midi-parser.hh | 54 --- hdr/track-column.hh | 24 -- init/Makefile | 24 +- init/symbol.ini | 4 +- input/Makefile | 30 +- input/midi.ly | 3 +- input/scales.ly | 14 +- lib/Makefile | 91 ++++ lib/include/Makefile | 23 + lib/include/config.hh | 1 + {hdr => lib/include}/debug.hh | 0 {hdr => lib/include}/input-file.hh | 0 {hdr => lib/include}/moment.hh | 0 {hdr => lib/include}/proto.hh | 1 + ...indhoos-suck-suck-suck-thank-you-cygnus.hh | 13 + {src => lib}/source-file.cc | 15 +- {src => lib}/source.cc | 0 ...indhoos-suck-suck-suck-thank-you-cygnus.cc | 1 + lily/Makefile | 99 +++++ {src => lily}/bar-reg.cc | 0 {src => lily}/bar.cc | 0 {src => lily}/beam.cc | 0 {src => lily}/boxes.cc | 0 {src => lily}/break.cc | 0 {src => lily}/calcideal.cc | 0 {src => lily}/clef-item.cc | 0 {src => lily}/clef-reg.cc | 0 {src => lily}/colhpos.cc | 0 {src => lily}/commandrequest.cc | 0 {src => lily}/complex-staff.cc | 0 {src => lily}/complex-walker.cc | 2 +- {src => lily}/debug.cc | 0 {src => lily}/dimen.cc | 0 {src => lily}/directional-spanner.cc | 0 {src => lily}/grouping.cc | 0 {src => lily}/groupregs.cc | 0 {src => lily}/headreg.cc | 0 {src => lily}/idealspacing.cc | 0 {src => lily}/identifier.cc | 0 lily/include/Makefile | 23 + {hdr => lily/include}/bar-reg.hh | 0 {hdr => lily/include}/bar.hh | 0 {hdr => lily/include}/beam.hh | 0 {hdr => lily/include}/boxes.hh | 0 {hdr => lily/include}/break.hh | 0 {hdr => lily/include}/class-name.hh | 0 {hdr => lily/include}/clef-item.hh | 0 {hdr => lily/include}/clef-reg.hh | 0 {hdr => lily/include}/colhpos.hh | 0 {hdr => lily/include}/commandrequest.hh | 0 {hdr => lily/include}/complex-staff.hh | 0 {hdr => lily/include}/complex-walker.hh | 0 lily/include/config.hh | 1 + {hdr => lily/include}/const.hh | 0 {hdr => lily/include}/dimen.hh | 0 {hdr => lily/include}/directional-spanner.hh | 0 {hdr => lily/include}/glob.hh | 0 {hdr => lily/include}/grouping.hh | 0 lily/include/head-reg.hh | 24 ++ {hdr => lily/include}/headreg.hh | 0 {hdr => lily/include}/idealspacing.hh | 0 {hdr => lily/include}/identifier.hh | 0 {hdr => lily/include}/identparent.hh | 0 {hdr => lily/include}/input-music.hh | 0 {hdr => lily/include}/input-score.hh | 0 {hdr => lily/include}/input-staff.hh | 0 {hdr => lily/include}/item.hh | 0 {hdr => lily/include}/key-item.hh | 0 {hdr => lily/include}/key-reg.hh | 0 {hdr => lily/include}/key.hh | 0 {hdr => lily/include}/keyword.hh | 0 {hdr => lily/include}/leastsquares.hh | 0 {hdr => lily/include}/lexer.hh | 0 {hdr => lily/include}/linespace.hh | 0 {hdr => lily/include}/local-key-item.hh | 0 {hdr => lily/include}/local-key-reg.hh | 0 {hdr => lily/include}/lookup.hh | 0 {hdr => lily/include}/main.hh | 1 + {hdr => lily/include}/meter-reg.hh | 0 {hdr => lily/include}/meter.hh | 0 {hdr => lily/include}/midi-output.hh | 10 +- {hdr => lily/include}/misc.hh | 0 {hdr => lily/include}/molecule.hh | 0 {hdr => lily/include}/musicalrequest.hh | 0 {hdr => lily/include}/notehead.hh | 0 {hdr => lily/include}/notename.hh | 0 {hdr => lily/include}/offset.hh | 0 hdr/pstaff.hh => lily/include/p-staff.hh | 0 {hdr => lily/include}/paper-def.hh | 0 {hdr => lily/include}/parseconstruct.hh | 0 lily/include/parser.hh | 86 ++++ {hdr => lily/include}/pcol.hh | 0 {hdr => lily/include}/pscore.hh | 0 lily/include/pstaff.hh | 25 ++ {hdr => lily/include}/qlp.hh | 0 {hdr => lily/include}/qlpsolve.hh | 0 {hdr => lily/include}/register.hh | 0 {hdr => lily/include}/registergroup.hh | 0 {hdr => lily/include}/reqtodo.hh | 0 {hdr => lily/include}/request.hh | 0 {hdr => lily/include}/rest.hh | 0 {hdr => lily/include}/score-column.hh | 0 {hdr => lily/include}/score-walker.hh | 0 {hdr => lily/include}/score.hh | 0 {hdr => lily/include}/scoreline.hh | 0 {hdr => lily/include}/script-def.hh | 0 {hdr => lily/include}/script-reg.hh | 0 {hdr => lily/include}/script.hh | 0 {hdr => lily/include}/slur-reg.hh | 0 {hdr => lily/include}/slur.hh | 0 {hdr => lily/include}/spanner.hh | 0 {hdr => lily/include}/staff-column.hh | 0 {hdr => lily/include}/staff-elem-info.hh | 0 {hdr => lily/include}/staff-elem.hh | 0 {hdr => lily/include}/staff-walker.hh | 0 {hdr => lily/include}/staff.hh | 0 lily/include/staffelem.hh | 84 ++++ lily/include/staffeleminfo.hh | 28 ++ {hdr => lily/include}/staffline.hh | 0 {hdr => lily/include}/staffsym.hh | 0 {hdr => lily/include}/stem-beam-reg.hh | 0 {hdr => lily/include}/stem.hh | 0 {hdr => lily/include}/symbol.hh | 0 {hdr => lily/include}/symtable.hh | 0 {hdr => lily/include}/tex-stream.hh | 0 {hdr => lily/include}/tex.hh | 0 {hdr => lily/include}/text-def.hh | 0 hdr/textitem.hh => lily/include/text-item.hh | 0 {hdr => lily/include}/text-reg.hh | 0 .../include/text-spanner.hh | 0 {hdr => lily/include}/time-description.hh | 0 {hdr => lily/include}/voice-element.hh | 0 {hdr => lily/include}/voice-group-regs.hh | 0 {hdr => lily/include}/voice-regs.hh | 0 {hdr => lily/include}/voice.hh | 0 hdr/walkregs.hh => lily/include/walk-regs.hh | 0 {src => lily}/input-music.cc | 0 {src => lily}/input-score.cc | 0 {src => lily}/input-staff.cc | 2 +- {src => lily}/item.cc | 0 {src => lily}/key-item.cc | 0 {src => lily}/key-reg.cc | 0 {src => lily}/key.cc | 0 {src => lily}/keyword.cc | 0 {src => lily}/leastsquares.cc | 0 {src => lily}/lexer.l | 2 +- {src => lily}/lexerinit.cc | 0 {src => lily}/linespace.cc | 0 {src => lily}/local-key-item.cc | 0 {src => lily}/local-key-reg.cc | 2 +- {src => lily}/lookup.cc | 0 {src => lily}/lyric-item.cc | 0 src/lyricstaff.cc => lily/lyric-staff.cc | 4 +- {src => lily}/main.cc | 2 + {src => lily}/meter-reg.cc | 0 {src => lily}/meter.cc | 0 {src => lily}/misc.cc | 0 {src => lily}/molecule.cc | 0 {src => lily}/mylexer.cc | 0 {src => lily}/note.cc | 0 {src => lily}/notehead.cc | 0 {src => lily}/notename.cc | 0 {src => lily}/paper-def.cc | 0 {src => lily}/parser.y | 8 +- {src => lily}/pcol.cc | 0 {src => lily}/pscore.cc | 2 +- {src => lily}/pstaff.cc | 0 {src => lily}/qlp.cc | 0 {src => lily}/qlpsolve.cc | 0 {src => lily}/register.cc | 0 {src => lily}/registergroup.cc | 4 +- {src => lily}/request.cc | 0 {src => lily}/rest.cc | 0 {src => lily}/score-column.cc | 0 {src => lily}/score-walker.cc | 3 +- {src => lily}/score.cc | 2 +- {src => lily}/scoreline.cc | 0 {src => lily}/scores.cc | 0 {src => lily}/script-def.cc | 0 {src => lily}/script-reg.cc | 0 {src => lily}/script.cc | 0 {src => lily}/slur-reg.cc | 1 + {src => lily}/slur.cc | 0 {src => lily}/spanner.cc | 0 {src => lily}/staff-column.cc | 2 + {src => lily}/staff-elem-info.cc | 0 {src => lily}/staff-elem.cc | 0 {src => lily}/staff-walker.cc | 4 +- {src => lily}/staff.cc | 4 +- {src => lily}/staffline.cc | 0 {src => lily}/staffsym.cc | 0 {src => lily}/stem-beam-reg.cc | 2 +- {src => lily}/stem.cc | 0 {src => lily}/symbol.cc | 0 {src => lily}/symtable.cc | 0 {src => lily}/template1.cc | 1 + {src => lily}/template2.cc | 0 {src => lily}/template3.cc | 0 {src => lily}/template4.cc | 0 {src => lily}/template5.cc | 0 {src => lily}/template6.cc | 0 src/texbeam.cc => lily/tex-beam.cc | 0 src/texslur.cc => lily/tex-slur.cc | 0 {src => lily}/tex-stream.cc | 1 + {src => lily}/tex.cc | 0 {src => lily}/text-def.cc | 0 src/textitem.cc => lily/text-item.cc | 2 +- {src => lily}/text-reg.cc | 2 +- src/textspanner.cc => lily/text-spanner.cc | 2 +- {src => lily}/time-description.cc | 2 +- {src => lily}/version.cc | 0 src/voiceelt.cc => lily/voice-elt.cc | 2 + {src => lily}/voice-group-regs.cc | 1 + {src => lily}/voice-regs.cc | 4 +- {src => lily}/voice.cc | 2 + src/walkregs.cc => lily/walk-regs.cc | 2 +- {src => lily}/warn.cc | 4 +- {src => lily}/wordwrap.cc | 0 m2m/.version | 7 + m2m/Makefile | 99 +++++ m2m/include/Makefile | 23 + {src => m2m}/midi-lexer.l | 64 +-- {src => m2m}/midi-parser.y | 81 ++-- make/Include.make | 51 +++ make/Initial.make | 52 +++ make/Makefile | 47 +++ make/Rules.make | 52 +++ make/Site.make | 0 make/Sources.make | 137 ++++++ make/Stuff.make | 31 ++ make/Targets.make | 126 ++++++ make/Template.make | 97 +++++ make/User.make | 40 ++ make/Variables.make | 154 +++++++ make_version | 9 - objects/Makefile | 6 - src/Makefile | 15 - src/binary-source-file.cc | 64 --- src/duration.cc | 249 ----------- src/lily-stream.cc | 72 ---- src/lyricwalker.cc | 39 -- src/midi-def.cc | 64 --- src/midi-event.cc | 198 --------- src/midi-item.cc | 196 --------- src/midi-main.cc | 205 --------- src/midi-output.cc | 52 --- src/midi-score.cc | 63 --- src/midi-stream.cc | 89 ---- src/midi-template.cc | 29 -- src/midi-track.cc | 84 ---- src/my-midi-lexer.cc | 81 ---- src/my-midi-parser.cc | 164 -------- src/track-column.cc | 35 -- tex/Makefile | 20 + dimen.tex => tex/dimen.tex | 0 lilyponddefs.tex => tex/lilyponddefs.tex | 0 ltest.tex => tex/ltest.tex | 0 test.tex => tex/test.tex | 0 titledefs.tex => tex/titledefs.tex | 0 382 files changed, 6981 insertions(+), 3411 deletions(-) delete mode 100644 .dstreamrc create mode 100644 .version delete mode 100644 Generate.make create mode 100644 INSTALL delete mode 100644 Initial.make delete mode 100644 Sources.make delete mode 100644 Variables.make create mode 100644 bin/Makefile rename clearlily => bin/clearlily (100%) create mode 100755 bin/configure create mode 100755 bin/cpgento rename genheader => bin/genheader (100%) create mode 100755 bin/make_fversion rename make_patch => bin/make_patch (100%) create mode 100755 bin/make_version rename {Documentation => bin}/make_website (89%) mode change 100755 => 120000 configure delete mode 100644 deps/Makefile create mode 100644 flower/.version create mode 100644 flower/lib/Makefile create mode 100644 flower/lib/choleski.cc rename flower/{datafile.cc => lib/data-file.cc} (98%) create mode 100644 flower/lib/dstream.cc create mode 100644 flower/lib/include/Makefile rename flower/{associter.hh => lib/include/assoc-iter.hh} (100%) create mode 100644 flower/lib/include/assoc.hh create mode 100644 flower/lib/include/choleski.hh create mode 100644 flower/lib/include/compare.hh create mode 100644 flower/lib/include/cursor.hh create mode 100644 flower/lib/include/cursor.inl create mode 100644 flower/lib/include/cursor.tcc rename flower/{datafile.hh => lib/include/data-file.hh} (94%) create mode 100644 flower/lib/include/dstream.hh rename deps/dummy.dep => flower/lib/include/flower-config.hh (100%) create mode 100644 flower/lib/include/fproto.hh create mode 100644 flower/lib/include/handle.hh create mode 100644 flower/lib/include/interval.hh create mode 100644 flower/lib/include/interval.tcc create mode 100644 flower/lib/include/iterate.hh create mode 100644 flower/lib/include/lgetopt.hh create mode 100644 flower/lib/include/libc-extension.hh create mode 100644 flower/lib/include/link.hh create mode 100644 flower/lib/include/link.inl create mode 100644 flower/lib/include/list.hh create mode 100644 flower/lib/include/list.inl create mode 100644 flower/lib/include/list.tcc create mode 100644 flower/lib/include/matrix.hh create mode 100644 flower/lib/include/path.hh create mode 100644 flower/lib/include/pcursor.tcc create mode 100644 flower/lib/include/plist.tcc create mode 100644 flower/lib/include/pqueue.hh create mode 100644 flower/lib/include/rational.hh create mode 100644 flower/lib/include/real.hh create mode 100644 flower/lib/include/scalar.hh create mode 100644 flower/lib/include/smat.hh create mode 100644 flower/lib/include/string-convert.hh rename flower/{stringdata.hh => lib/include/string-data.hh} (94%) rename flower/{stringdata.inl => lib/include/string-data.inl} (83%) rename flower/{stringhandle.hh => lib/include/string-handle.hh} (91%) rename flower/{stringhandle.inl => lib/include/string-handle.inl} (93%) create mode 100644 flower/lib/include/string.hh rename flower/{textdb.hh => lib/include/text-db.hh} (97%) rename flower/{textstream.hh => lib/include/text-stream.hh} (100%) create mode 100644 flower/lib/include/unionfind.hh create mode 100644 flower/lib/include/varray.hh create mode 100644 flower/lib/include/vector.hh create mode 100644 flower/lib/include/vsmat.hh create mode 100644 flower/lib/lgetopt.cc create mode 100644 flower/lib/libc-extension.cc create mode 100644 flower/lib/matdebug.cc create mode 100644 flower/lib/matrix.cc create mode 100644 flower/lib/path.cc create mode 100644 flower/lib/scalar.cc create mode 100644 flower/lib/smat.cc create mode 100644 flower/lib/string-convert.cc create mode 100644 flower/lib/stringtest.cc create mode 100644 flower/lib/stringutil.cc rename flower/{textdb.cc => lib/text-db.cc} (96%) rename flower/{textstream.cc => lib/text-stream.cc} (94%) create mode 100644 flower/lib/unionfind.cc create mode 100644 flower/lib/vector.cc delete mode 100644 hdr/Makefile delete mode 100644 hdr/duration.hh delete mode 100644 hdr/lily-stream.hh delete mode 100644 hdr/lyric-item.hh delete mode 100644 hdr/midi-event.hh delete mode 100644 hdr/midi-item.hh delete mode 100644 hdr/midi-main.hh delete mode 100644 hdr/midi-score.hh delete mode 100644 hdr/midi-stream.hh delete mode 100644 hdr/midi-track.hh delete mode 100644 hdr/my-midi-parser.hh delete mode 100644 hdr/track-column.hh create mode 100644 lib/Makefile create mode 100644 lib/include/Makefile create mode 100644 lib/include/config.hh rename {hdr => lib/include}/debug.hh (100%) rename {hdr => lib/include}/input-file.hh (100%) rename {hdr => lib/include}/moment.hh (100%) rename {hdr => lib/include}/proto.hh (99%) create mode 100644 lib/include/windhoos-suck-suck-suck-thank-you-cygnus.hh rename {src => lib}/source-file.cc (92%) rename {src => lib}/source.cc (100%) rename {src => lib}/windhoos-suck-suck-suck-thank-you-cygnus.cc (97%) create mode 100644 lily/Makefile rename {src => lily}/bar-reg.cc (100%) rename {src => lily}/bar.cc (100%) rename {src => lily}/beam.cc (100%) rename {src => lily}/boxes.cc (100%) rename {src => lily}/break.cc (100%) rename {src => lily}/calcideal.cc (100%) rename {src => lily}/clef-item.cc (100%) rename {src => lily}/clef-reg.cc (100%) rename {src => lily}/colhpos.cc (100%) rename {src => lily}/commandrequest.cc (100%) rename {src => lily}/complex-staff.cc (100%) rename {src => lily}/complex-walker.cc (98%) rename {src => lily}/debug.cc (100%) rename {src => lily}/dimen.cc (100%) rename {src => lily}/directional-spanner.cc (100%) rename {src => lily}/grouping.cc (100%) rename {src => lily}/groupregs.cc (100%) rename {src => lily}/headreg.cc (100%) rename {src => lily}/idealspacing.cc (100%) rename {src => lily}/identifier.cc (100%) create mode 100644 lily/include/Makefile rename {hdr => lily/include}/bar-reg.hh (100%) rename {hdr => lily/include}/bar.hh (100%) rename {hdr => lily/include}/beam.hh (100%) rename {hdr => lily/include}/boxes.hh (100%) rename {hdr => lily/include}/break.hh (100%) rename {hdr => lily/include}/class-name.hh (100%) rename {hdr => lily/include}/clef-item.hh (100%) rename {hdr => lily/include}/clef-reg.hh (100%) rename {hdr => lily/include}/colhpos.hh (100%) rename {hdr => lily/include}/commandrequest.hh (100%) rename {hdr => lily/include}/complex-staff.hh (100%) rename {hdr => lily/include}/complex-walker.hh (100%) create mode 100644 lily/include/config.hh rename {hdr => lily/include}/const.hh (100%) rename {hdr => lily/include}/dimen.hh (100%) rename {hdr => lily/include}/directional-spanner.hh (100%) rename {hdr => lily/include}/glob.hh (100%) rename {hdr => lily/include}/grouping.hh (100%) create mode 100644 lily/include/head-reg.hh rename {hdr => lily/include}/headreg.hh (100%) rename {hdr => lily/include}/idealspacing.hh (100%) rename {hdr => lily/include}/identifier.hh (100%) rename {hdr => lily/include}/identparent.hh (100%) rename {hdr => lily/include}/input-music.hh (100%) rename {hdr => lily/include}/input-score.hh (100%) rename {hdr => lily/include}/input-staff.hh (100%) rename {hdr => lily/include}/item.hh (100%) rename {hdr => lily/include}/key-item.hh (100%) rename {hdr => lily/include}/key-reg.hh (100%) rename {hdr => lily/include}/key.hh (100%) rename {hdr => lily/include}/keyword.hh (100%) rename {hdr => lily/include}/leastsquares.hh (100%) rename {hdr => lily/include}/lexer.hh (100%) rename {hdr => lily/include}/linespace.hh (100%) rename {hdr => lily/include}/local-key-item.hh (100%) rename {hdr => lily/include}/local-key-reg.hh (100%) rename {hdr => lily/include}/lookup.hh (100%) rename {hdr => lily/include}/main.hh (92%) rename {hdr => lily/include}/meter-reg.hh (100%) rename {hdr => lily/include}/meter.hh (100%) rename {hdr => lily/include}/midi-output.hh (70%) rename {hdr => lily/include}/misc.hh (100%) rename {hdr => lily/include}/molecule.hh (100%) rename {hdr => lily/include}/musicalrequest.hh (100%) rename {hdr => lily/include}/notehead.hh (100%) rename {hdr => lily/include}/notename.hh (100%) rename {hdr => lily/include}/offset.hh (100%) rename hdr/pstaff.hh => lily/include/p-staff.hh (100%) rename {hdr => lily/include}/paper-def.hh (100%) rename {hdr => lily/include}/parseconstruct.hh (100%) create mode 100644 lily/include/parser.hh rename {hdr => lily/include}/pcol.hh (100%) rename {hdr => lily/include}/pscore.hh (100%) create mode 100644 lily/include/pstaff.hh rename {hdr => lily/include}/qlp.hh (100%) rename {hdr => lily/include}/qlpsolve.hh (100%) rename {hdr => lily/include}/register.hh (100%) rename {hdr => lily/include}/registergroup.hh (100%) rename {hdr => lily/include}/reqtodo.hh (100%) rename {hdr => lily/include}/request.hh (100%) rename {hdr => lily/include}/rest.hh (100%) rename {hdr => lily/include}/score-column.hh (100%) rename {hdr => lily/include}/score-walker.hh (100%) rename {hdr => lily/include}/score.hh (100%) rename {hdr => lily/include}/scoreline.hh (100%) rename {hdr => lily/include}/script-def.hh (100%) rename {hdr => lily/include}/script-reg.hh (100%) rename {hdr => lily/include}/script.hh (100%) rename {hdr => lily/include}/slur-reg.hh (100%) rename {hdr => lily/include}/slur.hh (100%) rename {hdr => lily/include}/spanner.hh (100%) rename {hdr => lily/include}/staff-column.hh (100%) rename {hdr => lily/include}/staff-elem-info.hh (100%) rename {hdr => lily/include}/staff-elem.hh (100%) rename {hdr => lily/include}/staff-walker.hh (100%) rename {hdr => lily/include}/staff.hh (100%) create mode 100644 lily/include/staffelem.hh create mode 100644 lily/include/staffeleminfo.hh rename {hdr => lily/include}/staffline.hh (100%) rename {hdr => lily/include}/staffsym.hh (100%) rename {hdr => lily/include}/stem-beam-reg.hh (100%) rename {hdr => lily/include}/stem.hh (100%) rename {hdr => lily/include}/symbol.hh (100%) rename {hdr => lily/include}/symtable.hh (100%) rename {hdr => lily/include}/tex-stream.hh (100%) rename {hdr => lily/include}/tex.hh (100%) rename {hdr => lily/include}/text-def.hh (100%) rename hdr/textitem.hh => lily/include/text-item.hh (100%) rename {hdr => lily/include}/text-reg.hh (100%) rename hdr/textspanner.hh => lily/include/text-spanner.hh (100%) rename {hdr => lily/include}/time-description.hh (100%) rename {hdr => lily/include}/voice-element.hh (100%) rename {hdr => lily/include}/voice-group-regs.hh (100%) rename {hdr => lily/include}/voice-regs.hh (100%) rename {hdr => lily/include}/voice.hh (100%) rename hdr/walkregs.hh => lily/include/walk-regs.hh (100%) rename {src => lily}/input-music.cc (100%) rename {src => lily}/input-score.cc (100%) rename {src => lily}/input-staff.cc (98%) rename {src => lily}/item.cc (100%) rename {src => lily}/key-item.cc (100%) rename {src => lily}/key-reg.cc (100%) rename {src => lily}/key.cc (100%) rename {src => lily}/keyword.cc (100%) rename {src => lily}/leastsquares.cc (100%) rename {src => lily}/lexer.l (100%) rename {src => lily}/lexerinit.cc (100%) rename {src => lily}/linespace.cc (100%) rename {src => lily}/local-key-item.cc (100%) rename {src => lily}/local-key-reg.cc (97%) rename {src => lily}/lookup.cc (100%) rename {src => lily}/lyric-item.cc (100%) rename src/lyricstaff.cc => lily/lyric-staff.cc (87%) rename {src => lily}/main.cc (98%) rename {src => lily}/meter-reg.cc (100%) rename {src => lily}/meter.cc (100%) rename {src => lily}/misc.cc (100%) rename {src => lily}/molecule.cc (100%) rename {src => lily}/mylexer.cc (100%) rename {src => lily}/note.cc (100%) rename {src => lily}/notehead.cc (100%) rename {src => lily}/notename.cc (100%) rename {src => lily}/paper-def.cc (100%) rename {src => lily}/parser.y (99%) rename {src => lily}/pcol.cc (100%) rename {src => lily}/pscore.cc (99%) rename {src => lily}/pstaff.cc (100%) rename {src => lily}/qlp.cc (100%) rename {src => lily}/qlpsolve.cc (100%) rename {src => lily}/register.cc (100%) rename {src => lily}/registergroup.cc (96%) rename {src => lily}/request.cc (100%) rename {src => lily}/rest.cc (100%) rename {src => lily}/score-column.cc (100%) rename {src => lily}/score-walker.cc (99%) rename {src => lily}/score.cc (99%) rename {src => lily}/scoreline.cc (100%) rename {src => lily}/scores.cc (100%) rename {src => lily}/script-def.cc (100%) rename {src => lily}/script-reg.cc (100%) rename {src => lily}/script.cc (100%) rename {src => lily}/slur-reg.cc (99%) rename {src => lily}/slur.cc (100%) rename {src => lily}/spanner.cc (100%) rename {src => lily}/staff-column.cc (98%) rename {src => lily}/staff-elem-info.cc (100%) rename {src => lily}/staff-elem.cc (100%) rename {src => lily}/staff-walker.cc (97%) rename {src => lily}/staff.cc (97%) rename {src => lily}/staffline.cc (100%) rename {src => lily}/staffsym.cc (100%) rename {src => lily}/stem-beam-reg.cc (99%) rename {src => lily}/stem.cc (100%) rename {src => lily}/symbol.cc (100%) rename {src => lily}/symtable.cc (100%) rename {src => lily}/template1.cc (96%) rename {src => lily}/template2.cc (100%) rename {src => lily}/template3.cc (100%) rename {src => lily}/template4.cc (100%) rename {src => lily}/template5.cc (100%) rename {src => lily}/template6.cc (100%) rename src/texbeam.cc => lily/tex-beam.cc (100%) rename src/texslur.cc => lily/tex-slur.cc (100%) rename {src => lily}/tex-stream.cc (95%) rename {src => lily}/tex.cc (100%) rename {src => lily}/text-def.cc (100%) rename src/textitem.cc => lily/text-item.cc (97%) rename {src => lily}/text-reg.cc (97%) rename src/textspanner.cc => lily/text-spanner.cc (97%) rename {src => lily}/time-description.cc (98%) rename {src => lily}/version.cc (100%) rename src/voiceelt.cc => lily/voice-elt.cc (98%) rename {src => lily}/voice-group-regs.cc (98%) rename {src => lily}/voice-regs.cc (95%) rename {src => lily}/voice.cc (97%) rename src/walkregs.cc => lily/walk-regs.cc (99%) rename {src => lily}/warn.cc (100%) rename {src => lily}/wordwrap.cc (100%) create mode 100644 m2m/.version create mode 100644 m2m/Makefile create mode 100644 m2m/include/Makefile rename {src => m2m}/midi-lexer.l (89%) rename {src => m2m}/midi-parser.y (70%) create mode 100644 make/Include.make create mode 100644 make/Initial.make create mode 100644 make/Makefile create mode 100644 make/Rules.make create mode 100644 make/Site.make create mode 100644 make/Sources.make create mode 100644 make/Stuff.make create mode 100644 make/Targets.make create mode 100644 make/Template.make create mode 100644 make/User.make create mode 100644 make/Variables.make delete mode 100755 make_version delete mode 100644 objects/Makefile delete mode 100644 src/Makefile delete mode 100644 src/binary-source-file.cc delete mode 100644 src/duration.cc delete mode 100644 src/lily-stream.cc delete mode 100644 src/lyricwalker.cc delete mode 100644 src/midi-def.cc delete mode 100644 src/midi-event.cc delete mode 100644 src/midi-item.cc delete mode 100644 src/midi-main.cc delete mode 100644 src/midi-output.cc delete mode 100644 src/midi-score.cc delete mode 100644 src/midi-stream.cc delete mode 100644 src/midi-template.cc delete mode 100644 src/midi-track.cc delete mode 100644 src/my-midi-lexer.cc delete mode 100644 src/my-midi-parser.cc delete mode 100644 src/track-column.cc create mode 100644 tex/Makefile rename dimen.tex => tex/dimen.tex (100%) rename lilyponddefs.tex => tex/lilyponddefs.tex (100%) rename ltest.tex => tex/ltest.tex (100%) rename test.tex => tex/test.tex (100%) rename titledefs.tex => tex/titledefs.tex (100%) diff --git a/.dstreamrc b/.dstreamrc deleted file mode 100644 index 13642e8b39..0000000000 --- a/.dstreamrc +++ /dev/null @@ -1,54 +0,0 @@ -# class name silence? - -My_flex_lexer 1 -yyFlexLexer 1 -PCol 1 -Score_column 1 -Ineq_constrained_qp 1 -Spacing_problem 1 -Colinfo 1 -Mixed_qp 1 -PScore 1 -Idealspacing 1 - -# yydebug -InitParser 1 -Parser 1 -InitDeclarations 1 - -# FlexLexer debug -InitLexer 1 -Lexer 1 - -parse_duration 1 -parse_pitchmod 1 -Col_configuration 1 -Request 0 -Note_req 1 -Rhythmic_req 0 -Rest_req 1 -delete_identifiers 1 -Command 1 -Staff_commands 1 -Stem 1 -Staff 0 -Score 1 -Voice 0 -Voice_element 0 -Input_cursor 1 -Commands_at 1 -Input_command 1 -Time_description 1 -Melodic_req 0 -Midi_walker 0 -Stem_req 1 -Group_change_req 0 -Script_req 1 -Colinfo 1 -Word_wrap 1 -Text_req 1 -Script_def 1 -Text_def 1 -Paperdef 1 -Symtable 1 -Symtables 1 \ No newline at end of file diff --git a/.version b/.version new file mode 100644 index 0000000000..22587f334f --- /dev/null +++ b/.version @@ -0,0 +1,6 @@ +TOPLEVEL_MAJOR_VERSION = 0 +TOPLEVEL_MINOR_VERSION = 0 +TOPLEVEL_PATCH_LEVEL = 39 +# use to send patches, always empty for released version: +TOPLEVEL_MY_PATCH_LEVEL = -1# include separator: "-1" or ".a" +# diff --git a/Documentation/CodingStyle.pod b/Documentation/CodingStyle.pod index 2ccc103080..9bf71c3810 100644 --- a/Documentation/CodingStyle.pod +++ b/Documentation/CodingStyle.pod @@ -16,14 +16,13 @@ in emacs: (add-hook 'c-mode-hook '(lambda ()(setq c-basic-offset 4))) + + (add-hook 'c++-mode-hook '(lambda() (c-set-style "Stroustrup") ) ) -=head2 FILES -The class C is declared in F and -implemented in F. =head2 CLASSES and TYPES: @@ -35,7 +34,7 @@ implemented in F. Class::member() Type Class::member_type_ -the C is a Hungarian notation postfix for C. See below +the C is a Hungarian notation postfix for $C$. See below =head2 COMMENTS @@ -89,7 +88,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: @@ -121,9 +120,9 @@ Notation>. =head2 Hungarian The Hungarian Notation was conceived by or at least got its name from, -the hungarian programmer x. It is a naming convention with the aim to -make code more readable (for fellow programmers) and more accessible -for programmers that are new to a project. +the hungarian programmer Charles Simonyi. It is a naming convention +with the aim to make code more readable (for fellow programmers), and +more accessible for programmers that are new to a project. The essence of the Hungarian Notation is that every identifier has a part which identifies its type (for functions this is the result @@ -210,9 +209,9 @@ with the parts of the names separated by underscores. =over 5 =item C -unsigned cher. (The postfix _by is ambiguous) +unsigned char. (The postfix _by is ambiguous) -=item C +=item C bool =item C @@ -257,7 +256,7 @@ These are precede the prefixes: =item C array -=item C +=item C user built array. =item C @@ -283,19 +282,19 @@ Variable loop: an integer Temporary variable: an unsigned integer =item C -Variable Test: a character +Variable test: a character =item C Variable first_name: a String class object -=item C -Variable first_name: a C array +=item C +Variable last_name: a C array -=item C -Variable Loop: an C that you must delete +=item C +Variable foo: an C that you must delete -=item C -Variable Loop: an C that you must not delete +=item C +Variable bar: an C that you must not delete =back diff --git a/Documentation/Makefile b/Documentation/Makefile index 0dc97f7dbe..e95293e314 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -1,30 +1,53 @@ -PODS=README.pod CodingStyle.pod lilygut.pod lilyinput.pod error.pod\ - faq.pod index.pod language.pod -TXTS=$(PODS:.pod=.txt) -MANS=$(PODS:.pod=.1) -HTMLS=$(PODS:.pod=.html) -DISTFILES=$(PODS) Makefile lelie_logo.png make_website - - -default: - $(MAKE) -C .. doc - -doc: $(TXTS) - -dist: - ln $(DISTFILES) $(DDIR)/$(SUBDIR) -clean: - rm -f $(TXTS) $(MANS) - -%.txt: %.1 - groff -man -Tascii $< > $@ - -%.1: %.pod - pod2man --center="LilyPond documentation" --section="0"\ - --release="LilyPond $(MAJVER).$(MINVER).$(PATCHLEVEL)" $< > $@ +# Documentation/Makefile + +# subdir level: +# +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/.build +# + +# generic variables: +# +include ./$(depth)/make/Variables.make +# + +# list of source files: +# +PODFILES = $(shell ls *.pod) +OUTPODFILES = $(patsubst %,$(outdir)/%,$(PODFILES)) +TEXTFILES = $(OUTPODFILES:.pod=.text) +MANFILES = $(OUTPODFILES:.pod=.1) +HTMLFILES = $(OUTPODFILES:.pod=.html) +# + +# list of distribution files: +# +DISTFILES = $(PODFILES) Makefile lelie_logo.png +# + +default: do-doc + +do-doc: $(TEXTFILES) html: $(pod) pod2html htmldist: html - make_website + ./$(bindir)/make_website + +# generic targets and rules: +# +include ./$(depth)/make/Targets.make +include ./$(depth)/make/Rules.make +# + diff --git a/Documentation/README.pod b/Documentation/README.pod index a4dc31770b..96c5ea4dd5 100644 --- a/Documentation/README.pod +++ b/Documentation/README.pod @@ -123,7 +123,7 @@ add F to the search path for input files. =item B<-M,--midi> -Do midi output only. +do midi output only =item B<-d,--debug>, @@ -201,7 +201,7 @@ LilyPond does use a lot of resources. For operation you need the following: =over 5 =item * -A fast computer (a full page of music typically takes 1 minute +a fast computer (a full page of music typically takes 1 minute on my 486/66, using the DEBUG compile. It's lot slower than most MusiXTeX preprocessors) @@ -226,7 +226,7 @@ Do: You probably want to edit Variables.make to tailor the compilation flags. If you're not into debugging C++, then you should go for no -debugging and C<-O2>. +debugging and C<-O2> =head1 AUTHORS @@ -236,11 +236,11 @@ debugging and C<-O2>. Han-Wen Nienhuys , Main author =item * -Jan C. Nieuwenhuizen , Context errors, Lyrics, Midi -output, m2m, bits of FlowerLib, general comments. +Jan Nieuwenhuizen , Context errors, Lyrics, +bits of FlowerLib, general comments. =item * -Mats Bengtsson , bugfixes, testing, criticism, general comments. +Mats Bengtsson , bugfixes, testing, general comments. =back @@ -326,10 +326,8 @@ includes files from the directory F. =head1 SEE ALSO -There are some documentation files in the subdirectory -F, among others: lilygut, lilyinput, error, faq. There -is a rudimentary webpage at the following URL: -http://www.stack.nl/~hanwen/lilypond/index.html +There are some documentation files in the subdirectory F, +among others: lilygut, lilyinput, error, faq, =head1 REMARKS diff --git a/Documentation/faq.pod b/Documentation/faq.pod index 8cb445e23c..79e511498e 100644 --- a/Documentation/faq.pod +++ b/Documentation/faq.pod @@ -6,20 +6,6 @@ FAQ - LilyPond FAQs Some questions that have been answered before. -Q: Gee, I really like MPP, why would I want to switch to LilyPond? - -A: The design of MPP is broken beyond repair: it is very difficult to -enhance MPP, and any working version is (probably) bug-ridden. - -Every once in a while, I have a major attack of hybris, and I go in to -enhance MPP. I usually end up thoroughly frustated within an hour or -so. I concur, it does work but extending MPP is a major pain. - -We will not sacrifice development time on something else than the most -trivial bugfixes. If you insist on using MusiXTeX, then LilyPond is -not for you, and you might try PMX which does also nice output. - - Q: Why are [] around the notes, and () inbetween? A: [] designate beams, a note can only be in one beam at the same @@ -34,13 +20,13 @@ Q: I want a DOS/NT/W95 port. A0: Reconsider. Try Linux. It's fun! A1: Currently (patchlevel 27), LilyPond (and flowerLib) compiles, links -and runs on Windhoos-NT, using the CYGNUS GNU port (release b17.1). +and runs on windhoos-nt, using the cygnus gnu port (release b17.1). I (JCN) only had to make a minor workaround for missing library calls. Have a look at http://www.cygnus.com/gnu-win32. To make LilyPond type -C. (I am not promising to maintain this platform, it is just that +make $OS. (I am not promising to maintain this platform, it is just that when having to use doze, i-m sometimes too lazy to reboot.) -A2: I haven't had time to find a GCC crosscompiler (I g++, mind you) to +A2: I haven't had time to find a GCC crosscompiler (*with* g++, mind you) to DOS/win (in rpm, please :). @@ -48,7 +34,6 @@ Q: Why GPL? A: Yes. - Q: Why shouldn't I put all commands (\clef, \meter) inside the music? A: You should do what you like, but at some time we will enable @@ -68,10 +53,8 @@ simple front end to the complicated internals. Q: Why do I need g++ >= 2.7? A: By using g++ LilyPond is portable to all platforms which support -g++ (there are quite a few, more than platforms which have AT&T CC or -Micro$oft C++). Not having to support other compilers saves us a I -of trouble. You need a version better than 2.7 because LilyPond & -FlowerLib uses: +g++ (there are quite a few). Not having to support other compilers +saves us a *lot* of trouble. LilyPond & FlowerLib uses: =over 6 @@ -98,26 +81,3 @@ named return values =back -Q: Why do I have to tell LilyPond explictly that the lowest-line-note -is "es" if I am using the key of "bes"? - -A: The goal of lilypond (and MPP) was to design a language which -conveys the I message of a piece. That is the reason that it -does not ask you to enter the line on which the note is is. (Or the -"natural" note-name without any "es" or "is" postfix) - -We do realise it is a bit shortsighted of us to assume that any user could -readily read the music he/she is entering. We might extend LilyPond to -allow "programmable" intervals, keys and clefs (and thus give him a -means to build his own scales, custom etc.). - -For now, you can program LilyPond to use custom notenames and do - - notenames { ces_key_notenames } - music { $ % music in the key of ces - ... - $} - notenames { dutch_notenames } % restore default - -as an ad-hoc solution. - diff --git a/Documentation/language.pod b/Documentation/language.pod index c7e9a81bc9..e316fdc14e 100644 --- a/Documentation/language.pod +++ b/Documentation/language.pod @@ -22,12 +22,6 @@ A musical notation that is relatively easy to comprehend to both programmers and non programmers. The final aim is to be able to express what can be expressed in sheet music. -This document is intended to summarise the plans for mudela 2 (mudela -0 being mpp-input, and mudela-1 LilyPond input upto version 0.0.38). -Ideas for any further extensions (mudela 3, read total vapourware) -should be marked as such. - - =over 5 =item * @@ -135,11 +129,6 @@ voices on one staff? We might be able to do without the staff{} construct, but I doubt if it will make things easier. -=head1 DECISIONS - -[none, yet] - - =head1 THOUGHTS =head2 Typing @@ -208,11 +197,7 @@ As simple fix, we might do key declarations: \key{\keybes} -[LOOSE] -We could be even more rabid, and use '\rab' as \bar terminator. - -Just kidding of course... [LOOSE THOUGHT] @@ -313,7 +298,7 @@ Mats is an arduous fan of having the commands inside music. I am not. I see the Mudela music as something which can be plugged into different staffs, transposed, translated in time, copied, quoted, etc. Encouraging "inline" commands would be bad since they hinder this -reuse of mudela-isated music. +reuse of typed music. The way I figure it, the bad part is essentially counting bars/wholes. Maybe we can get rid of it, by reinstalling the "mark" @@ -328,7 +313,6 @@ There is another complication: some symbols (bars) sometimes are linked across staffs. I should first think of a way to do this in LilyPond, before even considering a syntax. -[see also: filtering] =head2 Volta @@ -338,14 +322,11 @@ uhh? The syntax of /, * and : has to be settled, we have - - notes (1, 2, 4, 8 etc), which also can take 1*2/3 to do plets. + - notes (1, 2, 4, 8 etc) - meter 2*4 - plet 2/3 - multiple notes: 3*4 - abbreviations (not implemented) c4/4 or c4*4 - - measure grouping, {2*4 3*4} - - skip - =head2 Filtering @@ -403,6 +384,7 @@ I don't see the big win of this. sc1.staff{<\b1 \b2>} sc1.paper=mypaperdef; + We're not doing a programming language. In this syntax the parser has to lookup what sc1 means, decide if it should copied shallow/deep, decide if has a staff block, switch the mode after it finds that staff @@ -414,9 +396,6 @@ listening, Philip Glass?), but I think that would be something for Mudela version 3. And I think using m4 (or something alike) would be just as convenient. -It might clear things up, if JCN told us what is so special about this -syntax (without the C++ looks). - =head2 Transposition Has to be done. How about: diff --git a/Generate.make b/Generate.make deleted file mode 100644 index 5be1641e1e..0000000000 --- a/Generate.make +++ /dev/null @@ -1,30 +0,0 @@ -# Generate.make ? - -parsheadorig=$(CCDIR)/parser.tab.h -parsheadnew=$(HEADERDIR)/parser.hh - -# -# take some trouble to avoid overwriting the old y.tab.h, -# because otherwise all dependants would be remade. -$(CCDIR)/parser.cc: $(CCDIR)/parser.y - $(BISON) -d $< - mv $(CCDIR)/parser.tab.c $@ - (if diff $(parsheadorig) $(parsheadnew)>/dev/null; then \ - echo Ignoring $(parsheadorig); \ - else \ - mv $(parsheadorig) $(parsheadnew); \ - fi ) - -$(parsheadnew): $(CCDIR)/parser.cc - -$(HEADERDIR)/version.hh: Variables.make make_version - make_version $(MAJVER) $(MINVER) $(PATCHLEVEL) "$(CXX) $(CXXVER)" > $@ - -$(CCDIR)/%.cc: $(CCDIR)/%.y - $(BISON) -d $< - mv $(CCDIR)/$(shell basename $@ .cc ).tab.h $(HEADERDIR)/$(shell basename $@ .cc).hh - mv $(CCDIR)/$(shell basename $@ .cc ).tab.c $@ - -$(CCDIR)/%.cc: $(CCDIR)/%.l - $(FLEX) -t $< > $@ - diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000000..29161e6fc4 --- /dev/null +++ b/INSTALL @@ -0,0 +1,50 @@ +IMPORTANT: + + if you have downloaded a + + *.pre* + + version, then this is version is *not* meant for producing nice output + (but to keep your patchsets up to date). It might not even compile. + + +INSTALL: + + to make LilyPond, simply type: + + sh configure + make + + assuming you have the gnu development tools, and your make is gnu make, + else try something like: + + MAKE=gmake configure + MAKE=gmake gmake + + \begin{masochist} + Windows NT: + + you need the cygnus win32 gnu port development stuff; have a look + at http://www.cygnus.com/gnu-win32. + + to make LilyPond under, brr, aargh, well, simply type: + + bash bin/configure + make win32 + \end{masochist} + + +SUPPORT + + LilyPond (pl 0.0.39) is known to compile on the following platforms: + + * linux 2.0.28, g++ 2.7.2[.1] + * aix 4.1, g++ 2.7.2 + * windows-nt 4.0, cygnus gnu-win32 beta17.1 (~=g++ 2.7.2) + * linux 2.0.28 X to doze, gcc-go32 (~=g++ 2.7.2) + +Have fun! + + hanwen@stack.nl + jan@digicash.com + diff --git a/Initial.make b/Initial.make deleted file mode 100644 index 416a7fcb6e..0000000000 --- a/Initial.make +++ /dev/null @@ -1,12 +0,0 @@ -include Variables.make - -initdefault: $(CCDIR)/parser.cc $(CCDIR)/lexer.cc hdr/version.hh alldeps - -include Generate.make - -alldeps: #$(ALLDEPS) - touch $(DEPDIR)/dummy.dep - -#$(DEPDIR)/%.dep: $(CCDIR)/%.cc -# $(DODEP) $(CXX) -E $(CXXFLAGS) $^ > /dev/null - diff --git a/Makefile b/Makefile index c990a7246c..b8abfd8b66 100644 --- a/Makefile +++ b/Makefile @@ -1,65 +1,52 @@ -# Makefile -# top level makefile of LilyPond +# +# project LilyPond -- the musical typesetter +# title top level makefile for LilyPond +# file Makefile +# +# Copyright (c) 1997 by +# Jan Nieuwenhuizen +# Han-Wen Nienhuys +# ...your sort order here, or how to comment-out a comment + +# subdir level: +# +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/.build +# + +# generic variables: +# +include ./$(depth)/make/Variables.make +# + +# descent order into subdirectories: +# +SUBDIRS = flower lib lily m2m \ + Documentation bin init input make tex +# + +# list of distribution files: +# +SYMLINKS = configure +README_FILES = ANNOUNCE COPYING INSTALL NEWS README TODO +DISTFILES= Makefile .version $(README_FILES) $(SYMLINKS) +# + +# generic targets and rules: +# +include ./$(depth)/make/Targets.make +include ./$(depth)/make/Rules.make +# -include Variables.make - -.SUFFIXES: -.SUFFIXES: .cc .o .hh .y .l .pod .txt .1 .dep - - -$(exe): $(obs) - $(STRIPDEBUG) $(STABLEOBS) - $(LINKER) -o $@ $^ $(LOADLIBES) - -$(m2m): $(m2mobs) - $(LINKER) -o $@ $^ $(LOADLIBES) - -.PHONY: clean docxx - -clean: - rm -f $(allexe) $(DOCDIR)/* core $(allobs) - for SUBDIR in $(SUBDIRS); \ - do \ - $(MAKE) SUBDIR=$$SUBDIR -C $$SUBDIR clean;\ - done - -distclean: clean - rm -f version.hh $(gencc) .GENERATE *~ $(ALLDEPS) - -all: $(exe) $(m2m) doc - -# value of $(OSTYPE) on windhoos; "make $OSTYPE" if you use bash :-) -win32: - $(MAKE) -C . CXX=g++ - -doc: - $(MAKE) -C Documentation doc - -# doc++ documentation of classes -docxx: $(progdocs) - doc++ -kp -d $(DOCDIR) $^ - - -include $(DEPDIR)/*.dep - -$(OBJECTDIR)/%.o: $(CCDIR)/%.cc - $(DODEP)\ - $(CXX) -c $(CXXFLAGS) $(OUTPUT_OPTION) - -$(OBJECTDIR)/version.o: $(obs) $(HEADERDIR)/version.hh - -include Generate.make - -dist: - -mkdir $(DDIR) - ln $(DFILES) $(DDIR)/ - for SUBDIR in $(SUBDIRS); \ - do mkdir $(DDIR)/$$SUBDIR; \ - $(MAKE) SUBDIR=$$SUBDIR -C $$SUBDIR dist;\ - done - tar cfz $(DNAME).tar.gz $(DNAME)/ - rm -rf $(DDIR)/ - -TAGS: - $(MAKE) -C $(HEADERDIR) TAGS - $(MAKE) -C $(CCDIR) TAGS diff --git a/NEWS b/NEWS index 130c3b9656..4441132305 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,40 @@ +pl 39-1 + - doze target (for 16 bit dos xcompiler: gcc-go32) +Internal + - make/User.make; C..FLAGS sorted out +Bugfix + - make clean... + +pl 39 + - new make structure, featuring: + * top-level/sub-level build + * auto custom-library dependencies/build + * top-level/sub-level dist + * minimal(? can even smaller) specific Makefiles + * which makes for simple lib/exe module split (make/Template.make) + * integrated flowerlib + * all stuff into subbirs (make/Stuff.make) + * all headers into /include dirs (make/Include.make) + * all output into /out (executables into bin/) + * more make features, like make config, make help + * small lily lib + * lilypond-x.x.x/.version for toplevel lily version + * lilypond-x.x.x//.version for version (eg: flower) + * versioning using additional optional MY_PATCH_LEVEL + for easy make_patch + + - bin/cptogen + +Internal + - generic m2m header: m2m.hh + +Bugfix + - small fixes, make, dist, configure + +pl 38-5 + - all of the below, e.g. new filenames and new makefile + structure patches merged + pl 38 Internal @@ -7,6 +44,19 @@ Internal intrinsically hierarchical. All walker communication is done via a "top level" register. +pl 37-3 + - m2m handles voices + - instrument, track_name, copyright/left stuff for m2m/ly + +Internal + - Midi_voice + +pl 37-1 + - text, key, tempo event in midi output/ly input + +Internal + - simple makefile structure, allows for multiple projects + ****** pl 37 diff --git a/README b/README index 83f807a7a0..5bfa9c21c5 100644 --- a/README +++ b/README @@ -15,9 +15,6 @@ To generate the pretty-printed docs, do this: make doc -in the top-level dir - - ====================== NOTE: diff --git a/Sources.make b/Sources.make deleted file mode 100644 index df8d33f407..0000000000 --- a/Sources.make +++ /dev/null @@ -1,135 +0,0 @@ -# Sources.make -# sourcefiles to be shipped. Also used for dependencies - -hdr=bar.hh bar-reg.hh beam.hh\ - binary-source-file.hh\ - boxes.hh break.hh class-name.hh clef-reg.hh clef-item.hh\ - colhpos.hh commandrequest.hh \ - complex-walker.hh complex-staff.hh\ - const.hh debug.hh dimen.hh directional-spanner.hh\ - glob.hh grouping.hh headreg.hh idealspacing.hh\ - identifier.hh identparent.hh \ - input-music.hh input-score.hh input-staff.hh\ - input-file.hh\ - item.hh key.hh key-item.hh\ - key-reg.hh\ - keyword.hh leastsquares.hh lexer.hh linespace.hh \ - local-key-item.hh local-key-reg.hh lookup.hh \ - lyric-item.hh lyricstaff.hh lyricwalker.hh\ - main.hh meter.hh meter-reg.hh\ - midi-def.hh midi-item.hh midi-output.hh midi-stream.hh\ - midi-walker.hh\ - misc.hh\ - molecule.hh moment.hh musicalrequest.hh\ - notehead.hh notename.hh offset.hh paper-def.hh\ - parseconstruct.hh pcol.hh proto.hh\ - pscore.hh pstaff.hh qlp.hh\ - qlpsolve.hh register.hh registergroup.hh reqtodo.hh \ - request.hh rest.hh score-column.hh score.hh\ - scoreline.hh score-walker.hh script.hh script-def.hh script-reg.hh \ - slur.hh slur-reg.hh source.hh source-file.hh\ - spanner.hh staff.hh\ - staff-elem.hh staff-elem-info.hh staffline.hh staffsym.hh stem-beam-reg.hh\ - staff-column.hh stem.hh staff-walker.hh symbol.hh symtable.hh\ - tex.hh text-def.hh \ - textitem.hh text-reg.hh textspanner.hh time-description.hh \ - tex-stream.hh voice.hh\ - voice-element.hh voice-regs.hh voice-group-regs.hh walkregs.hh - -mycc=bar.cc bar-reg.cc beam.cc \ - binary-source-file.cc\ - boxes.cc break.cc calcideal.cc clef-reg.cc\ - clef-item.cc colhpos.cc commandrequest.cc\ - complex-staff.cc complex-walker.cc \ - debug.cc dimen.cc\ - directional-spanner.cc\ - grouping.cc groupregs.cc headreg.cc\ - idealspacing.cc identifier.cc\ - input-music.cc input-score.cc\ - input-staff.cc\ - input-file.cc\ - item.cc key.cc key-item.cc \ - key-reg.cc keyword.cc\ - leastsquares.cc lexerinit.cc linespace.cc \ - local-key-item.cc local-key-reg.cc lookup.cc\ - lyric-item.cc lyricstaff.cc lyricwalker.cc\ - main.cc meter.cc meter-reg.cc\ - midi-def.cc midi-item.cc midi-output.cc midi-stream.cc\ - midi-walker.cc misc.cc molecule.cc mylexer.cc note.cc\ - notehead.cc notename.cc\ - paper-def.cc pcol.cc pscore.cc pstaff.cc qlp.cc qlpsolve.cc\ - register.cc registergroup.cc request.cc rest.cc\ - score-column.cc score.cc\ - scoreline.cc scores.cc score-walker.cc script.cc\ - script-def.cc script-reg.cc slur.cc\ - slur-reg.cc source.cc source-file.cc\ - spanner.cc staff.cc\ - staff-elem.cc staffline.cc staffsym.cc\ - stem-beam-reg.cc staff-column.cc stem.cc\ - staff-elem-info.cc staff-walker.cc symbol.cc\ - symtable.cc tex.cc texbeam.cc\ - texslur.cc text-def.cc textitem.cc text-reg.cc textspanner.cc\ - time-description.cc tex-stream.cc voice.cc voiceelt.cc \ - voice-regs.cc voice-group-regs.cc\ - walkregs.cc warn.cc windhoos-suck-suck-suck-thank-you-cygnus.cc wordwrap.cc\ - template1.cc template2.cc template3.cc template4.cc\ - template5.cc template6.cc version.cc - -# a bit of a hack to keep exec size under control. -stablecc=request.cc bar.cc boxes.cc break.cc \ - item.cc keyword.cc leastsquares.cc \ - molecule.cc meter.cc\ - paper-def.cc parser.cc lexer.cc pstaff.cc qlp.cc qlpsolve.cc\ - template1.cc template2.cc template3.cc template4.cc\ - template5.cc template6.cc version.cc tex-stream.cc tex.cc\ - voice.cc wordwrap.cc spanner.cc - - -# m2m headers -# -mym2mhh=\ - duration.hh\ - lily-stream.hh\ - midi-event.hh\ - midi-main.hh\ - midi-score.hh\ - midi-track.hh\ - my-midi-lexer.hh\ - my-midi-parser.hh\ - track-column.hh\ - -# - -# m2m shared headers -# -mym2msharedhh=\ - binary-source-file.hh\ - -# - -# m2m source -# -mym2mcc=\ - duration.cc\ - lily-stream.cc\ - midi-event.cc\ - midi-main.cc\ - midi-score.cc\ - midi-template.cc\ - midi-track.cc\ - my-midi-lexer.cc\ - my-midi-parser.cc\ - track-column.cc\ - -# - -# m2m shared source -# -mym2msharedcc=\ - binary-source-file.cc\ - input-file.cc\ - source-file.cc\ - source.cc\ - -# - diff --git a/TODO b/TODO index e9824ff756..87d3ef806c 100644 --- a/TODO +++ b/TODO @@ -17,6 +17,13 @@ before 0.1 This is an assorted collection of stuff that will be done, might be done, or is an idea that I want to think about +STUFF + * generate all (.hh) files into out dirs + + * sort out headers, see m2m + + * do platform stuff: configure, header(s), targets, build (out?) + BUGS * plet bugs: scales.ly @@ -175,4 +182,4 @@ IDEAS * caching breakpoints - * use exceptions iso assert? \ No newline at end of file + * use exceptions iso assert? diff --git a/Variables.make b/Variables.make deleted file mode 100644 index 1d8348bb86..0000000000 --- a/Variables.make +++ /dev/null @@ -1,130 +0,0 @@ -# -*-Makefile-*- - -# version info -MAJVER=0 -MINVER=0 -PATCHLEVEL=38 - - - -#### -#### USER CONFIGURABLE -#### - -#PROFILEFLAG=-pg -OPTIFLAG=-DNDEBUG -DNPRINT -O2 -DEBUGFLAG=-g - -# uncomment for windhoos -# CXX=g++ - -# turn off -pipe if linker doesn't support it -EXTRACXXFLAGS=-pipe -Wall -W -Wmissing-prototypes -DSTRING_UTILS_INLINED - -# -# -lefence = ElectricFence. -# -# ElectricFence is a memory debugger which uses the -# VM hardware to trap malloc/free errors. -# - -EXTRALIB+= #-lefence - -#### -#### END USER CONFIGURABLE part. -#### - -ifdef PROFILEFLAG - DEFINES+=$(OPTIFLAG) $(PROFILEFLAG) - EXTRALIB+=-pg -endif - -ifndef DEBUGFLAG - DEFINES+=$(OPTIFLAG) -else - DEFINES+=$(DEBUGFLAG) -endif - - - -VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL) -CXXVER=`$(CXX) --version` - -# directories -TOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi) - -OBJECTDIR=objects -HEADERDIR=hdr -CCDIR=src -INITDIR=init -DEPDIR=deps -INPUTDIR=input - -# -# -include Sources.make - -# UGH, this sux! -gencc=parser.cc lexer.cc -cc=$(mycc) $(gencc) -mym2mgencc=midi-parser.cc midi-lexer.cc -m2mcc=$(mym2mcc) $(mym2mgencc) $(mym2msharedcc) - -MY_CCSOURCE=$(addprefix $(CCDIR)/, $(mycc)) -CCSOURCE=$(addprefix $(CCDIR)/, $(cc)) - -obs=$(addprefix $(OBJECTDIR)/,$(cc:.cc=.o)) -m2mobs=$(addprefix $(OBJECTDIR)/,$(m2mcc:.cc=.o)) - -allcc=$(mycc) $(mym2mcc) -allobs=$(obs) $(m2mobs) -allexe=$(exe) $(m2m) -M2MCCSOURCE=$(addprefix $(CCDIR)/, $(m2mcc)) -ALLDEPS=$(addprefix $(DEPDIR)/,$(cc:.cc=.dep)) -STABLEOBS=$(addprefix $(OBJECTDIR)/,$(stablecc:.cc=.o)) -allhdr=$(hdr) $(mym2mhh) -HEADERS=$(addprefix $(HEADERDIR)/,$(allhdr)) -progdocs=$(HEADERS) $(MY_CCSOURCE) - -#dist -.EXPORT_ALL_VARIABLES: - -DOCDIR=docxx - -PACKAGENAME=lilypond -DNAME=$(PACKAGENAME)-$(VERSION) -M2MNAME=m2m - -# distribution files. -othersrc=lexer.l parser.y midi-lexer.l midi-parser.y -SCRIPTS=make_version make_patch genheader clearlily -MAKFILES=Makefile Variables.make Sources.make Initial.make Generate.make \ - configure -OFILES=COPYING README NEWS TODO ANNOUNCE -IFILES= titledefs.tex lilyponddefs.tex \ - ltest.tex test.tex .dstreamrc dimen.tex -DFILES=$(MAKFILES) $(OFILES) $(IFILES) $(SCRIPTS) - -#compiling -LOADLIBES=-L$(FLOWERDIR) -lflower $(EXTRALIB) -lg++ -FLOWERDIR=../flower - -CXXFLAGS=$(DEFINES) -I$(HEADERDIR) -I$(FLOWERDIR) $(EXTRACXXFLAGS) -FLEX=flex -BISON=bison -exe=$(PACKAGENAME) -m2m=$(M2MNAME) -OUTPUT_OPTION=$< -o $@ -DDIR=$(TOPDIR)/$(DNAME) -SUBDIRS=Documentation $(OBJECTDIR) $(CCDIR) $(HEADERDIR) $(INITDIR) $(DEPDIR) \ - $(INPUTDIR) - -depfile=deps/$(subst .o,.dep,$(notdir $@)) -DODEP=rm -f $(depfile); DEPENDENCIES_OUTPUT="$(depfile) $(OBJECTDIR)/$(notdir $@)" - -STRIPDEBUG=true #replace to do stripping of certain objects -LINKER=$(CXX) -include Site.make - -TAGSACTION=etags -l c++ --no-defines - diff --git a/bin/Makefile b/bin/Makefile new file mode 100644 index 0000000000..2549e4255f --- /dev/null +++ b/bin/Makefile @@ -0,0 +1,20 @@ +# bin/Makefile + +# subdir level: +# +depth = .. +# + +build = ./$(depth)/lily/.build + +# generic stuff/Makefile +# +include ./$(depth)/make/Stuff.make +# + +# list of distribution files: +# +SCRIPTS = clearlily configure cpgento genheader make_patch make_fversion make_version make_website +DISTFILES = Makefile $(SCRIPTS) +# + diff --git a/clearlily b/bin/clearlily similarity index 100% rename from clearlily rename to bin/clearlily diff --git a/bin/configure b/bin/configure new file mode 100755 index 0000000000..0c647c284d --- /dev/null +++ b/bin/configure @@ -0,0 +1,85 @@ +#!/bin/sh +# +# project LilyPond -- the musical typesetter +# title (bash/sh/ksh) script to setup library and auto generated files +# file bin/configure +# +# Copyright (c) 1997 by +# Han-Wen Nienhuys +# Jan Nieuwenhuizen +# + +MAKE=${MAKE:-make} +NEEDFLOWERVER=1.1.6 +PREFIX=${PREFIX:-.} + + +############# +############# + +# without "function" ok for ksh, bash +setversion() { + eval `sed -n 's/^\([A-Z_]*\)[ ]*=[ ]*\([^ \#]*\).*$/\1=\2/p' $1` +# NEWVER=$TOPLEVEL_MAJOR_VERSION.$TOPLEVEL_MINOR_VERSION.$TOPLEVEL_PATCH_LEVEL$TOPLEVEL_MY_PATCH_LEVEL + NEWVER=$MAJOR_VERSION.$MINOR_VERSION.$PATCH_LEVEL$MY_PATCH_LEVEL + echo + echo "Current version ("`pwd`") is:" + echo " $NEWVER" + echo +} + +do_outdir() { + if [ \! -d $1/out ] + then + mkdir $1/out + echo 0 > $1/.build + fi +} + +echo using PREFIX=$PREFIX +echo I need Flower version $NEEDFLOWERVER + +flowertar=flower-$NEEDFLOWERVER + +#ugh +do_outdir flower/lib +do_outdir Documentation +do_outdir lib +do_outdir lily +do_outdir m2m + +# mmm +if [ -x flower ] +then + echo Found flowerdir +else + if [ -d $flowertar ] + then + ln -fs $flowertar flower + elif [ -d ../$flowertar ] + then + ln -fs ../$flowertar flower + else + echo "can't find $flowertar" + exit 1; + fi +fi + +echo Configuring Flower Library +setversion ./flower/.version +if [ $NEWVER != $NEEDFLOWERVER ]; then + echo "You seem to be having an incorrect version of the Flower library" +else + echo "You got the correct Flower version." +fi + +#ugh +echo '#define LIBDIR "'$PREFIX'/"'> lib/out/config.hh +touch flower/lib/out/flower-config.hh +touch make/Site.make +$MAKE -C make -f Initial.make + +echo "The sources are ready for compiling. " +echo "To make sure that you don't have any stale dependencies: do" +echo " make clean" + diff --git a/bin/cpgento b/bin/cpgento new file mode 100755 index 0000000000..2bb4da29af --- /dev/null +++ b/bin/cpgento @@ -0,0 +1,49 @@ +#!/bin/sh +# cpgento +# + +if test $# -ne 1 +then + echo "Usage: " + echo " cpgento LOCATION, e.g.:"; + echo + echo " cpgento /mnt/aix/usr/src/lily" + echo " CP=rcp cpgento fred@pcnov095.win.tue.nl:music/lily" + exit 1 +fi + +MAKE=${MAKE:-make} +CP=${CP:-cp} + +genlily="out/parser.hh out/parser.cc out/lexer.cc" +echo generating $genlily ... +$MAKE -C lily $genlily + +genm2m="out/midi-parser.hh out/midi-parser.cc out/midi-lexer.cc" +echo generating $genm2m ... +$MAKE -C m2m $genm2m + +lilydir=`pwd | sed "s/.*\///"` +todir=$1/$lilydir +echo "copying $lilydir -> $todir" + +cpto() { + name=$1 + tostuff=$todir/$name/out + genstuff="$2" + if [ "$CP" = "cp" -a \! -d $tostuff ] + then + echo mkdir -p $tostuff + mkdir -p $tostuff + fi + echo $CP $genstuff $tostuff + (cd $name; $CP $genstuff $tostuff) +} + +cpto lily "$genlily" +cpto m2m "$genm2m" + +# if you cannot gen the above, you-ll probably want: +flexlexerh=/usr/include/FlexLexer.h +cpto lib $flexlexerh + diff --git a/genheader b/bin/genheader similarity index 100% rename from genheader rename to bin/genheader diff --git a/bin/make_fversion b/bin/make_fversion new file mode 100755 index 0000000000..185eaae445 --- /dev/null +++ b/bin/make_fversion @@ -0,0 +1,11 @@ +#!/bin/sh +echo '#ifndef FVERSION_HH' +echo '#define FVERSION_HH' +echo '#define FMAJOR_VERSION ' "$1" +echo '#define FMINOR_VERSION ' "$2" +echo '#define FPATCH_LEVEL ' "$3" +echo '#define FMY_PATCH_LEVEL ' "$4" +echo '#define FBUILD ' "$5" +echo '#define FVERSIONSTR "'$1.$2.$3$4 \#$5'"' +echo '#define FCOMPILER "'$6'"' +echo '#endif' diff --git a/make_patch b/bin/make_patch similarity index 100% rename from make_patch rename to bin/make_patch diff --git a/bin/make_version b/bin/make_version new file mode 100755 index 0000000000..fe5cb05c89 --- /dev/null +++ b/bin/make_version @@ -0,0 +1,11 @@ +#!/bin/sh +echo '#ifndef VERSION_HH' +echo '#define VERSION_HH' +echo '#define MAJOR_VERSION ' "$1" +echo '#define MINOR_VERSION ' "$2" +echo '#define PATCH_LEVEL ' "$3" +echo '#define MY_PATCH_LEVEL ' "$4" +echo '#define BUILD ' "$5" +echo '#define VERSIONSTR "'$1.$2.$3$4 \#$5'"' +echo '#define COMPILER "'$6'"' +echo '#endif' diff --git a/Documentation/make_website b/bin/make_website similarity index 89% rename from Documentation/make_website rename to bin/make_website index d1ec8d4a26..844e60bbd1 100755 --- a/Documentation/make_website +++ b/bin/make_website @@ -37,5 +37,5 @@ foreach $a (@examples) { } } -system "tar hcf website.tar *.html *.gif lelie_logo.png *.ps *.ly.txt *.midi docxx/;" . +system "cd out; tar hcf ../website.tar *.html *.gif lelie_logo.png *.ps *.ly.txt *.midi docxx/;" . "gzip -f9 website.tar;" diff --git a/configure b/configure deleted file mode 100755 index fec8a5617d..0000000000 --- a/configure +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/sh - -# script to setup library and auto generated files. - -function setversion() { - eval `sed -n 's/^\([A-Z]*\)=\([p0-9].*\)$/\1=\2/p' Variables.make` - NEWVER=$MAJVER.$MINVER.$PATCHLEVEL - echo - echo "Current version ("`pwd`") is $NEWVER" - echo -} - -MAKE=${MAKE:-make} -PREFIX=${PREFIX:-.} -NEEDFLOWERVER=1.1.4 - -echo using PREFIX=$PREFIX -echo I need Flower version $NEEDFLOWERVER - -flowertar=flower-$NEEDFLOWERVER -here=`pwd` -cd .. - -if [ -x flower ] -then - echo Found flowerdir -else - - if [ ! -d $flowertar ] - then - echo "can't find $flowertar" - exit 1; - fi - rm flower - ln -s $flowertar flower -fi - -echo Compiling Library -{ - cd flower; - setversion - if [ $NEWVER != $NEEDFLOWERVER ]; then - echo "You seem to be having an incorrect version of the Flower library" - else - echo "You got the correct Flower version." - fi - $MAKE -} - -cd $here - -echo '#define LIBDIR "'$PREFIX'/"'> hdr/config.hh -touch Site.make -$MAKE -f Initial.make - -echo "The sources are ready for compiling. " -echo "To make sure that you don't have any stale dependencies: do" -echo " make clean" diff --git a/configure b/configure new file mode 120000 index 0000000000..58b4a5f592 --- /dev/null +++ b/configure @@ -0,0 +1 @@ +bin/configure \ No newline at end of file diff --git a/deps/Makefile b/deps/Makefile deleted file mode 100644 index 79265b1c0f..0000000000 --- a/deps/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -DISTFILES=Makefile dummy.dep - - - -dummy.dep: - touch dummy.dep - - -dist: $(DISTFILES) - ln $(DISTFILES) $(DDIR)/$(SUBDIR) - -clean: - true diff --git a/flower/.version b/flower/.version new file mode 100644 index 0000000000..5a44cc8816 --- /dev/null +++ b/flower/.version @@ -0,0 +1,6 @@ +MAJOR_VERSION = 1 +MINOR_VERSION = 1 +PATCH_LEVEL = 6 +# use to send patches, always empty for released version: +MY_PATCH_LEVEL = -1# include separator: "-1" or ".a" +# diff --git a/flower/Makefile b/flower/Makefile index 447072b75a..779f1e5b82 100644 --- a/flower/Makefile +++ b/flower/Makefile @@ -3,11 +3,20 @@ include Variables.make $(staticlib): $(obs) fversion.hh $(AR) cr libflower.a $(obs) -include depend +include deps/*.dep + +deps/*.dep: + touch deps/dummy.dep depend: Sources.make $(CXX) $(CXXFLAGS) -MM $(cc) > depend + +$(OBJECTDIR)/%.o: $(CCDIR)/%.cc + $(DODEP)\ + $(CXX) -c $(CXXFLAGS) $(OUTPUT_OPTION) + + clean: rm -f $(obs) $(staticlib) fversion.hh @@ -24,9 +33,19 @@ docxx: $(hh) $(cc) $(templatecc) $(inl) dist: -mkdir $(DDIR) ln $(DFILES) $(DDIR)/ - tar cfz $(DNAME).tar.gz $(DDIR)/* + -for SUBDIR in $(SUBDIRS); \ + do mkdir $(DDIR)/$$SUBDIR; \ + $(MAKE) SUBDIR=$$SUBDIR -C $$SUBDIR dist;\ + done + tar cfz $(DNAME).tar.gz $(DNAME)/ rm -rf $(DDIR)/ TAGS: $(ALLSOURCES) etags -CT $(inl) $(cc) $(hh) + + +test: stringtest + +stringtest: $(OBJECTDIR)/stringtest.o + g++ -o $@ $< -L. -lflower \ No newline at end of file diff --git a/flower/NEWS b/flower/NEWS index d6d6d86aed..36c03ddcd4 100644 --- a/flower/NEWS +++ b/flower/NEWS @@ -1,4 +1,7 @@ -pl 1.1.3-1 + +pl 1.1.4 + - great file-renaming. + - String cleanup (binary <-> null terminate), several bugfixes - great renaming of String and String_convert interfaces - more conversions moved (copied actually) to String_convert - String indexing now all base = 0, not found = -1 diff --git a/flower/Sources.make b/flower/Sources.make index 82454e3e3c..4e08bec735 100644 --- a/flower/Sources.make +++ b/flower/Sources.make @@ -1,18 +1,21 @@ -cc=choleski.cc datafile.cc dstream.cc lgetopt.cc matdebug.cc matrix.cc\ -path.cc scalar.cc smat.cc string.cc string-convert.cc stringutil.cc\ -textdb.cc textstream.cc unionfind.cc vector.cc +cc=choleski.cc data-file.cc dstream.cc lgetopt.cc libc-extension.cc matdebug.cc\ + matrix.cc\ + path.cc scalar.cc smat.cc string.cc string-convert.cc stringutil.cc\ + text-db.cc text-stream.cc unionfind.cc vector.cc templatecc=cursor.tcc list.tcc plist.tcc interval.tcc\ pcursor.tcc -inl=link.inl list.inl cursor.inl plist.inl stringdata.inl stringhandle.inl +inl=link.inl list.inl cursor.inl plist.inl string-data.inl string-handle.inl -hh=assoc.hh associter.hh choleski.hh compare.hh cursor.hh dstream.hh\ -fproto.hh handle.hh interval.hh iterate.hh lgetopt.hh link.hh list.hh\ -matrix.hh path.hh pcursor.hh plist.hh rational.hh real.hh scalar.hh\ -smat.hh string.hh string-convert.hh stringhandle.hh stringdata.hh\ -textdb.hh textstream.hh unionfind.hh pqueue.hh\ -varray.hh vector.hh vsmat.hh datafile.hh +hh=assoc.hh assoc-iter.hh choleski.hh compare.hh cursor.hh data-file.hh \ + dstream.hh\ + fproto.hh handle.hh interval.hh iterate.hh lgetopt.hh \ + libc-extension.hh link.hh list.hh\ + matrix.hh path.hh pcursor.hh plist.hh rational.hh real.hh scalar.hh\ + smat.hh string.hh string-convert.hh string-handle.hh string-data.hh\ + text-db.hh text-stream.hh unionfind.hh pqueue.hh\ + varray.hh vector.hh vsmat.hh extra=stringtest.cc diff --git a/flower/TODO b/flower/TODO index d67ab72e9f..2026c95134 100644 --- a/flower/TODO +++ b/flower/TODO @@ -1,4 +1,8 @@ - * disable: const pointer->bool->string + * shared lib. + + * integrate Make mechanisms of flower & lily + + * disable this auto conv: const pointer -> bool -> string * PointerVec ? @@ -8,12 +12,6 @@ * extend Interval - * change String::pos - - s[s.pos('%')] == '%' - - would be nice - * use template handle in handle.hh for strings. * move towards gnu or STL? diff --git a/flower/Variables.make b/flower/Variables.make index d8cca75c97..564acd8c63 100644 --- a/flower/Variables.make +++ b/flower/Variables.make @@ -1,12 +1,12 @@ MAJVER=1 MINVER=1 -PATCHLEVEL=3 +PATCHLEVEL=4 PACKAGENAME=flower #PROFILEFLAG=-pg #DEBUGFLAG= -g -OPTIFLAG= -DNPRINT -O2 -DSTRING_UTILS_INLINED -DNDEBUG +OPTIFLAG= -DNPRINT -O2 -DSTRING_UTILS_INLINED # -DNDEBUG ######################################### @@ -29,11 +29,17 @@ VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL) DNAME=$(PACKAGENAME)-$(VERSION) include Sources.make +OBJECTDIR=objects +CCDIR=. +obs=$(addprefix $(OBJECTDIR)/,$(cc:.cc=.o)) -obs=$(cc:.cc=.o) staticlib=libflower.a ALLSOURCES=$(hh) $(cc) $(inl) $(templatecc) $(extra) DFILES=$(ALLSOURCES) Makefile Variables.make make_version\ Sources.make TODO README NEWS DDIR=$(DNAME) +depfile=deps/$(subst .o,.dep,$(notdir $@)) +DODEP=rm -f $(depfile); DEPENDENCIES_OUTPUT="$(depfile) $(OBJECTDIR)/$(notdir $@)" +OUTPUT_OPTION=$< -o $@ +SUBDIRS=deps objects diff --git a/flower/assoc.hh b/flower/assoc.hh index 07afb8a27c..99e20914b7 100644 --- a/flower/assoc.hh +++ b/flower/assoc.hh @@ -4,6 +4,9 @@ #include "varray.hh" #include +/** + A helper for Assoc + */ template struct Assoc_ent_ { bool free; @@ -12,7 +15,8 @@ struct Assoc_ent_ { }; -/** mindblowingly stupid Associative array implementation.Hungarian: map +/** mindblowingly stupid Associative array implementation. + Hungarian: map */ template struct Assoc { @@ -62,9 +66,6 @@ public: int i = find_creat(key); arr[i].val = val; } - /* - should create "set" template - */ V& operator[](K key) { return arr[find_creat(key)].val; } diff --git a/flower/choleski.cc b/flower/choleski.cc index 4202a9b1e5..1d64f949ac 100644 --- a/flower/choleski.cc +++ b/flower/choleski.cc @@ -59,7 +59,7 @@ Choleski_decomposition::Choleski_decomposition(Matrix P) assert((original()-P).norm() / P.norm() < EPS); #endif } - + Matrix Choleski_decomposition::original() const { diff --git a/flower/dstream.cc b/flower/dstream.cc index 8452b742eb..e6fdbc0e4d 100644 --- a/flower/dstream.cc +++ b/flower/dstream.cc @@ -2,28 +2,35 @@ #include "assoc.hh" #include "dstream.hh" #include "scalar.hh" -#include "textdb.hh" +#include "text-db.hh" +#include "string-convert.hh" /// indent of each level -const INDTAB = 3; +const INDTAB = 2; /* should use Regexp library. */ static String -strip_pretty(String pret) +strip_pretty(String pretty_str) { - String cl(pret.left_str(pret.index_i('('))); - int l = cl.index_last_i(' '); - cl = cl.right_str(cl.len() - l - 1); - return cl; + 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) { - String cl(pret.left_str(pret.index_last_i(':')-1)); - return cl; + int l=pret.index_last_i(':')-1; + if (l>=0) + pret = pret.left_str(l ); + return pret; } Dstream& @@ -46,7 +53,7 @@ Dstream::identify_as(String name) local_silence = (*silent)[idx]; if (classname != idx && !local_silence) { classname=idx; - *os << "[" << classname << ":]"; +// *os << "[" << classname << ":]"; // messy. } return *this; } @@ -59,17 +66,37 @@ Dstream::silence(String s) return (*silent)[s]; } -/** only output possibility. Delegates all conversion to String class. - */ +/** 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 *this; + return ; for (const char *cp = s ; *cp; cp++) - switch(*cp) - { + switch(*cp) { case '{': case '[': case '(': indentlvl += INDTAB; @@ -92,7 +119,7 @@ Dstream::operator<<(String s) *os << *cp; break; } - return *this; + return ; } @@ -125,6 +152,7 @@ Dstream::Dstream(ostream *r, const char * cfg_nm ) Dstream::~Dstream() -{ +{ delete silent; + assert(!indentlvl) ; } diff --git a/flower/dstream.hh b/flower/dstream.hh index 801b166774..5375304d85 100644 --- a/flower/dstream.hh +++ b/flower/dstream.hh @@ -29,7 +29,7 @@ class Dstream int indentlvl; bool local_silence; String classname; - + void output(String s); Assoc *silent; public: @@ -42,8 +42,13 @@ public: 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/fproto.hh b/flower/fproto.hh index 509d25d3fa..57469fead5 100644 --- a/flower/fproto.hh +++ b/flower/fproto.hh @@ -16,25 +16,25 @@ template struct IPointerList; template struct Cursor; template struct PCursor; template struct Link; -template struct Handle ; -templatestruct Interval_t ; +template struct Handle; +templatestruct Interval_t; #include "real.hh" typedef Interval_t Interval; -struct Choleski_decomposition ; +struct Choleski_decomposition; -struct long_option_init ; -struct Getopt_long ; -struct Matrix ; -struct String_data ; -struct String_handle ; +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 ; -class Text_stream; -class Data_file ; +struct virtual_smat; +struct Vector ; +struct Text_stream; +struct Data_file; struct Text_db; struct Scalar; typedef unsigned char Byte; diff --git a/flower/lgetopt.cc b/flower/lgetopt.cc index 523d54ee5f..a56c64c6db 100644 --- a/flower/lgetopt.cc +++ b/flower/lgetopt.cc @@ -1,7 +1,6 @@ /* process command line, GNU style. - this is (Copyleft) 1996, Han-Wen Nienhuys, */ #include @@ -10,15 +9,18 @@ #include "lgetopt.hh" long -Getopt_long::intarg() { +Getopt_long::intarg() +{ long l; if (sscanf(optarg, "%ld", &l) != 1) report(E_ILLEGALARG); return l; } -long_option_init * -Getopt_long::parselong() { + +Long_option_init * +Getopt_long::parselong() +{ const char *optnm = argv[optind] + 2 ; assert(*optnm); @@ -64,7 +66,7 @@ Getopt_long::parselong() { ostream & -long_option_init::printon(ostream &errorout) +Long_option_init::printon(ostream &errorout) { if (shortname) errorout <<"-" << shortname; @@ -91,7 +93,8 @@ Getopt_long::report(Errorcod c) *errorout << "requires an argument"<longname << "' does not allow an argument"<longname << "' does not allow an argument"< +# Han-Wen Nienhuys +# + +# subdir level: +# +depth = ../.. +# + +# identify module: +# +NAME = flower +MODULE_NAME = flower +include ./$(depth)/flower/.version +build = ./$(depth)/flower/lib/.build +# + +# generic variables: +# +include ./$(depth)/make/Variables.make +# + +# descent order into subdirectories: +# +SUBDIRS = include +# + +# to be remade each build: +# +VERSION_DEPENDENCY =# +# + +# list of c++ header files: +# +HHFILES = # $(shell ls include/*.hh) +# + +# list of c++ source files: +# +CCFILES = $(shell ls *.cc) +# + +# list of other source files: +# +EXTRA_SOURCE_FILES =# $(shell ls *.y *.l) +# + +# 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 +# + +# auto dependencies: +# +-include ./$(outdir)/*.dep +# + diff --git a/flower/lib/choleski.cc b/flower/lib/choleski.cc new file mode 100644 index 0000000000..1d64f949ac --- /dev/null +++ b/flower/lib/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 #include -#include "datafile.hh" +#include "data-file.hh" void Data_file::gobble_white() diff --git a/flower/lib/dstream.cc b/flower/lib/dstream.cc new file mode 100644 index 0000000000..e6fdbc0e4d --- /dev/null +++ b/flower/lib/dstream.cc @@ -0,0 +1,158 @@ +#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; +// *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/include/Makefile b/flower/lib/include/Makefile new file mode 100644 index 0000000000..36059a888f --- /dev/null +++ b/flower/lib/include/Makefile @@ -0,0 +1,19 @@ +# 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/lib/.build +# + diff --git a/flower/associter.hh b/flower/lib/include/assoc-iter.hh similarity index 100% rename from flower/associter.hh rename to flower/lib/include/assoc-iter.hh diff --git a/flower/lib/include/assoc.hh b/flower/lib/include/assoc.hh new file mode 100644 index 0000000000..99e20914b7 --- /dev/null +++ b/flower/lib/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; + } + 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 new file mode 100644 index 0000000000..f5e9fb4f5a --- /dev/null +++ b/flower/lib/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/lib/include/compare.hh b/flower/lib/include/compare.hh new file mode 100644 index 0000000000..203ba014e7 --- /dev/null +++ b/flower/lib/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/lib/include/cursor.hh b/flower/lib/include/cursor.hh new file mode 100644 index 0000000000..0ea99037f9 --- /dev/null +++ b/flower/lib/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( 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 new file mode 100644 index 0000000000..54d3703e60 --- /dev/null +++ b/flower/lib/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/lib/include/cursor.tcc b/flower/lib/include/cursor.tcc new file mode 100644 index 0000000000..3be73fe5d2 --- /dev/null +++ b/flower/lib/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/datafile.hh b/flower/lib/include/data-file.hh similarity index 94% rename from flower/datafile.hh rename to flower/lib/include/data-file.hh index 14d57369a3..dae9e56347 100644 --- a/flower/datafile.hh +++ b/flower/lib/include/data-file.hh @@ -1,5 +1,5 @@ /* - datafile.hh -- declare Data_file + data-file.hh -- declare Data_file source file of the LilyPond music typesetter @@ -10,7 +10,7 @@ #ifndef DATAFILE_HH #define DATAFILE_HH -#include "textstream.hh" +#include "text-stream.hh" /// read a data file class Data_file : private Text_stream diff --git a/flower/lib/include/dstream.hh b/flower/lib/include/dstream.hh new file mode 100644 index 0000000000..5375304d85 --- /dev/null +++ b/flower/lib/include/dstream.hh @@ -0,0 +1,54 @@ + +#ifndef DSTREAM_HH +#define DSTREAM_HH + +#include "string.hh" + +const char eol= '\n'; + +template +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/deps/dummy.dep b/flower/lib/include/flower-config.hh similarity index 100% rename from deps/dummy.dep rename to flower/lib/include/flower-config.hh diff --git a/flower/lib/include/fproto.hh b/flower/lib/include/fproto.hh new file mode 100644 index 0000000000..8c6fda680e --- /dev/null +++ b/flower/lib/include/fproto.hh @@ -0,0 +1,44 @@ +/* + fproto.hh -- typenames in flowerlib + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef FPROTO_HH +#define FPROTO_HH + +#include "flower-config.hh" + +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; +templatestruct Interval_t; +#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 new file mode 100644 index 0000000000..63c17ef1d2 --- /dev/null +++ b/flower/lib/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 const T&() { + return *obj; + } + operator T&() { + copy(); + return *obj; + } +} +#endif diff --git a/flower/lib/include/interval.hh b/flower/lib/include/interval.hh new file mode 100644 index 0000000000..aae16381db --- /dev/null +++ b/flower/lib/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/lib/include/interval.tcc b/flower/lib/include/interval.tcc new file mode 100644 index 0000000000..6e7b0b1279 --- /dev/null +++ b/flower/lib/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/lib/include/iterate.hh b/flower/lib/include/iterate.hh new file mode 100644 index 0000000000..1e924f0790 --- /dev/null +++ b/flower/lib/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/lib/include/lgetopt.hh b/flower/lib/include/lgetopt.hh new file mode 100644 index 0000000000..3b2b0348b3 --- /dev/null +++ b/flower/lib/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; + 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 new file mode 100644 index 0000000000..e71037c41e --- /dev/null +++ b/flower/lib/include/libc-extension.hh @@ -0,0 +1,32 @@ +/* + 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" + +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 new file mode 100644 index 0000000000..6f9c75a411 --- /dev/null +++ b/flower/lib/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( 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 new file mode 100644 index 0000000000..3926d6bc2a --- /dev/null +++ b/flower/lib/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/lib/include/list.hh b/flower/lib/include/list.hh new file mode 100644 index 0000000000..ec59fbff07 --- /dev/null +++ b/flower/lib/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( 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 new file mode 100644 index 0000000000..df0687b7c8 --- /dev/null +++ b/flower/lib/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/lib/include/list.tcc b/flower/lib/include/list.tcc new file mode 100644 index 0000000000..16e12a31f1 --- /dev/null +++ b/flower/lib/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( 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 new file mode 100644 index 0000000000..a633d6657a --- /dev/null +++ b/flower/lib/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+=(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 new file mode 100644 index 0000000000..bc4d9f3776 --- /dev/null +++ b/flower/lib/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/lib/include/pcursor.tcc b/flower/lib/include/pcursor.tcc new file mode 100644 index 0000000000..ffb01bcfe8 --- /dev/null +++ b/flower/lib/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/lib/include/plist.tcc b/flower/lib/include/plist.tcc new file mode 100644 index 0000000000..ac9daedf71 --- /dev/null +++ b/flower/lib/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/lib/include/pqueue.hh b/flower/lib/include/pqueue.hh new file mode 100644 index 0000000000..195232317e --- /dev/null +++ b/flower/lib/include/pqueue.hh @@ -0,0 +1,46 @@ +/* + 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. + */ + +template +struct PQueue +{ + Array value_arr_; + Array indices_arr_; + + void enter(V v, I idx) { + int j=0; + for (; j < value_arr_.size(); j++) + if (indices_arr_[j] > idx) + break; + + value_arr_.insert(v, j); + indices_arr_.insert(idx, j); + } + int size() { return value_arr_.size(); } + V front_val() { return value_arr_[0]; } + I front_idx() { return indices_arr_[0]; } + V get() { + V retval = front_val(); + value_arr_.del(0); + indices_arr_.del(0); + return retval; + } + +}; +#endif // PQUEUE_HH diff --git a/flower/lib/include/rational.hh b/flower/lib/include/rational.hh new file mode 100644 index 0000000000..30fa2cb6d6 --- /dev/null +++ b/flower/lib/include/rational.hh @@ -0,0 +1 @@ +#include diff --git a/flower/lib/include/real.hh b/flower/lib/include/real.hh new file mode 100644 index 0000000000..0533af2111 --- /dev/null +++ b/flower/lib/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/lib/include/scalar.hh b/flower/lib/include/scalar.hh new file mode 100644 index 0000000000..5cdfa427da --- /dev/null +++ b/flower/lib/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(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 new file mode 100644 index 0000000000..9b0987c8f4 --- /dev/null +++ b/flower/lib/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 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 new file mode 100644 index 0000000000..bcf461f8f3 --- /dev/null +++ b/flower/lib/include/string-convert.hh @@ -0,0 +1,43 @@ +/* + 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 hex2int_i( 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 i2dec_str( int i, int length_i, char ch ); + static String rational_str(Rational); + static String pointer_str(const void *); + static String longlong_str(long long , char const * fmt = 0); +}; + +#endif // __STRING_CONVERT_HH // diff --git a/flower/stringdata.hh b/flower/lib/include/string-data.hh similarity index 94% rename from flower/stringdata.hh rename to flower/lib/include/string-data.hh index ba9099c440..ecd7159074 100644 --- a/flower/stringdata.hh +++ b/flower/lib/include/string-data.hh @@ -1,5 +1,5 @@ /* - stringdata.hh -- declare String_data + string-data.hh -- declare String_data source file of the LilyPond music typesetter @@ -78,6 +78,7 @@ friend class String_handle; #String_data# knowing it. */ Byte &operator [](int j); Byte operator [](int j) const; + bool is_binary_bo()const; }; @@ -86,7 +87,7 @@ friend class String_handle; #ifndef INLINE #define INLINE inline #endif -#include "stringdata.inl" +#include "string-data.inl" #endif diff --git a/flower/stringdata.inl b/flower/lib/include/string-data.inl similarity index 83% rename from flower/stringdata.inl rename to flower/lib/include/string-data.inl index 7b55481085..d2b925d0ce 100644 --- a/flower/stringdata.inl +++ b/flower/lib/include/string-data.inl @@ -12,20 +12,10 @@ #include #include -#include "stringdata.hh" +#include "string-data.hh" const int INITIALMAX=8; #include -void* -mymemmove( void* dest, void const* src, size_t n ); -#if 0 // redef STRING_DEBUG -INLINE void* -mymemmove( void* dest, void const* src, size_t n ) -{ - return memmove( dest, src, n ); // wohltempererit: 69006 -} -#define memmove mymemmove -#endif INLINE void String_data::OKW() @@ -58,7 +48,7 @@ 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. - memmove( data_byte_p_, src.data_byte_p_, length_i_ + 1 ); + memcpy( data_byte_p_, src.data_byte_p_, length_i_ + 1 ); } INLINE @@ -96,10 +86,8 @@ String_data::remax(int j) { OKW(); if (j > maxlen) { -// maxlen = j; oeps -// Byte *p = new Byte[maxlen + 1]; Byte *p = new Byte[j + 1]; - memmove( p, data_byte_p_, ( maxlen #include -#include "stringdata.hh" -#include "stringhandle.hh" +#include "string-data.hh" +#include "string-handle.hh" INLINE void String_handle::down() @@ -148,4 +148,9 @@ 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 new file mode 100644 index 0000000000..8cef141169 --- /dev/null +++ b/flower/lib/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 =( 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/textdb.hh b/flower/lib/include/text-db.hh similarity index 97% rename from flower/textdb.hh rename to flower/lib/include/text-db.hh index c2cff2461b..3535a84f8f 100644 --- a/flower/textdb.hh +++ b/flower/lib/include/text-db.hh @@ -1,7 +1,7 @@ #ifndef TEXTDB_HH #define TEXTDB_HH -#include "datafile.hh" +#include "data-file.hh" /**a "const" Array. Contents can't be changed. do "#" comments, read quote enclosed fields */ diff --git a/flower/textstream.hh b/flower/lib/include/text-stream.hh similarity index 100% rename from flower/textstream.hh rename to flower/lib/include/text-stream.hh diff --git a/flower/lib/include/unionfind.hh b/flower/lib/include/unionfind.hh new file mode 100644 index 0000000000..fbaa51e731 --- /dev/null +++ b/flower/lib/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/lib/include/varray.hh b/flower/lib/include/varray.hh new file mode 100644 index 0000000000..febf3e7601 --- /dev/null +++ b/flower/lib/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(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 new file mode 100644 index 0000000000..4d91397cc6 --- /dev/null +++ b/flower/lib/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(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 new file mode 100644 index 0000000000..283b1e567b --- /dev/null +++ b/flower/lib/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 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 new file mode 100644 index 0000000000..f9a255683e --- /dev/null +++ b/flower/lib/libc-extension.cc @@ -0,0 +1,113 @@ +/* + 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 n, + 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 new file mode 100644 index 0000000000..bcc2843bca --- /dev/null +++ b/flower/lib/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/lib/matrix.cc b/flower/lib/matrix.cc new file mode 100644 index 0000000000..63bd85a33c --- /dev/null +++ b/flower/lib/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+=(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 new file mode 100644 index 0000000000..c79962f00f --- /dev/null +++ b/flower/lib/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/lib/scalar.cc b/flower/lib/scalar.cc new file mode 100644 index 0000000000..5edd9e997f --- /dev/null +++ b/flower/lib/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/lib/smat.cc b/flower/lib/smat.cc new file mode 100644 index 0000000000..dcc61ce44e --- /dev/null +++ b/flower/lib/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 "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::longlong_str(long long ll, char const* fmt) +{ + char buffer[STRING_BUFFER_LEN]; + snprintf(buffer, STRING_BUFFER_LEN, + (fmt ? fmt : "%Ld"), ll ); // 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::i2hex_str( int i, int length_i, char ch ) +{ + String str; + if ( !i ) + str = "0"; + while ( i ) { + str = String( ( i % 16 )["0123456789abcdef"] ) + str; + i /= 16; + } + if ( str.length_i() < length_i ) + str = String( ch, length_i - str.length_i() ) + str; + return str; +} + +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) +{ + long long int ill = (long long int )l; + return String_convert::longlong_str(ill, "0x%0Lx"); +} diff --git a/flower/lib/stringtest.cc b/flower/lib/stringtest.cc new file mode 100644 index 0000000000..0bbde77c99 --- /dev/null +++ b/flower/lib/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/textdb.cc b/flower/lib/text-db.cc similarity index 96% rename from flower/textdb.cc rename to flower/lib/text-db.cc index eefea16240..ebfc992ff2 100644 --- a/flower/textdb.cc +++ b/flower/lib/text-db.cc @@ -1,4 +1,4 @@ -#include "textdb.hh" +#include "text-db.hh" bool Text_db::eof() { diff --git a/flower/textstream.cc b/flower/lib/text-stream.cc similarity index 94% rename from flower/textstream.cc rename to flower/lib/text-stream.cc index 5ab3f3fcde..a2d3e4b119 100644 --- a/flower/textstream.cc +++ b/flower/lib/text-stream.cc @@ -1,4 +1,4 @@ -#include "textstream.hh" +#include "text-stream.hh" Text_stream::Text_stream(String fn) { diff --git a/flower/lib/unionfind.cc b/flower/lib/unionfind.cc new file mode 100644 index 0000000000..e7b0831dd1 --- /dev/null +++ b/flower/lib/unionfind.cc @@ -0,0 +1,35 @@ +#include "unionfind.hh" +/* + see a book on data structures + */ + +Union_find::Union_find(int n) +{ + classes.set_size(n); + + for (int i=0; i < n; i++) { + classes[i] = i; + } +} + +int +Union_find::find(int i) +{ + int rep = i; + while (classes[rep] != rep) + rep = classes[rep]; + while (classes[i] != rep) { + int next =classes[i]; + classes[i] = rep; + i = next; + } + return rep; +} + +void +Union_find::connect(int i, int j) +{ + i = find(i); + j = find(j); + classes[i] = j; +} diff --git a/flower/lib/vector.cc b/flower/lib/vector.cc new file mode 100644 index 0000000000..5cc76bfd7b --- /dev/null +++ b/flower/lib/vector.cc @@ -0,0 +1,25 @@ +#include "vector.hh" +Vector::Vector(Array 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/matdebug.cc b/flower/matdebug.cc index 1a5d867903..bcc2843bca 100644 --- a/flower/matdebug.cc +++ b/flower/matdebug.cc @@ -2,6 +2,7 @@ #include "matrix.hh" static Dstream *dout = 0; + /** Set the debugging output. Will not delete/swallow argument. */ diff --git a/flower/pcursor.hh b/flower/pcursor.hh index 1215270e3b..ea360078d1 100644 --- a/flower/pcursor.hh +++ b/flower/pcursor.hh @@ -25,14 +25,14 @@ public: Cursor::ok; Cursor::del; Cursor::backspace; - T get() { + T get_p() { T p = ptr(); Cursor::del(); return p; } T get_prev() { (*this)--; - return get(); + return get_p(); } PointerList &list() { return (PointerList&)Cursor::list(); } diff --git a/flower/plist.tcc b/flower/plist.tcc index 1dea8cefc1..2ceed2e9c7 100644 --- a/flower/plist.tcc +++ b/flower/plist.tcc @@ -5,7 +5,7 @@ IPointerList::~IPointerList() { PCursor c( *this ); while (c.ok()) { - delete c.get(); + delete c.get_p(); } } diff --git a/flower/smat.cc b/flower/smat.cc index d89e3bc285..dcc61ce44e 100644 --- a/flower/smat.cc +++ b/flower/smat.cc @@ -19,16 +19,6 @@ Full_storage::OK() const assert(maxh >= h && maxw >= w); assert(h >= 0 && w >= 0); assert(els||!maxh); - if (maxh>0) { // access outer elts. - Real *r = els[maxh -1]; - #if 0 - if (maxw>0) { - assert(r); - Real s = r[maxw -1]; // accessing unitialised memory. - s = sin(s); - } - #endif - } #endif } void @@ -59,7 +49,7 @@ Full_storage::resize_rows(int neww) return; } for (int i=0; i < maxh ; i++) { - Real* newa=new Real[neww]; + Real* newa = new Real[neww]; for (int k=0; k < w; k++) newa[k] = els[i][k]; diff --git a/flower/string-convert.cc b/flower/string-convert.cc index ccd62a0a5a..36c98dd490 100644 --- a/flower/string-convert.cc +++ b/flower/string-convert.cc @@ -7,6 +7,19 @@ #include #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 ) @@ -47,6 +60,15 @@ String_convert::dec2_i( String dec_str ) return (int)l; } +String +String_convert::longlong_str(long long ll, char const* fmt) +{ + char buffer[STRING_BUFFER_LEN]; + snprintf(buffer, STRING_BUFFER_LEN, + (fmt ? fmt : "%Ld"), ll ); // assume radix 10 + return String(buffer); + +} // breendet imp from String double String_convert::dec2_f( String dec_str ) @@ -101,7 +123,8 @@ String_convert::hex2nibble_i( Byte byte ) return byte - 'a' + 10; return -1; } - + +// stupido. Should use int_str() String String_convert::i2dec_str( int i, int length_i, char ch ) { @@ -116,6 +139,8 @@ String_convert::i2dec_str( int i, int length_i, char ch ) return String( fill_ch, length_i - dec_str.length_i() ) + dec_str; } + +// stupido. Should use int_str() String String_convert::i2hex_str( int i, int length_i, char ch ) { @@ -139,3 +164,71 @@ String_convert::nibble2hex_byte( Byte byte ) 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) +{ + long long int ill = (long long int )l; + return String_convert::longlong_str(ill, "0x%0Lx"); +} diff --git a/flower/string-convert.hh b/flower/string-convert.hh index b96af44bd0..bcf461f8f3 100644 --- a/flower/string-convert.hh +++ b/flower/string-convert.hh @@ -7,28 +7,37 @@ #ifndef STRING_CONVERT_HH #define STRING_CONVERT_HH -/// -#define functor class // :-) +/* + ///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. */ -functor 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 ); +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 dec_str ); - static String bin2hex_str( String bin_str ); - static String dec2bin_str( String str ); - static int bin2_i( String str ); - static int dec2_i( String dec_str ); - static double dec2_f( String dec_str ); - static int hex2int_i( String str ); - static String hex2bin_str( String str ); - static String i2hex_str( int i, int length_i, char ch ); - static String i2dec_str( int i, int length_i, char ch ); + 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 hex2int_i( 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 i2dec_str( int i, int length_i, char ch ); + static String rational_str(Rational); + static String pointer_str(const void *); + static String longlong_str(long long , char const * fmt = 0); }; #endif // __STRING_CONVERT_HH // diff --git a/flower/string.cc b/flower/string.cc index a9368fe4e4..b4687c0b7f 100644 --- a/flower/string.cc +++ b/flower/string.cc @@ -1,87 +1,85 @@ /* - PROJECT: FlowerSoft C++ library - FILE : string.cc - Rehacked by HWN 3/nov/95 - removed String & - introduced class String_handle - */ + string.cc - implement String + + (c) 1997 Han-Wen Nienhuys & Jan Nieuwenhuizen + + */ -#include #include #include -#include + #include +#include #include "string.hh" +#include "libc-extension.hh" +#include "string-convert.hh" #ifdef STRING_DEBUG void* mymemmove( void* dest, void const* src, size_t n ); #define memmove mymemmove #endif -static char* -strlwr( char* s ) -{ - char* p = s; - - while( *p ) { - *p = tolower( *p ); /* a macro on some compilers */ - p++; - } - return s; -} - -static char* -strupr( char* s ) -{ - char* p = s; - - while( *p ) { - *p = toupper( *p ); /* a macro on some compilers */ - p++; - } - return s; -} - -String::String(Rational r) -{ - char * n = Itoa(r.numerator()); // LEAK???? - - *this = n; - if (r.denominator() != 1) { - char * d = Itoa(r.denominator()); - *this += String( '/' ) + String(d); - //delete d; - } -/* delete n; - */ -} - // return array, alloced with new. Byte* String::copy_byte_p() const { Byte const* src = strh_.byte_c_l(); Byte* dest = new Byte[strh_.length_i() + 1]; - memmove( dest, src, strh_.length_i() + 1 ); + memcpy( dest, src, strh_.length_i() + 1 ); return dest; } - void String::print_on(ostream& os) const { - if ( length_i() == strlen( ch_c_l() ) ) + if (strh_.null_terminated_b()) os << ch_c_l(); else for ( int i = 0; i < length_i(); i++ ) os << (Byte)(*this)[ i ]; } + +/* + copying, constructing. + */ +String& +String::operator = (String const&source ) +{ + strh_ = source.strh_; + return *this; +} + + +String::String(Rational r) +{ + *this = String_convert::rational_str(r); +} + +String::String (double f, char const* fmt) +{ + *this= String_convert::double_str(f,fmt); +} + +String::String( char c, int n ) +{ + *this = String_convert::char_str (c,n); +} + +/** + @see + String_convert::int_str + */ +String::String(int i, const char * format ) +{ + *this = String_convert::int_str(i,format); +} String::String (bool b) { *this = (char const* ) (b ? "true" : "false"); } + String::String( char const* source ) { assert(source); @@ -90,50 +88,31 @@ String::String( char const* source ) String::String( Byte const* byte_l, int length_i ) { -// assert( !length_i || byte_l );// ugh. Storing null pointers? strh_.set( byte_l, length_i ); } - + void -String::operator +=(String s) +String::append(String s) { strh_.append( s.byte_c_l(), s.length_i() ); } - -int -String::length_i() const -{ - return strh_.length_i(); -} - -// will go away, fixed anyway -String::String( char c, int n ) +void +String::operator +=(String s) { - n = n >= 0 ? n : 0; - char* ch_p = new char[ n ]; - memset( ch_p, c, n ); - strh_.set( (Byte*)ch_p, n ); - delete ch_p; + append(s); } -String::String(int i) +void +String::prepend(String s) { - char digits[ 81 ]; // who the fuck is 80??? - digits[ 0 ] = '\0'; - sprintf(digits, "%d", i ); // assume radix 10 - strh_ = digits; + s += *this; + *this = s; } -String::String( const int i, const int n, char const c ) +int +String::length_i() const { - char fill_ch = c; - if ( fill_ch) - fill_ch = '0'; - - String v( i ); - - String str = String( fill_ch, n - v.length_i() ) + String( v ); - strh_.set( str.byte_c_l(), str.length_i() ); + return strh_.length_i(); } Byte const* @@ -160,7 +139,9 @@ String::ch_l() return strh_.ch_l(); } -// signed comparison, analogous to memcmp; +/** + Do a signed comparison, analogous to memcmp; + */ int String::compare_i(String const& s1, String const& s2 ) { @@ -177,96 +158,99 @@ String::compare_i(String const& s1, String const& s2 ) return result ? result : i1-i2; } - + int String::index_last_i( char const c ) const { - // not binary safe - assert( length_i() == strlen( ch_c_l() ) ); - if ( !length_i() ) - return -1; - - char const* me = strh_.ch_c_l(); - char const* p = strrchr(me, c ); - if ( p ) - return p - me; + if ( !length_i() ) return -1; + + char const* me = strh_.ch_c_l(); + char const* p = memrchr(me, length_i(), c ); + if ( p ) + return p - me; + return -1; } int -String::index_last_i( char const* string ) const -{ - // not binary safe - assert( length_i() == strlen( ch_c_l() ) ); - - int length = strlen( string ); - if ( !length_i() || !length ) - return -1; - - int next_i = index_i( string ); - if ( next_i == -1 ) - return -1; - - int index_i = 0; - while( next_i >= 0 ) { - index_i += next_i; - next_i = right_str( length_i() - index_i - length ).index_i( string ); - } - return index_i; +String::index_last_i( char const* string ) const // UGK! +{ + assert(false); // broken + int length = strlen( string ); // ugrh + if ( !length_i() || !length ) + return -1; + + int next_i = index_i( string ); + if ( next_i == -1 ) + return -1; + + int index_i = 0; + while( next_i >= 0 ) { + index_i += next_i; + next_i = right_str( length_i() - index_i - length ).index_i( string ); + } + return index_i; } -// find c -// return -1 if not found. +/** find a character. + + @return + the index of the leftmost character #c# (0 <= return < length_i()), + or -1 if not found. -// ? should return length_i()?, as in string.left_str(index_i(delimiter)) + ? should return length_i()?, as in string.left_str(index_i(delimiter)) +*/ int String::index_i(char c ) const { - // not binary safe - assert( length_i() == strlen( ch_c_l() ) ); - if ( !length_i() ) - return -1; - - char const* me = strh_.ch_c_l(); - char const* p = strchr( me, c ); - if ( p ) - return p - me; - return -1; + char const* me = strh_.ch_c_l(); + char const* p = (char const *) memchr( me,c, length_i()); + if ( p ) + return p - me; + return -1; } -// find searchfor. (what if this == "" && searchfor == "") ??? +/** + find the substring. + + @return + index of leftmost occurrence of #searchfor# + */ int -String::index_i( char const* searchfor ) const -{ - // not binary safe - assert( length_i() == strlen( ch_c_l() ) ); - if ( !length_i() || !searchfor ) - return -1; - - char const* me = strh_.ch_c_l(); - char const* p = strstr(me, searchfor); - if ( p ) - return p - me; +String::index_i( String searchfor ) const +{ + char const* me = strh_.ch_c_l(); + char const* p = (char const *) memmem(me, length_i(), searchfor.ch_c_l(), + searchfor.length_i()); + + if ( p ) + return p - me; + else return -1; } -// find chars of a set. +/** find chars of a set. + + @return + the index of the leftmost occurance of an element of #set# + */ int -String::index_any_i( char const* string ) const -{ - // not binary safe - assert( length_i() == strlen( ch_c_l() ) ); - - if ( !length_i() || !string ) - return -1; - - char const* s = (char const* )strh_.ch_c_l(); - char const* p = strpbrk( s, string ); - if ( p ) - return p - s; +String::index_any_i( String set ) const +{ + int n = length_i(); + if ( !n ) return -1; -} + const void * me_l = (const void*) strh_.ch_c_l(); + for (int i=0; i < set.length_i(); i++) { + char * found=(char*) memchr(me_l, set[i], n ); + if (found) { + return found - me_l; + } + } + return -1; +} + String String::left_str( int n ) const { @@ -282,8 +266,6 @@ String::left_str( int n ) const return retval; } - -// n rightmst chars String String::right_str( int n ) const { @@ -291,7 +273,7 @@ String::right_str( int n ) const return *this; if ( n < 1) - String(); + return ""; return String( strh_.byte_c_l() + length_i() - n, n ); } @@ -300,110 +282,80 @@ String::right_str( int n ) const String String::nomid_str( int index_i, int n ) const { - if ( index_i < 0 ) - return String(); - if ( index_i >= length_i() ) - return *this; + if ( index_i < 0 ) { + n += index_i; + index_i = 0; + } + if ( n <= 0) + return *this; - return String( String( left_str( index_i ) ) + right_str( length_i() - index_i - n )); + return + left_str( index_i ) + + right_str( length_i() - index_i - n ) ; } - +/* + proposal: change to "cut()" + */ String String::mid_str( int index_i, int n ) const { - if ( !length_i() || ( index_i < 0 ) || ( index_i >= length_i() ) || ( n < 1 ) ) - return String(); + if ( !length_i() || ( index_i < 0 ) || ( index_i >= length_i() ) || ( n < 1 ) ) + return String(); - if ( ( n > length_i() ) || ( index_i + n > length_i() ) ) - n = length_i() - index_i; + if ( ( n > length_i() ) || ( index_i + n > length_i() ) ) + n = length_i() - index_i; - return String( byte_c_l() + index_i, n ); + return String( byte_c_l() + index_i, n ); } - - -// return uppercase + String String::upper_str() const { - // not binary safe - assert( length_i() == strlen( ch_c_l() ) ); String str = *this; - char *s = str.strh_.byte_l(); - strupr( s ); + str.to_upper(); return str; } +void +String::to_upper() +{ + char *s = (char*)strh_.byte_l(); + strnupr( s ,length_i()); +} + +void +String::to_lower() +{ + char* s = strh_.ch_l(); + strnlwr(s,length_i()); +} -// return lowercase String String::lower_str() const { - // not binary safe - assert( length_i() == strlen( ch_c_l() ) ); String str = *this; - char* s = str.strh_.ch_l(); - strlwr(s); + str.to_lower(); return str; } - -String::String (double f, char const* fmt) +String +String::reversed_str() const { - /* worst case would be printing HUGE (or 1/HUGE), which is approx - 2e318, this number would have approx 318 zero's in its string. - - 1024 is a safe length for the buffer - */ - - char buf[1024]; - if (!fmt) - sprintf(buf, "%f", f); - else - sprintf(buf, fmt,f); - *this = buf; + String str = *this; + strrev( str.byte_l(), str.length_i() ); + return str; } int String::value_i() const { - return String_convert::dec2_i( *this ); + return String_convert::dec2_i( *this ); } double String::value_f() const { - return String_convert::dec2_f( *this ); + return String_convert::dec2_f( *this ); } -#if 0 -String -quoteString( String msg, String quote) -{ - return msg + " `" + quote + "' "; -} -#endif // 0 - -Byte* -strrev( Byte* byte_l, int length_i ) -{ - Byte byte; - Byte* left_byte_l = byte_l; - Byte* right_byte_l = byte_l + length_i; - - while ( right_byte_l > left_byte_l ) { - byte = *left_byte_l; - *left_byte_l++ = *right_byte_l; - *right_byte_l-- = byte; - } - return byte_l; -} - - -String -String::reversed_str() const -{ - String str = *this; - strrev( str.byte_l(), str.length_i() ); - return str; -} diff --git a/flower/string.hh b/flower/string.hh index 7aa19047d1..8cef141169 100644 --- a/flower/string.hh +++ b/flower/string.hh @@ -15,7 +15,7 @@ #include #include -#include "stringhandle.hh" +#include "string-handle.hh" /** @@ -24,15 +24,12 @@ \item ref counting through #String_handle# \item - - conversion from bool, int, double, char* , char. + conversion from bool, int, double, char* , char. \item - to be moved to String_convert: conversion to int, upcase, downcase \item - printable. \item @@ -51,35 +48,34 @@ No operator[] is provided, since this would be enormously slow. If needed, convert to char const* . \end{itemize} + */ class String { protected: - String_handle strh_; // should derive String from String_handle? + String_handle strh_; + bool null_terminated(); + public: - /** init to "". needed because other constructors are provided.*/ + /** 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 s( 10 ); - String( int i ); - + String( int i , char const *fmt=0); + String ( double f , char const* fmt =0); /// 'true' or 'false' String(bool ); - /// String s( 3.14, 6, '#' ); - String ( double f , char const* fmt =0); - String( int i, int n, char c = ' ' ); - /// return a "new"-ed copy of contents Byte* copy_byte_p() const; // return a "new"-ed copy of contents @@ -91,12 +87,15 @@ public: /// deprecated; use ch_c_l() operator char const* () const { return ch_c_l(); } - String operator =( const String & source ) { strh_ = source.strh_; return *this; } + 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 @@ -130,17 +129,12 @@ public: /// index of rightmost element of string int index_last_i( char const* string ) const; - /** - index of leftmost c. - - @return - -1 if not found, else index - */ int index_i(char c ) const; - int index_i(char const* string ) const; - int index_any_i(char const* string ) 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; @@ -157,7 +151,6 @@ public: /// convert to a double double value_f() const; - // ***** }; #include "compare.hh" @@ -197,6 +190,4 @@ operator << ( ostream& os, String d ) // String quoteString(String message, String quote); -#include "string-convert.hh" - #endif diff --git a/flower/stringtest.cc b/flower/stringtest.cc index c0c50da5c6..2f085a26d7 100644 --- a/flower/stringtest.cc +++ b/flower/stringtest.cc @@ -1,42 +1,113 @@ -// stringtest.cc - +/* + 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: "< class Array { @@ -146,7 +151,7 @@ public: size_--; } // quicksort. - void sort (int (*compare)(T& , T& ), + void sort (int (*compare)( T const&,T const&), int lower = -1, int upper = -1 ) { if (lower < 0) { lower = 0 ; diff --git a/hdr/Makefile b/hdr/Makefile deleted file mode 100644 index aab2511d4f..0000000000 --- a/hdr/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -default: - $(MAKE) -C .. -DISTFILES=Makefile $(allhdr) -dist: - ln $(DISTFILES) $(DDIR)/$(SUBDIR) - - -TAGS: $(hdr) - $(TAGSACTION) $^ - -clean: - rm -f parser.hh - rm -f midi-parser.hh diff --git a/hdr/duration.hh b/hdr/duration.hh deleted file mode 100644 index ff92cf23f3..0000000000 --- a/hdr/duration.hh +++ /dev/null @@ -1,111 +0,0 @@ -// -// duration.hh -- declare Duration, Plet, Duration_convert Duration_iterator -// -// copyright 1997 Jan Nieuwenhuizen - -// split into 4? - -#ifndef DURATION_HH -#define DURATION_HH - -/// (dur) -struct Duration { - // actually i hate it when other people use default arguments, - // because it makes you easily loose track of what-s really - // happening; in the routine-s implementation you-re not aware - // of this defaultness (who sets this stupid value?). - Duration( int type_i = 1, int dots_i = 0, Plet* plet_p = 0 ); - Duration( Duration const& dur_c_r ); - ~Duration(); - - Duration const& operator =( Duration const& dur_c_r ); - - void set_plet( Plet* plet_l ); // handiger: newt zelf - -// int i_; // balltype -> type! - int type_i_; - int dots_i_; - Plet* plet_p_; -}; - -/// (plet) -struct Plet { - Plet( int replace_i, int type_i ); - Plet( Plet const& plet_c_r ); - -// int i_; - int iso_i_; // 2/3; 2 is not duration, maar of count! - int type_i_; -}; - -/** - Duration_convert handles all conversions to -n fro Duration (dur). - That is including (integer + division) representation for MIDI, - and conversion from unexact time representation (best guess :-). - - A Moment (mom) is a Rational that holds the time fraction - compared to a whole note (before also called wholes). - - SUGGESTION: currently a moment in time is called moment too; - let-s typedef Rational When too, so that we get - When Staff_column::when(), Moment Voice_element::mom(). -*/ -struct Duration_convert { - /// Most used division in MIDI, all fine with me. - static int const division_1_c_i = 384; - - /// Return (integer, division) representation. - static int dur2_i( Duration dur, int division_1_i = division_1_c_i ); - - /// Return Moment representation (fraction of whole note). - static Moment dur2_mom( Duration dur ); - - /// Return Mudela string representation. - static String dur2_str( Duration dur ); - - /// Return Moment from (integer, division) representation. - static Moment i2_mom( int i, int division_1_i = division_1_c_i ); - - /// Return Moment (fraction of whole) representation, best guess. - static Duration mom2_dur( Moment mom ); - - /// Return plet factor (not a Moment: should use Rational?). - static Moment plet_factor_mom( Duration dur ); - - /** Return synchronisation factor for mom, so that - mom2_dur( mom / sync_f ) will return the duration dur. - */ - static Real sync_f( Duration dur, Moment mom ); -}; - -/// (iter_dur) -struct Duration_iterator { - /// start at shortest: 128:2/3 - Duration_iterator(); - - // **** what about these three here ? - /// return forward_dur(); - Duration operator ++(int); - - /// return ok() - operator bool(); - - /// return dur() - Duration operator ()(); - // **** - - /// return current dur - Duration dur(); - - /// return dur(), step to next - Duration forward_dur(); - - /// durations left? - bool ok(); - -private: - Duration cursor_dur_; -}; - -#endif // DURATION_HH - diff --git a/hdr/lily-stream.hh b/hdr/lily-stream.hh deleted file mode 100644 index 55ae71b6e3..0000000000 --- a/hdr/lily-stream.hh +++ /dev/null @@ -1,27 +0,0 @@ -// -// lily-stream.hh -- part of LilyPond -// -// copyright 1997 Jan Nieuwenhuizen - -// should i be named Mudela_stream? - -#ifndef LILY_STREAM_HH -#define LILY_STREAM_HH - -/// Lily output -struct Lily_stream { - ostream* os_p_; - String filename_str_; - - Lily_stream( String filename_str ); - ~Lily_stream(); - - Lily_stream& operator <<( String str ); - Lily_stream& operator <<( Midi_event& midi_event_r ); - - void header(); - void open(); -}; - -#endif // LILY_STREAM_HH - diff --git a/hdr/lyric-item.hh b/hdr/lyric-item.hh deleted file mode 100644 index dfbaf988d1..0000000000 --- a/hdr/lyric-item.hh +++ /dev/null @@ -1,19 +0,0 @@ -// -// lyric-item.hh -- part of LilyPond -// -// copyright 1997 Jan Nieuwenhuizen - -#ifndef LYRIC_ITEM_HH -#define LYRIC_ITEM_HH - -#include "textitem.hh" - -struct Lyric_item : Text_item { - /* *************** */ - Lyric_item(Lyric_req* lreq_l, int voice_count_i); - virtual void do_pre_processing(); -}; - - -#endif // LYRIC_ITEM_HH // - diff --git a/hdr/midi-event.hh b/hdr/midi-event.hh deleted file mode 100644 index 06b17221aa..0000000000 --- a/hdr/midi-event.hh +++ /dev/null @@ -1,85 +0,0 @@ -// -// midi-event.hh -- declare midi_event -// -// copyright 1997 Jan Nieuwenhuizen - -#ifndef MIDI_EVENT_HH -#define MIDI_EVENT_HH - - -// should these: -// * be Midi_items -// * be Voice_elements/requests -// * get a name-change -// ? - -/// (midi_event) -class Midi_event { -public: - Midi_event(); - virtual ~Midi_event(); - - virtual String mudela_str(); // = 0; - virtual void output_mudela( Lily_stream& lily_stream_r ); - virtual Moment mom(); - -protected: - String mudela_str_; -}; - -class Midi_key : public Midi_event { -public: - Midi_key( int accidentals_i, int minor ); - virtual ~Midi_key(); - - String notename_str( int pitch_i ); - -private: - int accidentals_i_; - int minor_i_; - int key_i_; -}; - -class Midi_note : public Midi_event { - public: - int const c0_pitch_i_c_ = 60; - - Midi_note( Midi_key* midi_key_l, Midi_time* midi_time_l, int division_1_i, int pitch_i, int time_i ); - virtual ~Midi_note(); - - virtual Moment mom(); - -private: - Duration dur_; -}; - -class Midi_tempo : public Midi_event { -public: - Midi_tempo( int useconds_per_4_i ); - virtual ~Midi_tempo(); - - int get_tempo_i( Moment moment ); - -private: - int useconds_per_4_i_; - Real seconds_per_1_f_; -}; - -class Midi_time : public Midi_event { -public: - Midi_time( int num_i, int den_i, int division_4_i, int count_32_i ); - virtual ~Midi_time(); - - Duration i2_dur( int time_i, int division_1_i ); - int clocks_1_i(); - -private: - Real sync_f_; - Duration sync_dur_; - int clocks_1_i_; - int num_i_; - int den_i_; -}; - -#endif // MIDI_EVENT_HH - diff --git a/hdr/midi-item.hh b/hdr/midi-item.hh deleted file mode 100644 index 6688e95411..0000000000 --- a/hdr/midi-item.hh +++ /dev/null @@ -1,85 +0,0 @@ -// -// midi-item.hh -- part of LilyPond -// -// copyright 1997 Jan Nieuwenhuizen - -#ifndef MIDI_ITEM_HH -#define MIDI_ITEM_HH -#include "string.hh" -#include "proto.hh" - -struct Midi_item { - /* *************** */ - static String i2varint_str( int i ); - virtual void output_midi( Midi_stream& midi_stream_r ); - virtual String str() = 0; -}; - -struct Midi_note : public Midi_item { - /* *************** */ - int const c0_pitch_i_c_ = 60; - Byte dynamic_byte_; - - /** - Generate a note-event on a channel pitch. - - @param #melreq_l# is the pitch. - */ - Midi_note( Melodic_req* melreq_l, int channel_i, bool on_b ); - - virtual String str(); - - int channel_i_; - int on_b_; - int pitch_i_; -}; - -struct Midi_duration : public Midi_item { - /* *************** */ - Midi_duration( Real seconds_f ); - - virtual String str(); - - Real seconds_f_; -}; - -struct Midi_chunk : Midi_item { - /* *************** */ - Midi_chunk(); - - void add( String str ); - void set( String header_str, String data_str, String footer_str ); - virtual String str(); - -private: - String data_str_; - String footer_str_; - String header_str_; -}; - -struct Midi_header : Midi_chunk { - /* *************** */ - Midi_header( int format_i, int tracks_i, int clocks_per_4_i ); -}; - -struct Midi_tempo : Midi_item { - /* *************** */ - Midi_tempo( int tempo_i ); - - virtual String str(); - - int tempo_i_; -}; - -struct Midi_track : Midi_chunk { - /* *************** */ - int number_i_; - Midi_track( int number_i ); - - void add( int delta_time_i, String event ); -// void add( Moment delta_time_moment, Midi_item& mitem_r ); - void add( Moment delta_time_moment, Midi_item* mitem_l ); -}; - -#endif // MIDI_ITEM_HH // - diff --git a/hdr/midi-main.hh b/hdr/midi-main.hh deleted file mode 100644 index b58e077d43..0000000000 --- a/hdr/midi-main.hh +++ /dev/null @@ -1,27 +0,0 @@ -// -// midi-main.hh -- global (sic) m2m stuff -// -// copyright 1997 Jan Nieuwenhuizen -#include "string.hh" - -#define monitor_p_g &cout -enum Verbose { QUIET_ver, BRIEF_ver, NORMAL_ver, VERBOSE_ver, DEBUG_ver }; -extern Verbose level_ver; -#ifdef NPRINT -#define dtor if ( 0 ) *monitor_p_g -#define mtor if ( 0 ) *monitor_p_g -#else -#define dtor if ( level_ver >= DEBUG_ver ) *monitor_p_g -#define vtor if ( level_ver >= VERBOSE_ver ) *monitor_p_g -#define mtor if ( level_ver >= NORMAL_ver ) *monitor_p_g -#define btor if ( level_ver >= BRIEF_ver ) *monitor_p_g -#define qtor if ( level_ver >= QUIET_ver ) *monitor_p_g -#endif - -extern Source* source_l_g; -extern bool no_triplets_bo_g; -void message( String message_str, char const* context_ch_c_l ); -void warning( String message_str, char const* context_ch_c_l ); -void error( String message_str, char const* context_ch_c_l ); - -String version_str(); diff --git a/hdr/midi-score.hh b/hdr/midi-score.hh deleted file mode 100644 index 68707633ef..0000000000 --- a/hdr/midi-score.hh +++ /dev/null @@ -1,27 +0,0 @@ -// -// midi-score.hh -- declare midi_score -// -// copyright 1997 Jan Nieuwenhuizen - -#ifndef MIDI_SCORE_HH -#define MIDI_SCORE_HH - -/// (midi_score) -class Midi_score { -public: - Midi_score( int format_i, int tracks_i, int tempo_i ); - ~Midi_score(); - - void add_track( Midi_track* midi_track_p ); - - int output_mudela( String filename_str ); - -private: - IPointerList midi_track_p_list_; - int format_i_; - int tracks_i_; - int tempo_i_; -}; - -#endif // MIDI_SCORE_HH - diff --git a/hdr/midi-stream.hh b/hdr/midi-stream.hh deleted file mode 100644 index 6946bfdda1..0000000000 --- a/hdr/midi-stream.hh +++ /dev/null @@ -1,32 +0,0 @@ -// -// midi-stream.hh -- part of LilyPond -// -// copyright 1997 Jan Nieuwenhuizen - -#ifndef MIDI_STREAM_HH -#define MIDI_STREAM_HH - -#include -#include "string.hh" - -/// Midi output -struct Midi_stream { - ostream* os_p_; - String filename_str_; - int clocks_per_4_i_; - int tracks_i_; - - Midi_stream( String filename_str, int tracks_i, int clocks_per_4_i_ ); - ~Midi_stream(); - - Midi_stream& operator <<( String str ); - Midi_stream& operator <<( Midi_item& mitem_r ); - Midi_stream& operator <<( int i ); - - void header(); - void open(); - -//private: -// Midi_stream(Midi_stream const&); -}; -#endif // MIDI_STREAM_HH // diff --git a/hdr/midi-track.hh b/hdr/midi-track.hh deleted file mode 100644 index d1458ed0ca..0000000000 --- a/hdr/midi-track.hh +++ /dev/null @@ -1,26 +0,0 @@ -// -// midi-track.hh -- declare midi_track -// -// copyright 1997 Jan Nieuwenhuizen - -#ifndef MIDI_TRACK_HH -#define MIDI_TRACK_HH - -/// (midi_track) -class Midi_track { -public: - Midi_track( int track_i ); - ~Midi_track(); - - void add_event( Moment mom, Midi_event* midi_event_p ); - String name_str(); - void output_mudela( Lily_stream& lily_stream_r ); - Track_column* tcol_l( Moment mom ); - -private: - IPointerList tcol_p_list_; - String name_str_; -}; - -#endif // MIDI_TRACK_HH - diff --git a/hdr/my-midi-parser.hh b/hdr/my-midi-parser.hh deleted file mode 100644 index d199bc1c4e..0000000000 --- a/hdr/my-midi-parser.hh +++ /dev/null @@ -1,54 +0,0 @@ -// -// my-midi-parser.hh -- declare My_midi_parser -// -// copyright 1997 Jan Nieuwenhuizen - -#ifndef MY_MIDI_PARSER_HH -#define MY_MIDI_PARSER_HH - -// #include "proto.hh" -// #include "string.hh" - -int yyparse(); - -/// (midi_parser) -class My_midi_parser { -public: - My_midi_parser( String filename_str ); - ~My_midi_parser(); - void add_score( Midi_score* midi_score_p ); - void error( char const* sz_l ); - int parse(); - void forward( int i ); - Moment mom(); - void note_begin( int channel_i, int pitch_i, int dyn_i ); - Midi_event* note_end_midi_event_p( int channel_i, int pitch_i, int dyn_i ); - int output_mudela( String filename_str ); - void reset(); - void set_division_4( int division_4_i ); - void set_key( int accidentals_i, int minor_i ); - void set_tempo( int useconds_i ); - void set_time( int num_i, int den_i, int clocks_i, int count_32_i ); - -private: - Int64 now_i64_; // 31 bits yields tipically about 1000 bars - - static int const CHANNELS_i = 16; - static int const PITCHES_i = 128; - Int64 running_i64_i64_a_[ CHANNELS_i ][ PITCHES_i ]; - - Midi_score* midi_score_p_; - int division_1_i_; - Midi_key* midi_key_p_; - Midi_tempo* midi_tempo_p_; - Midi_time* midi_time_p_; - - char const* defined_ch_c_l_; - int fatal_error_i_; - My_midi_lexer* midi_lexer_p_; -}; - -extern My_midi_parser* midi_parser_l_g; - -#endif // MY_MIDI_PARSER_HH - diff --git a/hdr/track-column.hh b/hdr/track-column.hh deleted file mode 100644 index 1d86755a9f..0000000000 --- a/hdr/track-column.hh +++ /dev/null @@ -1,24 +0,0 @@ -// -// track-column.hh -- declare Track_column -// -// copyright 1997 Jan Nieuwenhuizen - -#ifndef TRACK_COLUMN_HH -#define TRACK_COLUMN_HH - -/// (tcol) -class Track_column { -public: - Track_column( Moment mom ); - ~Track_column(); - - void add_event( Midi_event* midi_event_p ); - Moment mom(); - -//private: - IPointerList midi_event_p_list_; - Moment mom_; -}; - -#endif // TRACK_COLUMN_HH - diff --git a/init/Makefile b/init/Makefile index 83a2e5b9ae..ff8dd8efad 100644 --- a/init/Makefile +++ b/init/Makefile @@ -1,8 +1,20 @@ -DFILES=dutch.ini table_sixteen.ini table_twenty.ini\ - english.ini script.ini symbol.ini bare.ini swedish.ini +# init/Makefile -default: - echo huh? +# subdir level: +# +depth = .. +# + +build = ./$(depth)/lily/.build + +# generic stuff/Makefile +# +include ./$(depth)/make/Stuff.make +# + +# list of distribution files: +# +INIFILES = $(shell ls *.ini) +DISTFILES = Makefile $(INIFILES) +# -dist: - ln Makefile $(DFILES) $(DDIR)/$(INITDIR) diff --git a/init/symbol.ini b/init/symbol.ini index 82029a9e1b..7de1e0f521 100644 --- a/init/symbol.ini +++ b/init/symbol.ini @@ -1,7 +1,7 @@ include "dutch.ini" # do not include init/ path -include "script.ini" -include "table_sixteen.ini" # not needed if doing MIDI +include "script.ini" +include "table_sixteen.ini" diff --git a/input/Makefile b/input/Makefile index 47e58f972d..618e1ec24a 100644 --- a/input/Makefile +++ b/input/Makefile @@ -1,15 +1,21 @@ -default: ; +# input/Makefile -DISTFILES=Makefile kortjakje.ly maartje.ly\ - cadenza.ly scales.ly standchen.ly twinkle.ly\ - wohltemperirt.ly\ - error.ly midi.ly plet.ly\ - martien.ly mlalt.ly mlvio1.ly mlvio2.ly mlcello.ly\ - coriolan-alto.ly rhythm.ly \ - standchen.tex scsii-menuetto.tex scsii-menuetto.ly\ - martien.tex\ - pre1.midi.ly fugue1.midi.ly +# subdir level: +# +depth = .. +# +build = ./$(depth)/lily/.build + +# generic stuff/Makefile +# +include ./$(depth)/make/Stuff.make +# + +# list of distribution files: +# +LYFILES = $(shell ls *.ly) +TEXFILES = $(shell ls *.tex) +DISTFILES = Makefile $(LYFILES) $(TEXFILES) +# -dist: - ln $(DISTFILES) $(DDIR)/$(SUBDIR) diff --git a/input/midi.ly b/input/midi.ly index 9e45033808..38e5073778 100644 --- a/input/midi.ly +++ b/input/midi.ly @@ -4,7 +4,7 @@ melodie = music { $\clef\violin c c | g g | a a | g2 - f f | e e | d d8. e16 | c2 | % :| + f f | e e | d d8.( e16 | )c2 | % :| $ } @@ -33,7 +33,6 @@ score { commands { meter { 2 * 4} } - paper{} midi { tempo 4:120 } diff --git a/input/scales.ly b/input/scales.ly index 11568c9ea6..d98c1bba43 100644 --- a/input/scales.ly +++ b/input/scales.ly @@ -4,15 +4,15 @@ staff {melodic music{ $ \duration { 8 } \octave{ } - |[ a a a a a a a a a ]8/9 + |[ a a a a a a a a a ] \octave{ ' } - |[ a a a a a a a a a ]8/9 + |[ a a a a a a a a a ] \octave { ` } - [ `c `g d a 'e 'b ''f '''c '''g ] 8/9 - [ '''g '''c ''f 'b 'e a d `g `c ] 8/9 + [ `c `g d a 'e 'b ''f '''c '''g ] + [ '''g '''c ''f 'b 'e a d `g `c ] \octave{ ' } - [ `c `g d a 'e 'b ''f '''c '''g ] 8/9 - [ '''g '''c ''f 'b 'e a d `g `c ] 8/9 + [ `c `g d a 'e 'b ''f '''c '''g ] + [ '''g '''c ''f 'b 'e a d `g `c ] \octave { } [ c g 'd ]2/3 [ 'd g c ]2/3 @@ -54,7 +54,7 @@ score { } commands { meter {6*8} - skip {36*8} + skip 36*8 meter {4*4} } } diff --git a/lib/Makefile b/lib/Makefile new file mode 100644 index 0000000000..7da9879256 --- /dev/null +++ b/lib/Makefile @@ -0,0 +1,91 @@ +# +# 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 = .. +# + +# 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 = ./$(depth)/lily/.build +# + +# generic variables: +# +include ./$(depth)/make/Variables.make +# + +# descent order into subdirectories: +# +SUBDIRS = include +# + +# to be remade each build: +# +VERSION_DEPENDENCY = $(lily-version) +# + +# list of c++ header files: +# +HHFILES = # $(shell ls include/*.hh) +# + +# list of c++ source files: +# +CCFILES = $(shell ls *.cc) +# + +# list of other source files: +# +EXTRA_SOURCE_FILES = # $(shell ls *.y *.l) +# + +# 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) +# + +# generic targets and rules: +# +include ./$(depth)/make/Targets.make +include ./$(depth)/make/Rules.make +# + +# auto dependencies: +# +-include ./$(outdir)/*.dep +# + diff --git a/lib/include/Makefile b/lib/include/Makefile new file mode 100644 index 0000000000..cb4f4ea6d1 --- /dev/null +++ b/lib/include/Makefile @@ -0,0 +1,23 @@ +# lib/include/Makefile + +# subdir level: +# +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/.build +# + +# generic stuff/Makefile +# +include ./$(depth)/make/Include.make +# + diff --git a/lib/include/config.hh b/lib/include/config.hh new file mode 100644 index 0000000000..ca44f294d7 --- /dev/null +++ b/lib/include/config.hh @@ -0,0 +1 @@ +#define LIBDIR "./" diff --git a/hdr/debug.hh b/lib/include/debug.hh similarity index 100% rename from hdr/debug.hh rename to lib/include/debug.hh diff --git a/hdr/input-file.hh b/lib/include/input-file.hh similarity index 100% rename from hdr/input-file.hh rename to lib/include/input-file.hh diff --git a/hdr/moment.hh b/lib/include/moment.hh similarity index 100% rename from hdr/moment.hh rename to lib/include/moment.hh diff --git a/hdr/proto.hh b/lib/include/proto.hh similarity index 99% rename from hdr/proto.hh rename to lib/include/proto.hh index 5a47fc459a..e9d3e60d38 100644 --- a/hdr/proto.hh +++ b/lib/include/proto.hh @@ -85,6 +85,7 @@ struct Midi_stream; struct Midi_tempo; struct Midi_time; struct Midi_track; +struct Midi_voice; struct Midi_walker; struct Mixed_qp; class My_midi_lexer; diff --git a/lib/include/windhoos-suck-suck-suck-thank-you-cygnus.hh b/lib/include/windhoos-suck-suck-suck-thank-you-cygnus.hh new file mode 100644 index 0000000000..540be21682 --- /dev/null +++ b/lib/include/windhoos-suck-suck-suck-thank-you-cygnus.hh @@ -0,0 +1,13 @@ +// +// windhoos-suck-suck-suck-thank-you-cygnus.hh +// +#ifdef _WIN32 +#ifndef WINDHOOS_SUCK_SUCK_SUCK_HH +#define WINDHOOS_SUCK_SUCK_SUCK_HH + +caddr_t mmap(caddr_t addr, size_t len, int prot, int flags, int fd, off_t offset); + +int munmap(caddr_t addr, size_t len); + +#endif // WINDHOOS_SUCK_SUCK_SUCK_HH +#endif // _WIN32 // diff --git a/src/source-file.cc b/lib/source-file.cc similarity index 92% rename from src/source-file.cc rename to lib/source-file.cc index f0d21bf91a..a39a57cbfa 100644 --- a/src/source-file.cc +++ b/lib/source-file.cc @@ -17,10 +17,17 @@ #include "string.hh" #include "proto.hh" #include "plist.hh" -#include "lexer.hh" + +//#include "lexer.hh" + #include "debug.hh" -#include "parseconstruct.hh" -#include "main.hh" // find_file +#include "windhoos-suck-suck-suck-thank-you-cygnus.hh" +// #include "parseconstruct.hh" // defined_ch_c_l +extern char const* defined_ch_c_l; + +// ugh +// #include "main.hh" // find_file +String find_file(String); #include "source-file.hh" @@ -107,7 +114,7 @@ Source_file::error_str( char const* pos_ch_c_l ) String str = line_str.left_str( pos_ch_c_l - begin_ch_c_l ) + String( '\n' ) + String( ' ', error_col_i ) - + line_str.mid_str( pos_ch_c_l - begin_ch_c_l + 1, INT_MAX ); // String::mid should take 0 arg.. + + line_str.mid_str( pos_ch_c_l - begin_ch_c_l, INT_MAX ); // String::mid should take 0 arg.. return str; } diff --git a/src/source.cc b/lib/source.cc similarity index 100% rename from src/source.cc rename to lib/source.cc diff --git a/src/windhoos-suck-suck-suck-thank-you-cygnus.cc b/lib/windhoos-suck-suck-suck-thank-you-cygnus.cc similarity index 97% rename from src/windhoos-suck-suck-suck-thank-you-cygnus.cc rename to lib/windhoos-suck-suck-suck-thank-you-cygnus.cc index caecb610da..15db908eab 100644 --- a/src/windhoos-suck-suck-suck-thank-you-cygnus.cc +++ b/lib/windhoos-suck-suck-suck-thank-you-cygnus.cc @@ -6,6 +6,7 @@ #include #include #include +#include "windhoos-suck-suck-suck-thank-you-cygnus.hh" /* HANDLE CreateFileMapping( diff --git a/lily/Makefile b/lily/Makefile new file mode 100644 index 0000000000..f31a93426a --- /dev/null +++ b/lily/Makefile @@ -0,0 +1,99 @@ +# +# project LilyPond -- the musical typesetter +# title makefile for lilypond +# file lily/Makefile +# +# Copyright (c) 1997 by +# Jan Nieuwenhuizen +# Han-Wen Nienhuys +# + +# subdir level: +# +depth = .. +# + +# 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 = ./$(depth)/lily/.build +# + +# generic variables: +# +include ./$(depth)/make/Variables.make +# + +# descent order into subdirectories: +# +SUBDIRS = include +# + +# to be remade each build: +# +VERSION_DEPENDENCY = $(lily-version) +# + +# list of c++ header files: +# +HHFILES = # $(shell ls include/*.hh) +# + +# list of c++ source files: +# +CCFILES = $(shell ls *.cc) +# + +# list of other source files: +# +EXTRA_SOURCE_FILES = $(shell ls *.y *.l) +# + +# 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 = $(LIBLILY) $(LIBFLOWER) + +LOADLIBES += +# + +# main target of this module: +# +# MAINTARGET = $(EXECUTABLE) +# MAINTARGET = $(LIBRARY) +MAINTARGET = $(bindir)/$(EXECUTABLE)# huh? +# MAINTARGET = $(libdir)/$(LIBRARY)# huh? + +default: $(MAINTARGET) +# + +# generic targets and rules: +# +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 +lexer.l: $(outdir)/parser.hh +# + +# auto dependencies: +# +-include ./$(outdir)/*.dep +# + diff --git a/src/bar-reg.cc b/lily/bar-reg.cc similarity index 100% rename from src/bar-reg.cc rename to lily/bar-reg.cc diff --git a/src/bar.cc b/lily/bar.cc similarity index 100% rename from src/bar.cc rename to lily/bar.cc diff --git a/src/beam.cc b/lily/beam.cc similarity index 100% rename from src/beam.cc rename to lily/beam.cc diff --git a/src/boxes.cc b/lily/boxes.cc similarity index 100% rename from src/boxes.cc rename to lily/boxes.cc diff --git a/src/break.cc b/lily/break.cc similarity index 100% rename from src/break.cc rename to lily/break.cc diff --git a/src/calcideal.cc b/lily/calcideal.cc similarity index 100% rename from src/calcideal.cc rename to lily/calcideal.cc diff --git a/src/clef-item.cc b/lily/clef-item.cc similarity index 100% rename from src/clef-item.cc rename to lily/clef-item.cc diff --git a/src/clef-reg.cc b/lily/clef-reg.cc similarity index 100% rename from src/clef-reg.cc rename to lily/clef-reg.cc diff --git a/src/colhpos.cc b/lily/colhpos.cc similarity index 100% rename from src/colhpos.cc rename to lily/colhpos.cc diff --git a/src/commandrequest.cc b/lily/commandrequest.cc similarity index 100% rename from src/commandrequest.cc rename to lily/commandrequest.cc diff --git a/src/complex-staff.cc b/lily/complex-staff.cc similarity index 100% rename from src/complex-staff.cc rename to lily/complex-staff.cc diff --git a/src/complex-walker.cc b/lily/complex-walker.cc similarity index 98% rename from src/complex-walker.cc rename to lily/complex-walker.cc index 9fbd0525e6..0a76c81d0e 100644 --- a/src/complex-walker.cc +++ b/lily/complex-walker.cc @@ -17,7 +17,7 @@ #include "complex-walker.hh" //#include "misc.hh" #include "commandrequest.hh" -#include "walkregs.hh" +#include "walk-regs.hh" void Complex_walker::do_post_move() diff --git a/src/debug.cc b/lily/debug.cc similarity index 100% rename from src/debug.cc rename to lily/debug.cc diff --git a/src/dimen.cc b/lily/dimen.cc similarity index 100% rename from src/dimen.cc rename to lily/dimen.cc diff --git a/src/directional-spanner.cc b/lily/directional-spanner.cc similarity index 100% rename from src/directional-spanner.cc rename to lily/directional-spanner.cc diff --git a/src/grouping.cc b/lily/grouping.cc similarity index 100% rename from src/grouping.cc rename to lily/grouping.cc diff --git a/src/groupregs.cc b/lily/groupregs.cc similarity index 100% rename from src/groupregs.cc rename to lily/groupregs.cc diff --git a/src/headreg.cc b/lily/headreg.cc similarity index 100% rename from src/headreg.cc rename to lily/headreg.cc diff --git a/src/idealspacing.cc b/lily/idealspacing.cc similarity index 100% rename from src/idealspacing.cc rename to lily/idealspacing.cc diff --git a/src/identifier.cc b/lily/identifier.cc similarity index 100% rename from src/identifier.cc rename to lily/identifier.cc diff --git a/lily/include/Makefile b/lily/include/Makefile new file mode 100644 index 0000000000..fa2827b30a --- /dev/null +++ b/lily/include/Makefile @@ -0,0 +1,23 @@ +# lily/include/Makefile + +# subdir level: +# +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/.build +# + +# generic stuff/Makefile +# +include ./$(depth)/make/Include.make +# + diff --git a/hdr/bar-reg.hh b/lily/include/bar-reg.hh similarity index 100% rename from hdr/bar-reg.hh rename to lily/include/bar-reg.hh diff --git a/hdr/bar.hh b/lily/include/bar.hh similarity index 100% rename from hdr/bar.hh rename to lily/include/bar.hh diff --git a/hdr/beam.hh b/lily/include/beam.hh similarity index 100% rename from hdr/beam.hh rename to lily/include/beam.hh diff --git a/hdr/boxes.hh b/lily/include/boxes.hh similarity index 100% rename from hdr/boxes.hh rename to lily/include/boxes.hh diff --git a/hdr/break.hh b/lily/include/break.hh similarity index 100% rename from hdr/break.hh rename to lily/include/break.hh diff --git a/hdr/class-name.hh b/lily/include/class-name.hh similarity index 100% rename from hdr/class-name.hh rename to lily/include/class-name.hh diff --git a/hdr/clef-item.hh b/lily/include/clef-item.hh similarity index 100% rename from hdr/clef-item.hh rename to lily/include/clef-item.hh diff --git a/hdr/clef-reg.hh b/lily/include/clef-reg.hh similarity index 100% rename from hdr/clef-reg.hh rename to lily/include/clef-reg.hh diff --git a/hdr/colhpos.hh b/lily/include/colhpos.hh similarity index 100% rename from hdr/colhpos.hh rename to lily/include/colhpos.hh diff --git a/hdr/commandrequest.hh b/lily/include/commandrequest.hh similarity index 100% rename from hdr/commandrequest.hh rename to lily/include/commandrequest.hh diff --git a/hdr/complex-staff.hh b/lily/include/complex-staff.hh similarity index 100% rename from hdr/complex-staff.hh rename to lily/include/complex-staff.hh diff --git a/hdr/complex-walker.hh b/lily/include/complex-walker.hh similarity index 100% rename from hdr/complex-walker.hh rename to lily/include/complex-walker.hh diff --git a/lily/include/config.hh b/lily/include/config.hh new file mode 100644 index 0000000000..ca44f294d7 --- /dev/null +++ b/lily/include/config.hh @@ -0,0 +1 @@ +#define LIBDIR "./" diff --git a/hdr/const.hh b/lily/include/const.hh similarity index 100% rename from hdr/const.hh rename to lily/include/const.hh diff --git a/hdr/dimen.hh b/lily/include/dimen.hh similarity index 100% rename from hdr/dimen.hh rename to lily/include/dimen.hh diff --git a/hdr/directional-spanner.hh b/lily/include/directional-spanner.hh similarity index 100% rename from hdr/directional-spanner.hh rename to lily/include/directional-spanner.hh diff --git a/hdr/glob.hh b/lily/include/glob.hh similarity index 100% rename from hdr/glob.hh rename to lily/include/glob.hh diff --git a/hdr/grouping.hh b/lily/include/grouping.hh similarity index 100% rename from hdr/grouping.hh rename to lily/include/grouping.hh diff --git a/lily/include/head-reg.hh b/lily/include/head-reg.hh new file mode 100644 index 0000000000..d5eb6fa5cd --- /dev/null +++ b/lily/include/head-reg.hh @@ -0,0 +1,24 @@ +/* + headreg.hh -- part of LilyPond + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef HEADREG_HH +#define HEADREG_HH +#include "register.hh" + +struct Notehead_register : Request_register { + Item* note_p_; + int dir_i_; + /* *************** */ + Notehead_register(Complex_walker*); + virtual bool try_request(Request *req_l) ; + virtual void process_request(); + virtual void do_pre_move_process(); + void set_dir(int); +}; + + +#endif // HEADREG_HH diff --git a/hdr/headreg.hh b/lily/include/headreg.hh similarity index 100% rename from hdr/headreg.hh rename to lily/include/headreg.hh diff --git a/hdr/idealspacing.hh b/lily/include/idealspacing.hh similarity index 100% rename from hdr/idealspacing.hh rename to lily/include/idealspacing.hh diff --git a/hdr/identifier.hh b/lily/include/identifier.hh similarity index 100% rename from hdr/identifier.hh rename to lily/include/identifier.hh diff --git a/hdr/identparent.hh b/lily/include/identparent.hh similarity index 100% rename from hdr/identparent.hh rename to lily/include/identparent.hh diff --git a/hdr/input-music.hh b/lily/include/input-music.hh similarity index 100% rename from hdr/input-music.hh rename to lily/include/input-music.hh diff --git a/hdr/input-score.hh b/lily/include/input-score.hh similarity index 100% rename from hdr/input-score.hh rename to lily/include/input-score.hh diff --git a/hdr/input-staff.hh b/lily/include/input-staff.hh similarity index 100% rename from hdr/input-staff.hh rename to lily/include/input-staff.hh diff --git a/hdr/item.hh b/lily/include/item.hh similarity index 100% rename from hdr/item.hh rename to lily/include/item.hh diff --git a/hdr/key-item.hh b/lily/include/key-item.hh similarity index 100% rename from hdr/key-item.hh rename to lily/include/key-item.hh diff --git a/hdr/key-reg.hh b/lily/include/key-reg.hh similarity index 100% rename from hdr/key-reg.hh rename to lily/include/key-reg.hh diff --git a/hdr/key.hh b/lily/include/key.hh similarity index 100% rename from hdr/key.hh rename to lily/include/key.hh diff --git a/hdr/keyword.hh b/lily/include/keyword.hh similarity index 100% rename from hdr/keyword.hh rename to lily/include/keyword.hh diff --git a/hdr/leastsquares.hh b/lily/include/leastsquares.hh similarity index 100% rename from hdr/leastsquares.hh rename to lily/include/leastsquares.hh diff --git a/hdr/lexer.hh b/lily/include/lexer.hh similarity index 100% rename from hdr/lexer.hh rename to lily/include/lexer.hh diff --git a/hdr/linespace.hh b/lily/include/linespace.hh similarity index 100% rename from hdr/linespace.hh rename to lily/include/linespace.hh diff --git a/hdr/local-key-item.hh b/lily/include/local-key-item.hh similarity index 100% rename from hdr/local-key-item.hh rename to lily/include/local-key-item.hh diff --git a/hdr/local-key-reg.hh b/lily/include/local-key-reg.hh similarity index 100% rename from hdr/local-key-reg.hh rename to lily/include/local-key-reg.hh diff --git a/hdr/lookup.hh b/lily/include/lookup.hh similarity index 100% rename from hdr/lookup.hh rename to lily/include/lookup.hh diff --git a/hdr/main.hh b/lily/include/main.hh similarity index 92% rename from hdr/main.hh rename to lily/include/main.hh index 4a4a85e786..fe4f9ad8c2 100644 --- a/hdr/main.hh +++ b/lily/include/main.hh @@ -10,6 +10,7 @@ void set_default_output(String s); Input_score* current_iscore_l(); String find_file(String); const char *get_version(); +extern String infile_str_g; extern Source* source_l_g; extern bool only_midi; diff --git a/hdr/meter-reg.hh b/lily/include/meter-reg.hh similarity index 100% rename from hdr/meter-reg.hh rename to lily/include/meter-reg.hh diff --git a/hdr/meter.hh b/lily/include/meter.hh similarity index 100% rename from hdr/meter.hh rename to lily/include/meter.hh diff --git a/hdr/midi-output.hh b/lily/include/midi-output.hh similarity index 70% rename from hdr/midi-output.hh rename to lily/include/midi-output.hh index a590f5a790..19457172cd 100644 --- a/hdr/midi-output.hh +++ b/lily/include/midi-output.hh @@ -1,5 +1,5 @@ /* - midi-output.hh -- declare Midi_output + midioutput.hh -- declare Midi_output source file of the LilyPond music typesetter @@ -12,10 +12,16 @@ #include "pscore.hh" struct Midi_output { - Midi_stream* midi_stream_l_; Midi_output(Score* score_l, Midi_def* ); + void do_staff(Staff*st_l, int count); + void header(); + void staffs(); + Score* score_l_; Midi_def* midi_l_; + Midi_stream* midi_stream_l_; }; + #endif // MIDIOUTPUT_HH + diff --git a/hdr/misc.hh b/lily/include/misc.hh similarity index 100% rename from hdr/misc.hh rename to lily/include/misc.hh diff --git a/hdr/molecule.hh b/lily/include/molecule.hh similarity index 100% rename from hdr/molecule.hh rename to lily/include/molecule.hh diff --git a/hdr/musicalrequest.hh b/lily/include/musicalrequest.hh similarity index 100% rename from hdr/musicalrequest.hh rename to lily/include/musicalrequest.hh diff --git a/hdr/notehead.hh b/lily/include/notehead.hh similarity index 100% rename from hdr/notehead.hh rename to lily/include/notehead.hh diff --git a/hdr/notename.hh b/lily/include/notename.hh similarity index 100% rename from hdr/notename.hh rename to lily/include/notename.hh diff --git a/hdr/offset.hh b/lily/include/offset.hh similarity index 100% rename from hdr/offset.hh rename to lily/include/offset.hh diff --git a/hdr/pstaff.hh b/lily/include/p-staff.hh similarity index 100% rename from hdr/pstaff.hh rename to lily/include/p-staff.hh diff --git a/hdr/paper-def.hh b/lily/include/paper-def.hh similarity index 100% rename from hdr/paper-def.hh rename to lily/include/paper-def.hh diff --git a/hdr/parseconstruct.hh b/lily/include/parseconstruct.hh similarity index 100% rename from hdr/parseconstruct.hh rename to lily/include/parseconstruct.hh diff --git a/lily/include/parser.hh b/lily/include/parser.hh new file mode 100644 index 0000000000..3a3d4de3ef --- /dev/null +++ b/lily/include/parser.hh @@ -0,0 +1,86 @@ +typedef union { + Request * request; + Real real; + Identifier *id; + Voice *voice; + Voice_element *el; + String *string; + const char *consstr; + Paper_def *paper; + Midi_def* midi; + Input_music *music; + Music_general_chord *chord; + Music_voice *mvoice; + int i; + char c; + int ii[10]; + Moment *moment; + + Array * strvec; + Array *intvec; + Array *melreqvec; + Input_staff *staff; + Input_score *score; + Symtables * symtables; + Symtable * symtable; + Symbol * symbol; + Lookup*lookup; + Interval *interval; + Box *box; + Notename_tab *notename_tab; + Script_def * script; + Text_def * textdef; +} YYSTYPE; +#define VOICE 258 +#define STAFF 259 +#define SCORE 260 +#define TITLE 261 +#define BAR 262 +#define OUTPUT 263 +#define MULTIVOICE 264 +#define CM_T 265 +#define IN_T 266 +#define PT_T 267 +#define MM_T 268 +#define PAPER 269 +#define WIDTH 270 +#define METER 271 +#define UNITSPACE 272 +#define SKIP 273 +#define COMMANDS 274 +#define COMMAND 275 +#define GEOMETRIC 276 +#define START_T 277 +#define DURATIONCOMMAND 278 +#define OCTAVECOMMAND 279 +#define KEY 280 +#define CLEF 281 +#define TABLE 282 +#define VOICES 283 +#define STEM 284 +#define PARTIAL 285 +#define MUSIC 286 +#define GROUPING 287 +#define CADENZA 288 +#define END 289 +#define SYMBOLTABLES 290 +#define TEXID 291 +#define NOTENAMES 292 +#define SCRIPT 293 +#define TEXTSTYLE 294 +#define PLET 295 +#define GOTO 296 +#define MIDI 297 +#define TEMPO 298 +#define IDENTIFIER 299 +#define PITCHMOD 300 +#define DURATION 301 +#define RESTNAME 302 +#define NOTENAME 303 +#define REAL 304 +#define STRING 305 +#define DOTS 306 +#define INT 307 + + +extern YYSTYPE yylval; diff --git a/hdr/pcol.hh b/lily/include/pcol.hh similarity index 100% rename from hdr/pcol.hh rename to lily/include/pcol.hh diff --git a/hdr/pscore.hh b/lily/include/pscore.hh similarity index 100% rename from hdr/pscore.hh rename to lily/include/pscore.hh diff --git a/lily/include/pstaff.hh b/lily/include/pstaff.hh new file mode 100644 index 0000000000..50a7f0c719 --- /dev/null +++ b/lily/include/pstaff.hh @@ -0,0 +1,25 @@ +#ifndef PSTAFF_HH +#define PSTAFF_HH + +#include "proto.hh" +#include "plist.hh" +#include "item.hh" +#include "symbol.hh" + +/// items grouped horizontally +struct PStaff { + PScore * pscore_l_; + + + PointerList spans; + PointerList its; + + /* *************** */ + void add(Item*i); + PStaff(PScore*); + +private: + PStaff(PStaff const&); +}; + +#endif diff --git a/hdr/qlp.hh b/lily/include/qlp.hh similarity index 100% rename from hdr/qlp.hh rename to lily/include/qlp.hh diff --git a/hdr/qlpsolve.hh b/lily/include/qlpsolve.hh similarity index 100% rename from hdr/qlpsolve.hh rename to lily/include/qlpsolve.hh diff --git a/hdr/register.hh b/lily/include/register.hh similarity index 100% rename from hdr/register.hh rename to lily/include/register.hh diff --git a/hdr/registergroup.hh b/lily/include/registergroup.hh similarity index 100% rename from hdr/registergroup.hh rename to lily/include/registergroup.hh diff --git a/hdr/reqtodo.hh b/lily/include/reqtodo.hh similarity index 100% rename from hdr/reqtodo.hh rename to lily/include/reqtodo.hh diff --git a/hdr/request.hh b/lily/include/request.hh similarity index 100% rename from hdr/request.hh rename to lily/include/request.hh diff --git a/hdr/rest.hh b/lily/include/rest.hh similarity index 100% rename from hdr/rest.hh rename to lily/include/rest.hh diff --git a/hdr/score-column.hh b/lily/include/score-column.hh similarity index 100% rename from hdr/score-column.hh rename to lily/include/score-column.hh diff --git a/hdr/score-walker.hh b/lily/include/score-walker.hh similarity index 100% rename from hdr/score-walker.hh rename to lily/include/score-walker.hh diff --git a/hdr/score.hh b/lily/include/score.hh similarity index 100% rename from hdr/score.hh rename to lily/include/score.hh diff --git a/hdr/scoreline.hh b/lily/include/scoreline.hh similarity index 100% rename from hdr/scoreline.hh rename to lily/include/scoreline.hh diff --git a/hdr/script-def.hh b/lily/include/script-def.hh similarity index 100% rename from hdr/script-def.hh rename to lily/include/script-def.hh diff --git a/hdr/script-reg.hh b/lily/include/script-reg.hh similarity index 100% rename from hdr/script-reg.hh rename to lily/include/script-reg.hh diff --git a/hdr/script.hh b/lily/include/script.hh similarity index 100% rename from hdr/script.hh rename to lily/include/script.hh diff --git a/hdr/slur-reg.hh b/lily/include/slur-reg.hh similarity index 100% rename from hdr/slur-reg.hh rename to lily/include/slur-reg.hh diff --git a/hdr/slur.hh b/lily/include/slur.hh similarity index 100% rename from hdr/slur.hh rename to lily/include/slur.hh diff --git a/hdr/spanner.hh b/lily/include/spanner.hh similarity index 100% rename from hdr/spanner.hh rename to lily/include/spanner.hh diff --git a/hdr/staff-column.hh b/lily/include/staff-column.hh similarity index 100% rename from hdr/staff-column.hh rename to lily/include/staff-column.hh diff --git a/hdr/staff-elem-info.hh b/lily/include/staff-elem-info.hh similarity index 100% rename from hdr/staff-elem-info.hh rename to lily/include/staff-elem-info.hh diff --git a/hdr/staff-elem.hh b/lily/include/staff-elem.hh similarity index 100% rename from hdr/staff-elem.hh rename to lily/include/staff-elem.hh diff --git a/hdr/staff-walker.hh b/lily/include/staff-walker.hh similarity index 100% rename from hdr/staff-walker.hh rename to lily/include/staff-walker.hh diff --git a/hdr/staff.hh b/lily/include/staff.hh similarity index 100% rename from hdr/staff.hh rename to lily/include/staff.hh diff --git a/lily/include/staffelem.hh b/lily/include/staffelem.hh new file mode 100644 index 0000000000..3928c994e9 --- /dev/null +++ b/lily/include/staffelem.hh @@ -0,0 +1,84 @@ +/* + 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 new file mode 100644 index 0000000000..b8af8aeb22 --- /dev/null +++ b/lily/include/staffeleminfo.hh @@ -0,0 +1,28 @@ +/* + staffeleminfo.hh -- declare Staff_elem_info + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef STAFFELEMINFO_HH +#define STAFFELEMINFO_HH + +#include "proto.hh" + +/// data container. +struct Staff_elem_info { + Staff_elem * elem_p_; + Request*req_l_; + const Voice * voice_l_; + Voice_group_registers * group_regs_l_; + Request_register * origin_reg_l_; + + /* *** */ + Staff_elem_info(Staff_elem*, Request*, Request_register*); + Staff_elem_info(); +}; + +#endif // STAFFELEMINFO_HH diff --git a/hdr/staffline.hh b/lily/include/staffline.hh similarity index 100% rename from hdr/staffline.hh rename to lily/include/staffline.hh diff --git a/hdr/staffsym.hh b/lily/include/staffsym.hh similarity index 100% rename from hdr/staffsym.hh rename to lily/include/staffsym.hh diff --git a/hdr/stem-beam-reg.hh b/lily/include/stem-beam-reg.hh similarity index 100% rename from hdr/stem-beam-reg.hh rename to lily/include/stem-beam-reg.hh diff --git a/hdr/stem.hh b/lily/include/stem.hh similarity index 100% rename from hdr/stem.hh rename to lily/include/stem.hh diff --git a/hdr/symbol.hh b/lily/include/symbol.hh similarity index 100% rename from hdr/symbol.hh rename to lily/include/symbol.hh diff --git a/hdr/symtable.hh b/lily/include/symtable.hh similarity index 100% rename from hdr/symtable.hh rename to lily/include/symtable.hh diff --git a/hdr/tex-stream.hh b/lily/include/tex-stream.hh similarity index 100% rename from hdr/tex-stream.hh rename to lily/include/tex-stream.hh diff --git a/hdr/tex.hh b/lily/include/tex.hh similarity index 100% rename from hdr/tex.hh rename to lily/include/tex.hh diff --git a/hdr/text-def.hh b/lily/include/text-def.hh similarity index 100% rename from hdr/text-def.hh rename to lily/include/text-def.hh diff --git a/hdr/textitem.hh b/lily/include/text-item.hh similarity index 100% rename from hdr/textitem.hh rename to lily/include/text-item.hh diff --git a/hdr/text-reg.hh b/lily/include/text-reg.hh similarity index 100% rename from hdr/text-reg.hh rename to lily/include/text-reg.hh diff --git a/hdr/textspanner.hh b/lily/include/text-spanner.hh similarity index 100% rename from hdr/textspanner.hh rename to lily/include/text-spanner.hh diff --git a/hdr/time-description.hh b/lily/include/time-description.hh similarity index 100% rename from hdr/time-description.hh rename to lily/include/time-description.hh diff --git a/hdr/voice-element.hh b/lily/include/voice-element.hh similarity index 100% rename from hdr/voice-element.hh rename to lily/include/voice-element.hh diff --git a/hdr/voice-group-regs.hh b/lily/include/voice-group-regs.hh similarity index 100% rename from hdr/voice-group-regs.hh rename to lily/include/voice-group-regs.hh diff --git a/hdr/voice-regs.hh b/lily/include/voice-regs.hh similarity index 100% rename from hdr/voice-regs.hh rename to lily/include/voice-regs.hh diff --git a/hdr/voice.hh b/lily/include/voice.hh similarity index 100% rename from hdr/voice.hh rename to lily/include/voice.hh diff --git a/hdr/walkregs.hh b/lily/include/walk-regs.hh similarity index 100% rename from hdr/walkregs.hh rename to lily/include/walk-regs.hh diff --git a/src/input-music.cc b/lily/input-music.cc similarity index 100% rename from src/input-music.cc rename to lily/input-music.cc diff --git a/src/input-score.cc b/lily/input-score.cc similarity index 100% rename from src/input-score.cc rename to lily/input-score.cc diff --git a/src/input-staff.cc b/lily/input-staff.cc similarity index 98% rename from src/input-staff.cc rename to lily/input-staff.cc index 9e3958e97e..8305a094a9 100644 --- a/src/input-staff.cc +++ b/lily/input-staff.cc @@ -12,7 +12,7 @@ #include "input-staff.hh" #include "staff.hh" #include "complex-staff.hh" -#include "lyricstaff.hh" +#include "lyric-staff.hh" #include "lexer.hh" diff --git a/src/item.cc b/lily/item.cc similarity index 100% rename from src/item.cc rename to lily/item.cc diff --git a/src/key-item.cc b/lily/key-item.cc similarity index 100% rename from src/key-item.cc rename to lily/key-item.cc diff --git a/src/key-reg.cc b/lily/key-reg.cc similarity index 100% rename from src/key-reg.cc rename to lily/key-reg.cc diff --git a/src/key.cc b/lily/key.cc similarity index 100% rename from src/key.cc rename to lily/key.cc diff --git a/src/keyword.cc b/lily/keyword.cc similarity index 100% rename from src/keyword.cc rename to lily/keyword.cc diff --git a/src/leastsquares.cc b/lily/leastsquares.cc similarity index 100% rename from src/leastsquares.cc rename to lily/leastsquares.cc diff --git a/src/lexer.l b/lily/lexer.l similarity index 100% rename from src/lexer.l rename to lily/lexer.l index 3f86adcd54..6f5945a605 100644 --- a/src/lexer.l +++ b/lily/lexer.l @@ -3,6 +3,7 @@ #include #include "string.hh" +#include "string-convert.hh" #include "notename.hh" #include "lexer.hh" #include "varray.hh" @@ -11,7 +12,6 @@ #include "input-score.hh" #include "parseconstruct.hh" #include "main.hh" -#include "string-convert.hh" %} diff --git a/src/lexerinit.cc b/lily/lexerinit.cc similarity index 100% rename from src/lexerinit.cc rename to lily/lexerinit.cc diff --git a/src/linespace.cc b/lily/linespace.cc similarity index 100% rename from src/linespace.cc rename to lily/linespace.cc diff --git a/src/local-key-item.cc b/lily/local-key-item.cc similarity index 100% rename from src/local-key-item.cc rename to lily/local-key-item.cc diff --git a/src/local-key-reg.cc b/lily/local-key-reg.cc similarity index 97% rename from src/local-key-reg.cc rename to lily/local-key-reg.cc index b71f14e920..f13ec98b9f 100644 --- a/src/local-key-reg.cc +++ b/lily/local-key-reg.cc @@ -63,7 +63,7 @@ Local_key_register::process_requests() if (! time_c_l_->whole_in_measure_){ if (key_c_l_) local_key_.reset(*key_c_l_); - else if( time_c_l_->when_ >0) + else if( time_c_l_->when_ >Moment(0)) warning ("Help me! can't figure current key", 0); } } diff --git a/src/lookup.cc b/lily/lookup.cc similarity index 100% rename from src/lookup.cc rename to lily/lookup.cc diff --git a/src/lyric-item.cc b/lily/lyric-item.cc similarity index 100% rename from src/lyric-item.cc rename to lily/lyric-item.cc diff --git a/src/lyricstaff.cc b/lily/lyric-staff.cc similarity index 87% rename from src/lyricstaff.cc rename to lily/lyric-staff.cc index abefcd2048..8414f4ecaf 100644 --- a/src/lyricstaff.cc +++ b/lily/lyric-staff.cc @@ -3,8 +3,8 @@ #include "staff-walker.hh" #include "debug.hh" #include "staff.hh" -#include "lyricstaff.hh" -#include "lyricwalker.hh" +#include "lyric-staff.hh" +#include "lyric-walker.hh" #include "pscore.hh" void diff --git a/src/main.cc b/lily/main.cc similarity index 98% rename from src/main.cc rename to lily/main.cc index 058db492d9..1073f940bf 100644 --- a/src/main.cc +++ b/lily/main.cc @@ -13,6 +13,7 @@ Source source; Source* source_l_g = &source; +String infile_str_g; bool only_midi = false; extern void parse_file(String,String); @@ -127,6 +128,7 @@ main (int argc, char **argv) while ( (arg= oparser.get_next_arg()) ) { String f(arg); destill_inname(f); + infile_str_g = f; parse_file(init_str,f); do_scores(); p++; diff --git a/src/meter-reg.cc b/lily/meter-reg.cc similarity index 100% rename from src/meter-reg.cc rename to lily/meter-reg.cc diff --git a/src/meter.cc b/lily/meter.cc similarity index 100% rename from src/meter.cc rename to lily/meter.cc diff --git a/src/misc.cc b/lily/misc.cc similarity index 100% rename from src/misc.cc rename to lily/misc.cc diff --git a/src/molecule.cc b/lily/molecule.cc similarity index 100% rename from src/molecule.cc rename to lily/molecule.cc diff --git a/src/mylexer.cc b/lily/mylexer.cc similarity index 100% rename from src/mylexer.cc rename to lily/mylexer.cc diff --git a/src/note.cc b/lily/note.cc similarity index 100% rename from src/note.cc rename to lily/note.cc diff --git a/src/notehead.cc b/lily/notehead.cc similarity index 100% rename from src/notehead.cc rename to lily/notehead.cc diff --git a/src/notename.cc b/lily/notename.cc similarity index 100% rename from src/notename.cc rename to lily/notename.cc diff --git a/src/paper-def.cc b/lily/paper-def.cc similarity index 100% rename from src/paper-def.cc rename to lily/paper-def.cc diff --git a/src/parser.y b/lily/parser.y similarity index 99% rename from src/parser.y rename to lily/parser.y index 08ea828119..ba9703e4b8 100644 --- a/src/parser.y +++ b/lily/parser.y @@ -796,19 +796,15 @@ parse_file(String init, String s) *mlog << "Parsing ... "; lexer = new My_flex_lexer; -#ifndef NDEBUG +#ifdef YYDEBUG yydebug = !monitor->silence("InitParser") && check_debug; lexer->set_debug( !monitor->silence("InitLexer") && check_debug); #endif lexer->new_input(init); - yyparse(); -#ifndef NDEBUG - if (check_debug && !monitor->silence("InitDeclarations")) - lexer->print_declarations(); - +#ifdef YYDEBUG yydebug = !monitor->silence("Parser") && check_debug; lexer->set_debug( !monitor->silence("Lexer") && check_debug); #endif diff --git a/src/pcol.cc b/lily/pcol.cc similarity index 100% rename from src/pcol.cc rename to lily/pcol.cc diff --git a/src/pscore.cc b/lily/pscore.cc similarity index 99% rename from src/pscore.cc rename to lily/pscore.cc index 73e57ce6f2..1f4a8b68c8 100644 --- a/src/pscore.cc +++ b/lily/pscore.cc @@ -28,7 +28,7 @@ PScore::clean_cols() { for (iter_top(cols,c); c.ok(); ) if (!c->used_b()) { - delete c.get_p(); + delete c.remove_p(); } else c++; } diff --git a/src/pstaff.cc b/lily/pstaff.cc similarity index 100% rename from src/pstaff.cc rename to lily/pstaff.cc diff --git a/src/qlp.cc b/lily/qlp.cc similarity index 100% rename from src/qlp.cc rename to lily/qlp.cc diff --git a/src/qlpsolve.cc b/lily/qlpsolve.cc similarity index 100% rename from src/qlpsolve.cc rename to lily/qlpsolve.cc diff --git a/src/register.cc b/lily/register.cc similarity index 100% rename from src/register.cc rename to lily/register.cc diff --git a/src/registergroup.cc b/lily/registergroup.cc similarity index 96% rename from src/registergroup.cc rename to lily/registergroup.cc index 87652e5e54..a94f14560a 100644 --- a/src/registergroup.cc +++ b/lily/registergroup.cc @@ -6,6 +6,8 @@ (c) 1997 Han-Wen Nienhuys */ +#include "proto.hh" +#include "plist.hh" #include "registergroup.hh" #include "register.hh" @@ -100,7 +102,7 @@ Register_group_register::get_register_p(Request_register*reg_l) { iterator(reg_list_) reg_cur= reg_list_.find(reg_l); assert(reg_cur.ok()); - return reg_cur.get_p(); + return reg_cur.remove_p(); } void diff --git a/src/request.cc b/lily/request.cc similarity index 100% rename from src/request.cc rename to lily/request.cc diff --git a/src/rest.cc b/lily/rest.cc similarity index 100% rename from src/rest.cc rename to lily/rest.cc diff --git a/src/score-column.cc b/lily/score-column.cc similarity index 100% rename from src/score-column.cc rename to lily/score-column.cc diff --git a/src/score-walker.cc b/lily/score-walker.cc similarity index 99% rename from src/score-walker.cc rename to lily/score-walker.cc index a780b05ff6..d011c331ad 100644 --- a/src/score-walker.cc +++ b/lily/score-walker.cc @@ -5,8 +5,9 @@ (c) 1997 Han-Wen Nienhuys */ -#include "debug.hh" +#include "proto.hh" #include "plist.hh" +#include "debug.hh" #include "score-walker.hh" #include "score.hh" #include "staff-walker.hh" diff --git a/src/score.cc b/lily/score.cc similarity index 99% rename from src/score.cc rename to lily/score.cc index 0dd16ecbf7..88e2e2f07b 100644 --- a/src/score.cc +++ b/lily/score.cc @@ -96,7 +96,7 @@ Score::clean_cols() for (iter_top(cols_,c); c.ok(); ) { if (!c->pcol_l_->used_b()) { - delete c.get_p(); + delete c.remove_p(); } else { c->preprocess(); c++; diff --git a/src/scoreline.cc b/lily/scoreline.cc similarity index 100% rename from src/scoreline.cc rename to lily/scoreline.cc diff --git a/src/scores.cc b/lily/scores.cc similarity index 100% rename from src/scores.cc rename to lily/scores.cc diff --git a/src/script-def.cc b/lily/script-def.cc similarity index 100% rename from src/script-def.cc rename to lily/script-def.cc diff --git a/src/script-reg.cc b/lily/script-reg.cc similarity index 100% rename from src/script-reg.cc rename to lily/script-reg.cc diff --git a/src/script.cc b/lily/script.cc similarity index 100% rename from src/script.cc rename to lily/script.cc diff --git a/src/slur-reg.cc b/lily/slur-reg.cc similarity index 99% rename from src/slur-reg.cc rename to lily/slur-reg.cc index 15a9af8eaa..f2b7113ca0 100644 --- a/src/slur-reg.cc +++ b/lily/slur-reg.cc @@ -4,6 +4,7 @@ (c) 1997 Han-Wen Nienhuys */ +#include "proto.hh" #include "plist.hh" #include "musicalrequest.hh" #include "complex-walker.hh" diff --git a/src/slur.cc b/lily/slur.cc similarity index 100% rename from src/slur.cc rename to lily/slur.cc diff --git a/src/spanner.cc b/lily/spanner.cc similarity index 100% rename from src/spanner.cc rename to lily/spanner.cc diff --git a/src/staff-column.cc b/lily/staff-column.cc similarity index 98% rename from src/staff-column.cc rename to lily/staff-column.cc index 546a2a66e1..0dd969ab0a 100644 --- a/src/staff-column.cc +++ b/lily/staff-column.cc @@ -5,6 +5,8 @@ (c) 1997 Han-Wen Nienhuys */ +#include "proto.hh" +#include "plist.hh" #include "staff.hh" #include "voice.hh" #include "time-description.hh" diff --git a/src/staff-elem-info.cc b/lily/staff-elem-info.cc similarity index 100% rename from src/staff-elem-info.cc rename to lily/staff-elem-info.cc diff --git a/src/staff-elem.cc b/lily/staff-elem.cc similarity index 100% rename from src/staff-elem.cc rename to lily/staff-elem.cc diff --git a/src/staff-walker.cc b/lily/staff-walker.cc similarity index 97% rename from src/staff-walker.cc rename to lily/staff-walker.cc index a383d351b3..74c18f3b18 100644 --- a/src/staff-walker.cc +++ b/lily/staff-walker.cc @@ -6,6 +6,8 @@ (c) 1997 Han-Wen Nienhuys */ +#include "proto.hh" +#include "plist.hh" #include "grouping.hh" #include "staff.hh" #include "musicalrequest.hh" @@ -88,7 +90,7 @@ Staff_walker::operator++(int i) PCursor::operator++(i); if (ok() ) { Moment delta_t = when() - last; - assert(delta_t >0); + assert(delta_t >Moment(0)); time_.add( delta_t ); } do_post_move(); diff --git a/src/staff.cc b/lily/staff.cc similarity index 97% rename from src/staff.cc rename to lily/staff.cc index 4f72617f5e..a3ad17d076 100644 --- a/src/staff.cc +++ b/lily/staff.cc @@ -1,3 +1,5 @@ +#include "proto.hh" +#include "plist.hh" #include "staff.hh" #include "score.hh" #include "voice.hh" @@ -34,7 +36,7 @@ Staff::clean_cols() i->command_column_l_ =0; if (!i->command_column_l_&& !i->musical_column_l_) - delete i.get_p(); + delete i.remove_p(); else i++; } diff --git a/src/staffline.cc b/lily/staffline.cc similarity index 100% rename from src/staffline.cc rename to lily/staffline.cc diff --git a/src/staffsym.cc b/lily/staffsym.cc similarity index 100% rename from src/staffsym.cc rename to lily/staffsym.cc diff --git a/src/stem-beam-reg.cc b/lily/stem-beam-reg.cc similarity index 99% rename from src/stem-beam-reg.cc rename to lily/stem-beam-reg.cc index f08b02f424..54579d337d 100644 --- a/src/stem-beam-reg.cc +++ b/lily/stem-beam-reg.cc @@ -9,7 +9,7 @@ #include "beam.hh" #include "stem.hh" #include "grouping.hh" -#include "textspanner.hh" +#include "text-spanner.hh" #include "complex-walker.hh" #include "complex-staff.hh" #include "debug.hh" diff --git a/src/stem.cc b/lily/stem.cc similarity index 100% rename from src/stem.cc rename to lily/stem.cc diff --git a/src/symbol.cc b/lily/symbol.cc similarity index 100% rename from src/symbol.cc rename to lily/symbol.cc diff --git a/src/symtable.cc b/lily/symtable.cc similarity index 100% rename from src/symtable.cc rename to lily/symtable.cc diff --git a/src/template1.cc b/lily/template1.cc similarity index 96% rename from src/template1.cc rename to lily/template1.cc index 283a488b1a..5aa1906af6 100644 --- a/src/template1.cc +++ b/lily/template1.cc @@ -1,3 +1,4 @@ +#include "proto.hh" #include "idealspacing.hh" #include "plist.hh" #include "pcol.hh" diff --git a/src/template2.cc b/lily/template2.cc similarity index 100% rename from src/template2.cc rename to lily/template2.cc diff --git a/src/template3.cc b/lily/template3.cc similarity index 100% rename from src/template3.cc rename to lily/template3.cc diff --git a/src/template4.cc b/lily/template4.cc similarity index 100% rename from src/template4.cc rename to lily/template4.cc diff --git a/src/template5.cc b/lily/template5.cc similarity index 100% rename from src/template5.cc rename to lily/template5.cc diff --git a/src/template6.cc b/lily/template6.cc similarity index 100% rename from src/template6.cc rename to lily/template6.cc diff --git a/src/texbeam.cc b/lily/tex-beam.cc similarity index 100% rename from src/texbeam.cc rename to lily/tex-beam.cc diff --git a/src/texslur.cc b/lily/tex-slur.cc similarity index 100% rename from src/texslur.cc rename to lily/tex-slur.cc diff --git a/src/tex-stream.cc b/lily/tex-stream.cc similarity index 95% rename from src/tex-stream.cc rename to lily/tex-stream.cc index 5722599b31..06459a2d72 100644 --- a/src/tex-stream.cc +++ b/lily/tex-stream.cc @@ -30,6 +30,7 @@ Tex_stream::header() *os << "% Automatically generated, at "; time_t t(time(0)); *os << ctime(&t); + *os << "% from musical definition: " + infile_str_g + "\n"; } Tex_stream::~Tex_stream() { diff --git a/src/tex.cc b/lily/tex.cc similarity index 100% rename from src/tex.cc rename to lily/tex.cc diff --git a/src/text-def.cc b/lily/text-def.cc similarity index 100% rename from src/text-def.cc rename to lily/text-def.cc diff --git a/src/textitem.cc b/lily/text-item.cc similarity index 97% rename from src/textitem.cc rename to lily/text-item.cc index ed943f52a2..7cdab7c71f 100644 --- a/src/textitem.cc +++ b/lily/text-item.cc @@ -9,7 +9,7 @@ #include "musicalrequest.hh" #include "paper-def.hh" -#include "textitem.hh" +#include "text-item.hh" #include "stem.hh" #include "molecule.hh" #include "lookup.hh" diff --git a/src/text-reg.cc b/lily/text-reg.cc similarity index 97% rename from src/text-reg.cc rename to lily/text-reg.cc index 5232549a14..5461b83368 100644 --- a/src/text-reg.cc +++ b/lily/text-reg.cc @@ -6,7 +6,7 @@ #include "musicalrequest.hh" #include "text-reg.hh" -#include "textitem.hh" +#include "text-item.hh" Text_register::Text_register() { diff --git a/src/textspanner.cc b/lily/text-spanner.cc similarity index 97% rename from src/textspanner.cc rename to lily/text-spanner.cc index 8a648232f6..3f231223d8 100644 --- a/src/textspanner.cc +++ b/lily/text-spanner.cc @@ -1,6 +1,6 @@ #include "molecule.hh" #include "boxes.hh" -#include "textspanner.hh" +#include "text-spanner.hh" #include "text-def.hh" #include "debug.hh" #include "paper-def.hh" diff --git a/src/time-description.cc b/lily/time-description.cc similarity index 98% rename from src/time-description.cc rename to lily/time-description.cc index a7b04bafae..cdc0071a92 100644 --- a/src/time-description.cc +++ b/lily/time-description.cc @@ -36,7 +36,7 @@ Time_description::OK() const #ifndef NDEBUG if (!cadenza_b_) assert(whole_in_measure_ < whole_per_measure_); - assert(0 <= whole_in_measure_); + assert(Moment(0) <= whole_in_measure_); assert(one_beat_); #endif } diff --git a/src/version.cc b/lily/version.cc similarity index 100% rename from src/version.cc rename to lily/version.cc diff --git a/src/voiceelt.cc b/lily/voice-elt.cc similarity index 98% rename from src/voiceelt.cc rename to lily/voice-elt.cc index 501ffbc89b..90060ec43c 100644 --- a/src/voiceelt.cc +++ b/lily/voice-elt.cc @@ -6,6 +6,8 @@ (c) 1997 Han-Wen Nienhuys */ +#include "proto.hh" +#include "plist.hh" #include "debug.hh" #include "voice.hh" #include "voice-element.hh" diff --git a/src/voice-group-regs.cc b/lily/voice-group-regs.cc similarity index 98% rename from src/voice-group-regs.cc rename to lily/voice-group-regs.cc index a5a5c3735b..430b0cf33f 100644 --- a/src/voice-group-regs.cc +++ b/lily/voice-group-regs.cc @@ -6,6 +6,7 @@ (c) 1997 Han-Wen Nienhuys */ +#include "proto.hh" #include "plist.hh" #include "musicalrequest.hh" #include "voice-regs.hh" diff --git a/src/voice-regs.cc b/lily/voice-regs.cc similarity index 95% rename from src/voice-regs.cc rename to lily/voice-regs.cc index 1f61617007..5cf14d1a01 100644 --- a/src/voice-regs.cc +++ b/lily/voice-regs.cc @@ -5,13 +5,15 @@ (c) 1997 Han-Wen Nienhuys */ +#include "proto.hh" +#include "plist.hh" #include "commandrequest.hh" #include "musicalrequest.hh" #include "voice-regs.hh" #include "register.hh" #include "slur-reg.hh" #include "headreg.hh" -#include "walkregs.hh" +#include "walk-regs.hh" #include "debug.hh" Voice_registers::Voice_registers(Voice *v_p) diff --git a/src/voice.cc b/lily/voice.cc similarity index 97% rename from src/voice.cc rename to lily/voice.cc index 6301f29945..810a15dd36 100644 --- a/src/voice.cc +++ b/lily/voice.cc @@ -6,6 +6,8 @@ (c) 1997 Han-Wen Nienhuys */ +#include "proto.hh" +#include "plist.hh" #include "debug.hh" #include "voice.hh" #include "musicalrequest.hh" diff --git a/src/walkregs.cc b/lily/walk-regs.cc similarity index 99% rename from src/walkregs.cc rename to lily/walk-regs.cc index cf88c06c73..0c40802501 100644 --- a/src/walkregs.cc +++ b/lily/walk-regs.cc @@ -13,7 +13,7 @@ #include "meter-reg.hh" #include "bar-reg.hh" #include "bar.hh" -#include "walkregs.hh" +#include "walk-regs.hh" #include "staff-elem.hh" #include "staff.hh" #include "complex-walker.hh" diff --git a/src/warn.cc b/lily/warn.cc similarity index 100% rename from src/warn.cc rename to lily/warn.cc index b1a0357942..ad548c6f58 100644 --- a/src/warn.cc +++ b/lily/warn.cc @@ -1,9 +1,9 @@ +#include "proto.hh" +#include "plist.hh" #include "debug.hh" #include "lexer.hh" #include "moment.hh" #include "time-description.hh" -#include "proto.hh" -#include "plist.hh" #include "source-file.hh" #include "source.hh" #include "main.hh" diff --git a/src/wordwrap.cc b/lily/wordwrap.cc similarity index 100% rename from src/wordwrap.cc rename to lily/wordwrap.cc diff --git a/m2m/.version b/m2m/.version new file mode 100644 index 0000000000..d04b0e030a --- /dev/null +++ b/m2m/.version @@ -0,0 +1,7 @@ +# not currently used +MAJOR_VERSION = 0 +MINOR_VERSION = 0 +PATCH_LEVEL = 1 +# use to send patches, always empty for released version: +MY_PATCH_LEVEL = # +# diff --git a/m2m/Makefile b/m2m/Makefile new file mode 100644 index 0000000000..789bf17a2e --- /dev/null +++ b/m2m/Makefile @@ -0,0 +1,99 @@ +# +# project LilyPond -- the musical typesetter +# title makefile for m2m +# file m2m/Makefile +# +# Copyright (c) 1997 by +# Jan Nieuwenhuizen +# Han-Wen Nienhuys +# + +# subdir level: +# +depth = .. +# + +# identify module: +# +NAME = m2m +MODULE_NAME = m2m +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) +# include ./$(depth)/m2m/.version +build = ./$(depth)/lily/.build +# + +# generic variables: +# +include ./$(depth)/make/Variables.make +# + +# descent order into subdirectories: +# +SUBDIRS = include +# + +# to be remade each build: +# +VERSION_DEPENDENCY = $(lily-version) +# + +# list of c++ header files: +# +HHFILES = # $(shell ls include/*.hh) +# + +# list of c++ source files: +# +CCFILES = $(shell ls *.cc) +# + +# list of other source files: +# +EXTRA_SOURCE_FILES = $(shell ls *.y *.l) +# + +# list of distribution files: +# +DISTFILES = Makefile .version $(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 = $(LIBLILY) $(LIBFLOWER) + +LOADLIBES += +# + +# main target of this module: +# +# MAINTARGET = $(EXECUTABLE) +# MAINTARGET = $(LIBRARY) +MAINTARGET = $(bindir)/$(EXECUTABLE)# huh? +# MAINTARGET = $(libdir)/$(LIBRARY)# huh? + +default: $(MAINTARGET) +# + +# generic targets and rules: +# +include ./$(depth)/make/Targets.make +include ./$(depth)/make/Rules.make +# + +# explicit dependencies: (how to do auto?) +# +midi-lexer.l: $(outdir)/midi-parser.hh +midi-main.cc: check-flower-version $(lily-version) +# + +# auto dependencies: +# +-include ./$(outdir)/*.dep +# + diff --git a/m2m/include/Makefile b/m2m/include/Makefile new file mode 100644 index 0000000000..cb4f4ea6d1 --- /dev/null +++ b/m2m/include/Makefile @@ -0,0 +1,23 @@ +# lib/include/Makefile + +# subdir level: +# +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/.build +# + +# generic stuff/Makefile +# +include ./$(depth)/make/Include.make +# + diff --git a/src/midi-lexer.l b/m2m/midi-lexer.l similarity index 89% rename from src/midi-lexer.l rename to m2m/midi-lexer.l index 49f74ead0e..b5ae41046c 100644 --- a/src/midi-lexer.l +++ b/m2m/midi-lexer.l @@ -1,12 +1,8 @@ %{ // midi-lexer.l -//#include -#include "string.hh" -#include "proto.hh" -#include "midi-main.hh" -#include "my-midi-lexer.hh" +#include "m2m.hh" #include "midi-parser.hh" %} @@ -55,13 +51,13 @@ SYSEX_EVENT2 [\xf7] META_EVENT [\xff] SEQUENCE [\x00][\x02] -TEXT [\x01] -COPYRIGHT [\x02] -TRACK_NAME [\x03] -INSTRUMENT_NAME [\x04] -LYRIC [\x05] -MARKER [\x06] -CUE_POINT [\x07] +YYTEXT [\x01] +YYCOPYRIGHT [\x02] +YYTRACK_NAME [\x03] +YYINSTRUMENT_NAME [\x04] +YYLYRIC [\x05] +YYMARKER [\x06] +YYCUE_POINT [\x07] END_OF_TRACK [\x2f][\x00] TEMPO [\x51][\x03] @@ -250,54 +246,68 @@ SSME [\0x7f][\x03] yy_push_state( int16 ); return SEQUENCE; } -{TEXT} { // len data +{YYTEXT} { // len data dtor << "lex: text" << endl; +// yylval.byte = *(Byte*)YYText(); + yylval.i = *(Byte*)YYText(); yy_pop_state(); yy_pop_state(); yy_push_state( data ); - return TEXT; + return YYTEXT; } -{COPYRIGHT} { +{YYCOPYRIGHT} { dtor << "lex: copyright" << endl; +// yylval.byte = *(Byte*)YYText(); + yylval.i = *(Byte*)YYText(); yy_pop_state(); yy_pop_state(); yy_push_state( data ); - return COPYRIGHT; + return YYCOPYRIGHT; } -{TRACK_NAME} { +{YYTRACK_NAME} { dtor << "lex: track name" << endl; +// yylval.byte = *(Byte*)YYText(); + yylval.i = *(Byte*)YYText(); yy_pop_state(); yy_pop_state(); yy_push_state( data ); - return TRACK_NAME; + return YYTRACK_NAME; } -{INSTRUMENT_NAME} { +{YYINSTRUMENT_NAME} { dtor << "lex: instrument name" << endl; +// yylval.byte = *(Byte*)YYText(); + yylval.i = *(Byte*)YYText(); yy_pop_state(); yy_pop_state(); yy_push_state( data ); - return INSTRUMENT_NAME; + return YYINSTRUMENT_NAME; } -{LYRIC} { +{YYLYRIC} { dtor << "lex: lyric" << endl; +// yylval.byte = *(Byte*)YYText(); + yylval.i = *(Byte*)YYText(); yy_pop_state(); yy_pop_state(); yy_push_state( data ); - return LYRIC; + return YYLYRIC; } -{MARKER} { +{YYMARKER} { dtor << "lex: marker" << endl; +// yylval.byte = *(Byte*)YYText(); + yylval.i = *(Byte*)YYText(); yy_pop_state(); yy_pop_state(); yy_push_state( data ); - return MARKER; + return YYMARKER; } -{CUE_POINT} { +{YYCUE_POINT} { dtor << "lex: cue point" << endl; +// yylval.byte = *(Byte*)YYText(); + yylval.i = *(Byte*)YYText(); yy_pop_state(); yy_pop_state(); yy_push_state( data ); - return CUE_POINT; + return YYCUE_POINT; } {TEMPO} { // tttttt usec dtor << "lex: tempo" << endl; @@ -354,7 +364,7 @@ SSME [\0x7f][\x03] {INT8} { warning( String( "meta_event: unimplemented event: " ) + String_convert::bin2hex_str( String( *YYText() ) ), - *this->here_ch_c_l() ); + this->here_ch_c_l() ); yy_pop_state(); yy_pop_state(); yy_push_state( int8 ); diff --git a/src/midi-parser.y b/m2m/midi-parser.y similarity index 70% rename from src/midi-parser.y rename to m2m/midi-parser.y index 466b5c58d5..297b9facd8 100644 --- a/src/midi-parser.y +++ b/m2m/midi-parser.y @@ -1,29 +1,11 @@ %{ -#include - -#include "proto.hh" // ugh, these all for midi-main.hh -#include "plist.hh" -#include "string.hh" -#include "sourcefile.hh" -#include "source.hh" -#include "midi-main.hh" // *tors - -#include "my-midi-lexer.hh" -#include "my-midi-parser.hh" -#include "moment.hh" -#include "duration.hh" -#include "midi-event.hh" -#include "midi-track.hh" -#include "midi-score.hh" +#include "m2m.hh" #ifndef NDEBUG #define YYDEBUG 1 #endif -//ugh -static track_i = 0; - %} %union { @@ -40,7 +22,7 @@ static track_i = 0; %token HEADER TRACK %token SYSEX_EVENT1 SYSEX_EVENT2 %token META_EVENT -%token SEQUENCE TEXT COPYRIGHT TRACK_NAME INSTRUMENT_NAME LYRIC MARKER CUE_POINT +%token SEQUENCE %token END_OF_TRACK TEMPO SMPTE_OFFSET TIME KEY SSME %token INT8 INT16 INT32 INT7_8UNSET INT7_8SET VARINT @@ -48,6 +30,7 @@ static track_i = 0; %token NOTE_OFF NOTE_ON %token POLYPHONIC_AFTERTOUCH CONTROLMODE_CHANGE PROGRAM_CHANGE %token CHANNEL_AFTERTOUCH PITCHWHEEL_RANGE +%token YYTEXT YYCOPYRIGHT YYTRACK_NAME YYINSTRUMENT_NAME YYLYRIC YYMARKER YYCUE_POINT %token DATA %type varint @@ -65,7 +48,6 @@ static track_i = 0; midi: /* empty */ | midi midi_score { midi_parser_l_g->add_score( $2 ); - track_i = 0; } ; @@ -74,6 +56,12 @@ midi_score: } | midi_score track { $$->add_track( $2 ); + if ( midi_parser_l_g->copyright_str_.length_i() ) + $2->copyright_str_ = midi_parser_l_g->copyright_str_; + if ( midi_parser_l_g->track_name_str_.length_i() ) + $2->name_str_ = midi_parser_l_g->track_name_str_; + if ( midi_parser_l_g->instrument_str_.length_i() ) + $2->instrument_str_ = midi_parser_l_g->instrument_str_; midi_parser_l_g->reset(); } ; @@ -87,7 +75,11 @@ header: track: TRACK INT32 { - $$ = new Midi_track( track_i++ ); + $$ = new Midi_track( midi_parser_l_g->track_i_++, + // silly, cause not set yet! + midi_parser_l_g->copyright_str_, + midi_parser_l_g->track_name_str_, + midi_parser_l_g->instrument_str_ ); } | track event { $$->add_event( midi_parser_l_g->mom(), $2 ); @@ -97,8 +89,11 @@ track: event: varint the_event { $$ = $2; - if ( $2 && $2->mudela_str().length_i() ) - dtor << $2->mudela_str() << " " << flush; + if ( $2 ) { + String str = $2->mudela_str( false ); + if ( str.length_i() ) + dtor << str << " " << flush; + } } ; @@ -131,7 +126,25 @@ the_meta_event: SEQUENCE INT16 { } | text_event DATA { + Midi_text::Type type = (Midi_text::Type)$1; $$ = 0; + switch ( type ) + { + case Midi_text::COPYRIGHT: + midi_parser_l_g->copyright_str_ = *$2; + break; + case Midi_text::TRACK_NAME: + midi_parser_l_g->track_name_str_ = *$2; + while ( midi_parser_l_g->track_name_str_.index_i( ' ' ) != -1 ) + *(midi_parser_l_g->track_name_str_.ch_l() + midi_parser_l_g->track_name_str_.index_i( ' ' ) ) = '_'; + break; + case Midi_text::INSTRUMENT_NAME: + midi_parser_l_g->instrument_str_ = *$2; + break; + default: + $$ = new Midi_text( type, *$2 ); + break; + } dtor << *$2 << endl; delete $2; } @@ -140,7 +153,7 @@ the_meta_event: } | TEMPO INT8 INT8 INT8 { $$ = new Midi_tempo( ( $2 << 16 ) + ( $3 << 8 ) + $4 ); - dtor << $$->mudela_str() << endl; // ?? waai not at event: + dtor << $$->mudela_str( false ) << endl; midi_parser_l_g->set_tempo( ( $2 << 16 ) + ( $3 << 8 ) + $4 ); } | SMPTE_OFFSET INT8 INT8 INT8 INT8 INT8 { @@ -148,7 +161,7 @@ the_meta_event: } | TIME INT8 INT8 INT8 INT8 { $$ = new Midi_time( $2, $3, $4, $5 ); - dtor << $$->mudela_str() << endl; // ?? waai not at event: + dtor << $$->mudela_str( true ) << endl; midi_parser_l_g->set_time( $2, $3, $4, $5 ); } | KEY INT8 INT8 { @@ -156,31 +169,31 @@ the_meta_event: midi_parser_l_g->set_key( $2, $3 ); } | SSME DATA { - $$ = 0; + $$ = new Midi_text( (Midi_text::Type)0, *$2 ); delete $2; } ; text_event: - TEXT { + YYTEXT { dtor << "\n% Text: "; } - | COPYRIGHT { + | YYCOPYRIGHT { dtor << "\n% Copyright: "; } - | TRACK_NAME { + | YYTRACK_NAME { dtor << "\n% Track name: "; } - | INSTRUMENT_NAME { + | YYINSTRUMENT_NAME { dtor << "\n% Instrument name: "; } - | LYRIC { + | YYLYRIC { dtor << "\n% Lyric: "; } - | MARKER { + | YYMARKER { dtor << "\n% Marker: "; } - | CUE_POINT { + | YYCUE_POINT { dtor << "\n% Cue point: "; } ; diff --git a/make/Include.make b/make/Include.make new file mode 100644 index 0000000000..987b1fa264 --- /dev/null +++ b/make/Include.make @@ -0,0 +1,51 @@ +# +# project LilyPond -- the musical typesetter +# title generic red tape for include/Makefile +# file make/Include.make +# +# Copyright (c) 1997 by +# Jan Nieuwenhuizen +# Han-Wen Nienhuys + +# 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/.build +# + +# generic variables: +# +include ./$(depth)/make/Variables.make +# + +# list of c++ header files: +# +HHFILES = $(shell ls *.hh) +# + +# list of c++ inline files: +# +INLFILES = $(shell ls *.inl) +# + +# list of c++ template files: +# +TCCFILES = $(shell ls *.tcc) +# + +# list of distribution files: +# +DISTFILES = Makefile $(HHFILES) $(INLFILES) $(TCCFILES) +# + +# generic targets and rules: +# +include ./$(depth)/make/Targets.make +include ./$(depth)/make/Rules.make +# + diff --git a/make/Initial.make b/make/Initial.make new file mode 100644 index 0000000000..24c5cecc3a --- /dev/null +++ b/make/Initial.make @@ -0,0 +1,52 @@ +# +# project LilyPond -- the musical typesetter +# title initial makefile for lilypond +# file make/Initial.make +# +# Copyright (c) 1997 by +# Jan Nieuwenhuizen +# Han-Wen Nienhuys +# + +# subdir level: +# +depth = .. +# + +# ugh +NAME = dummy +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/.build +# + +# generic variables: +# +include ./$(depth)/make/Variables.make +# + + +# ugh +# initdefault: $(CCDIR)/parser.cc $(CCDIR)/lexer.cc hdr/version.hh alldeps +initdefault: check-flower-version $(lily-version) dummydep +# $(MAKE) -C ./$(depth)/lily $(outdir)/parser.cc + +# ugh! +dummydep: + touch ./$(depth)/flower/lib/$(depdir)/dummy.dep + touch ./$(depth)/lib/$(depdir)/dummy.dep + touch ./$(depth)/lily/$(depdir)/dummy.dep + touch ./$(depth)/m2m/$(depdir)/dummy.dep + +#$(DEPDIR)/%.dep: $(CCDIR)/%.cc +# $(DODEP) $(CXX) -E $(CXXFLAGS) $^ > /dev/null + +# generic targets and rules: +# +include ./$(depth)/make/Targets.make +include ./$(depth)/make/Rules.make +# + diff --git a/make/Makefile b/make/Makefile new file mode 100644 index 0000000000..2699f6140e --- /dev/null +++ b/make/Makefile @@ -0,0 +1,47 @@ +# +# project LilyPond -- the musical typesetter +# title zucht +# file make/Makefile +# +# Copyright (c) 1997 by +# Jan Nieuwenhuizen +# Han-Wen Nienhuys +# ...your sort order here, or how to comment-out a comment + +# subdir level: +# +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/.build +# + +# list of generic make files: +# +MAKEFILES = $(shell ls *.make) +# + +# list of distribution files: +# +DISTFILES = Makefile $(MAKEFILES) +# + +# 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/Rules.make b/make/Rules.make new file mode 100644 index 0000000000..0c2a5493b2 --- /dev/null +++ b/make/Rules.make @@ -0,0 +1,52 @@ +# +# project LilyPond -- the musical typesetter +# title generic make rules +# file make/Rules.make +# +# Copyright (c) 1997 by +# Jan Nieuwenhuizen +# Han-Wen Nienhuys + +.SUFFIXES: +.SUFFIXES: .cc .o .hh .y .l .pod .txt .1 .dep + +# compile rules: +# +$(outdir)/%.o: %.cc + $(DODEP)\ + $(CXX) -c $(CXXFLAGS) $(CXX_OUTPUT_OPTION) + +$(outdir)/%.cc: %.y +# $(BISON) -d $< + $(BISON) $< +# mv $(shell basename $@ .cc ).tab.h $(include-lib)/$(shell basename $@ .cc).hh +# mv $(shell basename $@ .cc ).tab.h $(outdir)/$(shell basename $@ .cc).hh + mv $(shell basename $@ .cc ).tab.c $@ + +$(outdir)/%.hh: %.y + $(BISON) -d $< + mv $(shell basename $@ .hh ).tab.h $@ + mv $(shell basename $@ .hh ).tab.c $(outdir)/$(shell basename $@ .hh).cc + +$(outdir)/%.cc: %.l + $(FLEX) -t $< > $@ + +$(outdir)/%.text: $(outdir)/%.1 + groff -man -Tascii $< > $@ + +$(outdir)/%.1: %.pod + pod2man --center="LilyPond documentation" --section="0"\ + --release="LilyPond $(MAJVER).$(MINVER).$(PATCHLEVEL)" $< > $@ +# + +# specific stuff: +# +$(LIBFLOWER): check-flower-version +# $(MAKE) -C ./$(depth)/flower/lib + $(MAKE) ./$(outdir)/$(@F) -C $(depth)/flower/lib +# +$(LIBLILY): check-flower-version $(lily-version) +# $(MAKE) -C ./$(depth)/lib + $(MAKE) ./$(outdir)/$(@F) -C $(depth)/lib +# + diff --git a/make/Site.make b/make/Site.make new file mode 100644 index 0000000000..e69de29bb2 diff --git a/make/Sources.make b/make/Sources.make new file mode 100644 index 0000000000..98eea71710 --- /dev/null +++ b/make/Sources.make @@ -0,0 +1,137 @@ +# kept in dist bo stripping stable stuff, still to copy... + +# Sources.make +# sourcefiles to be shipped. Also used for dependencies + +hdr=bar.hh barreg.hh beam.hh\ + binary-source-file.hh\ + boxes.hh break.hh clefreg.hh clefitem.hh\ + colhpos.hh commandrequest.hh \ + complexwalker.hh complexstaff.hh\ + const.hh debug.hh dimen.hh directionalspanner.hh\ + glob.hh grouping.hh headreg.hh idealspacing.hh\ + identifier.hh identparent.hh \ + inputmusic.hh inputscore.hh inputstaff.hh\ + inputfile.hh\ + item.hh key.hh keyitem.hh\ + keyreg.hh\ + keyword.hh leastsquares.hh lexer.hh linespace.hh \ + localkeyitem.hh localkeyreg.hh lookup.hh \ + lyricitem.hh lyricstaff.hh lyricwalker.hh\ + main.hh meter.hh meterreg.hh\ + mididef.hh midiitem.hh midioutput.hh midistream.hh\ + midiwalker.hh\ + misc.hh\ + molecule.hh moment.hh musicalrequest.hh\ + notehead.hh notename.hh offset.hh paperdef.hh\ + parseconstruct.hh pcol.hh proto.hh\ + pscore.hh pstaff.hh qlp.hh\ + qlpsolve.hh register.hh registergroup.hh reqtodo.hh \ + request.hh rest.hh scorecolumn.hh score.hh\ + scoreline.hh scorewalker.hh script.hh scriptdef.hh scriptreg.hh \ + slur.hh slurreg.hh source.hh sourcefile.hh\ + spanner.hh staff.hh\ + staffelem.hh staffeleminfo.hh staffline.hh staffsym.hh stembeamreg.hh\ + staffcolumn.hh stem.hh staffwalker.hh symbol.hh symtable.hh\ + tex.hh textdef.hh \ + textitem.hh textreg.hh textspanner.hh timedescription.hh \ + tstream.hh voice.hh\ + voiceregs.hh voicegroupregs.hh walkregs.hh + +mycc=bar.cc barreg.cc beam.cc \ + binary-source-file.cc\ + boxes.cc break.cc calcideal.cc clefreg.cc\ + clefitem.cc colhpos.cc commandrequest.cc\ + complexstaff.cc complexwalker.cc \ + debug.cc dimen.cc\ + directionalspanner.cc\ + grouping.cc groupregs.cc headreg.cc\ + idealspacing.cc identifier.cc\ + inputmusic.cc inputscore.cc\ + inputstaff.cc\ + inputfile.cc\ + item.cc key.cc keyitem.cc \ + keyreg.cc keyword.cc\ + leastsquares.cc lexerinit.cc linespace.cc \ + localkeyitem.cc localkeyreg.cc lookup.cc\ + lyricitem.cc lyricstaff.cc lyricwalker.cc\ + main.cc meter.cc meterreg.cc\ + mididef.cc midiitem.cc midioutput.cc midistream.cc\ + midiwalker.cc misc.cc molecule.cc mylexer.cc note.cc\ + notehead.cc notename.cc\ + paperdef.cc pcol.cc pscore.cc pstaff.cc qlp.cc qlpsolve.cc\ + register.cc registergroup.cc request.cc rest.cc\ + scorecolumn.cc score.cc\ + scoreline.cc scores.cc scorewalker.cc script.cc\ + scriptdef.cc scriptreg.cc slur.cc\ + slurreg.cc source.cc sourcefile.cc\ + spanner.cc staff.cc\ + staffelem.cc staffline.cc staffsym.cc\ + stembeamreg.cc staffcolumn.cc stem.cc\ + staffeleminfo.cc staffwalker.cc symbol.cc\ + symtable.cc tex.cc texbeam.cc\ + texslur.cc textdef.cc textitem.cc textreg.cc textspanner.cc\ + timedescription.cc tstream.cc voice.cc voiceelt.cc \ + voiceregs.cc voicegroupregs.cc\ + walkregs.cc warn.cc windhoos-suck-suck-suck-thank-you-cygnus.cc wordwrap.cc\ + template1.cc template2.cc template3.cc template4.cc\ + template5.cc template6.cc version.cc + +# a bit of a hack to keep exec size under control. +stablecc=request.cc bar.cc boxes.cc break.cc \ + item.cc keyword.cc leastsquares.cc \ + lookup.cc molecule.cc meter.cc\ + paperdef.cc parser.cc lexer.cc pstaff.cc qlp.cc qlpsolve.cc\ + template1.cc template2.cc template3.cc template4.cc\ + template5.cc template6.cc version.cc tstream.cc tex.cc\ + voice.cc wordwrap.cc spanner.cc + + +# m2m headers +# +mym2mhh=\ + duration.hh\ + lily-stream.hh\ + midi-event.hh\ + midi-main.hh\ + midi-score.hh\ + midi-track.hh\ + my-midi-lexer.hh\ + my-midi-parser.hh\ + track-column.hh\ + +# + +# m2m shared headers +# +mym2msharedhh=\ + binary-source-file.hh\ + +# + +# m2m source +# +mym2mcc=\ + duration.cc\ + lily-stream.cc\ + midi-event.cc\ + midi-main.cc\ + midi-score.cc\ + midi-template.cc\ + midi-track.cc\ + my-midi-lexer.cc\ + my-midi-parser.cc\ + track-column.cc\ + +# + +# m2m shared source +# +mym2msharedcc=\ + binary-source-file.cc\ + inputfile.cc\ + sourcefile.cc\ + source.cc\ + +# + diff --git a/make/Stuff.make b/make/Stuff.make new file mode 100644 index 0000000000..69cf6d70d7 --- /dev/null +++ b/make/Stuff.make @@ -0,0 +1,31 @@ +# +# 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) +# build = ./$(depth)/lily/.build +# + +# 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 new file mode 100644 index 0000000000..884eef7846 --- /dev/null +++ b/make/Targets.make @@ -0,0 +1,126 @@ +# +# project LilyPond -- the musical typesetter +# title generic make rules +# file make/Rules.make +# +# Copyright (c) 1997 by +# Jan Nieuwenhuizen +# Han-Wen Nienhuys + +.PHONY : all clean default dist doc doc++ dummy exe help lib tags + +# target all: +# +all: default + for i in $(SUBDIRS); do $(MAKE) -C $$i all; done +# + +# dependency list of executable: +# +EXECUTABLE = $(bindir)/$(NAME) +$(EXECUTABLE): $(OFILES) $(CUSTOMLIBES) +# $(STRIPDEBUG) $(STABLEOBS) +# $(LD_COMMAND) -o $@ $^ $(LOADLIBES) + $(LD_COMMAND) $(OFILES) $(LOADLIBES) + touch $(VERSION_DEPENDENCY) + $(INCREASE_BUILD) + touch $(build) #waai necessary? +# +exe: $(EXECUTABLE) +# + +# dependency list of library: +# +LIBRARY = $(libdir)/$(LIB_PREFIX)$(NAME)$(LIB_SUFFIX) +$(LIBRARY): $(OFILES) $(CUSTOMLIBES) + $(AR_COMMAND) $(OFILES) + touch $(VERSION_DEPENDENCY) + $(INCREASE_BUILD) + touch $(build) #waai necessary? +# +lib: $(LIBRARY) +# + +clean: + rm -f $(allexe) core $(allobs) + for i in $(SUBDIRS); do $(MAKE) -C $$i clean; done + +distclean: clean + rm -rf $(lily-version) $(flower-version) .b $(build) .GENERATE *~ $(allout) + + +# configure: +# +config: + $(bindir)/configure +# + +# value of $(OSTYPE) on windhoos; "make $OSTYPE" if you use bash :-) +# +win32: + $(MAKE) -C . CXX=g++ +# + +# xcompile to doze: +# +doze: dos +dos: + $(MAKE) -C . CXX="gcc-go32 -I/usr/i386-go32/include -I/usr/i386-go32/include/g++ -D_WIN32 -Dcaddr_t=char* -DMAP_SHARED=0" +# + +# target help: +# +help: + @echo "Usage:" + @echo " $(MAKE) ["VARIABLE=value" ...] [target]" + @echo + @echo "targets:" + @echo " all clean config dist distclean doc doc++" + @echo " exe help lib moduledist tags" + @echo " dos: xcomplile to dos" + @echo " win32: native cygnus-win32 compile" +# + +doc: + $(MAKE) -C Documentation do-doc + +# doc++ documentation of classes +doc++: $(progdocs) + doc++ -kp -d $(DOCDIR) $^ + +dist: + -mkdir $(distdir) + $(MAKE) localdist + (cd ./$(depth); tar cfz $(DIST_NAME).tar.gz $(DIST_NAME)) + rm -rf $(distdir)/ # should be trapped + +localdist: + ln $(DISTFILES) $(distdir)/$(localdir) + for i in $(SUBDIRS); do mkdir $(distdir)/$(localdir)/$$i; done + for i in $(SUBDIRS); do $(MAKE) localdir=$(localdir)/$$i -C $$i localdist; done + +moduledist: + -mkdir $(module-distdir) + $(MAKE) localmoduledist + (cd ./$(depth); tar cfz $(MODULE_DIST_NAME).tar.gz $(MODULE_DIST_NAME)) + rm -rf $(module-distdir)/ # should be trapped + +localmoduledist: + ln $(DISTFILES) $(module-distdir)/$(localdir) + for i in $(SUBDIRS); do mkdir $(module-distdir)/$(localdir)/$$i; done + for i in $(SUBDIRS); do $(MAKE) localdir=$(localdir)/$$i -C $$i localmoduledist; done + +all-tags: tags + for i in $(SUBDIRS); do $(MAKE) -C $$i all-tags; done + +tags: + etags -CT $(allcc) + +# version stuff: +# +check-flower-version: + $(MAKE) flower-version -C ./$(depth)/flower +$(lily-version): ./$(depth)/.version ./$(bindir)/make_version $(build) + ./$(bindir)/make_version "$(MAJOR_VERSION)" "$(MINOR_VERSION)" "$(PATCH_LEVEL)" "$(MY_PATCH_LEVEL)" "$(BUILD)" "$(CXX) $(CXXVER)" > $@ +# + diff --git a/make/Template.make b/make/Template.make new file mode 100644 index 0000000000..016ebf008f --- /dev/null +++ b/make/Template.make @@ -0,0 +1,97 @@ +# THIS IS A TEMPLATE FOR SUB-PROJECT MAKEFILES +# should we make Include-dir and Stuff-dir templates too? + +# project LilyPond -- the musical typesetter +# title makefile for ... +# file ../Makefile +# +# Copyright (c) 1997 by +# Jan Nieuwenhuizen +# Han-Wen Nienhuys +# + +# subdir level: +# +depth = .. +# + +# identify 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 = ./$(depth)/lily/.build +# + +# generic variables: +# +include ./$(depth)/make/Variables.make +# + +# descent order into subdirectories: +# +SUBDIRS = +# + +# to be remade each build: +# +VERSION_DEPENDENCY = $(lily-version) +# + +# module compile settings: (not generally needed! +# +EXTRA_CFLAGS = +EXTRA_CXXFLAGS = +EXTRA_LDFLAGS = +# + +# list of c++ header files: +# +HHFILES = $(shell ls *.hh) +# + +# list of c++ source files: +# +CCFILES = $(shell ls *.cc) +# + +# list of other source files: +# +EXTRA_SOURCE_FILES = $(shell ls *.y *.l) +# + +# list of distribution files: +# +DISTFILES = $(HHFILES) $(CCFILES) $(EXTRA_SOURCE_FILES) +# + +# list of custom libraries: +# +CUSTOMLIBES = \ + +LOADLIBES += +# + +# main target of this module: +# +MAINTARGET = $(EXECUTABLE) +# MAINTARGET = $(LIBRARY) + +default: $(MAINTARGET) +# + +# generic targets and rules: +# +include ./$(depth)/make/Targets.make +include ./$(depth)/make/Rules.make +# + +# auto dependencies: +# +include ./$(outdir)/*.dep +# + diff --git a/make/User.make b/make/User.make new file mode 100644 index 0000000000..5a8be80454 --- /dev/null +++ b/make/User.make @@ -0,0 +1,40 @@ +# +# project LilyPond -- the musical typesetter +# title user changeable settings +# file make/User.make +# +# Copyright (c) 1997 by +# Jan Nieuwenhuizen +# Han-Wen Nienhuys + +# this still sux +# will be split into CFLAGS/EXTRA_CFLAGS etc, +# so that defineable generically and per module + +# you-re using a i386, eh? +# +#PROFILEFLAG=-pg +# + +# optimization and debugging: +# +# if defined (=not commented-out), debugging flag is ignored! +OPTIFLAG=-DNDEBUG -DNPRINT -O2 +# +DEBUGFLAG=-g +# + +# turn off -pipe if linker doesn't support it +# +USER_CXXFLAGS=-pipe -Wall -W -Wmissing-prototypes -DSTRING_UTILS_INLINED -O +# + +# +# -lefence = ElectricFence. +# +# ElectricFence is a memory debugger which uses the +# VM hardware to trap malloc/free errors. +# + +EXTRALIB+= #-lefence + diff --git a/make/Variables.make b/make/Variables.make new file mode 100644 index 0000000000..824c16db33 --- /dev/null +++ b/make/Variables.make @@ -0,0 +1,154 @@ +# +# project LilyPond -- the musical typesetter +# title generic variables +# file make/Variables.make +# abstract do not change this file; edit settings in User.make +# +# Copyright (c) 1997 by +# Jan Nieuwenhuizen +# Han-Wen Nienhuys + +# toplevel version info, might be handy? +# +include ./$(depth)/.version +# + +# directory names: +# +outdir = out# "objects" won-t do, used for libs and deps as well +bindir = ./$(depth)/bin +distdir = ./$(depth)/$(DIST_NAME) +module-distdir = ./$(depth)/$(MODULE_DIST_NAME) +depdir = $(outdir) +libdir = $(outdir) +flowerout = ./$(depth)/flower/lib/$(outdir) +libout = ./$(depth)/lib/$(outdir) +# flower-dir = ./$(depth)/flower +include-lib = ./$(depth)/lib/include +include-flower = ./$(depth)/flower/lib/include +# + +# user settings: +# +include ./$(depth)/make/User.make +# + +ifdef PROFILEFLAG + DEFINES+=$(OPTIFLAG) $(PROFILEFLAG) + EXTRA_LIBES+=-pg +endif + +ifndef DEBUGFLAG + DEFINES+=$(OPTIFLAG) +else + DEFINES+=$(DEBUGFLAG) +endif + +# build no: +# +# need to be defined in local Makefiles: +# build = ./$(depth)/lily/.build +BUILD = $(shell cat $(build)) +INCREASE_BUILD = @echo `expr \`cat $(build)\` + 1` > .b; mv .b $(build) +# + +# the version: +# +VERSION=$(MAJOR_VERSION).$(MINOR_VERSION).$(PATCH_LEVEL)$(MY_PATCH_LEVEL) +TOPLEVEL_VERSION=$(TOPLEVEL_MAJOR_VERSION).$(TOPLEVEL_MINOR_VERSION).$(TOPLEVEL_PATCH_LEVEL)$(TOPLEVEL_MY_PATCH_LEVEL) +# + +# compiler version: +# +CXXVER=`$(CXX) --version` +# + +# module and top level dist: +# +# fix naming, use TOPLEVEL_ prefix _or_ MODULE? +MODULE_DIST_NAME = $(MODULE_NAME)-$(VERSION) +DIST_NAME = lilypond-$(TOPLEVEL_VERSION) +# + +# list of object files: +# +SOURCE_FILES = $(CCFILES) $(EXTRA_SOURCE_FILES) +OFILEC = $(SOURCE_FILES:.c=.o) +OFILECC = $(OFILEC:.cc=.o) +OFILEL = $(OFILECC:.l=.o) +OFILEY = $(OFILEL:.y=.o) +OFILES = $(patsubst %,$(outdir)/%,$(OFILEY)) +# + +# clean file lists: +# +allexe = $(bindir)/lilypond $(bindir)/m2m +allobs = $(shell find $(outdir) -name "*.o" ) +allibs = $(shell find $(libdir) -name "*.lib" ) +alldeps = $(shell find $(outdir) -name "*.dep" ) +allout = $(shell find . -name "$(outdir)" ) +# + +# version stuff: +# +flower-version = $(flowerout)/fversion.hh +lily-version = $(libout)/version.hh +# + +# custom libraries: +# +LIBFLOWER = $(depth)/flower/lib/$(outdir)/$(LIB_PREFIX)flower$(LIB_SUFFIX) +LIBLILY = $(depth)/lib/$(outdir)/$(LIB_PREFIX)lily$(LIB_SUFFIX) +# + +# compile and link options: +# +ARFLAGS = ru +CFLAGS = $(DEFINES) $(INCLUDES) $(USER_CFLAGS) $(EXTRA_CFLAGS) +CXXFLAGS = $(CFLAGS) $(USER_CXXFLAGS) $(EXTRA_CXXFLAGS) +INCLUDES = -Iinclude -I$(outdir) -I$(include-lib) -I$(libout) -I$(include-flower) -I$(flowerout) +CXX_OUTPUT_OPTION = $< -o $@ +LDFLAGS = $(EXTRA_LDFLAGS) +LOADLIBES = $(EXTRA_LIBES) $(CUSTOMLIBES) -lg++ +# + +# librarian: +# +AR = ar +AR_COMMAND = $(AR) $(ARFLAGS) $@ +# + +# compiler: +# +# "CC = $(CC)" +# "CXX = $(CXX)" +# + +# linker: +# +LD = $(CXX) +LD_COMMAND = $(LD) $(LDFLAGS) -o $@ +# + +# dependencies: +# +depfile = ./$(depdir)/$(subst .o,.dep,$(notdir $@)) +DODEP=rm -f $(depfile); DEPENDENCIES_OUTPUT="$(depfile) $(outdir)/$(notdir $@)" +# + +# utils: +# +FLEX = flex +BISON = bison +# + +# generic target names: +# +EXECUTABLE = $(NAME)$(EXE) +LIB_PREFIX = lib +LIB_SUFFIX = .a +LIBRARY = $(LIB_PREFIX)$(NAME)$(LIB_SUFFIX) +# + +STRIPDEBUG=true #replace to do stripping of certain objects + diff --git a/make_version b/make_version deleted file mode 100755 index 188855e0f9..0000000000 --- a/make_version +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -echo '#ifndef VERSION_HH' -echo '#define VERSION_HH' -echo '#define MAJORVERSION ' $1 -echo '#define MINORVERSION ' $2 -echo '#define PATCHLEVEL ' $3 -echo '#define VERSIONSTR "'$1.$2.$3'"' -echo '#define COMPILER "'$4'"' -echo '#endif' diff --git a/objects/Makefile b/objects/Makefile deleted file mode 100644 index 479dbfe1c2..0000000000 --- a/objects/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -DISTFILES=Makefile -dist: - ln $(DISTFILES) $(DDIR)/$(SUBDIR) - -clean: - rm *.o \ No newline at end of file diff --git a/src/Makefile b/src/Makefile deleted file mode 100644 index f49e05d64d..0000000000 --- a/src/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -default: - $(MAKE) -C .. - -win32: - $(MAKE) -C .. Windows_NT - -DISTFILES=Makefile $(allcc) $(othersrc) -dist: - ln $(DISTFILES) $(DDIR)/$(SUBDIR) - -TAGS: $(allcc) - $(TAGSACTION) $^ - -clean: - rm -f $(gencc) diff --git a/src/binary-source-file.cc b/src/binary-source-file.cc deleted file mode 100644 index 39eec37254..0000000000 --- a/src/binary-source-file.cc +++ /dev/null @@ -1,64 +0,0 @@ -/* - binary-source-file.cc -- implement Binary_source_file - - source file of the LilyPond music typesetter - - (c) 1997 Jan Nieuwenhuizen -*/ - - -#include // INT_MAX -#include - -#include "proto.hh" -#include "plist.hh" -#include "string.hh" -#include "debug.hh" -#include "source-file.hh" -#include "binary-source-file.hh" -#include "string-convert.hh" - -Binary_source_file::Binary_source_file( String& filename_str ) - : Source_file( filename_str ) -{ -} - -Binary_source_file::~Binary_source_file() -{ -} - -String -Binary_source_file::error_str( char const* pos_ch_c_l ) -{ - assert( this ); - if ( !in_b( pos_ch_c_l ) ) - return ""; - - char const* begin_ch_c_l = pos_ch_c_l - 8 >? ch_c_l(); - char const* end_ch_c_l = pos_ch_c_l + 7 - -// split into 4? - -#include "proto.hh" // ugh, these all for midi-main.hh -#include "plist.hh" -#include "string.hh" -#include "source-file.hh" -#include "source.hh" -#include "midi-main.hh" // *tors - -#include "string.hh" -#include "moment.hh" -#include "duration.hh" - -Duration::Duration( int type_i, int dots_i = 0, Plet* plet_l ) -{ - type_i_ = type_i; - dots_i_ = dots_i; - plet_p_ = 0; - set_plet( plet_l ); -} - -Duration::Duration( Duration const& dur_c_r ) -{ - type_i_ = 0; - dots_i_ = 0; - plet_p_ = 0; - *this = dur_c_r; -} - -Duration::~Duration() -{ - delete plet_p_; -} - -Duration const& -Duration::operator =( Duration const& dur_c_r ) -{ - if ( &dur_c_r == this ) - return *this; - - type_i_ = dur_c_r.type_i_; - dots_i_ = dur_c_r.dots_i_; - set_plet( dur_c_r.plet_p_ ); - - return *this; -} - -void -Duration::set_plet( Plet* plet_l ) -{ - delete plet_p_; - plet_p_ = 0; - if ( plet_l ) - plet_p_ = new Plet( *plet_l ); -} - -Plet::Plet( int iso_i, int type_i ) -{ - iso_i_ = iso_i; - type_i_ = type_i; -} - -Plet::Plet( Plet const& plet_c_r ) -{ - iso_i_ = plet_c_r.iso_i_; - type_i_ = plet_c_r.type_i_; -} - -String -Duration_convert::dur2_str( Duration dur ) -{ - String str( dur.type_i_ ); - str += String( '.', dur.dots_i_ ); - if ( dur.plet_p_ ) - str += String( "*" ) + String( dur.plet_p_->iso_i_ ) - + String( "/" ) + String( dur.plet_p_->type_i_ ); - return str; -} - -int -Duration_convert::dur2_i( Duration dur, int division_1_i ) -{ - return dur2_mom( dur ) * Moment( division_1_i ); -} - -Moment -Duration_convert::dur2_mom( Duration dur ) -{ - if ( !dur.type_i_ ) - return 0; - - Moment mom = Moment( 1 , dur.type_i_ ); - - Moment delta = mom; - while ( dur.dots_i_-- ) { - delta /= 2.0; - mom += delta; - } - - return mom * plet_factor_mom( dur ); -} - -Duration -Duration_convert::mom2_dur( Moment mom ) -{ - /* this is cute, - but filling an array using Duration_iterator - might speed things up, a little - */ - Duration_iterator iter_dur; - assert( iter_dur ); - while ( iter_dur ) { - Duration lower_dur = iter_dur++; - Duration upper_dur( 0 ); - if ( iter_dur ) - upper_dur = iter_dur(); - Moment lower_mom = dur2_mom( lower_dur ); - Moment upper_mom = dur2_mom( upper_dur ); - if ( mom == lower_mom ) - return lower_dur; - if ( mom == upper_mom ) // don-t miss last (sic) - return upper_dur; - if ( ( mom >= lower_mom ) && ( mom <= upper_mom ) ) { - warning( String( "duration not exact: " ) + String( (Real)mom ) , 0 ); - if ( abs( mom - lower_mom ) < abs( mom - upper_mom ) ) - return lower_dur; - else - return upper_dur; - } - lower_dur = upper_dur; - } - return Duration( 0 ); -} - -Moment -Duration_convert::plet_factor_mom( Duration dur ) -{ - if ( !dur.plet_p_ ) - return 1; - return Moment( dur.plet_p_->iso_i_, dur.plet_p_->type_i_ ); -} - -Real -Duration_convert::sync_f( Duration dur, Moment mom ) -{ - return mom / dur2_mom( dur ); -} - -Moment -Duration_convert::i2_mom( int time_i, int division_1_i ) -{ - if ( !time_i ) - return Moment( 0 ); - - if ( division_1_i > 0 ) - return Moment( time_i, division_1_i ); - else - return Moment( -division_1_i, time_i ); -} - -Duration_iterator::Duration_iterator() -{ - cursor_dur_.type_i_ = 128; - cursor_dur_.set_plet( 0 ); -} - -Duration -Duration_iterator::operator ++(int) -{ - return forward_dur(); -} - -Duration -Duration_iterator::operator ()() -{ - return dur(); -} - -Duration_iterator::operator bool() -{ - return ok(); -} - -Duration -Duration_iterator::dur() -{ - return cursor_dur_; -} - -Duration -Duration_iterator::forward_dur() -{ - // should do smart table? guessing: - // duration wholes - // 16 0.0625 - // 32.. 0.0703 - // 8:2/3 0.0833 - // 16. 0.0938 - // 8 0.1250 - // 16.. 0.1406 - // 4:2/3 0.1667 - // 8. 0.1875 - - assert( ok() ); - - Duration dur = cursor_dur_; - - if ( !cursor_dur_.dots_i_ && !cursor_dur_.plet_p_ ) { - cursor_dur_.type_i_ *= 2; - cursor_dur_.dots_i_ = 2; - } - else if ( cursor_dur_.dots_i_ == 2 ) { - assert( !cursor_dur_.plet_p_ ); - cursor_dur_.dots_i_ = 0; - cursor_dur_.type_i_ /= 4; - cursor_dur_.set_plet( &Plet( 2, 3 ) ); - } - else if ( cursor_dur_.plet_p_ - && ( cursor_dur_.plet_p_->iso_i_ == 2 ) - && ( cursor_dur_.plet_p_->type_i_ == 3 ) ) { - assert( !cursor_dur_.dots_i_ ); - cursor_dur_.set_plet( 0 ); - cursor_dur_.type_i_ *= 2; - cursor_dur_.dots_i_ = 1; - } - else if ( cursor_dur_.dots_i_ == 1 ) { - assert( !cursor_dur_.plet_p_ ); - cursor_dur_.dots_i_ = 0; - cursor_dur_.type_i_ /= 2; - } - - // ugh - if ( no_triplets_bo_g && cursor_dur_.plet_p_ && ok() ) - forward_dur(); - - return dur; -} - -bool -Duration_iterator::ok() -{ - return ( cursor_dur_.type_i_ - && !( ( cursor_dur_.type_i_ == 1 ) && ( cursor_dur_.dots_i_ > 2 ) ) ); -} diff --git a/src/lily-stream.cc b/src/lily-stream.cc deleted file mode 100644 index 4b79481424..0000000000 --- a/src/lily-stream.cc +++ /dev/null @@ -1,72 +0,0 @@ -// -// lily-stream.cc -// -// source file of the LilyPond music typesetter -// -// (c) 1997 Jan Nieuwenhuizen - -// should i be named Mudela_stream? - -#include -#include - -#include "proto.hh" -#include "plist.hh" -#include "string.hh" - -#include "moment.hh" -#include "source-file.hh" -#include "source.hh" -#include "midi-main.hh" // *tors - -#include "duration.hh" -#include "midi-event.hh" -#include "lily-stream.hh" - -Lily_stream::Lily_stream( String filename_str ) -{ - filename_str_ = filename_str; - os_p_ = 0; - open(); - header(); -} - -Lily_stream::~Lily_stream() -{ - delete os_p_; -} - -Lily_stream& -Lily_stream::operator <<( String str ) -{ - *os_p_ << str; - return *this; -} - -Lily_stream& -Lily_stream::operator <<( Midi_event& midi_event_r ) -{ - midi_event_r.output_mudela( *this ); - return *this; -} - -void -Lily_stream::header() -{ - *os_p_ << "% Creator: " << version_str() << "\n"; - *os_p_ << "% Automatically generated, at "; - time_t t( time( 0 ) ); - *os_p_ << ctime( &t ); - *os_p_ << "% from input file: "; -// *os_p_ << midi_parser_l_g-> - *os_p_ << "\n\n"; -} - -void -Lily_stream::open() -{ - os_p_ = new ofstream( filename_str_ ); - if ( !*os_p_ ) - error ( "can't open `" + filename_str_ + "\'", 0 ); -} - diff --git a/src/lyricwalker.cc b/src/lyricwalker.cc deleted file mode 100644 index 6abc2192a9..0000000000 --- a/src/lyricwalker.cc +++ /dev/null @@ -1,39 +0,0 @@ -/* - lyricwalker.cc -- implement Lyric_walker - - source file of the LilyPond music typesetter - - (c) 1997 Jan Nieuwenhuizen -*/ - -#include "musicalrequest.hh" -#include "voice.hh" -#include "pscore.hh" -#include "lyricstaff.hh" -#include "lyricwalker.hh" -#include "debug.hh" -#include "lyric-item.hh" -#include "staff-column.hh" - -void -Lyric_walker::process_requests() -{ - allow_break(); - - int req_count=0; - for (int i = 0; i < ptr()->musicalreq_l_arr_.size(); i++) { - Lyric_req * lreq_l = ptr()->musicalreq_l_arr_[i]->lreq_l(); - if (!lreq_l) - continue; - Item *lp = new Lyric_item(lreq_l,req_count++); - ptr()->typeset_musical_item( lp); - } -} - -Lyric_walker::Lyric_walker(Lyric_staff* lstaff_l) - : Staff_walker(lstaff_l, lstaff_l->pstaff_l_->pscore_l_) -{ - -} - - diff --git a/src/midi-def.cc b/src/midi-def.cc deleted file mode 100644 index 5430823ed2..0000000000 --- a/src/midi-def.cc +++ /dev/null @@ -1,64 +0,0 @@ -// -// midi-def.cc -- implement midi output -// -// source file of the LilyPond music typesetter -// -// (c) 1997 Jan Nieuwenhuizen - -#include -#include "misc.hh" -#include "midi-def.hh" -#include "debug.hh" - -// classes, alphasorted -// statics -// constructors -// destructor -// routines, alphasorted - -Midi_def::Midi_def() -{ - set_tempo( Moment( 1, 4 ), 60 ); - outfile_str_ = "lelie.midi"; -} - -Midi_def::Midi_def( Midi_def const& midi_c_r ) -{ - whole_seconds_f_ = midi_c_r.whole_seconds_f_; - outfile_str_ = midi_c_r.outfile_str_; -} - -Midi_def::~Midi_def() -{ -} - -Real -Midi_def::duration_to_seconds_f( Moment moment ) -{ - if (!moment) - return 0; - - return whole_seconds_f_ * moment; -} - -int -Midi_def::get_tempo_i( Moment moment ) -{ - return Moment( whole_seconds_f_ ) * Moment( 60 ) * moment; -} - -void -Midi_def::print() const -{ -#ifndef NPRINT - mtor << "Midi {4/min: " << Real( 60 ) / ( whole_seconds_f_ * 4 ); - mtor << "out: " << outfile_str_; - mtor << "}\n"; -#endif -} - -void -Midi_def::set_tempo( Moment moment, int count_per_minute_i ) -{ - whole_seconds_f_ = Moment( count_per_minute_i ) / Moment( 60 ) / moment; -} diff --git a/src/midi-event.cc b/src/midi-event.cc deleted file mode 100644 index 36d6694779..0000000000 --- a/src/midi-event.cc +++ /dev/null @@ -1,198 +0,0 @@ -// -// midi-event.cc -- implement Midi_event -// -// copyright 1997 Jan Nieuwenhuizen - -#include - -#include "proto.hh" -#include "plist.hh" // all for midi-main.hh -#include "string.hh" -#include "source.hh" -#include "source-file.hh" -#include "midi-main.hh" // *tors -#include "moment.hh" -#include "duration.hh" -#include "midi-event.hh" -#include "lily-stream.hh" - -Midi_event::Midi_event() -{ -} - -Midi_event::~Midi_event() -{ -} - -Moment -Midi_event::mom() -{ - return Moment( 0 ); -} - -String -Midi_event::mudela_str() -{ - return mudela_str_; -} - -void -Midi_event::output_mudela( Lily_stream& lily_stream_r ) -{ - lily_stream_r << mudela_str_ << String( " " ); -} - -Midi_key::Midi_key( int accidentals_i, int minor_i ) -{ - accidentals_i_ = accidentals_i; - minor_i_ = minor_i; - if ( !minor_i_ ) - key_i_ = ( ( accidentals_i % 7 )[ "cgdaebf" ] - 'a' + 2 ) % 7; - else - key_i_ = ( ( -accidentals_i % 7 )[ "fbeadg" ] - 'a' + 2 ) % 7; - mudela_str_ = String( "% \\key\\" ); - if ( !minor_i_ ) - mudela_str_ += String( (char)( key_i_ - 2 + 'A' ) ); - else - mudela_str_ += String( (char)( key_i_ - 2 + 'a' ) ); -} - -String -Midi_key::notename_str( int pitch_i ) -{ - // this may seem very smart, - // but it-s only an excuse not to read a notename table - - // major scale: do-do - // minor scale: la-la ( = + 5 ) - static int notename_i_a[ 12 ] = { 0, 0, 1, 1, 2, 3, 3, 4, 4, 5, 5, 6 }; - int notename_i = notename_i_a[ ( minor_i_ * 5 + pitch_i ) % 12 ]; - - static int accidentals_i_a[ 12 ] = { 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0 }; - int accidental_i = accidentals_i_a[ minor_i_ * 5 + pitch_i % 12 ]; - if ( accidentals_i_ < 0 ) { - accidental_i = - accidental_i; - notename_i = ( notename_i + 1 ) % 7; - } - - String notename_str = (char)( ( ( notename_i + key_i_ - 2 ) % 7 ) + 'a' ); - while ( accidental_i-- > 0 ) - notename_str += "is"; - accidental_i++; - while ( accidental_i++ < 0 ) - if ( ( notename_str == "a" ) || ( notename_str == "e" ) ) - notename_str += "s"; - else - notename_str += "es"; - accidental_i--; - String octave_str; - - octave_str += String( '\'', ( pitch_i - Midi_note::c0_pitch_i_c_ ) / 12 ); - octave_str += String( '`', ( Midi_note::c0_pitch_i_c_ - pitch_i ) / 12 ); - return octave_str + notename_str; -} - -Midi_key::~Midi_key() -{ -} - -Midi_note::Midi_note( Midi_key* midi_key_l, Midi_time* midi_time_l, int division_1_i, int pitch_i, int time_i ) -{ - dur_ = midi_time_l->i2_dur( time_i, division_1_i ); - - if ( dur_.plet_p_ ) - mudela_str_ += String( "\\plet{ " ) - + String_convert::i2dec_str( dur_.plet_p_->iso_i_, 0, 0 ) - + "/" - + String_convert::i2dec_str( dur_.plet_p_->type_i_, 0, 0 ) - + " } "; - - mudela_str_ += midi_key_l->notename_str( pitch_i ); - - Duration dur = dur_; - dur.set_plet( 0 ); - mudela_str_ += Duration_convert::dur2_str( dur ); - - if ( dur_.plet_p_ ) - mudela_str_ += String( " \\plet{ 1/1 }" ); -} - -Midi_note::~Midi_note() -{ -} - -Moment -Midi_note::mom() -{ - return Duration_convert::dur2_mom( dur_ ); -} - -Midi_tempo::Midi_tempo( int useconds_per_4_i ) -{ - useconds_per_4_i_ = useconds_per_4_i; - seconds_per_1_f_ = (Real)useconds_per_4_i_ * 4 / 1e6; - mudela_str_ = "% \\Tempo: "; - mudela_str_ += String( useconds_per_4_i_ ); - mudela_str_ += String( ": " ) - + String( get_tempo_i( Moment( 1, 4 ) ) ) - + String( " 4 per minute" ); -} - -Midi_tempo::~Midi_tempo() -{ -} - -int -Midi_tempo::get_tempo_i( Moment moment ) -{ - return Moment( 60 ) / moment / Moment( seconds_per_1_f_ ); -} - -Midi_time::Midi_time( int num_i, int den_i, int clocks_4_i, int count_32_i ) - : sync_dur_( 8 ) -{ - sync_f_ = 1.0; - if ( count_32_i != 8 ) - warning( String( "#32 in quarter: " ) + String( count_32_i ), 0 ); - num_i_ = num_i; - den_i_ = 2 << den_i; - clocks_1_i_ = clocks_4_i * 4; - mudela_str_ = "% \\Time: "; - mudela_str_ += String( num_i_ ) + "/" + String( den_i_ ) - + ", " + String( clocks_1_i_ ) - + ": " + String( count_32_i ); -} - -Midi_time::~Midi_time() -{ -} - -Duration -Midi_time::i2_dur( int time_i, int division_1_i ) -{ - Moment mom = Duration_convert::i2_mom( time_i, division_1_i ); - mom /= sync_f_; - - dtor << "\n% (" << time_i << ", " << mom << "): " - << sync_f_ << endl; - - Duration dur = Duration_convert::mom2_dur( mom ); - if ( !dur.type_i_ ) { - vtor << "\n% resyncing(" << time_i << ", " << mom << "): " - << sync_f_ << " -> "; - mom *= sync_f_; - sync_f_ = Duration_convert::sync_f( sync_dur_, mom ); - vtor << sync_f_ << endl; - mom /= sync_f_; - dur = Duration_convert::mom2_dur( mom ); - } - - return dur; -} - -int -Midi_time::clocks_1_i() -{ - return clocks_1_i_; -} - diff --git a/src/midi-item.cc b/src/midi-item.cc deleted file mode 100644 index 9d121cfcd8..0000000000 --- a/src/midi-item.cc +++ /dev/null @@ -1,196 +0,0 @@ -// -// midi-item.cc -// -// source file of the LilyPond music typesetter -// -// (c) 1997 Jan Nieuwenhuizen - -#include -#include "plist.hh" -#include "pcol.hh" -#include "debug.hh" -#include "misc.hh" -#include "request.hh" -#include "musicalrequest.hh" -#include "voice.hh" -#include "midi-item.hh" -#include "midi-stream.hh" -#include "string-convert.hh" - -Midi_chunk::Midi_chunk() -{ -} - -void -Midi_chunk::add( String str ) -{ - data_str_ += str; -} - -void -Midi_chunk::set( String header_str, String data_str, String footer_str ) -{ - data_str_ = data_str; - footer_str_ = footer_str; - header_str_ = header_str; -} - -String -Midi_chunk::str() -{ - String str = header_str_; - String length_str = String_convert::i2hex_str( data_str_.length_i() + footer_str_.length_i(), 8, '0' ); - length_str = String_convert::hex2bin_str( length_str ); - str += length_str; - str += data_str_; - str += footer_str_; - return str; -} - -Midi_duration::Midi_duration( Real seconds_f ) -{ - seconds_f_ = seconds_f; -} - -String -Midi_duration::str() -{ - return String( ""; -} - -Midi_header::Midi_header( int format_i, int tracks_i, int clocks_per_4_i ) -{ - String str; - - String format_str = String_convert::i2hex_str( format_i, 4, '0' ); - str += String_convert::hex2bin_str( format_str ); - - String tracks_str = String_convert::i2hex_str( tracks_i, 4, '0' ); - str += String_convert::hex2bin_str( tracks_str ); - - String tempo_str = String_convert::i2hex_str( clocks_per_4_i, 4, '0' ); - str += String_convert::hex2bin_str( tempo_str ); - - set( "MThd", str, "" ); -} - -String -Midi_item::i2varint_str( int i ) -{ - int buffer_i = i & 0x7f; - while ( (i >>= 7) > 0 ) { - buffer_i <<= 8; - buffer_i |= 0x80; - buffer_i += (i & 0x7f); - } - - String str; - while ( 1 ) { - str += (char)buffer_i; - if ( buffer_i & 0x80 ) - buffer_i >>= 8; - else - break; - } - return str; -} - -void -Midi_item::output_midi( Midi_stream& midi_stream_r ) -{ - midi_stream_r << str(); -} - - -Midi_note::Midi_note( Melodic_req* melreq_l, int channel_i, bool on_bo ) -{ - assert(melreq_l); - pitch_i_ = melreq_l->pitch() + c0_pitch_i_c_; - channel_i_ = channel_i; - - // poor man-s staff dynamics: - dynamic_byte_ = (melreq_l)? 0x64 - 0x10 * channel_i_:0; - on_b_ = on_bo; -} - -String -Midi_note::str() -{ - if ( pitch_i_ != INT_MAX ) { - Byte status_byte = ( on_b_ ? 0x90 : 0x80 ) + channel_i_; - String str = String( (char)status_byte ); - str += (char)pitch_i_; - // poor man-s staff dynamics: - str += (char)dynamic_byte_; - return str; - } - return String( "" ); -} - -Midi_tempo::Midi_tempo( int tempo_i ) -{ - tempo_i_ = tempo_i; -} - -String -Midi_tempo::str() -{ - int useconds_per_4_i = 60 * (int)1e6 / tempo_i_; - String str = "ff5103"; - str += String_convert::i2hex_str( useconds_per_4_i, 6, '0' ); - return String_convert::hex2bin_str( str ); -} - -Midi_track::Midi_track( int number_i ) -{ -// 4D 54 72 6B MTrk -// 00 00 00 3B chunk length (59) -// 00 FF 58 04 04 02 18 08 time signature -// 00 FF 51 03 07 A1 20 tempo - -// FF 59 02 sf mi Key Signature -// sf = -7: 7 flats -// sf = -1: 1 flat -// sf = 0: key of C -// sf = 1: 1 sharp -// sf = 7: 7 sharps -// mi = 0: major key -// mi = 1: minor key - - number_i_ = number_i; - - char const* data_ch_c_l = "00" "ff58" "0404" "0218" "08" -// "00" "ff51" "0307" "a120" -// why a key at all, in midi? -// key: C - "00" "ff59" "02" "00" "00" -// key: F (scsii-menuetto) -// "00" "ff59" "02" "ff" "00" - ; - - String data_str; - // only for format 0 (currently using format 1)? - data_str += String_convert::hex2bin_str( data_ch_c_l ); - - char const* footer_ch_c_l = "00" "ff2f" "00"; - String footer_str = String_convert::hex2bin_str( footer_ch_c_l ); - - set( "MTrk", data_str, footer_str ); -} - -void -Midi_track::add( int delta_time_i, String event_str ) -{ - assert(delta_time_i >= 0); - Midi_chunk::add( i2varint_str( delta_time_i ) + event_str ); -} - -void -Midi_track::add( Moment delta_time_moment, Midi_item* mitem_l ) -{ - // use convention of 384 clocks per 4 - // use Duration_convert - int delta_time_i = delta_time_moment * Moment( 384 ) / Moment( 1, 4 ); - add( delta_time_i, mitem_l->str() ); -} - diff --git a/src/midi-main.cc b/src/midi-main.cc deleted file mode 100644 index 90aad5299e..0000000000 --- a/src/midi-main.cc +++ /dev/null @@ -1,205 +0,0 @@ -// -// midi-main.cc -- implement silly main() entry point -// should have Root class. -// -// copyright 1997 Jan Nieuwenhuizen - -#include -#include -#include "proto.hh" -#include "plist.hh" -#include "version.hh" -#include "fversion.hh" -#include "string.hh" -#include "lgetopt.hh" -#include "source.hh" -#include "source-file.hh" -#include "midi-main.hh" -#include "moment.hh" -#include "duration.hh" -#include "midi-event.hh" -#include "midi-track.hh" -#include "my-midi-lexer.hh" -#include "my-midi-parser.hh" - -Source source; -Source* source_l_g = &source; - -Verbose level_ver = NORMAL_ver; - -// ugh -bool no_triplets_bo_g = false; - -//ugh -char const* defined_ch_c_l = 0; - -// ugh, another global -String -find_file( String str ) -{ - return str; -} - -// ugh, copied from warn.cc, cannot use -void -message( String message_str, char const* context_ch_c_l ) -{ - String str = "m2m: "; - 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(": "); - } - str += message_str; - if ( sourcefile_l ) { - str += ":\n"; - str += sourcefile_l->error_str( context_ch_c_l ); - } -// if ( busy_parsing() ) -// cerr << endl; - cerr << str << endl; -} - -void -warning( String message_str, char const* context_ch_c_l ) -{ - message( "warning: " + message_str, context_ch_c_l ); -} - -void -error( String message_str, char const* context_ch_c_l ) -{ - message( message_str, context_ch_c_l ); - // since when exits error again? - // i-d say: error: errorlevel |= 1; -> no output upon error - // warning: recovery -> output (possibly wrong) - if ( midi_lexer_l_g ) - midi_lexer_l_g->errorlevel_i_ |= 1; -} - -void -help() -{ - btor << - "--debug, -d be really verbose\n" - "--help, -h this help\n" - "--include=DIR, -I DIR add DIR to search path\n" - "--no-triplets, -n assume no triplets\n" - "--output=FILE, -o FILE set FILE as default output\n" - "--quiet, -q be quiet\n" - "--verbose, -v be verbose\n" - "--warranty, -w show warranty & copyright\n" - ; -} - -void -identify() -{ - mtor << version_str() << endl; -} - -void -notice() -{ - mtor << - "\n" - "M2m, translate midi to mudela.\n" - "Copyright (C) 1997 by\n" - " Han-Wen Nienhuys \n" -// "Contributors\n" - " Jan Nieuwenhuizen \n" -// " Mats Bengtsson \n" - "\n" - " This program is free software; you can redistribute it and/or\n" - "modify it under the terms of the GNU General Public License version 2\n" - "as published by the Free Software Foundation.\n" - "\n" - " This program is distributed in the hope that it will be useful,\n" - "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" - "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n" - "General Public License for more details.\n" - "\n" - " You should have received a copy (refer to the file COPYING) of the\n" - "GNU General Public License along with this program; if not, write to\n" - "the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n" - "USA.\n"; -} - -// should simply have Root class... -String -version_str() -{ - return String ( "This is m2m " ) + VERSIONSTR - + "/FlowerLib " + FVERSIONSTR - + " of " + __DATE__ + " " + __TIME__; -} - -int -main( int argc_i, char* argv_sz_a[] ) -{ - long_option_init long_option_init_a[] = { - 0, "debug", 'd', - 0, "help", 'h', -// 1, "include", 'I', - 0, "no-triplets", 'n', - 1, "output", 'o', - 0, "quiet", 'q', - 0, "verbose", 'v', - 0, "warranty", 'w', - 0,0,0 - }; - Getopt_long getopt_long( argc_i, argv_sz_a, long_option_init_a ); - identify(); - - String output_str; - while ( long_option_init* long_option_init_p = getopt_long() ) - switch ( long_option_init_p->shortname ) { - case 'd': - level_ver = DEBUG_ver; - break; - case 'h': - help(); - exit( 0 ); - break; -// case 'I': -// path->push( getopt_long.optarg ); -// break; - case 'n': - no_triplets_bo_g = true; - break; - case 'o': - output_str = getopt_long.optarg; - break; - case 'q': - level_ver = QUIET_ver; - break; - case 'v': - level_ver = VERBOSE_ver; - break; - case 'w': - notice(); - exit( 0 ); - break; - default: - assert( 0 ); - break; - } - - char* arg_sz = 0; - while ( ( arg_sz = getopt_long.get_next_arg() ) ) { - My_midi_parser midi_parser( arg_sz ); - int error_i = midi_parser.parse(); - if ( error_i ) - return error_i; - if ( !output_str.length_i() ) { - output_str = String( arg_sz ) + ".ly"; - // i-m sure there-s already some routine for this - int name_i; // too bad we can-t declare local to if - if ( ( name_i = output_str.index_last_i( '/' ) ) != -1 ) - output_str = output_str.mid_str( name_i + 1, INT_MAX ); - } - error_i = midi_parser.output_mudela( output_str ); - if ( error_i ) - return error_i; - } - return 0; -} diff --git a/src/midi-output.cc b/src/midi-output.cc deleted file mode 100644 index af298f74dd..0000000000 --- a/src/midi-output.cc +++ /dev/null @@ -1,52 +0,0 @@ -/* - midi-output.cc -- implement Midi_output - - source file of the LilyPond music typesetter - - (c) 1997 Han-Wen Nienhuys , Jan Nieuwehuizen -*/ - -#include "plist.hh" -#include "debug.hh" -#include "score.hh" -#include "staff.hh" -#include "midi-stream.hh" -#include "midi-def.hh" -#include "midi-output.hh" -#include "midi-walker.hh" -#include "midi-item.hh" -#include "staff-column.hh" -#include "musicalrequest.hh" - - -Midi_output:: Midi_output(Score* score_l, Midi_def* midi_l ) -{ - midi_l_ = midi_l; - - Midi_stream midi_stream(midi_l->outfile_str_, - score_l->staffs_.size(), - 384 ); -// oeps, not tempo, but clocks per 4 (384 convention) -// must set tempo in tempo request -// midi_l->get_tempo_i(Moment(1, 4))); - - midi_stream_l_ = &midi_stream; - int track_i=0; - - for (iter_top(score_l->staffs_,i); i.ok(); i++) { - do_staff(i, track_i++); - } - -} - -void -Midi_output::do_staff(Staff*st_l,int track_i) -{ - Midi_track midi_track( track_i ); - Midi_tempo midi_tempo( midi_l_->get_tempo_i( Moment( 1, 4 ) ) ); - midi_track.add( Moment( 0.0 ), &midi_tempo ); - for (Midi_walker w (st_l, &midi_track); w.ok(); w++) - w.process_requests(); - - *midi_stream_l_ << midi_track; -} diff --git a/src/midi-score.cc b/src/midi-score.cc deleted file mode 100644 index 02905b8718..0000000000 --- a/src/midi-score.cc +++ /dev/null @@ -1,63 +0,0 @@ -// -// midi-score.cc -- implement Midi_score -// -// copyright 1997 Jan Nieuwenhuizen - -#include "proto.hh" -#include "plist.hh" -#include "string.hh" -#include "moment.hh" -#include "duration.hh" -#include "source-file.hh" -#include "source.hh" -#include "midi-main.hh" // *tors -#include "midi-event.hh" -#include "lily-stream.hh" -#include "track-column.hh" -#include "midi-track.hh" -#include "midi-score.hh" - -Midi_score::Midi_score( int format_i, int tracks_i, int tempo_i ) -{ - format_i_ = format_i; - tracks_i_ = tracks_i; - tempo_i_ = tempo_i; -} - -Midi_score::~Midi_score() -{ -} - -void -Midi_score::add_track( Midi_track* midi_track_p ) -{ - midi_track_p_list_.bottom().add( midi_track_p ); -} - -int -Midi_score::output_mudela( String filename_str ) -{ - mtor << "Lily output to " << filename_str << " ..." << endl; - - Lily_stream lily_stream( filename_str ); - for ( PCursor midi_track_l_pcur( midi_track_p_list_.top() ); midi_track_l_pcur.ok(); midi_track_l_pcur++ ) { - midi_track_l_pcur->output_mudela( lily_stream ); - lily_stream << "\n"; - } - - lily_stream << "score {\n"; - - for ( PCursor midi_track_l_pcur( midi_track_p_list_.top() ); midi_track_l_pcur.ok(); midi_track_l_pcur++ ) { - lily_stream << "\tstaff { melodic music { "; - lily_stream << midi_track_l_pcur->name_str(); - lily_stream << " } }\n"; - } - - lily_stream << "\tcommands { meter { 4*4 } }\n"; - lily_stream << "\tmidi { tempo 4:60 }\n"; - - lily_stream << "}\n"; - - return 0; -} - diff --git a/src/midi-stream.cc b/src/midi-stream.cc deleted file mode 100644 index 3630831ac6..0000000000 --- a/src/midi-stream.cc +++ /dev/null @@ -1,89 +0,0 @@ -// -// midi-stream.cc -// -// source file of the LilyPond music typesetter -// -// (c) 1997 Jan Nieuwenhuizen - -#include -#include -#include "main.hh" -#include "misc.hh" -#include "midi-item.hh" -#include "midi-stream.hh" -#include "debug.hh" -#include "string-convert.hh" - -Midi_stream::Midi_stream( String filename_str, int tracks_i, int clocks_per_4_i ) -{ - filename_str_ = filename_str; - tracks_i_ = tracks_i; - clocks_per_4_i_ = clocks_per_4_i; - os_p_ = 0; - open(); - header(); -} - -Midi_stream::~Midi_stream() -{ - delete os_p_; -} - -Midi_stream& -Midi_stream::operator <<( String str ) -{ - // still debugging... - if ( check_debug ) - str = String_convert::bin2hex_str( str ); - // string now 1.0.26-2 handles binary streaming - *os_p_ << str; - return *this; -} - -Midi_stream& -Midi_stream::operator <<( Midi_item& mitem_r ) -{ - mitem_r.output_midi( *this ); - if ( check_debug ) - *os_p_ << "\n"; - return *this; -} - -Midi_stream& -Midi_stream::operator <<( int i ) -{ - // output binary string ourselves - *this << Midi_item::i2varint_str( i ); - return *this; -} - -void -Midi_stream::header() -{ -// *os_p_ << "% Creator: " << get_version(); -// *os_p_ << "% Automatically generated, at "; -// time_t t(time(0)); -// *os_p_ << ctime(&t); - -// 4D 54 68 64 MThd -// String str = "MThd"; -// 00 00 00 06 chunk length -// 00 01 format 1 -// 00 01 one track -// 00 60 96 per quarter-note - -// char const ch_c_l = "0000" "0006" "0001" "0001" "0060"; -// str += String_convert::hex2bin_str( ch_c_l ); -// *os_p_ << str; - -// *this << Midi_header( 1, 1, tempo_i_ ); - *this << Midi_header( 1, tracks_i_, clocks_per_4_i_ ); -} - -void -Midi_stream::open() -{ - os_p_ = new ofstream( filename_str_ ); - if ( !*os_p_ ) - error ("can't open `" + filename_str_ + "\'" ); -} diff --git a/src/midi-template.cc b/src/midi-template.cc deleted file mode 100644 index c2bfd01eaa..0000000000 --- a/src/midi-template.cc +++ /dev/null @@ -1,29 +0,0 @@ -// -// midi-template.cc -- implementemplate -// -// copyright 1997 Jan Nieuwenhuizen - -#include "list.tcc" -#include "cursor.tcc" - -L_instantiate(void *); - -class istream; -class ostream; -#include "proto.hh" -#include "plist.tcc" -#include "pcursor.tcc" -#include "string.hh" -#include "source-file.hh" - -#include "moment.hh" -#include "duration.hh" -#include "midi-event.hh" -#include "lily-stream.hh" -#include "track-column.hh" -#include "midi-track.hh" - -IPL_instantiate(Midi_event); -IPL_instantiate(Midi_track); -IPL_instantiate(Source_file); -IPL_instantiate(Track_column); diff --git a/src/midi-track.cc b/src/midi-track.cc deleted file mode 100644 index 6fccd518ec..0000000000 --- a/src/midi-track.cc +++ /dev/null @@ -1,84 +0,0 @@ -// -// midi-track.cc -- implement Midi_track -// -// copyright 1997 Jan Nieuwenhuizen - -#include "proto.hh" -#include "plist.hh" -#include "string.hh" -#include "source-file.hh" -#include "source.hh" -#include "midi-main.hh" // *tors - -#include "moment.hh" -#include "duration.hh" -#include "midi-event.hh" -#include "lily-stream.hh" -#include "track-column.hh" -#include "midi-track.hh" - -Midi_track::Midi_track( int track_i ) -{ - name_str_ = String( "track" ) + String( track_i ); - tcol_p_list_.bottom().add( new Track_column( Moment( 0 ) ) ); -} - -Midi_track::~Midi_track() -{ -} - -void -Midi_track::add_event( Moment mom, Midi_event* midi_event_p ) -{ - if ( ! midi_event_p ) - return; - tcol_l( mom - midi_event_p->mom() )->add_event( midi_event_p ); -} - -// too much red tape ? -String -Midi_track::name_str() -{ - return name_str_; -} - -void -Midi_track::output_mudela( Lily_stream& lily_stream_r ) -{ - lily_stream_r << name_str_ << " = music { $\n"; - lily_stream_r << "\t"; - int column_i = 8; - - for ( PCursor tcol_l_pcur( tcol_p_list_.top() ); tcol_l_pcur.ok(); tcol_l_pcur++ ) { - if ( tcol_l_pcur->midi_event_p_list_.size() > 1 ) - warning( "oeps, chord: can-t do that yet", 0 ); - if ( !tcol_l_pcur->midi_event_p_list_.size() ) - continue; - lily_stream_r << **tcol_l_pcur->midi_event_p_list_.top(); - column_i += tcol_l_pcur->midi_event_p_list_.top()->mudela_str().length_i(); - if ( column_i > 40 ) { - lily_stream_r << "\n\t"; - column_i = 8; - } - } - lily_stream_r << "\n$} % " << name_str_ << "\n"; -} - -Track_column* -Midi_track::tcol_l( Moment mom ) -{ - for ( PCursor tcol_l_pcur( tcol_p_list_.top() ); tcol_l_pcur.ok(); tcol_l_pcur++ ) { - if ( tcol_l_pcur->mom() == mom ) - return *tcol_l_pcur; - if ( tcol_l_pcur->mom() > mom ) { - Track_column* tcol_p = new Track_column( mom ); - tcol_l_pcur.insert( tcol_p ); - return tcol_p; - } - } - - Track_column* tcol_p = new Track_column( mom ); - tcol_p_list_.bottom().add( tcol_p ); - return tcol_p; -} - diff --git a/src/my-midi-lexer.cc b/src/my-midi-lexer.cc deleted file mode 100644 index 4aa37d3146..0000000000 --- a/src/my-midi-lexer.cc +++ /dev/null @@ -1,81 +0,0 @@ -// -// my-midi-lexer.cc -- implement My_midi_lexer -// -// copyright 1997 Jan Nieuwenhuizen - -#include "debug.hh" -#include "input-file.hh" -#include "source-file.hh" -#include "my-midi-lexer.hh" - -int -yylex() -{ - return midi_lexer_l_g->yylex(); -} - -My_midi_lexer* midi_lexer_l_g; - -My_midi_lexer::My_midi_lexer( String filename_str ) -{ - input_file_p_ = new Input_file( filename_str ); - switch_streams( input_file_p_->is ); - midi_lexer_l_g = this; - errorlevel_i_ = 0; -} - -My_midi_lexer::~My_midi_lexer() -{ - delete input_file_p_; - midi_lexer_l_g = 0; -} - -void -My_midi_lexer::error( char const* sz_l ) -{ - if ( !input_file_p_ ) { -// *mlog << "error at EOF" << sz_l << '\n'; - cerr << "error at EOF" << sz_l << '\n'; - } else { - char const* ch_c_l = here_ch_c_l(); - if ( ch_c_l ) { - ch_c_l--; - while ( ( *ch_c_l == ' ' ) || ( *ch_c_l == '\t' ) || ( *ch_c_l == '\n' ) ) - ch_c_l--; - ch_c_l++; - } - errorlevel_i_ |= 1; -// ::error( sz_l, ch_c_l ); - ::error( sz_l, ch_c_l ); - } -} - -char const* -My_midi_lexer::here_ch_c_l() -{ - return input_file_p_->sourcefile_l_->ch_c_l() + yyin->tellg(); -} - -int -My_midi_lexer::varint2_i( String str ) -{ - int var_i = 0; - - for ( int i = 0; i < str.length_i(); i++ ) { - Byte byte = str[ i ]; - var_i <<= 7; - var_i += byte & 0x7f; - if ( ! ( byte & 0x80 ) ) - return var_i; - } - cout << "\nvarint2_i:" << String_convert::bin2hex_str( str ) << endl; - assert( 0 ); // illegal varint - return 0; -} - -int -My_midi_lexer::close_i() -{ - return 0; -} - diff --git a/src/my-midi-parser.cc b/src/my-midi-parser.cc deleted file mode 100644 index 31555f79af..0000000000 --- a/src/my-midi-parser.cc +++ /dev/null @@ -1,164 +0,0 @@ -// -// my-midi-parser.cc -- implement My_midi_parser -// -// copyright 1997 Jan Nieuwenhuizen - -#include "proto.hh" - -#include "plist.hh" // ugh -#include "string.hh" -#include "source-file.hh" -#include "source.hh" -#include "midi-main.hh" // *tors - -#include "my-midi-lexer.hh" -#include "my-midi-parser.hh" -#include "duration.hh" -#include "midi-event.hh" -#include "lily-stream.hh" -#include "track-column.hh" -#include "midi-track.hh" -#include "midi-score.hh" -#include "my-midi-lexer.hh" -#include "my-midi-parser.hh" - -void -yyerror(char const* sz_l ) -{ - midi_parser_l_g->error( sz_l ); -} - - -My_midi_parser* midi_parser_l_g; - -My_midi_parser::My_midi_parser( String filename_str ) -{ - midi_lexer_p_ = new My_midi_lexer( filename_str ); - midi_parser_l_g = this; - defined_ch_c_l_ = 0; - fatal_error_i_ = 0; - midi_key_p_ = 0; - midi_score_p_ = 0; - midi_tempo_p_ = 0; - midi_time_p_ = 0; - reset(); -} - -void -My_midi_parser::reset() -{ - delete midi_key_p_; - midi_key_p_ = new Midi_key( 0, 0 ); - // useconds per 4: 250000 === 60 4 per minute - delete midi_tempo_p_; - midi_tempo_p_ = new Midi_tempo( 250000 ); - delete midi_time_p_; - midi_time_p_ = new Midi_time( 4, 4, 384, 8 ); - - now_i64_ = 0; - - for ( int i = 0; i < CHANNELS_i; i++ ) - for ( int j = 0; j < PITCHES_i; j++ ) -// running_i64_i64_a_[ i ][ j ] = -1; - running_i64_i64_a_[ i ][ j ] = 0; -} - -My_midi_parser::~My_midi_parser() -{ - delete midi_lexer_p_; - midi_parser_l_g = 0; - delete midi_key_p_; - delete midi_tempo_p_; - delete midi_time_p_; - delete midi_score_p_; -} - -void -My_midi_parser::add_score( Midi_score* midi_score_p ) -{ - assert( !midi_score_p_ ); - midi_score_p_ = midi_score_p; -} - -void -My_midi_parser::error( char const* sz_l ) -{ - midi_lexer_l_g->error( sz_l ); - - if ( fatal_error_i_ ) - exit( fatal_error_i_ ); -} - -void -My_midi_parser::forward( int i ) -{ - now_i64_ += i; -} - -Moment -My_midi_parser::mom() -{ - return Duration_convert::i2_mom( now_i64_, division_1_i_ ); -} - -void -My_midi_parser::note_begin( int channel_i, int pitch_i, int dyn_i ) -{ - // one pitch a channel at time! - // heu, what about { < c2 > < c4 d4 > } -// assert( running_i64_i64_a_[ channel_i ][ pitch_i ] == -1 ); - running_i64_i64_a_[ channel_i ][ pitch_i ] = now_i64_; -} - -Midi_event* -My_midi_parser::note_end_midi_event_p( int channel_i, int pitch_i, int dyn_i ) -{ - Int64 start_i64 = running_i64_i64_a_[ channel_i ][ pitch_i ]; -// running_i64_i64_a_[ channel_i ][ pitch_i ] = -1; - // did we start? -// assert( start_i64 != -1 ); - return new Midi_note( midi_key_p_, midi_time_p_, division_1_i_, pitch_i, now_i64_ - start_i64 ); -} - -int -My_midi_parser::output_mudela( String filename_str ) -{ - assert( midi_score_p_ ); - return midi_score_p_->output_mudela( filename_str ); -} - -int -My_midi_parser::parse() -{ - return ::yyparse(); -} - -void -My_midi_parser::set_division_4( int division_4_i ) -{ - division_1_i_ = division_4_i * 4; - if ( division_4_i < 0 ) - warning( "seconds iso metrical time" , 0 ); -} - -void -My_midi_parser::set_key( int accidentals_i, int minor_i ) -{ - delete midi_key_p_; - midi_key_p_ = new Midi_key( accidentals_i, minor_i ); -} - -void -My_midi_parser::set_tempo( int useconds_i ) -{ - delete midi_tempo_p_; - midi_tempo_p_ = new Midi_tempo( useconds_i ); -} - -void -My_midi_parser::set_time( int num_i, int den_i, int clocks_i, int count_32_i ) -{ - delete midi_time_p_; - midi_time_p_ = new Midi_time( num_i, den_i, clocks_i, count_32_i ); -} - diff --git a/src/track-column.cc b/src/track-column.cc deleted file mode 100644 index 22a828376f..0000000000 --- a/src/track-column.cc +++ /dev/null @@ -1,35 +0,0 @@ -// -// track-column.cc -- implement Track_column -// -// copyright 1997 Jan Nieuwenhuizen - -#include "proto.hh" -#include "plist.hh" -#include "string.hh" -#include "moment.hh" -#include "duration.hh" -#include "midi-event.hh" -#include "lily-stream.hh" -#include "track-column.hh" -#include "midi-track.hh" - -Track_column::Track_column( Moment mom ) -{ - mom_ = mom; -} - -Track_column::~Track_column() -{ -} - -void -Track_column::add_event( Midi_event* midi_event_p ) -{ - midi_event_p_list_.bottom().add( midi_event_p ); -} - -Moment -Track_column::mom() -{ - return mom_; -} diff --git a/tex/Makefile b/tex/Makefile new file mode 100644 index 0000000000..7098987a94 --- /dev/null +++ b/tex/Makefile @@ -0,0 +1,20 @@ +# tex/Makefile + +# subdir level: +# +depth = .. +# + +build = ./$(depth)/lily/.build + +# generic stuff/Makefile +# +include ./$(depth)/make/Stuff.make +# + +# list of distribution files: +# +TEXFILES = $(shell ls *.tex) +DISTFILES = Makefile $(TEXFILES) +# + diff --git a/dimen.tex b/tex/dimen.tex similarity index 100% rename from dimen.tex rename to tex/dimen.tex diff --git a/lilyponddefs.tex b/tex/lilyponddefs.tex similarity index 100% rename from lilyponddefs.tex rename to tex/lilyponddefs.tex diff --git a/ltest.tex b/tex/ltest.tex similarity index 100% rename from ltest.tex rename to tex/ltest.tex diff --git a/test.tex b/tex/test.tex similarity index 100% rename from test.tex rename to tex/test.tex diff --git a/titledefs.tex b/tex/titledefs.tex similarity index 100% rename from titledefs.tex rename to tex/titledefs.tex -- 2.39.5