[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote Thu, Mar 24, 2005:
> This is an automated notification of a change to the ELinks CVS tree.
>
> Author: zas
> Module: elinks
> Tag: <TRUNK>
> Date: Thu Mar 24 16:52:58 2005 GMT
>
> ---- Log message:
>
> add_cursor_move_to_string(): simplify and handle oversized numbers in a
> gentle way.
>
>
> ---- Files affected:
>
> elinks/src/terminal:
> screen.c (1.157 -> 1.158)
>
> http://cvsweb.elinks.or.cz/cvsweb.cgi/elinks/src/terminal/screen.c.diff?r1=1.157&r2=1.158&f=u
>
>
> ---- Diffs:
>
> elinks/src/terminal/screen.c | 14 +++++++-------
> 1 files changed, 7 insertions(+), 7 deletions(-)
>
>
> Index: elinks/src/terminal/screen.c
> diff -u elinks/src/terminal/screen.c:1.157 elinks/src/terminal/screen.c:1.158
> --- elinks/src/terminal/screen.c:1.157 Mon Feb 28 15:57:58 2005
> +++ elinks/src/terminal/screen.c Thu Mar 24 17:52:53 2005
> @@ -321,26 +321,26 @@
> static inline struct string *
> add_cursor_move_to_string(struct string *screen, int y, int x)
> {
> - /* 28 chars for both of the @y and @x numbers should be enough. */
> - unsigned char code[32];
> +#define CURSOR_NUM_LEN 10 /* 10 chars for @y and @x numbers should be more
> than enough. */
> + unsigned char code[4 + 2 * CURSOR_NUM_LEN];
> int length = 2;
> int ret;
>
> code[0] = '\033';
> code[1] = '[';
>
> - ret = longcat(code, &length, y, 30, 0);
> - /* Make sure theres atleast room for ';' and `some' number ;) */
> - if (ret < 0 || length > 30) return NULL;
> + ret = longcat(code, &length, y, CURSOR_NUM_LEN, 0);
> + if (ret < 0) return screen;
>
> code[length++] = ';';
>
> - ret = longcat(code, &length, x, sizeof(code) - length, 0);
> - if (ret < 0 || length > 31) return NULL;
> + ret = longcat(code, &length, x, CURSOR_NUM_LEN, 0);
> + if (ret < 0) return screen;
ret = longcat(code, &length, x, CURSOR_NUM_LEN - length - 1, 0);
else longcat() could end up using CURSOR_NUM_LEN + length chars _and_
there would be no char left for the line below.
>
> code[length++] = 'H';
Off by one here if length is CURSOR_NUM_LEN, no?
>
> return add_bytes_to_string(screen, code, length);
> +#undef CURSOR_NUM_LEN
> }
>
> struct screen_state {
--
Jonas Fonseca
_______________________________________________
elinks-dev mailing list
[email protected]
http://linuxfromscratch.org/mailman/listinfo/elinks-dev