]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/source-file.cc
* lily/source-file.cc (get_line): oops. All line numbers were off
[lilypond.git] / lily / source-file.cc
index 1ff2f3d6d4965d819e3be6f3953363b62fb39350..0520502e540ca4dff1a6f0fefff1261fda6986c8 100644 (file)
@@ -84,9 +84,6 @@ Source_file::Source_file (String filename, String data)
   init_port();
 }
 
-
-
-
 Source_file::Source_file (String filename_string)
 {
   name_string_ = filename_string;
@@ -262,15 +259,24 @@ Source_file::get_line (char const* pos_str0) const
   if (!in_b (pos_str0))
     return 0;
 
+  if (!newline_locations_.size())
+    return 1;
+  
   int lo=0;
   int hi = newline_locations_.size();
+
+  if (newline_locations_[lo] > pos_str0)
+    return 1;
+  
+  if (newline_locations_[hi-1] < pos_str0)
+    return hi;
   
   binary_search_bounds (newline_locations_,
                        pos_str0, 
                        Link_array<char>::default_compare,
                        &lo, &hi);
   
-  return lo;
+  return lo + 2;
 }
 
 int