summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/glibext/gcodebuffer.c12
1 files changed, 7 insertions, 5 deletions
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;