[Xfce4-commits] [apps/xfce4-dict] 01/01: Correctly separate header and body (bug #10136)

noreply at xfce.org noreply at xfce.org
Wed Mar 11 23:24:28 CET 2015


This is an automated email from the git hooks/post-receive script.

hjudt pushed a commit to branch master
in repository apps/xfce4-dict.

commit 4f1d429e9ca3a64e721018a71843cfd65fa2d07b
Author: Harald Judt <h.judt at gmx.at>
Date:   Wed Mar 11 23:19:34 2015 +0100

    Correctly separate header and body (bug #10136)
    
    Body lines start with spaces, header lines do not. Try a conservative
    approach of distinguishing between header and body lines. This fixes
    bug #10136 (wrong formatting of phonetic text).
---
 lib/dictd.c |   15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/lib/dictd.c b/lib/dictd.c
index d2578d3..f2e9781 100644
--- a/lib/dictd.c
+++ b/lib/dictd.c
@@ -105,7 +105,7 @@ static gchar *phon_find_start(gchar *buf, gchar **start_str, gchar **end_str)
 	gchar *start;
 
 	/* we check only once for the various (\, / and [...]) formats for phonetic information
-	 * per line, for further occurences on the same line we use the same format */
+	 * per line, for further occurrences on the same line we use the same format */
 	if (**start_str == '\0')
 	{
 		start = strchr(buf, '\\');
@@ -293,7 +293,7 @@ static gint process_response_content(DictData *dd, gchar **lines, gint line_no,
 									 GString *header, GString *body)
 {
 	gchar **dict_parts;
-	gboolean first_line;
+	gboolean is_header;
 
 	line_no++;
 	if (strncmp(lines[line_no], "250", 3) == 0)
@@ -325,7 +325,7 @@ static gint process_response_content(DictData *dd, gchar **lines, gint line_no,
 
 	/* all following lines represents the translation */
 	line_no++;
-	first_line = TRUE;
+	is_header = TRUE;
 
 	while (lines[line_no] != NULL && lines[line_no][0] != '\r' && lines[line_no][0] != '\n')
 	{
@@ -340,14 +340,17 @@ static gint process_response_content(DictData *dd, gchar **lines, gint line_no,
 			else
 				break; /* we reached the end of the test response */
 		}
-		if (first_line)
+		if (is_header && lines[line_no][0] != ' ')
 		{
 			g_string_append(header, lines[line_no]);
-			first_line = FALSE;
+			g_string_append_c(header, '\n');
 		}
 		else
+		{
 			g_string_append(body, lines[line_no]);
-		g_string_append_c(body, '\n');
+			g_string_append_c(body, '\n');
+			is_header = FALSE;
+		}
 
 		line_no++;
 	}

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list