[geany/geany-plugins] d85193: debugger/gdb_mi: Test: allow for lines of arbitrary length

Colomban Wendling git-noreply at xxxxx
Sun Feb 7 03:35:36 UTC 2016


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Sun, 07 Feb 2016 03:35:36 UTC
Commit:      d851935f818994de1380252185a2359e982ea341
             https://github.com/geany/geany-plugins/commit/d851935f818994de1380252185a2359e982ea341

Log Message:
-----------
debugger/gdb_mi: Test: allow for lines of arbitrary length


Modified Paths:
--------------
    debugger/src/gdb_mi.c

Modified: debugger/src/gdb_mi.c
24 lines changed, 21 insertions(+), 3 deletions(-)
===================================================================
@@ -482,17 +482,35 @@ static void gdb_mi_record_dump(const struct gdb_mi_record *record)
 		gdb_mi_result_dump(record->first, TRUE, 2);
 }
 
-int main(void)
+static gchar *read_line(FILE *fp)
 {
 	char buf[1024] = {0};
+	GString *line = g_string_new(NULL);
 
-	while (fgets(buf, sizeof buf, stdin))
+	while (fgets(buf, sizeof buf, fp))
 	{
-		struct gdb_mi_record *record = gdb_mi_record_parse(buf);
+		g_string_append(line, buf);
+		if (line->len < 1 || line->str[line->len - 1] == '\n')
+			break;
+	}
+
+	return g_string_free(line, line->len < 1);
+}
+
+int main(int argc, char **argv)
+{
+	gchar *line;
+
+	while ((line = read_line(stdin)) != NULL)
+	{
+		struct gdb_mi_record *record = gdb_mi_record_parse(line);
 
 		gdb_mi_record_dump(record);
 		gdb_mi_record_free(record);
+
+		g_free(line);
 	}
+
 	return 0;
 }
 



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Plugins-Commits mailing list