diff options
author | Paulo Cesar Pereira de Andrade <pcpa@mandriva.com.br> | 2008-12-02 02:05:42 -0200 |
---|---|---|
committer | Paulo Cesar Pereira de Andrade <pcpa@mandriva.com.br> | 2008-12-02 02:05:42 -0200 |
commit | 99faa7b727a5441b0dfeed72f43571a85ff0a079 (patch) | |
tree | 2c21982ac1c9d0adff021877e157dabb06735cca /tags.c | |
parent | 2c5007e4aa838b0faf1020d90661adfe0a9b6275 (diff) |
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.
Diffstat (limited to 'tags.c')
-rw-r--r-- | tags.c | 20 |
1 files changed, 13 insertions, 7 deletions
@@ -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); |