From 3bb21ac9ac9be5bd7d45f2e64ee549f5c9f02b08 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sun, 3 Nov 2002 14:54:42 +0000 Subject: [PATCH] * scripts/midi2ly.py: Fix global syntax warnings. * GNUmakefile.in: Generate builddir locale tree too. * scripts/ly2dvi.py: * scripts/midi2ly.py: * scripts/mup2ly.py: * scripts/update-lily.py: * lily/main.cc (setup_paths): Fix for locales setup. --- ChangeLog | 14 +++++++++ GNUmakefile.in | 8 +++++ lily/main.cc | 19 ++++-------- scripts/lilypond-book.py | 2 +- scripts/ly2dvi.py | 65 ++++++++++++++++++++++++++++++---------- scripts/midi2ly.py | 13 ++++---- scripts/mup2ly.py | 3 +- scripts/update-lily.py | 4 +-- 8 files changed, 86 insertions(+), 42 deletions(-) diff --git a/ChangeLog b/ChangeLog index 827f2a6286..8734b1f306 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2002-11-03 Jan Nieuwenhuizen + + * stepmake/stepmake/po-targets.make: Remove --c++ option. + + * scripts/midi2ly.py: Fix global syntax warnings. + + * GNUmakefile.in: Generate builddir locale tree too. + + * scripts/ly2dvi.py: + * scripts/midi2ly.py: + * scripts/mup2ly.py: + * scripts/update-lily.py: + * lily/main.cc (setup_paths): Fix for locales setup. + 2002-10-29 Jan Nieuwenhuizen * Documentation/windows/installing.texi: Soften wording about diff --git a/GNUmakefile.in b/GNUmakefile.in index 568118f0a9..6f0bf75d27 100644 --- a/GNUmakefile.in +++ b/GNUmakefile.in @@ -125,6 +125,10 @@ default: $(config_h) builddir-setup builddir-setup: $(builddir)/share/lilypond-force +PO_FILES = $(wildcard $(srcdir)/po/*.po) +HELP_CATALOGS = $(PO_FILES:$(srcdir)/po/%.po=%) +CATALOGS = $(HELP_CATALOGS:lilypond=) + $(builddir)/share/lilypond-force: # Preparing LilyPond tree for builddir exec cd $(builddir) && rm -rf share @@ -148,6 +152,10 @@ $(builddir)/share/lilypond-force: ln -s ../../../mf/$(outconfbase) afm && \ ln -s ../../../mf/$(outconfbase) tfm && \ ln -s ../../../mf/$(outconfbase) type1 + $(foreach i,$(CATALOGS), \ + mkdir -p $(builddir)/share/locale/$i/LC_MESSAGES && \ + cd $(builddir)/share/locale/$i/LC_MESSAGES && \ + ln -fs ../../../../po/$(outconfbase)/$i.mo lilypond.mo &&) true touch $@ local-clean: builddir-setup-clean diff --git a/lily/main.cc b/lily/main.cc index dd856b5a81..5253bb54f5 100644 --- a/lily/main.cc +++ b/lily/main.cc @@ -231,23 +231,14 @@ setup_paths () prefix_directory[1] = lilypond_prefix; #if HAVE_GETTEXT - setlocale (LC_ALL, ""); /* enable locales */ - setlocale (LC_NUMERIC, "C"); /* musn't have comma's in TeX output... */ + /* Enable locales */ + setlocale (LC_ALL, ""); + /* Mustn't have commas in TeX output... */ + setlocale (LC_NUMERIC, "C"); String lily_locale_dir; String name (PACKAGE); name.to_lower (); - - /* - urg; what *do* we want with $LILYPONDPREFIX, DIR_DATADIR and $prefix/share - handy for multiple source-dir runs, though... - */ - if (!String (prefix_directory[0]).empty_b ()) - { - lily_locale_dir = String (prefix_directory[0]) + "/share/locale"; - bindtextdomain (name.to_str0 (), lily_locale_dir.to_str0 ()); - } - else - bindtextdomain (name.to_str0 (), LOCALEDIR); + bindtextdomain (name.to_str0 (), LOCALEDIR); textdomain (name.to_str0 ()); #endif diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py index 68ff22873f..cd5b6e5c87 100644 --- a/scripts/lilypond-book.py +++ b/scripts/lilypond-book.py @@ -89,7 +89,7 @@ errorport = sys.stderr verbose_p = 0 - +localedir = '@localedir@' try: import gettext gettext.bindtextdomain ('lilypond', localedir) diff --git a/scripts/ly2dvi.py b/scripts/ly2dvi.py index 5f5e0771b4..3e2e1db95f 100644 --- a/scripts/ly2dvi.py +++ b/scripts/ly2dvi.py @@ -90,6 +90,7 @@ try: except: pass +localedir = '@localedir@' try: import gettext gettext.bindtextdomain ('lilypond', localedir) @@ -249,7 +250,7 @@ def system (cmd, ignore_error = 0, quiet =0): name = re.match ('[ \t]*([^ \t]*)', cmd).group (1) msg = name + ': ' + _ ("command exited with value %d") % st if ignore_error: - if not quiet: + if not quiet or verbose_p: warning (msg + ' ' + _ ("(ignored)") + ' ') else: error (msg) @@ -399,20 +400,6 @@ dependency_files = [] -kpse = os.popen ('kpsexpand \$TEXMF').read() -kpse = re.sub('[ \t\n]+$','', kpse) -type1_paths = os.popen ('kpsewhich -expand-path=\$T1FONTS').read () - -environment = { - # TODO: * prevent multiple addition. - # * clean TEXINPUTS, MFINPUTS, TFMFONTS, - # as these take prevalence over $TEXMF - # and thus may break tex run? - 'TEXMF' : "{%s,%s}" % (datadir, kpse) , - 'GS_FONTPATH' : type1_paths, - 'GS_LIB' : datadir + '/ps', -} - # tex needs lots of memory, more than it gets by default on Debian non_path_environment = { 'extra_mem_top' : '1000000', @@ -420,7 +407,53 @@ non_path_environment = { 'pool_size' : '250000', } +def command_name (cmd): + return re.match ('^[ \t]*([^ \t]*)', cmd).group (1) + +def error_log (name): + return os.path.join (__main__.temp_dir, '%s.errorlog' % name) + +def read_pipe (cmd, mode = 'r'): + redirect = '' + if verbose_p: + progress (_ ("Opening pipe `%s\'") % cmd) + redirect = ' 2>%s' % error_log (command_name (cmd)) + pipe = os.popen (cmd + redirect, mode) + output = pipe.read () + status = pipe.close () + # successful pipe close returns 'None' + if not status: + status = 0 + signal = 0x0f & status + exit_status = status >> 8 + + if status: + sys.stderr.write (_ ("`%s\' failed (%d)") % (cmd, exit_status)) + if not verbose_p: + sys.stderr.write (_ ("The error log is as follows:")) + sys.stderr.write (open (error_log (command_name (cmd)).read ())) + sys.exit (status) + if __main__.verbose_p: + progress ('\n') + return output + def setup_environment (): + global environment + + kpse = read_pipe ('kpsexpand \$TEXMF') + texmf = re.sub ('[ \t\n]+$','', kpse) + type1_paths = read_pipe ('kpsewhich -expand-path=\$T1FONTS') + + environment = { + # TODO: * prevent multiple addition. + # * clean TEXINPUTS, MFINPUTS, TFMFONTS, + # as these take prevalence over $TEXMF + # and thus may break tex run? + 'TEXMF' : "{%s,%s}" % (datadir, texmf) , + 'GS_FONTPATH' : type1_paths, + 'GS_LIB' : datadir + '/ps', + } + # $TEXMF is special, previous value is already taken care of if os.environ.has_key ('TEXMF'): del os.environ['TEXMF'] @@ -1002,8 +1035,8 @@ if files: if outdir != '.' and (track_dependencies_p or targets): mkdir_p (outdir, 0777) - setup_environment () tmpdir = setup_temp () + setup_environment () # to be sure, add tmpdir *in front* of inclusion path. #os.environ['TEXINPUTS'] = tmpdir + ':' + os.environ['TEXINPUTS'] diff --git a/scripts/midi2ly.py b/scripts/midi2ly.py index 7fe8b24b04..a0e431aef4 100644 --- a/scripts/midi2ly.py +++ b/scripts/midi2ly.py @@ -4,8 +4,8 @@ # # source file of the GNU LilyPond music typesetter # -# convert MIDI to LilyPond source -# +# (c) 1998--2002 Han-Wen Nienhuys +# Jan Nieuwenhuizen ''' @@ -424,6 +424,7 @@ class Note: return (o, n, a) def dump (self): + global reference_note s = chr ((self.notename + 2) % 7 + ord ('a')) s = s + self.alteration_names[self.alteration + 2] if absolute_p: @@ -444,10 +445,10 @@ class Note: s = s + "," * -commas if explicit_durations_p \ - or Duration.compare (self.duration, reference_note.duration): + or Duration.compare (self.duration, + reference_note.duration): s = s + self.duration.dump () - global reference_note reference_note = self # TODO: move space @@ -1045,13 +1046,10 @@ for opt in options: elif o == '--absolute-pitches' or o == '-a': - global absolute_p absolute_p = 1 elif o == '--duration-quant' or o == '-d': - global duration_quant duration_quant = string.atoi (a) elif o == '--explicit-durations' or o == '-e': - global explicit_durations_p explicit_durations_p = 1 elif o == '--key' or o == '-k': (alterations, minor) = map (string.atoi, string.split (a + ':0', ':'))[0:2] @@ -1061,7 +1059,6 @@ for opt in options: sharps = alterations else: flats = - alterations - global key key = Key (sharps, flats, minor) elif o == '--start-quant' or o == '-s': start_quant = string.atoi (a) diff --git a/scripts/mup2ly.py b/scripts/mup2ly.py index da3a43be25..88868a8e03 100644 --- a/scripts/mup2ly.py +++ b/scripts/mup2ly.py @@ -55,9 +55,10 @@ errorport = sys.stderr keep_temp_dir_p = 0 verbose_p = 0 +localedir = '@localedir@' try: import gettext - gettext.bindtextdomain ('lilypond', '@localedir@') + gettext.bindtextdomain ('lilypond', localedir) gettext.textdomain ('lilypond') _ = gettext.gettext except: diff --git a/scripts/update-lily.py b/scripts/update-lily.py index ad34a284ab..89b13bc773 100644 --- a/scripts/update-lily.py +++ b/scripts/update-lily.py @@ -53,10 +53,10 @@ release_dir = build_root + '/releases' patch_dir = build_root + '/patches' - +localedir = '@localedir@' try: import gettext - gettext.bindtextdomain ('lilypond', '@localedir@') + gettext.bindtextdomain ('lilypond', localedir) gettext.textdomain ('lilypond') _ = gettext.gettext except: -- 2.39.5