summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--src/glibext/gcodebuffer.c12
2 files changed, 12 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 07eb283..6968d8a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+12-06-30 Cyrille Bagard <nocbos@gmail.com>
+
+ * src/glibext/gcodebuffer.c:
+ Improve the function providing line indexes from addresses.
+
12-06-24 Cyrille Bagard <nocbos@gmail.com>
* src/glibext/gcodebuffer.c:
diff --git a/src/glibext/gcodebuffer.c b/src/glibext/gcodebuffer.c
index de92b71..d5dbc8c 100644
--- a/src/glibext/gcodebuffer.c
+++ b/src/glibext/gcodebuffer.c
@@ -26,7 +26,6 @@
#include <malloc.h>
#include <string.h>
-#include <sys/param.h>
#include "../glibext/delayed-int.h"
@@ -380,8 +379,7 @@ GCodeBuffer *g_code_buffer_new(void)
* *
* Description : Convertit une adresse en indice de ligne. *
* *
-* Retour : Indice de l'adresse trouvée, ou buffer->used en cas d'échec, *
-* pour assurer la prise en compte de VMPA_MAX. *
+* Retour : Indice de l'adresse trouvée, ou 0 en cas d'échec. *
* *
* Remarques : - *
* *
@@ -391,10 +389,16 @@ static size_t g_code_buffer_get_index_from_address(GCodeBuffer *buffer, vmpa_t a
{
size_t result; /* Indice à retourner */
+ if (addr == VMPA_MAX)
+ return (buffer->used > 0 ? buffer->used - 1 : 0);
+
for (result = 0; result < buffer->used; result++)
if (g_buffer_line_get_address(buffer->lines[result]) == addr)
break;
+ if (result == buffer->used)
+ result = 0;
+
return result;
}
@@ -650,8 +654,6 @@ static void g_buffer_view_compute_required_widths(GBufferView *view)
first = g_code_buffer_get_index_from_address(view->buffer, view->start);
last = g_code_buffer_get_index_from_address(view->buffer, view->end);
- last = MIN(last, view->buffer->used > 0 ? view->buffer->used - 1 : 0);
-
view->line_height = 17;
view->left_margin = 2 * view->line_height;