summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2012-06-30 10:58:19 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2012-06-30 10:58:19 (GMT)
commit51dff92af8ca82ac1cce3f74be70c3705ca88683 (patch)
tree4ae9cdb182b5e5c755ecebe6ffaf61405cca073a /src
parenta4b70be160203f0c0c50e9ba4d8ab07db08bdeb6 (diff)
Improved the function providing line indexes from addresses.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@246 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
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;