From 8f4cae575aefc2710ec11ea79135b16db431305c Mon Sep 17 00:00:00 2001
From: hanwen <hanwen>
Date: Sat, 13 Jul 2002 14:40:42 +0000
Subject: [PATCH] 2002-07-13  Han-Wen  <hanwen@cs.uu.nl>

* scripts/ly2dvi.py (run_latex): show latex error log. Ask for
bugreport if lilypond is killed.

2002-07-12  Mats Bengtsson  <matsb@s3.kth.se>

* lily/beam.cc (after_line_breaking): Set correct stem lengths
also when beam positions are set manually.
(consider_auto_knees): Do not use automatic knees if the directions
are set manually by the user.

2002-07-13  Han-Wen  <hanwen@cs.uu.nl>

* lily/input-smob.cc (make_input): GUILE 1.7 compatibility fixes.
---
 ChangeLog                 | 17 ++++++++++++++--
 autogen.sh                | 11 ++++++----
 lily/beam.cc              | 19 +++++++++--------
 lily/cxx-function-smob.cc |  6 +-----
 lily/duration.cc          |  2 --
 lily/include/ly-smobs.icc | 17 ++++++++--------
 lily/input-smob.cc        |  5 +----
 lily/moment.cc            |  1 -
 scm/script.scm            |  4 +---
 scripts/ly2dvi.py         | 43 ++++++++++++++++++++++++++++++++-------
 stepmake/autogen.sh       |  8 +++++++-
 11 files changed, 87 insertions(+), 46 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 90b0d805af..d2e6c9654d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,11 +1,24 @@
 2002-07-13  Han-Wen  <hanwen@cs.uu.nl>
 
+	* scripts/ly2dvi.py (run_latex): show latex error log. Ask for
+	bugreport if lilypond is killed. 
+
+2002-07-12  Mats Bengtsson  <matsb@s3.kth.se>
+
+	* lily/beam.cc (after_line_breaking): Set correct stem lengths
+	also when beam positions are set manually.
+	(consider_auto_knees): Do not use automatic knees if the directions
+	are set manually by the user.
+
+2002-07-13  Han-Wen  <hanwen@cs.uu.nl>
+
+	* lily/input-smob.cc (make_input): GUILE 1.7 compatibility fixes.
+
 	* lily/beam.cc: complete rewrite of multiplicity. This fixes 16th
 	knees code.
 	(quanting): add french beaming support (property french-beaming)
+	(stem_beams): removed.
 
-
-	
 2002-07-12  Han-Wen  <hanwen@cs.uu.nl>
 
 	* input/regression/grace-auto-beam.ly: new file
diff --git a/autogen.sh b/autogen.sh
index 4cc98ffdf7..e3ee7da81d 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -1,11 +1,14 @@
 #!/bin/sh
-# WARNING WARNING WARNING
-# do not edit! this is autogen.sh, generated from stepmake/autogen.sh
-#!/bin/sh
 # Run this to generate configure and initial GNUmakefiles
 
 srcdir=`dirname $0`
 
+if [ stepmake/autogen.sh -nt autogen.sh ]; then
+    echo "stepmake/autogen.sh is newer. Copying file." 
+    cp -f stepmake/autogen.sh autogen.sh
+    exec ./autogen.sh
+fi
+
 # Be paranoid: check for autoconf == 2.13
 # Some setups have both autoconf 2.13 and 2.50 available through
 # a wrapper script: /usr/bin/autoconf.
@@ -13,7 +16,7 @@ srcdir=`dirname $0`
 # advertises itself as autoconf 2.13.
 # If you have such a setup, invoke this script as:
 #   autoconf=autoconf2.13 ./autogen.sh
-for i in autoconf autoconf2.13 false; do
+for i in autoconf-2.13 autoconf2.13 autoconf  false; do
   version=`$i --version 2>/dev/null | head -1 | awk '{print $NF}' | awk -F. '{print $1 * 100 + $2}'`
   if test "0$version" -eq 213; then
     autoconf=$i
diff --git a/lily/beam.cc b/lily/beam.cc
index a71e306beb..915363e4ac 100644
--- a/lily/beam.cc
+++ b/lily/beam.cc
@@ -304,6 +304,7 @@ Beam::brew_molecule (SCM grob)
   Real last_width = -1 ;
   
 
+  * Determine auto knees based on positions if it's set by the user.
   
   Molecule the_beam;
   Real lt = me->paper_l ()->get_var ("linethickness");
@@ -565,9 +566,10 @@ Beam::consider_auto_knees (Grob *me, Direction d)
 	{
 	  for (int i=0; i < stems.size (); i++)
 	    {
-	      if (Stem::invisible_b (stems[i]))
-		continue;
 	      Item *s = stems[i];	  
+	      if (Stem::invisible_b (s) || 
+		  s->get_grob_property ("dir-forced") == SCM_BOOL_T)
+		continue;
 	      Real y = Stem::extremal_heads (stems[i])[d]
 		->relative_coordinate (common, Y_AXIS);
 
@@ -630,13 +632,14 @@ Beam::after_line_breaking (SCM smob)
   SCM s = ly_deep_copy (me->get_grob_property ("positions"));
   me->set_grob_property ("positions", s);
 
-  if (ly_car (s) != SCM_BOOL_F)
-    return SCM_UNSPECIFIED;
+  if (ly_car (s) == SCM_BOOL_F)
+    {
 
-  // one wonders if such genericity is necessary  --hwn.
-  SCM callbacks = me->get_grob_property ("position-callbacks");
-  for (SCM i = callbacks; gh_pair_p (i); i = ly_cdr (i))
-    gh_call1 (ly_car (i), smob);
+      // one wonders if such genericity is necessary  --hwn.
+      SCM callbacks = me->get_grob_property ("position-callbacks");
+      for (SCM i = callbacks; gh_pair_p (i); i = ly_cdr (i))
+	gh_call1 (ly_car (i), smob);
+    }
 
   set_stem_lengths (me);  
   return SCM_UNSPECIFIED;
diff --git a/lily/cxx-function-smob.cc b/lily/cxx-function-smob.cc
index 603a16203e..6ad764d796 100644
--- a/lily/cxx-function-smob.cc
+++ b/lily/cxx-function-smob.cc
@@ -50,11 +50,7 @@ SCM
 smobify_cxx_function (Cxx_function cb)
 {
   SCM z;
-  
-  SCM_NEWCELL (z);
-  SCM_SETCDR (z, (SCM)cb);
-  SCM_SETCAR (z, (SCM)callback_tag);
-
+  SCM_NEWSMOB(z,callback_tag, cb) ;
   return z;
 }
 
diff --git a/lily/duration.cc b/lily/duration.cc
index 5a6abfd1ca..28b41a0210 100644
--- a/lily/duration.cc
+++ b/lily/duration.cc
@@ -95,8 +95,6 @@ Duration::mark_smob (SCM)
 }
 
 IMPLEMENT_SIMPLE_SMOBS (Duration);
-
-
 int
 Duration::print_smob (SCM s, SCM port, scm_print_state *)
 {
diff --git a/lily/include/ly-smobs.icc b/lily/include/ly-smobs.icc
index b82378dc1b..aa35f4c973 100644
--- a/lily/include/ly-smobs.icc
+++ b/lily/include/ly-smobs.icc
@@ -54,7 +54,7 @@ SCM CL::smobbed_self () const					\
 {								\
   SCM s;							\
   s = gh_cons (SCM_PACK (CL::smob_tag_), SCM_PACK (this));	\
-  scm_done_malloc (sizeof (CL));				\
+  scm_gc_register_collectable_memory ((CL*)this, sizeof (CL), #CL " smob");				\
 								\
   return s;							\
 }								\
@@ -62,9 +62,10 @@ size_t  							\
 CL::free_smob (SCM ses)						\
 {								\
   CL * s = (CL*) SCM_CDR (ses);					\
-   delete s;							\
-  return sizeof (CL);						\
-}								\
+  delete s;							\
+  scm_gc_unregister_collectable_memory (s, sizeof (CL), #CL " smob");  \
+  return 0;\
+}\
 ADD_SCM_INIT_FUNC (CL, CL::init_smobs)
 
 #define IMPLEMENT_SMOBS(CL)							\
@@ -87,12 +88,10 @@ CL::unprotected_smobify_self ()								\
     deal half-initialized objects: scm_done_malloc ( ) might trigger GC.		\
     the warning in smobs.hh is just to be doubleplus goodly sure		\
    */										\
-  SCM s;										\
-  SCM_NEWCELL (s);								\
-  SCM_SETCAR (s,CL::smob_tag_);							\
-  SCM_SETCDR (s, SCM_PACK (this));						\
+  SCM s;\
+  SCM_NEWSMOB (s, CL::smob_tag_, this);\
   self_scm_ = s;								\
- scm_done_malloc (sizeof (CL));							\
+ scm_gc_register_collectable_memory (this, sizeof (CL), #CL " smob");							\
   return s;									\
 }
 
diff --git a/lily/input-smob.cc b/lily/input-smob.cc
index bbd6f34dc3..0ea9b3664c 100644
--- a/lily/input-smob.cc
+++ b/lily/input-smob.cc
@@ -80,10 +80,7 @@ make_input (Input ip)
   Input * nip =  new Input (ip);
   SCM z;
   
-  SCM_NEWCELL (z);
-  SCM_SETCAR (z, (SCM)input_tag);
-  SCM_SETCDR (z, (SCM)nip);
-				// fixme: done_malloc
+  SCM_NEWSMOB (z, input_tag, nip);
   return z;
 }
 
diff --git a/lily/moment.cc b/lily/moment.cc
index 8de57af23b..d44af366e2 100644
--- a/lily/moment.cc
+++ b/lily/moment.cc
@@ -13,7 +13,6 @@
 #include "warn.hh"
 #include "ly-smobs.icc"
 
-
 IMPLEMENT_SIMPLE_SMOBS (Moment);
 IMPLEMENT_TYPE_P (Moment, "moment?");
 
diff --git a/scm/script.scm b/scm/script.scm
index 93f437b9e8..8fde1da280 100644
--- a/scm/script.scm
+++ b/scm/script.scm
@@ -2,17 +2,15 @@
 ;;           follow-into-staff :: bool
 ;;           dir-relative-to-stem :: int
 ;;           force-dir :: int
-;;           priority :: int
 
-;;TODO?      extra padding :: Real (given in staff spaces)
 
+;;           priority :: int -- lower number means closer to the  note head. 
 
 ;; TODO: generate Grob types for this, by prepending appropriate props
 ;; on top of Script (?)  
 
 
 ;; TODO: don't use 2 level indiriection, simply set
-
 ;; thumb = \script #'((feta . ( . .. ) (follow-staff .  #f))
 
 
diff --git a/scripts/ly2dvi.py b/scripts/ly2dvi.py
index 96f0a43b63..bdd9f4ac5a 100644
--- a/scripts/ly2dvi.py
+++ b/scripts/ly2dvi.py
@@ -226,7 +226,7 @@ def setup_temp ():
 	return temp_dir
 
 
-def system (cmd, ignore_error = 0):
+def system (cmd, ignore_error = 0, quiet =0):
 	"""Run CMD. If IGNORE_ERROR is set, don't complain when CMD returns non zero.
 
 	RETURN VALUE
@@ -242,7 +242,8 @@ def system (cmd, ignore_error = 0):
 		name = re.match ('[ \t]*([^ \t]*)', cmd).group (1)
 		msg = name + ': ' + _ ("command exited with value %d") % st
 		if ignore_error:
-			warning (msg + ' ' + _ ("(ignored)") + ' ')
+			if not quiet:
+				warning (msg + ' ' + _ ("(ignored)") + ' ')
 		else:
 			error (msg)
 
@@ -436,12 +437,12 @@ def print_environment ():
 	for (k,v) in os.environ.items ():
 		sys.stderr.write ("%s=\"%s\"\n" % (k,v)) 
 
-def quiet_system (cmd, name):
+def quiet_system (cmd, name, ignore_error = 0):
 	if not verbose_p:
 		progress ( _("Running %s...") % name)
 		cmd = cmd + ' 1> /dev/null 2> /dev/null'
 
-	return system (cmd)
+	return system (cmd, ignore_error, quiet = 1)
 
 
 def run_lilypond (files, outbase, dep_prefix):
@@ -470,8 +471,22 @@ def run_lilypond (files, outbase, dep_prefix):
 
 		# for better debugging!
 		print_environment ()
-	print opts, fs	
-	system ('lilypond %s %s ' % (opts, fs), 'lilypond')
+
+	cmd = 'lilypond %s %s ' % (opts, fs)
+	if  verbose_p:
+		progress ("Invoking `%s'"% cmd)
+	status = os.system (cmd)
+
+	signal = 0x0f & status
+	exit_status = status >> 8
+
+	# 2 == user interrupt.
+	if signal <> 2:
+		error("\n\nLilyPond crashed (signal %d). Please submit a bugreport to bug-lilypond@gnu.org\n" % signal)
+
+	if status:
+		error ("\n\nLilyPond failed on the input file. (exit status %d)\n" % exit_status)
+		
 
 def analyse_lilypond_output (filename, extra):
 	
@@ -669,8 +684,22 @@ None
 	f.close ()
 
 	cmd = 'latex \\\\nonstopmode \\\\input %s' % latex_fn
-	quiet_system (cmd, 'LaTeX')
+	status = quiet_system (cmd, 'LaTeX', ignore_error = 1)
+
+	signal = 0xf & status
+	exit_stat = status >> 8
 
+	if exit_stat:
+		logstr = open (outbase + '.log').read()
+		m = re.search ("\n!", logstr)
+		start = m.start (0)
+		logstr = logstr[start:start+200]
+		
+		sys.stderr.write(_("""LaTeX failed on the output file.
+The error log is as follows:
+%s...\n""" % logstr))
+		raise 'LaTeX error'
+	
 	if preview_p:
 		# make a preview by rendering only the 1st line.
 		preview_fn = outbase + '.preview.tex'
diff --git a/stepmake/autogen.sh b/stepmake/autogen.sh
index ad9781b51c..e3ee7da81d 100755
--- a/stepmake/autogen.sh
+++ b/stepmake/autogen.sh
@@ -3,6 +3,12 @@
 
 srcdir=`dirname $0`
 
+if [ stepmake/autogen.sh -nt autogen.sh ]; then
+    echo "stepmake/autogen.sh is newer. Copying file." 
+    cp -f stepmake/autogen.sh autogen.sh
+    exec ./autogen.sh
+fi
+
 # Be paranoid: check for autoconf == 2.13
 # Some setups have both autoconf 2.13 and 2.50 available through
 # a wrapper script: /usr/bin/autoconf.
@@ -10,7 +16,7 @@ srcdir=`dirname $0`
 # advertises itself as autoconf 2.13.
 # If you have such a setup, invoke this script as:
 #   autoconf=autoconf2.13 ./autogen.sh
-for i in autoconf autoconf2.13 false; do
+for i in autoconf-2.13 autoconf2.13 autoconf  false; do
   version=`$i --version 2>/dev/null | head -1 | awk '{print $NF}' | awk -F. '{print $1 * 100 + $2}'`
   if test "0$version" -eq 213; then
     autoconf=$i
-- 
2.39.5