Przeglądaj źródła

Line buffer API changed a while ago

tags/v0.9.3
Michael Brown 17 lat temu
rodzic
commit
01b3dd4fc3
1 zmienionych plików z 6 dodań i 3 usunięć
  1. 6
    3
      src/tests/linebuf_test.c

+ 6
- 3
src/tests/linebuf_test.c Wyświetl plik

@@ -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
 	}

Ładowanie…
Anuluj
Zapisz