[geany/geany-plugins] b8ba6f: debugger/gdb_mi: Fix prompt detection

Colomban Wendling git-noreply at xxxxx
Sun Nov 15 17:28:24 UTC 2015


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Sun, 08 Mar 2015 19:43:50 UTC
Commit:      b8ba6f938c541a20b064edcef18b228421df73e9
             https://github.com/geany/geany-plugins/commit/b8ba6f938c541a20b064edcef18b228421df73e9

Log Message:
-----------
debugger/gdb_mi: Fix prompt detection

Fix the code for prompt to be locale-agnostic and actually work.
This doesn't change anything however, because the default action for
unknown record type is reporting a prompt, and a real prompt would
trigger it.


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

Modified: debugger/src/gdb_mi.c
16 lines changed, 13 insertions(+), 3 deletions(-)
===================================================================
@@ -250,6 +250,16 @@ static struct gdb_mi_value *parse_value(const gchar **p)
 	return val;
 }
 
+static gboolean is_prompt(const gchar *p)
+{
+	if (strncmp("(gdb)", p, 5) == 0)
+	{
+		p += 5;
+		while (g_ascii_isspace(*p)) p++;
+	}
+	return *p == 0;
+}
+
 /* parses: async-record | stream-record | result-record
  * note: post-value data is ignored.
  * 
@@ -278,10 +288,10 @@ static struct gdb_mi_value *parse_value(const gchar **p)
 struct gdb_mi_record *gdb_mi_record_parse(const gchar *line)
 {
 	struct gdb_mi_record *record = g_malloc0(sizeof *record);
-	char nl;
 
-	/* FIXME */
-	if (sscanf(line, "(gdb) %c", &nl) == 1 && (nl == '\r' || nl == '\n'))
+	/* FIXME: prompt detection should not really be useful, especially not as a
+	 * special case, as the prompt should always follow an (optional) record */
+	if (is_prompt(line))
 		record->type = GDB_MI_TYPE_PROMPT;
 	else
 	{



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