[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] Commit [09040dbf] is wrong
From: |
Steffen Nurpmeso |
Subject: |
[groff] Commit [09040dbf] is wrong |
Date: |
Wed, 15 Nov 2017 23:33:57 +0100 |
User-agent: |
s-nail v14.9.5-29-gab03c38f |
Hi,
i am in the process of syncing my GPL2 roff tree once again,
hopefully to be able to start getting that thing going.
Let me first wonder why my valid remark regarding that Unicode
error (i have forgotten what it was, actually) is still not fixed
even if now with that GNU patch-in library thing there is
something regular and usable available. But anyway i have
forgotten about this.
I am here for something else, the commit mentioned changed
- if ((*t)->buffer[j] == INLINE_LEADER_CHAR) {
+ if (j < char_block::SIZE && (*t)->buffer[j] == INLINE_LEADER_CHAR) {
where it should have been
+ if (j < (*t)->used && (*t)->buffer[j] == INLINE_LEADER_CHAR) {
instead. But better would be redoing the entire thing, if that
comment is allowed, including indentation fixes. Note especially
that, if all the buffer of *t consumed, and *t stepped to next
buffer, an array index of that _next_ *t with _this_ j is
performed. That cannot be correct? Note i changed blindly, my
roff clone does not yet compile, and also i have no documents to
feed through this thing for testing yet, anyway.
I come up with (uncompiled and untested):
void
char_buffer::write_upto_newline(char_block **t, int *i, int is_html){
enum {a_NONE, a_NL, a_LEADER} ev;
char *b;
int j, u;
if(*t == NULL)
goto jleave;
j = *i;
u = (*t)->used;
b = (*t)->buffer;
ev = a_NONE;
for(; j < u; ++j){
if(b[j] == '\n'){
++j;
ev = a_NL;
break;
}else if(b[j] == HTML_INLINE_LEADER_CHAR){
ev = a_LEADER;
break;
}
}
writeNbytes(&b[*i], j - *i);
*i = j;
if(ev == a_LEADER){
if(can_see(t, &j, HTML_IMAGE_INLINE_BEGIN))
write_start_image(INLINE, is_html);
else if(can_see(t, &j, HTML_IMAGE_INLINE_END))
write_end_image(is_html);
else if(j < u){
++j;
writeNbytes(&b[*i], 1);
}
}
// Rotate block if all the buffer was consumed
if(j == u){
*i = 0;
if((*t = (*t)->next) != NULL)
write_upto_newline(t, i, is_html);
}
jleave:;
}
--steffen
|
|Der Kragenbaer, The moon bear,
|der holt sich munter he cheerfully and one by one
|einen nach dem anderen runter wa.ks himself off
|(By Robert Gernhardt)
- [groff] Commit [09040dbf] is wrong,
Steffen Nurpmeso <=