From 5f78eb4d214a7792a0c1eb7ec2f6b5dabc4ec20e Mon Sep 17 00:00:00 2001
From: Stefan Ritt
Date: Mon, 6 Oct 2008 06:38:41 +0000
Subject: [PATCH] Added function to determine line breaks in HTML code
SVN revision: 2131
---
src/elogd.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/elogd.c b/src/elogd.c
index 6c8c7d98..7ed17695 100755
--- a/src/elogd.c
+++ b/src/elogd.c
@@ -5459,6 +5459,23 @@ void strip_html(char *s)
/*------------------------------------------------------------------*/
+int line_break(char *str, char *encoding)
+{
+ if (strieq(encoding, "plain") || strieq(encoding, "ELCode")) {
+ return str[0] == '\n';
+ }
+
+ // HTML encoding
+ if (strncmp(str, "
", 4) == 0 ||
+ strncmp(str, "
", 4) == 0 ||
+ strncmp(str, "
", 4) == 0)
+ return 1;
+
+ return 0;
+}
+
+/*------------------------------------------------------------------*/
+
void insert_breaks(char *str, int n, int size)
{
int i, j, i_last;
@@ -16993,7 +17010,7 @@ void display_line(LOGBOOK * lbs, int message_id, int number, char *mode, int exp
if (expand == 2) {
for (i = i_line = line_len = 0; i < (int) sizeof(str) - 1; i++, line_len++) {
str[i] = text[i];
- if (str[i] == '\n') {
+ if (line_break(text+i, encoding)) {
i_line++;
line_len = 0;
} else
@@ -17041,7 +17058,7 @@ void display_line(LOGBOOK * lbs, int message_id, int number, char *mode, int exp
max_line_len = n_line >= 10 ? 140 : 40;
for (i = i_line = line_len = 0; i < (int) sizeof(str) - 1; line_len++, i++) {
str[i] = text[i];
- if (str[i] == '\n') {
+ if (line_break(text+i, encoding)) {
i_line++;
line_len = 0;
} else