From 99faa7b727a5441b0dfeed72f43571a85ff0a079 Mon Sep 17 00:00:00 2001 From: Paulo Cesar Pereira de Andrade Date: Tue, 2 Dec 2008 02:05:42 -0200 Subject: Properly read symbol name in tags interface. If the symbol is not in a full text "Piece", XawTextSourceRead() will return an XawTextBlock that points to an incomplete buffer, and a new call must be made to read the remaining data. --- tags.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tags.c b/tags.c index b8f3970..0c9e65b 100644 --- a/tags.c +++ b/tags.c @@ -116,7 +116,7 @@ TagsAction(Widget w, XEvent *event, String *params, Cardinal *num_params) char buffer[1024]; XawTextPosition position, left, right; XawTextBlock block; - int length; + int length, bytes; Widget source; source = XawTextGetSource(w); @@ -128,14 +128,20 @@ TagsAction(Widget w, XEvent *event, String *params, Cardinal *num_params) position = XawTextGetInsertionPoint(w); XawTextGetSelectionPos(w, &left, &right); if (right > left) { - XawTextSourceRead(source, left, &block, right - left); - length = block.length + 1; - if (length >= sizeof(buffer)) - length = sizeof(buffer); - XmuSnprintf(buffer, length, "%s", block.ptr); + length = 0; + do { + bytes = right - left; + left = XawTextSourceRead(source, left, &block, bytes); + if (block.length < bytes) + bytes = block.length; + if (length + bytes + 1 >= sizeof(buffer)) + bytes = sizeof(buffer) - length - 1; + XmuSnprintf(buffer + length, bytes + 1, "%s", block.ptr); + length += bytes; + } while (left < right); item->tags->textwindow = w; item->tags->position = position; - FindTagFirst(item->tags, buffer, length - 1); + FindTagFirst(item->tags, buffer, length); } else FindTagNext(item->tags, w, position); -- cgit v1.2.3