[Github-comments] [geany] Fix the "source file has been modified" issue (#621)

Jiří Techet notifications at xxxxx
Mon Sep 28 21:35:27 UTC 2015


>  	{
>  		ui_set_statusbar(TRUE, "%s", err->message);
>  		g_error_free(err);
>  		return FALSE;
>  	}
>  
> -	filedata->len = (gsize) st.st_size;

@b4n Maybe I miss something but right now (without my patch):

1. The stat() length value is passed to encodings_convert_to_utf8_auto() here

https://github.com/geany/geany/blob/master/src/document.c#L963

2. encodings_convert_to_utf8_auto() stores this value to buffer.size and strlen() to buffer.len parameter passed to handle_buffer() here:

https://github.com/geany/geany/blob/master/src/encodings.c#L1082

3. Finally, handle_buffer() compares these two and does some magic based on this:

https://github.com/geany/geany/blob/master/src/encodings.c#L1029

The thing is we need both the stat() value and strlen() value in order to do what's done in (3). Right now, my patch discards the stat() value which causes that the buffer->len != buffer->size check is equivalent to FALSE.

In the commit I mentioned the size was just moved into encodings.c but the two values are still there.

So I think this is something that should be fixed in my patch - personally I'd move the stat call inside handle_buffer() because passing the size value from somewhere else is a bit misleading (I at least assumed it was the size of the string which isn't the case).

What do you think?




---
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/621/files#r40608720
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20150928/2f8ffa50/attachment.html>


More information about the Github-comments mailing list