git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 4/5] vcs-svn: Add outfile option to buffer_copy_bytes()

From
David Barr <david.barr@cordelta.com>
Date
Oct 15, 2010, 12:54 UTC
Message-ID
<1287147256-9457-5-git-send-email-david.barr@cordelta.com>
In-Reply-To
<1287147256-9457-1-git-send-email-david.barr@cordelta.com>

Explicitly declare that output is to stdout for existing use. Allow users of buffer_copy_bytes() to specify the output file.

Signed-off-by: David Barr <david.barr@cordelta.com>
---
 test-line-buffer.c    |    2 +-
 vcs-svn/fast_export.c |    2 +-
 vcs-svn/line_buffer.c |    6 +++---
 vcs-svn/line_buffer.h |    2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/test-line-buffer.c b/test-line-buffer.c
index f9af892..adc23e8 100644
--- a/test-line-buffer.c
+++ b/test-line-buffer.c
@@ -36,7 +36,7 @@ int main(int argc, char *argv[])
 		buffer_skip_bytes(&buf, 1);
 		if (!(s = buffer_read_line(&buf)))
 			break;
-		buffer_copy_bytes(&buf, strtouint32(s) + 1);
+		buffer_copy_bytes(&buf, stdout, strtouint32(s) + 1);
 	}
 	if (buffer_deinit(&buf))
 		die("input error");
diff --git a/vcs-svn/fast_export.c b/vcs-svn/fast_export.c
index d984aaa..b017dfb 100644
--- a/vcs-svn/fast_export.c
+++ b/vcs-svn/fast_export.c
@@ -73,6 +73,6 @@ void fast_export_blob(uint32_t mode, uint32_t mark, uint32_t len,
 		len -= 5;
 	}
 	printf("blob\nmark :%"PRIu32"\ndata %"PRIu32"\n", mark, len);
-	buffer_copy_bytes(input, len);
+	buffer_copy_bytes(input, stdout, len);
 	fputc('\n', stdout);
 }
diff --git a/vcs-svn/line_buffer.c b/vcs-svn/line_buffer.c
index c54031b..676cb62 100644
--- a/vcs-svn/line_buffer.c
+++ b/vcs-svn/line_buffer.c
@@ -82,7 +82,7 @@ void buffer_read_binary(struct strbuf *sb, uint32_t size,
 	strbuf_fread(sb, size, buf->infile);
 }
 
-void buffer_copy_bytes(struct line_buffer *buf, off_t len)
+void buffer_copy_bytes(struct line_buffer *buf, FILE *outfile, off_t len)
 {
 	char byte_buffer[COPY_BUFFER_LEN];
 	uint32_t in;
@@ -90,8 +90,8 @@ void buffer_copy_bytes(struct line_buffer *buf, off_t len)
 		in = len < COPY_BUFFER_LEN ? len : COPY_BUFFER_LEN;
 		in = fread(byte_buffer, 1, in, buf->infile);
 		len -= in;
-		fwrite(byte_buffer, 1, in, stdout);
-		if (ferror(stdout)) {
+		fwrite(byte_buffer, 1, in, outfile);
+		if (ferror(outfile)) {
 			buffer_skip_bytes(buf, len);
 			return;
 		}
diff --git a/vcs-svn/line_buffer.h b/vcs-svn/line_buffer.h
index 2375ee1..23f4931 100644
--- a/vcs-svn/line_buffer.h
+++ b/vcs-svn/line_buffer.h
@@ -20,7 +20,7 @@ char *buffer_read_line(struct line_buffer *buf);
 char *buffer_read_string(struct line_buffer *buf, uint32_t len);
 int buffer_read_char(struct line_buffer *buf);
 void buffer_read_binary(struct strbuf *sb, uint32_t len, struct line_buffer *f);
-void buffer_copy_bytes(struct line_buffer *buf, off_t len);
+void buffer_copy_bytes(struct line_buffer *buf, FILE *outfile, off_t len);
 off_t buffer_skip_bytes(struct line_buffer *buf, off_t len);
 void buffer_reset(struct line_buffer *buf);
 
-- 
1.7.3.32.g634ef
Previous: Ramkumar RamachandraNext: Jonathan Nieder
Message 25 of 34 in “[PATCHv2] Add support for subversion dump format v3”
  1. David BarrOct 15, 2010
  2. 1/5 fast-import: Let importers retrieve blobsDavid Barr, Oct 15, 2010
  3. Ramkumar RamachandraOct 18, 2010
  4. Jonathan NiederOct 18, 2010
  5. Jonathan NiederOct 18, 2010
  6. 0/4 fast-import: Let importers retrieve blobsJonathan Nieder, Nov 28, 2010
  7. 1/4 fast-import: stricter parsing of integer optionsJonathan Nieder, Nov 28, 2010
  8. Junio C HamanoNov 30, 2010
  9. 2/4 fast-import: clarify documentation of "feature" commandJonathan Nieder, Nov 28, 2010
  10. 3/4 fast-import: let importers retrieve blobsJonathan Nieder, Nov 28, 2010
  11. fixup! fast-import: let importers retrieve blobsDavid Barr, Nov 29, 2010
  12. David BarrNov 30, 2010
  13. Jonathan NiederNov 30, 2010
  14. Thomas RastDec 3, 2010
  15. Jonathan NiederDec 3, 2010
  16. Junio C HamanoDec 3, 2010
  17. Jonathan NiederDec 3, 2010
  18. Thomas RastDec 4, 2010
  19. Jonathan NiederDec 4, 2010
  20. Documentation/fast-import: capitalize beginning of sentenceJonathan Nieder, Jan 16, 2011
  21. 4/4 fast-import: Allow cat-blob requests at arbitrary points in streamJonathan Nieder, Nov 28, 2010
  22. 2/5 vcs-svn: Extend svndump to parse version 3 formatDavid Barr, Oct 15, 2010
  23. 3/5 vcs-svn: Implement prop-delta handling.David Barr, Oct 15, 2010
  24. Ramkumar RamachandraOct 18, 2010
  25. 4/5 vcs-svn: Add outfile option to buffer_copy_bytes()David Barr, Oct 15, 2010
  26. Jonathan NiederOct 18, 2010
  27. 5/5 svn-fe: Use the cat-blob command to apply deltasDavid Barr, Oct 15, 2010
  28. Ramkumar RamachandraOct 18, 2010
  29. Jonathan NiederOct 18, 2010
  30. Ramkumar RamachandraOct 18, 2010
  31. Jonathan NiederOct 18, 2010
  32. 3/4 fast-import: let importers retrieve blobsJonathan Nieder, Nov 19, 2010
  33. 4/4 fast-import: Allow cat-blob requests at arbitrary points in streamJonathan Nieder, Nov 19, 2010
  34. Sverre RabbelierNov 19, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.