Implement bt_getline
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 2/2 Implement bt_getline
Implement our own getline to remove dependency from glibc 2.10+ and to increase portability to other operating systems.
Signed-off-by Mathieu Desnoyers <[email protected]>
--- converter/babeltrace-log.c | 5 ++--- tests/lib/test_ctf_writer.c | 7 ++++--- 2 files changed, 6 insertions(+), 6 deletions(-)
converter/babeltrace-log.c +2 -3
@@ -24,8 +24,6 @@* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. -* -* Depends on glibc 2.10 for getline(). */ #define _GNU_SOURCE
@@ -47,6 +45,7 @@#include <babeltrace/ctf/types.h> #include <babeltrace/compat/uuid.h> #include <babeltrace/compat/utc.h> +#include <babeltrace/compat/stdio.h> #include <babeltrace/endian.h> #define NSEC_PER_USEC 1000UL
@@ -331,7 +330,7 @@ void trace_text(FILE *input, int output)write_packet_header (&pos, s_uuid);write_packet_context (&pos);for (;;) { - len =getline (&line, &linesize, input); + len =bt_getline (&line, &linesize, input);if (len <0 )break ; nl =strrchr (line,'\n' );
tests/lib/test_ctf_writer.c +4 -3
@@ -35,6 +35,7 @@#include <stdio.h> #include <sys/utsname.h> #include <babeltrace/compat/limits.h> +#include <babeltrace/compat/stdio.h> #include <string.h> #include <assert.h> #include <sys/wait.h>
@@ -160,12 +161,12 @@ result:rewind (metadata_fp);/* Output the metadata and parser output as diagnostic */ -while (getline (&line, &len, metadata_fp) >0 ) { +while (bt_getline (&line, &len, metadata_fp) >0 ) {fprintf (stderr,"# %s" , line); }rewind (parser_output_fp); -while (getline (&line, &len, parser_output_fp) >0 ) { +while (bt_getline (&line, &len, parser_output_fp) >0 ) {fprintf (stderr,"# %s" , line); }
@@ -257,7 +258,7 @@ result:diag ("malloc error" ); }rewind (babeltrace_output_fp); -while (getline (&line, &len, babeltrace_output_fp) >0 ) { +while (bt_getline (&line, &len, babeltrace_output_fp) >0 ) {diag ("%s" , line); }
Signature · 1 line
2.1.4