Browse Source

Line buffer API changed a while ago

tags/v0.9.3
Michael Brown 17 years ago
parent
commit
01b3dd4fc3
1 changed files with 6 additions and 3 deletions
  1. 6
    3
      src/tests/linebuf_test.c

+ 6
- 3
src/tests/linebuf_test.c View File

@@ -14,16 +14,19 @@ void linebuf_test ( void ) {
14 14
 	struct line_buffer linebuf;
15 15
 	const char *data = data1;
16 16
 	size_t len = ( sizeof ( data1 ) - 1 /* be mean; strip the NUL */ );
17
+	ssize_t frag_len;
17 18
 	char *line;
18
-	int rc;
19 19
 
20 20
 	memset ( &linebuf, 0, sizeof ( linebuf ) );
21 21
 	while ( len ) {
22
-		if ( ( rc = line_buffer ( &linebuf, &data, &len ) ) != 0 ) {
22
+		frag_len = line_buffer ( &linebuf, data, len );
23
+		if ( frag_len < 0 ) {
23 24
 			printf ( "line_buffer() failed: %s\n",
24
-				 strerror ( rc ) );
25
+				 strerror ( frag_len ) );
25 26
 			return;
26 27
 		}
28
+		data += frag_len;
29
+		len -= frag_len;
27 30
 		if ( ( line = buffered_line ( &linebuf ) ) )
28 31
 			printf ( "\"%s\"\n", line );
29 32
 	}

Loading…
Cancel
Save