RE: XForms: browser object

Michael Glickman (michaelg@linx.com.au)
Wed, 22 Sep 1999 12:26:30 +1000

# To subscribers of the xforms list from Michael Glickman <michaelg@linx.com.au> :

Hello, Peter

As it was mentioned by T.C, strncpy can only copy '\0',
but can't insert it. So probably does strncat.

Adding "@C"+colour_number will increase its length by 2+n,
where n is the number of digits needed to hold the colour number.
This is why the line can become too long to hold the full
length, and this BTW explains why the problem occurs
only for big colour numbers.

The simple patch would be an extra line
buffer2[BUFFER_SIZE-1] = '\0';
after strncat. This will be effective only for long lines, while
the short lines will have '\0' before the end of buffer

If you don't wish the lines to be truncated, try to increase the
actual buffer size and use BUFFER_SIZE+2 for strncat:

char buffer2[BUFFER_SIZE+3];
.......
strncat(buffer2, buffer1, BUFFER_SIZE+2);
buffer2[BUFFER_SIZE+2] = '\0';

Honeslty, I have a strong feeling that this is not an
XForms bug, but rather your personal problem

Use gdb of just print the lines and the index - this will
help to locate the problem.

Michael

> -----Original Message-----
> From: Peter Hanley [SMTP:peter@hanley.demon.co.uk]
> Sent: Tuesday, 21 September 1999 21:05 EST
> To: xforms
> Subject: XForms: browser object
>
> To highlight the selected range I am using code like:
>
> fl_freeze_form(viewer_form);
> for(i = first; i <= last; i++)
> {
> /* make selected lines highlighted */
> strncpy(buffer1, fl_get_browser_line(file_viewer,i), BUFFER_SIZE);
> if(*buffer != '@')
> {
> sprintf(buffer2,"@C%i",SELECTION_COLOR);
> strncat(buffer2, buffer1, BUFFER_SIZE);
> fl_replace_browser_line(file_viewer,i,buffer2);
> }
> }
> fl_unfreeze_form(viewer_form);
>
>
>
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuhs.mil or see
http://bob.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuhs.mil/mailserv/list-archives/