CVSROOT: /cvsroot/lilypond
Module name: lilypond
Branch:
Changes by: Han-Wen Nienhuys <[EMAIL PROTECTED]> 05/08/22 14:49:23
Modified files:
. : ChangeLog
lily : general-scheme.cc lily-guile.cc lily-parser.cc
pfb.cc source-file.cc
scm : backend-library.scm ps-to-png.scm
Log message:
* lily/lily-guile.cc (gulp_file_to_string): take size argument.
* lily/general-scheme.cc (LY_DEFINE): take optional size argument.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/ChangeLog.diff?tr1=1.4059&tr2=1.4060&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/general-scheme.cc.diff?tr1=1.23&tr2=1.24&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/lily-guile.cc.diff?tr1=1.220&tr2=1.221&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/lily-parser.cc.diff?tr1=1.50&tr2=1.51&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/pfb.cc.diff?tr1=1.20&tr2=1.21&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/source-file.cc.diff?tr1=1.33&tr2=1.34&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scm/backend-library.scm.diff?tr1=1.40&tr2=1.41&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scm/ps-to-png.scm.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
Patches:
Index: lilypond/ChangeLog
diff -u lilypond/ChangeLog:1.4059 lilypond/ChangeLog:1.4060
--- lilypond/ChangeLog:1.4059 Mon Aug 22 14:06:11 2005
+++ lilypond/ChangeLog Mon Aug 22 14:49:23 2005
@@ -1,5 +1,9 @@
2005-08-22 Han-Wen Nienhuys <[EMAIL PROTECTED]>
+ * lily/lily-guile.cc (gulp_file_to_string): take size argument.
+
+ * lily/general-scheme.cc (LY_DEFINE): take optional size argument.
+
* input/regression/tie-manual.ly: new file
* input/regression/tie-chord.ly: update.
Index: lilypond/lily/general-scheme.cc
diff -u lilypond/lily/general-scheme.cc:1.23
lilypond/lily/general-scheme.cc:1.24
--- lilypond/lily/general-scheme.cc:1.23 Sat Aug 13 21:35:23 2005
+++ lilypond/lily/general-scheme.cc Mon Aug 22 14:49:23 2005
@@ -52,12 +52,19 @@
buffering.)
*/
LY_DEFINE (ly_gulp_file, "ly:gulp-file",
- 1, 0, 0, (SCM name),
+ 1, 1, 0, (SCM name, SCM size),
"Read the file @var{name}, and return its contents in a string. "
- "The file is looked up using the search path.")
+ "The file is looked up using the search path. ")
{
SCM_ASSERT_TYPE (scm_is_string (name), name, SCM_ARG1, __FUNCTION__,
"string");
- String contents = gulp_file_to_string (ly_scm2string (name), true);
+ int sz = -1;
+ if (size != SCM_UNDEFINED)
+ {
+ SCM_ASSERT_TYPE (scm_is_number (size), size, SCM_ARG2, __FUNCTION__,
"number");
+ sz = scm_to_int (size);
+ }
+
+ String contents = gulp_file_to_string (ly_scm2string (name), true, sz);
return scm_from_locale_stringn (contents.get_str0 (), contents.length ());
}
Index: lilypond/lily/lily-guile.cc
diff -u lilypond/lily/lily-guile.cc:1.220 lilypond/lily/lily-guile.cc:1.221
--- lilypond/lily/lily-guile.cc:1.220 Sat Aug 13 21:35:23 2005
+++ lilypond/lily/lily-guile.cc Mon Aug 22 14:49:23 2005
@@ -84,7 +84,7 @@
}
String
-gulp_file_to_string (String fn, bool must_exist)
+gulp_file_to_string (String fn, bool must_exist, int size)
{
String s = global_path.find (fn);
if (s == "")
@@ -103,7 +103,7 @@
if (be_verbose_global)
progress_indication ("[" + s);
- int n;
+ int n = sz;
char *str = gulp_file (s, &n);
String result ((Byte *) str, n);
delete[] str;
Index: lilypond/lily/lily-parser.cc
diff -u lilypond/lily/lily-parser.cc:1.50 lilypond/lily/lily-parser.cc:1.51
--- lilypond/lily/lily-parser.cc:1.50 Tue Aug 16 23:43:56 2005
+++ lilypond/lily/lily-parser.cc Mon Aug 22 14:49:23 2005
@@ -103,7 +103,7 @@
File_name f (name);
String s = global_path.find (f.base_ + ".twy");
- s = gulp_file_to_string (s, false);
+ s = gulp_file_to_string (s, false, -1);
scm_eval_string (scm_makfrom0str (s.to_str0 ()));
/* Read .ly IN_FILE, lex, parse, write \score blocks from IN_FILE to
Index: lilypond/lily/pfb.cc
diff -u lilypond/lily/pfb.cc:1.20 lilypond/lily/pfb.cc:1.21
--- lilypond/lily/pfb.cc:1.20 Sat Aug 13 21:35:22 2005
+++ lilypond/lily/pfb.cc Mon Aug 22 14:49:23 2005
@@ -77,11 +77,11 @@
SCM_ARG1, __FUNCTION__, "string");
String file_name = ly_scm2string (pfb_file_name);
- int len;
+ int len = -1;
if (be_verbose_global)
progress_indication ("[" + file_name);
-
+
char *str = gulp_file (file_name, &len);
char *pfa = pfb2pfa ((Byte *)str, len);
Index: lilypond/lily/source-file.cc
diff -u lilypond/lily/source-file.cc:1.33 lilypond/lily/source-file.cc:1.34
--- lilypond/lily/source-file.cc:1.33 Sat Aug 13 21:35:22 2005
+++ lilypond/lily/source-file.cc Mon Aug 22 14:49:23 2005
@@ -57,16 +57,21 @@
}
fseek (f, 0, SEEK_END);
- *filesize = ftell (f);
+ int real_size = ftell (f);
+ int read_count = real_size;
+
+ if (*filesize >= 0)
+ read_count = min (read_count, *filesize);
+
rewind (f);
- char *str = new char[*filesize + 1];
- str[*filesize] = 0;
+ char *str = new char[read_count + 1];
+ str[read_count] = 0;
- int bytes_read = fread (str, sizeof (char), *filesize, f);
- if (bytes_read != *filesize)
+ int bytes_read = fread (str, sizeof (char), read_count, f);
+ if (bytes_read != read_count)
warning (_f ("expected to read %d characters, got %d", bytes_read,
- *filesize));
+ read_count));
fclose (f);
return str;
@@ -95,8 +100,11 @@
if (filename_string == "-")
load_stdin ();
else
- contents_str0_ = gulp_file (filename_string, &length_);
-
+ {
+ length_ = -1;
+ contents_str0_ = gulp_file (filename_string, &length_);
+ }
+
pos_str0_ = to_str0 ();
init_port ();
Index: lilypond/scm/backend-library.scm
diff -u lilypond/scm/backend-library.scm:1.40
lilypond/scm/backend-library.scm:1.41
--- lilypond/scm/backend-library.scm:1.40 Sun Jun 19 14:52:33 2005
+++ lilypond/scm/backend-library.scm Mon Aug 22 14:49:23 2005
@@ -94,6 +94,7 @@
(let ((paper-size (sanitize-command-option paper-size-name))
(verbose (ly:get-option 'verbose))
(rename-page-1 #f))
+
(ly:message (_ "Converting to ~a...") "PNG")
(make-ps-images name resolution paper-size rename-page-1 verbose
(ly:get-option 'anti-alias-factor))
Index: lilypond/scm/ps-to-png.scm
diff -u lilypond/scm/ps-to-png.scm:1.12 lilypond/scm/ps-to-png.scm:1.13
--- lilypond/scm/ps-to-png.scm:1.12 Tue Jun 21 21:43:36 2005
+++ lilypond/scm/ps-to-png.scm Mon Aug 22 14:49:23 2005
@@ -42,8 +42,8 @@
(define (gulp-port port max-length)
(let ((str (make-string max-length)))
- (read-string!/partial str port)
- str))
+ (read-string!/partial str port 0 max-length)
+ str))
(define (dir-listing dir-name)
(define (dir-helper dir lst)
@@ -121,7 +121,8 @@
)
(let* ((base (basename (re-sub "[.]e?ps" "" ps-name)))
- (header (gulp-port (open-file ps-name "r") 10240))
+ (header (ly:gulp-file ps-name))
+; (header (gulp-port (open-file ps-name "r") 10240))
(png1 (string-append base ".png"))
(pngn (string-append base "-page%d.png"))
(pngn-re (re-sub "%d" "[0-9]*" pngn))
@@ -152,6 +153,7 @@
(* aa-factor resolution) ps-name))
(status 0)
(files '()))
+
(for-each delete-file (append (dir-re "." png1)
(dir-re "." pngn-re)))
_______________________________________________
Lilypond-cvs mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/lilypond-cvs