[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: branch: master updated (1.4.0-20080127-99-g0a770cf)



The branch, master has been updated
       via  0a770cff6b42dd3ba80215482ee7c4f230b3cf0f (commit)
      from  199743d5ae8e89fa4065e544d998ebaeab1c1cd6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 libgeda/src/s_textbuffer.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)


=================
 Commit Messages
=================

commit 0a770cff6b42dd3ba80215482ee7c4f230b3cf0f
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Sat Jun 14 19:41:03 2008 +0200

    libgeda: fixed EOL handling for mixed windows/linux usage
    
    A file that is created on windows with windows EOL characters
    may not be read into gschem without errors on Linux. This fix
    strips off leading and trailing CR characters when reading a
    single line from the textbuffer.
    Bug reported by Thomas Arndt [#1993952]
    The bug was introduced with commit 40833189228f8edeff

:100644 100644 4b0fd5c... 7bb33ac... M	libgeda/src/s_textbuffer.c

=========
 Changes
=========

commit 0a770cff6b42dd3ba80215482ee7c4f230b3cf0f
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Sat Jun 14 19:41:03 2008 +0200

    libgeda: fixed EOL handling for mixed windows/linux usage
    
    A file that is created on windows with windows EOL characters
    may not be read into gschem without errors on Linux. This fix
    strips off leading and trailing CR characters when reading a
    single line from the textbuffer.
    Bug reported by Thomas Arndt [#1993952]
    The bug was introduced with commit 40833189228f8edeff

diff --git a/libgeda/src/s_textbuffer.c b/libgeda/src/s_textbuffer.c
index 4b0fd5c..7bb33ac 100644
--- a/libgeda/src/s_textbuffer.c
+++ b/libgeda/src/s_textbuffer.c
@@ -195,12 +195,19 @@ gchar *s_textbuffer_next (TextBuffer *tb, const gsize count)
 gchar *s_textbuffer_next_line (TextBuffer *tb)
 {
   int len = 0;
+  gchar *line;
 
   if (tb == NULL) return NULL;
 
   if (tb->offset >= tb->size) 
     return NULL;
 
+  /* skip leading CR characters */
+  while (tb->buffer[tb->offset] == '\r'
+	 && tb->offset < tb->size - 1) {
+    tb->offset += 1;
+  }
+
   while ((tb->buffer[tb->offset + len] != '\n')
 	 && (len < tb->size - tb->offset - 1)) {
     len++;
@@ -208,5 +215,13 @@ gchar *s_textbuffer_next_line (TextBuffer *tb)
 
   len++;
 
-  return s_textbuffer_next (tb, len);
+  line = s_textbuffer_next (tb, len);
+
+  /* wipe out all trailing CR characters */
+  while (len > 1 && line[len-2] == '\r') {
+    line[len-1] = 0;
+    len--;
+  }
+
+  return line;
 }




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs