fix: Prevent crash in fteapot when rendering very narrow columns (#76)
Co-authored-by: Glen Whitney <glen@studioinfinity.org> Reviewed-on: #76
This commit is contained in:
parent
efdd63d351
commit
118374c46e
8
INSTALL
8
INSTALL
@ -1,6 +1,14 @@
|
|||||||
The new build system uses CMake (http://www.cmake.org). It handles
|
The new build system uses CMake (http://www.cmake.org). It handles
|
||||||
all platform differences.
|
all platform differences.
|
||||||
|
|
||||||
|
Once all prerequisites are in place, you should be able to build teapot via
|
||||||
|
```
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake ..
|
||||||
|
make
|
||||||
|
```
|
||||||
|
|
||||||
In addition to the information in the README.md file on prerequisites, here
|
In addition to the information in the README.md file on prerequisites, here
|
||||||
are some additional guidelines:
|
are some additional guidelines:
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#ifndef WK1_H
|
#ifndef WK1_H
|
||||||
#define WK1_H
|
#define WK1_H
|
||||||
|
/* Functions for reading Lotus 1-2-3 file format. */
|
||||||
|
|
||||||
#include "sheet.h"
|
#include "sheet.h"
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
/* Notes */ /*{{{C}}}*//*{{{*/
|
/* Notes */ /*{{{C}}}*//*{{{*/
|
||||||
/*
|
/*
|
||||||
|
This file contains code to read the legacy binary XDR format for
|
||||||
|
spreadsheet files, typically written in files with the .tp extension.
|
||||||
|
|
||||||
xdr_enum() is unusable, because enum_t may have a different size than
|
xdr_enum() is unusable, because enum_t may have a different size than
|
||||||
an enum. The construction
|
an enum. The construction
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#ifndef XDR_H
|
#ifndef XDR_H
|
||||||
#define XDR_H
|
#define XDR_H
|
||||||
|
/* Functions used for reading the legacy XDR binary file format */
|
||||||
|
|
||||||
/* Thanks to curses. */
|
/* Thanks to curses. */
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -78,6 +78,12 @@ class TeapotTable {open : {public Fl_Table}}
|
|||||||
{draw_cell(TableContext context, int R, int C, int xx, int yy,
|
{draw_cell(TableContext context, int R, int C, int xx, int yy,
|
||||||
int W, int H)} {open return_type void} {code
|
int W, int H)} {open return_type void} {code
|
||||||
{
|
{
|
||||||
|
// Fl_Table calls this function to draw each visible cell in the table.
|
||||||
|
// context specifies what part of the table is being drawn;
|
||||||
|
// R and C give the row and column of the cell in the table;
|
||||||
|
// xx and yy give the screen coordinates where the cell is to be drawn;
|
||||||
|
// and W and H give the width and height of the rectangle into which to
|
||||||
|
// draw.
|
||||||
char s[1024];
|
char s[1024];
|
||||||
if (debug_level > 2)
|
if (debug_level > 2)
|
||||||
printf("DRAW: %i @%i,%i - (%i,%i) %ix%i\\n",
|
printf("DRAW: %i @%i,%i - (%i,%i) %ix%i\\n",
|
||||||
@ -167,13 +173,14 @@ class TeapotTable {open : {public Fl_Table}}
|
|||||||
if (sc.italic) cellfont |= FL_ITALIC;
|
if (sc.italic) cellfont |= FL_ITALIC;
|
||||||
fl_font(cellfont, 14);
|
fl_font(cellfont, 14);
|
||||||
|
|
||||||
size_t len = printvalue(s, sizeof(s), 0, quote, sc.fform,
|
size_t ulen = printvalue(s, sizeof(s), 0, quote, sc.fform,
|
||||||
sc.precision, cursheet, test);
|
sc.precision, cursheet, test);
|
||||||
size_t nlen = len;
|
ptrdiff_t len = ulen;
|
||||||
|
ptrdiff_t nlen = len;
|
||||||
int ww = 0, hh = 0;
|
int ww = 0, hh = 0;
|
||||||
fl_measure(s, ww, hh, 0);
|
fl_measure(s, ww, hh, 0);
|
||||||
while (ww > W-6) {
|
while (ww > W-6) {
|
||||||
char *dc = mbspos(s+nlen-1, -1);
|
char *dc = mbspos(s+nlen, -1);
|
||||||
nlen = dc - s;
|
nlen = dc - s;
|
||||||
s[nlen] = (char)0;
|
s[nlen] = (char)0;
|
||||||
ww = 0;
|
ww = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user