]> git.donarmstrong.com Git - lilypond.git/commitdiff
Lilypond-book: Fix problem with os.path.abspath in Windows
authorReinhold Kainhofer <reinhold@kainhofer.com>
Mon, 6 Sep 2010 19:25:16 +0000 (21:25 +0200)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Mon, 6 Sep 2010 19:25:16 +0000 (21:25 +0200)
The check whether input file == output file needs to use the absolute
path to the input file, since the CWD has changed meanwhile (and is
the output dir at that point). Unfortunately, we can't call os.path.abspath
right at the beginning and use the abspath for all of the processing,
because os.path.abspath will replace forward slashes by backslashes
in Windows (the path is normalized!). That path with backslashes
are then printed to the snippet map files and cause l-p to fail with
wrongly escaped characters...

As a solution, use the relative pathname of the input file for all
processing, but also store the abspath for that one particular
infile==outfile check.

scripts/lilypond-book.py

index 832cea0c6292ad1f77a79f2d6dda7337ab39d3f3..f8f09966fdf49c1e0b4c135b43302fe4d38252cb 100644 (file)
@@ -487,6 +487,7 @@ def samefile (f1, f2):
 
 def do_file (input_filename, included=False):
     # Ugh.
+    input_absname = input_filename
     if not input_filename or input_filename == '-':
         in_handle = sys.stdin
         input_fullname = '<stdin>'
@@ -499,7 +500,7 @@ def do_file (input_filename, included=False):
         # Otherwise, "lilypond-book -o out test.tex" will complain that it is
         # overwriting the input file (which it is actually not), since the
         # input filename is relative to the CWD...
-        input_fullname = os.path.abspath (input_fullname)
+        input_absname = os.path.abspath (input_fullname)
 
         note_input_file (input_fullname)
         in_handle = file (input_fullname)
@@ -526,7 +527,7 @@ def do_file (input_filename, included=False):
                                    input_base + global_options.formatter.default_extension)
     if (os.path.exists (input_filename)
         and os.path.exists (output_filename)
-        and samefile (output_filename, input_fullname)):
+        and samefile (output_filename, input_absname)):
      error (
      _ ("Output would overwrite input file; use --output."))
      exit (2)