On Thu Aug 08 21:27:02 2013, andreas.guldstrand@gmail.com wrote:
Show quoted text> After some bughunting on irc, tm604 solved it by telling me to change
> "-std=c99" to "-std=gnu99" in the Build.Pl
...
Show quoted text> > lib/Tickit.xs:366:4: warning: declaration does not declare anything
> > lib/Tickit.xs:372:4: warning: declaration does not declare anything
Yeah; looks like -std=c99 is insufficient to recognise anonymous unions after all.. :/ It needs either GNU C99 or C11.
Since it's only a minor edit, I'll actually just do away with the anonymous unions instead. That seems easier than working out what C compiler args to pass.
Find attached a patch to do this.
Will be in next version.
--
Paul Evans
=== modified file 'lib/Tickit.xs'
--- lib/Tickit.xs 2013-08-09 16:34:44 +0000
+++ lib/Tickit.xs 2013-08-09 20:27:02 +0000
@@ -360,16 +360,13 @@
typedef struct {
enum TickitRenderBufferCellState state;
- union {
- int len; // state != CONT
- int startcol; // state == CONT
- };
+ int len; // or "startcol" for state == CONT
TickitPen *pen; // state -> {TEXT, ERASE, LINE, CHAR}
union {
struct { int idx; int offs; } text; // state == TEXT
struct { int mask; } line; // state == LINE
struct { int codepoint; } chr; // state == CHAR
- };
+ } v;
} TickitRenderBufferCell;
typedef struct TickitRenderBufferStack TickitRenderBufferStack;
@@ -473,9 +470,9 @@
break;
}
- cell->state = CONT;
- cell->startcol = startcol;
- cell->pen = NULL;
+ cell->state = CONT;
+ cell->len = startcol;
+ cell->pen = NULL;
}
static TickitRenderBufferCell *_tickit_rb_make_span(TickitRenderBuffer *rb, int line, int col, int len)
@@ -485,7 +482,7 @@
// If the following cell is a CONT, it needs to become a new start
if(end < rb->cols && cells[line][end].state == CONT) {
- int spanstart = cells[line][end].startcol;
+ int spanstart = cells[line][end].len;
TickitRenderBufferCell *spancell = &cells[line][spanstart];
int spanend = spanstart + spancell->len;
int afterlen = spanend - end;
@@ -497,11 +494,11 @@
endcell->len = afterlen;
break;
case TEXT:
- endcell->state = TEXT;
- endcell->len = afterlen;
- endcell->pen = tickit_pen_clone(spancell->pen);
- endcell->text.idx = spancell->text.idx;
- endcell->text.offs = spancell->text.offs + end - spanstart;
+ endcell->state = TEXT;
+ endcell->len = afterlen;
+ endcell->pen = tickit_pen_clone(spancell->pen);
+ endcell->v.text.idx = spancell->v.text.idx;
+ endcell->v.text.offs = spancell->v.text.offs + end - spanstart;
break;
case ERASE:
endcell->state = ERASE;
@@ -516,12 +513,12 @@
// We know these are already CONT cells
int c;
for(c = end + 1; c < spanend; c++)
- cells[line][c].startcol = end;
+ cells[line][c].len = end;
}
// If the initial cell is a CONT, shorten its start
if(cells[line][col].state == CONT) {
- int beforestart = cells[line][col].startcol;
+ int beforestart = cells[line][col].len;
TickitRenderBufferCell *spancell = &cells[line][beforestart];
int beforelen = col - beforestart;
@@ -1083,8 +1080,8 @@
rb->cells[line][0].pen = NULL;
for(col = 1; col < rb->cols; col++) {
- rb->cells[line][col].state = CONT;
- rb->cells[line][col].startcol = 0;
+ rb->cells[line][col].state = CONT;
+ rb->cells[line][col].len = 0;
}
}
@@ -1505,10 +1502,10 @@
rb->texts[rb->n_texts] = savepv(textbytes);
cell = _tickit_rb_make_span(rb, line, col, len);
- cell->state = TEXT;
- cell->pen = _tickit_rb_merge_pen(rb, pen ? pen->pen : NULL);
- cell->text.idx = rb->n_texts;
- cell->text.offs = startcol;
+ cell->state = TEXT;
+ cell->pen = _tickit_rb_merge_pen(rb, pen ? pen->pen : NULL);
+ cell->v.text.idx = rb->n_texts;
+ cell->v.text.offs = startcol;
rb->n_texts++;
done:
@@ -1575,10 +1572,10 @@
cell = &rb->cells[line][col];
if(cell->state != LINE) {
_tickit_rb_make_span(rb, line, col, len);
- cell->state = LINE;
- cell->len = 1;
- cell->pen = cellpen;
- cell->line.mask = 0;
+ cell->state = LINE;
+ cell->len = 1;
+ cell->pen = cellpen;
+ cell->v.line.mask = 0;
}
else if(!tickit_pen_equiv(cell->pen, cellpen)) {
warn("Pen collision for line cell (%d,%d)", line, col);
@@ -1588,7 +1585,7 @@
else
tickit_pen_destroy(cellpen);
- cell->line.mask |= bits;
+ cell->v.line.mask |= bits;
void
char_at(self,line,col,codepoint,pen=NULL)
@@ -1617,9 +1614,9 @@
croak("$col+$len out of range");
cell = _tickit_rb_make_span(rb, line, col, len);
- cell->state = CHAR;
- cell->pen = _tickit_rb_merge_pen(rb, pen ? pen->pen : NULL);
- cell->chr.codepoint = codepoint;
+ cell->state = CHAR;
+ cell->pen = _tickit_rb_merge_pen(rb, pen ? pen->pen : NULL);
+ cell->v.chr.codepoint = codepoint;
MODULE = Tickit PACKAGE = Tickit::RenderBuffer::Cell
@@ -1668,7 +1665,7 @@
cell = (void *)SvIV(SvRV(self));
if(cell->state != TEXT)
croak("Cannot call ->textidx on a non-TEXT cell");
- RETVAL = cell->text.idx;
+ RETVAL = cell->v.text.idx;
OUTPUT:
RETVAL
@@ -1681,7 +1678,7 @@
cell = (void *)SvIV(SvRV(self));
if(cell->state != TEXT)
croak("Cannot call ->textoffs on a non-TEXT cell");
- RETVAL = cell->text.offs;
+ RETVAL = cell->v.text.offs;
OUTPUT:
RETVAL
@@ -1694,7 +1691,7 @@
cell = (void *)SvIV(SvRV(self));
if(cell->state != LINE)
croak("Cannot call ->linemask on a non-LINE cell");
- RETVAL = cell->line.mask;
+ RETVAL = cell->v.line.mask;
OUTPUT:
RETVAL
@@ -1707,7 +1704,7 @@
cell = (void *)SvIV(SvRV(self));
if(cell->state != CHAR)
croak("Cannot call ->codepoint on a non-CHAR cell");
- RETVAL = cell->chr.codepoint;
+ RETVAL = cell->v.chr.codepoint;
OUTPUT:
RETVAL