Factor Cell into its own file

THis will make adding other Cell operations easier.
This commit is contained in:
Glen Whitney 2019-07-27 03:00:03 -04:00
parent ea230efc23
commit 8b95dec96d
8 changed files with 274 additions and 246 deletions

View File

@ -3,4 +3,4 @@ include_directories("${Teapot_SOURCE_DIR}/src/common")
link_directories("${Teapot_SOURCE_DIR}/src/common")
add_library(teapotlib context.c csv.c eval.c func.c htmlio.c latex.c main.c misc.c parser.c sc.c scanner.c sheet.c utf8.c wk1.c xdr.c)
add_library(teapotlib cell.c context.c csv.c eval.c func.c htmlio.c latex.c main.c misc.c parser.c sc.c scanner.c sheet.c utf8.c wk1.c xdr.c)

170
src/common/cell.c Normal file
View File

@ -0,0 +1,170 @@
#include "cell.h"
#include <assert.h>
#include <string.h>
#include "default.h"
#include "eval.h"
#include "main.h"
/* initcellcontents - make a fresh cell into the "empty" one; don't worry
about freeing anything there, that will have been handled. */
void initcellcontents(Cell *fresh)
{
(void)memset(fresh->contents, 0, sizeof(fresh->contents));
fresh->label=(char*)0;
fresh->adjust=AUTOADJUST;
fresh->precision=-1;
fresh->shadowed=0;
fresh->bold=0;
fresh->underline=0;
fresh->scientific=DEF_SCIENTIFIC;
fresh->value.type=EMPTY;
fresh->resvalue.type=EMPTY;
fresh->locked=0;
fresh->ignored=0;
fresh->clock_t0=0;
fresh->clock_t1=0;
fresh->clock_t2=0;
}
/* getcont -- get contents */
Token **getcont(const Cell *cell, ContentVariety v)
{
if (cell == NULLCELL) return EMPTY_TVEC;
if (v == CONTINGENT)
v = (cell->clock_t0 && cell->contents[ITERATIVE]) ? ITERATIVE : BASE;
return cell->contents[v];
}
/* getadjust -- get cell adjustment */
Adjust getadjust(const Cell* cell)
{
if (cell == NULLCELL) return LEFT;
else if (cell->adjust == AUTOADJUST)
return (cell->value.type == INT || cell->value.type == FLOAT ? RIGHT : LEFT);
else return cell->adjust;
}
/* shadowed -- is cell shadowed? */
bool shadowed(const Cell *cell)
{
return (cell != NULLCELL) && cell->shadowed;
}
/* isbold -- is cell bold? */
bool isbold(const Cell* cell)
{
return (cell != NULLCELL) && cell->bold;
}
/* isunderline -- is cell underlined? */
bool underlined(const Cell *cell)
{
return (cell != NULLCELL) && cell->underline;
}
/* locked -- is cell locked? */
bool locked(const Cell *cell)
{
return (cell != NULLCELL) && cell->locked;
}
/* transparent -- is cell transparent? */
bool transparent(const Cell* cell)
{
return (cell != NULLCELL) && cell->transparent;
}
/* ignored -- is cell ignored? */
bool ignored(const Cell *cell)
{
return (cell != NULLCELL) && cell->ignored;
}
/* getscientific -- should value be displayed in scientific notation? */
bool getscientific(const Cell *cell )
{
return (cell == NULLCELL) ? DEF_SCIENTIFIC : cell->scientific;
}
/* getprecision -- get cell precision */
int getprecision(const Cell *cell)
{
if (cell == NULLCELL || cell->precision == -1) return def_precision;
return cell->precision;
}
/* getlabel -- get cell label */
const char *getlabel(const Cell* cell)
{
if (cell == NULLCELL || cell->label == (char*)0) return "";
return cell->label;
}
/* copytokens -- copy a sequence of tokens, possibly reallocating dest */
static void copytokens(Token*** totoks, Token** fromtoks)
{
size_t from_len = tveclen(fromtoks);
if (from_len == 0)
{
tvecfree(*totoks);
*totoks = EMPTY_TVEC;
return;
}
size_t to_len = tveclen(*totoks);
if (from_len > to_len || *totoks == fromtoks)
{
if (*totoks != fromtoks) tvecfree(*totoks);
*totoks = malloc((from_len+1)*sizeof(Token*));
(*totoks)[from_len] = NULLTOKEN;
} else {
tvecfreetoks(*totoks);
}
for (size_t i = 0; i<from_len; ++i) /* destination already has NULLTOKEN at end */
{
if (fromtoks[i] == NULLTOKEN) (*totoks)[i] = NULLTOKEN;
else
{
(*totoks)[i] = malloc(sizeof(Token));
*((*totoks)[i]) = tcopy(*(fromtoks[i]));
}
}
}
/* freecellcontents -- free the resources of the cell at destruction time */
void freecellcontents(Cell *faded)
{
tvecfree(faded->contents[BASE]);
tvecfree(faded->contents[ITERATIVE]);
tfree(&(faded->value));
tfree(&(faded->resvalue));
if (faded->label != (char*)0) {
free(faded->label);
}
}
/* copycell - copies one Cell to another, handling any allocation issues */
void copycell(Cell *to, const Cell *fromcell)
{
assert(to != NULLCELL);
freecellcontents(to);
if (fromcell != NULLCELL) {
memcpy(to, fromcell, sizeof(Cell));
copytokens(&(to->contents[BASE]), fromcell->contents[BASE]);
copytokens(&(to->contents[ITERATIVE]), fromcell->contents[ITERATIVE]);
if (fromcell->label != (char*)0) {
size_t len = strlen(fromcell->label);
to->label = strcpy(malloc(len+2), fromcell->label);
(to->label)[len] = '_';
(to->label)[len+1] = '\0';
}
to->value.type = EMPTY;
to->resvalue.type = EMPTY;
} else {
initcellcontents(to);
}
}

56
src/common/cell.h Normal file
View File

@ -0,0 +1,56 @@
#ifndef CELL_H
#define CELL_H
#include "scanner.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum { LEFT=0, RIGHT=1, CENTER=2, AUTOADJUST=3 } Adjust;
typedef enum { BASE=0, ITERATIVE=1, CONTINGENT=2 } ContentVariety;
typedef struct
{
Token **contents[CONTINGENT];
char *label;
Token value;
Token resvalue;
Adjust adjust;
int precision;
unsigned int updated:1;
unsigned int shadowed:1;
unsigned int scientific:1;
unsigned int locked:1;
unsigned int transparent:1;
unsigned int ignored:1;
unsigned int clock_t0:1;
unsigned int clock_t1:1;
unsigned int clock_t2:1;
unsigned int bold:1;
unsigned int underline:1;
} Cell;
#define NULLCELL ((Cell*)0)
Token **getcont(const Cell *cell, ContentVariety v);
Adjust getadjust(const Cell *cell);
bool shadowed(const Cell *cell);
bool isbold(const Cell *cell);
bool underlined(const Cell *cell);
bool locked(const Cell *cell);
bool transparent(const Cell *cell);
bool ignored(const Cell *cell);
bool getscientific(const Cell *cell);
int getprecision(const Cell* cell);
const char *getlabel(const Cell *cell);
void initcellcontents(Cell *cell);
void freecellcontents(Cell *cell);
void copycell(Cell *to, const Cell *from);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -890,7 +890,7 @@ static int do_clear(Sheet *sheet)
else if (c!=1) return -1;
}
for (ALL_LOCS_IN_REGION(sheet, w)) freecell(sheet, w);
for (ALL_LOCS_IN_REGION(sheet, w)) freecellofsheet(sheet, w);
cachelabels(sheet);
forceupdate(sheet);
}

View File

@ -235,7 +235,7 @@ const char *loadsc(Sheet *sheet, const char *name)
col=(colstr[0]-'A'); if (colstr[1]) col=col*26+(colstr[1]-'A');
OLOCATION(tmp);
tmp[X] = col;
cell = initcell(sheet, tmp);
cell = initcellofsheet(sheet, tmp);
cell->adjust = RIGHT;
cell->precision = precision;
setwidth(sheet, col, 0, colwidth);
@ -260,7 +260,7 @@ const char *loadsc(Sheet *sheet, const char *name)
goto eek;
}
tmp[X] = x; tmp[Y] = y; tmp[Z] = 0;
cell = initcell(sheet, tmp);
cell = initcellofsheet(sheet, tmp);
cell->adjust = strncmp(buf,"leftstring ",11) ? RIGHT : LEFT;
cell->contents[BASE] = contents;
}
@ -301,7 +301,7 @@ const char *loadsc(Sheet *sheet, const char *name)
goto eek;
}
tmp[X] = x; tmp[Y] = y; tmp[Z] = 0;
cell = initcell(sheet, tmp);
cell = initcellofsheet(sheet, tmp);
cell->adjust = RIGHT;
cell->contents[BASE] = contents;
}

View File

@ -45,71 +45,19 @@ Location upd_l;
int max_eval;
/*}}}*/
/* copytokens -- copy a sequence of tokens, possibly reallocating dest */ /*{{{*/
static void copytokens(Token*** totoks, Token** fromtoks)
{
/* variables */ /*{{{*/
size_t from_len, to_len;
/*}}}*/
from_len = tveclen(fromtoks);
if (from_len == 0)
{
tvecfree(*totoks);
*totoks = EMPTY_TVEC;
return;
}
to_len = tveclen(*totoks);
if (from_len > to_len || *totoks == fromtoks)
{
if (*totoks != fromtoks) tvecfree(*totoks);
*totoks = malloc((from_len+1)*sizeof(Token*));
(*totoks)[from_len] = NULLTOKEN;
} else {
tvecfreetoks(*totoks);
}
for (size_t i = 0; i<from_len; ++i) /* destination already has NULLTOKEN at end */
{
if (fromtoks[i] == NULLTOKEN) (*totoks)[i] = NULLTOKEN;
else
{
(*totoks)[i] = malloc(sizeof(Token));
*((*totoks)[i]) = tcopy(*(fromtoks[i]));
}
}
}
/*}}}*/
/* copycell -- copy a cell */ /*{{{*/
static void copycell(const Cell *fromcell,
/* copycelltosheet -- copy a cell into a sheet*/ /*{{{*/
static void copycelltosheet(const Cell *fromcell,
Sheet *sheet2, const Location to)
{
/* variables */ /*{{{*/
Cell *tocell;
int len;
/*}}}*/
assert(sheet2 != (Sheet*)0);
freecell(sheet2, to);
freecellofsheet(sheet2, to);
if (fromcell != NULLCELL)
/* copy first cell to second */ /*{{{*/
{
sheet2->changed = 1;
tocell = initcell(sheet2, to);
memcpy(tocell, fromcell, sizeof(Cell));
copytokens(&(tocell->contents[BASE]), fromcell->contents[BASE]);
copytokens(&(tocell->contents[ITERATIVE]), fromcell->contents[ITERATIVE]);
if (fromcell->label != (char*)0)
{
len = strlen(fromcell->label);
tocell->label = strcpy(malloc(len+2), fromcell->label);
(tocell->label)[len] = '_';
(tocell->label)[len+1] = '\0';
}
tocell->value.type = EMPTY;
tocell->resvalue.type = EMPTY;
Cell *tocell = initcellofsheet(sheet2, to);
copycell(tocell, fromcell);
}
/*}}}*/
}
@ -355,27 +303,8 @@ void resize(Sheet *sheet, int x, int y, int z)
}
/*}}}*/
static void preparecell(Cell *c)
{
(void)memset(c->contents, 0, sizeof(c->contents));
c->label=(char*)0;
c->adjust=AUTOADJUST;
c->precision=-1;
c->shadowed=0;
c->bold=0;
c->underline=0;
c->scientific=DEF_SCIENTIFIC;
c->value.type=EMPTY;
c->resvalue.type=EMPTY;
c->locked=0;
c->ignored=0;
c->clock_t0=0;
c->clock_t1=0;
c->clock_t2=0;
}
/* initcell -- initialise new cell, if it does not exist yet */ /*{{{*/
Cell *initcell(Sheet *sheet, const Location at)
/* initcellofsheet -- initialise new cell, if it does not exist yet */ /*{{{*/
Cell *initcellofsheet(Sheet *sheet, const Location at)
{
Cell *nc;
@ -387,7 +316,7 @@ Cell *initcell(Sheet *sheet, const Location at)
sheet->changed = 1;
nc = malloc(sizeof(Cell));
CELL_AT(sheet,at) = nc;
preparecell(nc);
initcellcontents(nc);
}
return nc;
}
@ -471,7 +400,7 @@ void freesheet(Sheet *sheet, int all)
sheet->changed=0;
for (ALL_LOCS_IN_SHEET(sheet,w))
{
freecell(sheet,w);
freecellofsheet(sheet,w);
}
if (all)
{
@ -522,19 +451,14 @@ void forceupdate(Sheet *sheet)
}
/*}}}*/
/* freecell -- free one cell */ /*{{{*/
void freecell(Sheet *sheet, const Location at)
/* freecellofsheet -- free one cell */ /*{{{*/
void freecellofsheet(Sheet *sheet, const Location at)
{
Cell *c;
assert(sheet != (Sheet*)0);
if (sheet->sheet != (Cell**)0 && CELL_IS_GOOD(sheet,at))
{
c = CELL_AT(sheet,at);
tvecfree(c->contents[BASE]);
tvecfree(c->contents[ITERATIVE]);
tfree(&(c->value));
tfree(&(c->resvalue));
Cell *c = CELL_AT(sheet,at);
freecellcontents(c);
free(c);
CELL_AT(sheet,at) = NULLCELL;
sheet->changed = 1;
@ -580,23 +504,13 @@ void putcont(Sheet *sheet, const Location at, Token **t, ContentVariety v)
assert(sheet != (Sheet*)0);
sheet->changed = 1;
cell = initcell(sheet, at);
cell = initcellofsheet(sheet, at);
tvecfree(cell->contents[v]);
cell->contents[v] = t;
redraw_cell(sheet, at);
}
/*}}}*/
/* getcont -- get contents */ /*{{{*/
Token **getcont(const Cell *cell, ContentVariety v)
{
if (cell == NULLCELL) return EMPTY_TVEC;
if (v == CONTINGENT)
v = (cell->clock_t0 && cell->contents[ITERATIVE]) ? ITERATIVE : BASE;
return cell->contents[v];
}
/*}}}*/
/* getvalue -- get tcopy()ed value */ /*{{{*/
Token getvalue(Sheet *sheet, const Location at)
{
@ -758,22 +672,12 @@ void printvalue(char *s, size_t size, size_t chars, int quote, int scientific, i
}
/*}}}*/
/* getadjust -- get cell adjustment */ /*{{{*/
Adjust getadjust(const Cell* cell)
{
if (cell == NULLCELL) return LEFT;
else if (cell->adjust == AUTOADJUST)
return (cell->value.type == INT || cell->value.type == FLOAT ? RIGHT : LEFT);
else return cell->adjust;
}
/*}}}*/
/* setadjust -- set cell adjustment */ /*{{{*/
void setadjust(Sheet *sheet, const Location at, Adjust adjust)
{
assert(sheet != (Sheet*)0);
sheet->changed = 1;
initcell(sheet, at)->adjust = adjust;
initcellofsheet(sheet, at)->adjust = adjust;
}
/*}}}*/
@ -782,14 +686,7 @@ void shadow(Sheet *sheet, const Location at, int yep)
{
assert(sheet != (Sheet*)0);
sheet->changed = 1;
initcell(sheet, at)->shadowed = yep;
}
/*}}}*/
/* shadowed -- is cell shadowed? */ /*{{{*/
int shadowed(const Cell *cell)
{
return (cell != NULLCELL) && cell->shadowed;
initcellofsheet(sheet, at)->shadowed = yep;
}
/*}}}*/
@ -798,14 +695,7 @@ void bold(Sheet *sheet, const Location at, int yep)
{
assert(sheet != (Sheet*)0);
sheet->changed = 1;
initcell(sheet,at)->bold = yep;
}
/*}}}*/
/* isbold -- is cell bold? */ /*{{{*/
int isbold(const Cell* cell)
{
return (cell != NULLCELL) && cell->bold;
initcellofsheet(sheet,at)->bold = yep;
}
/*}}}*/
@ -814,14 +704,7 @@ void underline(Sheet *sheet, const Location at, int yep)
{
assert(sheet != (Sheet*)0);
sheet->changed = 1;
initcell(sheet,at)->underline = yep;
}
/*}}}*/
/* isunderline -- is cell underlined? */ /*{{{*/
int underlined(const Cell *cell)
{
return (cell != NULLCELL) && cell->underline;
initcellofsheet(sheet,at)->underline = yep;
}
/*}}}*/
@ -830,21 +713,7 @@ void lockcell(Sheet *sheet, const Location at, int yep)
{
assert(sheet != (Sheet*)0);
sheet->changed = 1;
initcell(sheet,at)->locked = yep;
}
/*}}}*/
/* locked -- is cell locked? */ /*{{{*/
int locked(const Cell *cell)
{
return (cell != NULLCELL) && cell->locked;
}
/*}}}*/
/* transparent -- is cell transparent? */ /*{{{*/
int transparent(const Cell* cell)
{
return (cell != NULLCELL) && cell->transparent;
initcellofsheet(sheet,at)->locked = yep;
}
/*}}}*/
@ -853,7 +722,7 @@ void maketrans(Sheet *sheet, const Location at, int yep)
{
assert(sheet != (Sheet*)0);
sheet->changed = 1;
initcell(sheet,at)->transparent = yep;
initcellofsheet(sheet,at)->transparent = yep;
}
/*}}}*/
@ -862,14 +731,7 @@ void igncell(Sheet *sheet, const Location at, int yep)
{
assert(sheet != (Sheet*)0);
sheet->changed = 1;
initcell(sheet,at)->ignored = yep;
}
/*}}}*/
/* ignored -- is cell ignored? */ /*{{{*/
int ignored(const Cell *cell)
{
return (cell != NULLCELL) && cell->ignored;
initcellofsheet(sheet,at)->ignored = yep;
}
/*}}}*/
@ -892,14 +754,7 @@ void setscientific(Sheet *sheet, const Location at, int yep)
{
assert(sheet != (Sheet*)0);
sheet->changed = 1;
initcell(sheet,at)->scientific = yep;
}
/*}}}*/
/* getscientific -- should value be displayed in scientific notation? */ /*{{{*/
int getscientific(const Cell *cell )
{
return (cell == NULLCELL) ? DEF_SCIENTIFIC : cell->scientific;
initcellofsheet(sheet,at)->scientific = yep;
}
/*}}}*/
@ -908,25 +763,10 @@ void setprecision(Sheet *sheet, const Location at, int precision)
{
assert(sheet != (Sheet*)0);
sheet->changed = 1;
initcell(sheet,at)->precision = precision;
initcellofsheet(sheet,at)->precision = precision;
}
/*}}}*/
/* getprecision -- get cell precision */ /*{{{*/
int getprecision(const Cell *cell)
{
if (cell == NULLCELL || cell->precision == -1) return def_precision;
return cell->precision;
}
/*}}}*/
/* getlabel -- get cell label */ /*{{{*/
const char *getlabel(const Cell* cell)
{
if (cell == NULLCELL || cell->label == (char*)0) return "";
return cell->label;
}
/*}}}*/
/* getmarkstate -- find out where in the marking cycle the sheet is */ /*{{{*/
MarkState getmarkstate(Sheet *sheet) {
if (sheet == (Sheet*)0) return MARK_CYCLE;
@ -940,7 +780,7 @@ void setlabel(Sheet *sheet, const Location at, const char *buf, int update)
assert(sheet != (Sheet*)0);
sheet->changed = 1;
cell = initcell(sheet, at);
cell = initcellofsheet(sheet, at);
if (cell->label != (char*)0) free(cell->label);
if (*buf == '\0') cell->label = (char*)0;
else cell->label = strcpy(malloc(strlen(buf)+1), buf);
@ -1426,7 +1266,7 @@ const char *loadport(Sheet *sheet, const char *name)
ContentVariety cv = BASE, nextcv = BASE;
if (width > 0 && buf[width-1]=='\\') { buf[--width]='\0'; ++nextcv; }
preparecell(&loaded);
initcellcontents(&loaded);
/* parse x y and z */ /*{{{*/
os=ns=buf+1;
loc[X] = posnumber(os,&ns);
@ -1612,7 +1452,7 @@ const char *loadport(Sheet *sheet, const char *name)
}
/*}}}*/
copycell(&loaded, sheet, loc);
copycelltosheet(&loaded, sheet, loc);
break;
}
/*}}}*/
@ -1732,10 +1572,10 @@ const char *loadxdr(Sheet *sheet, const char *name)
(void)fclose(fp);
return strerror(olderror);
}
nc = initcell(sheet, w);
nc = initcellofsheet(sheet, w);
if (xdr_cell(&xdrs, nc)==0)
{
freecell(sheet, w);
freecellofsheet(sheet, w);
olderror=errno;
xdr_destroy(&xdrs);
(void)fclose(fp);
@ -1932,7 +1772,7 @@ void deletecube(Sheet *sheet, const Location beg, const Location end,
for (w[X]=beg[X]; w[X]<=end[X]; ++w[X])
for (w[Y]=beg[Y]; w[Y]<=end[Y]; ++w[Y])
for (w[Z]=beg[Z]; w[Z]<=end[Z]; ++w[Z])
freecell(sheet, w);
freecellofsheet(sheet, w);
/*}}}*/
switch (del)
{
@ -2025,8 +1865,8 @@ void moveblock(Sheet *sheet, const Location beg, const Location end,
for (get[X] = beg[X]+fm[X], go[X] = dest[X]+fm[X];
get[X] != to[X]; get[X] += dir[X], go[X] += dir[X])
{
if (!LOC_WITHIN(sheet, get)) freecell(sheet, go);
else if (copy) { copycell(CELL_AT(sheet, get), sheet, go); }
if (!LOC_WITHIN(sheet, get)) freecellofsheet(sheet, go);
else if (copy) { copycelltosheet(CELL_AT(sheet, get), sheet, go); }
else
{
resize(sheet, go[X], go[Y], go[Z]);

View File

@ -1,14 +1,12 @@
#ifndef SHEET_H
#define SHEET_H
#include "scanner.h"
#include "cell.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum { LEFT=0, RIGHT=1, CENTER=2, AUTOADJUST=3 } Adjust;
typedef enum { IN_X, IN_Y, IN_Z } Direction;
/* must be a prime */
@ -24,31 +22,6 @@ typedef struct
int sortkey; /* OR-ed value of the above constants */
} Sortkey;
typedef enum { BASE=0, ITERATIVE=1, CONTINGENT=2 } ContentVariety;
typedef struct
{
Token **contents[CONTINGENT];
char *label;
Token value;
Token resvalue;
Adjust adjust;
int precision;
unsigned int updated:1;
unsigned int shadowed:1;
unsigned int scientific:1;
unsigned int locked:1;
unsigned int transparent:1;
unsigned int ignored:1;
unsigned int clock_t0:1;
unsigned int clock_t1:1;
unsigned int clock_t2:1;
unsigned int bold:1;
unsigned int underline:1;
} Cell;
#define NULLCELL ((Cell*)0)
struct Label
{
const char *label;
@ -99,7 +72,7 @@ extern int max_eval;
void initialize_sheet(Sheet *sheet);
void resize(Sheet *sheet, int x, int y, int z);
Cell *initcell(Sheet *sheet, const Location at);
Cell *initcellofsheet(Sheet *sheet, const Location at);
Cell *safe_cell_at(Sheet *sheet, const Location at);
Cell *curcell(Sheet *sheet);
void cachelabels(Sheet *sheet);
@ -107,36 +80,25 @@ void freesheet(Sheet *sheet, int all);
void forceupdate(Sheet *sheet);
MarkState getmarkstate(Sheet *sheet);
void dump_current_cell(Sheet *sheet);
void freecell(Sheet *sheet, const Location at);
void freecellofsheet(Sheet *sheet, const Location at);
int columnwidth(Sheet *sheet, int x, int z);
void setwidth(Sheet *sheet, int x, int z, int width);
int cellwidth(Sheet *sheet, const Location at);
void putcont(Sheet *sheet, const Location at, Token **t, ContentVariety v);
Token **getcont(const Cell *cell, ContentVariety v);
Token getvalue(Sheet *sheet, const Location at);
void update(Sheet *sheet);
char *geterror(Sheet *sheet, const Location at);
void printvalue(char *s, size_t size, size_t chars, int quote, int scientific, int precision, Sheet *sheet, const Location at);
Adjust getadjust(const Cell *cell);
void setadjust(Sheet *sheet, const Location at, Adjust adjust);
void shadow(Sheet *sheet, const Location at, int yep);
int shadowed(const Cell *cell);
void bold(Sheet *sheet, const Location at, int yep);
int isbold(const Cell *cell);
void underline(Sheet *sheet, const Location at, int yep);
int underlined(const Cell *cell);
void lockcell(Sheet *sheet, const Location at, int yep);
int locked(const Cell *cell);
int transparent(const Cell *cell);
void maketrans(Sheet *sheet, const Location at, int yep);
void igncell(Sheet *sheet, const Location at, int yep);
int ignored(const Cell *cell);
void clk(Sheet *sheet, const Location at);
void setscientific(Sheet *sheet, const Location at, int yep);
int getscientific(const Cell *cell);
void setprecision(Sheet *sheet, const Location at, int precision);
int getprecision(const Cell* cell);
const char *getlabel(const Cell* cell);
void setlabel(Sheet *sheet, const Location at, const char *buf, int update);
Token findlabel(Sheet *sheet, const char *label);
void relabel(Sheet* sheet, const Location at,

View File

@ -838,7 +838,7 @@ const char *loadwk1(Sheet *sheet, const char *name)
{
if (bodylen!=5) { err=_("Invalid record body length"); goto ouch; }
tmp[X] = it(body+1); tmp[Y] = it(body+3); tmp[Z] = 0;
cell = initcell(sheet, tmp);
cell = initcellofsheet(sheet, tmp);
format((unsigned char)body[0], cell);
break;
}
@ -850,7 +850,7 @@ const char *loadwk1(Sheet *sheet, const char *name)
assert(bodylen==7);
tmp[X] = it(body+1); tmp[Y] = it(body+3); tmp[Z] = 0;
cell = initcell(sheet, tmp);
cell = initcellofsheet(sheet, tmp);
t=malloc(2*sizeof(Token*));
t[0]=malloc(sizeof(Token));
t[1]=(Token*)0;
@ -868,7 +868,7 @@ const char *loadwk1(Sheet *sheet, const char *name)
assert(bodylen==13);
tmp[X] = it(body+1); tmp[Y] = it(body+3); tmp[Z] = 0;
cell = initcell(sheet, tmp);
cell = initcellofsheet(sheet, tmp);
t=malloc(2*sizeof(Token*));
t[0]=malloc(sizeof(Token));
t[1]=(Token*)0;
@ -886,7 +886,7 @@ const char *loadwk1(Sheet *sheet, const char *name)
assert(bodylen>=6 && bodylen<=245);
tmp[X] = it(body+1); tmp[Y] = it(body+3); tmp[Z] = 0;
cell = initcell(sheet, tmp);
cell = initcellofsheet(sheet, tmp);
t=malloc(2*sizeof(Token*));
t[0]=malloc(sizeof(Token));
t[1]=(Token*)0;
@ -975,7 +975,7 @@ const char *loadwk1(Sheet *sheet, const char *name)
#endif
free(offset);
tmp[X] = it(body+1); tmp[Y] = it(body+3); tmp[Z] = 0;
cell = initcell(sheet, tmp);
cell = initcellofsheet(sheet, tmp);
cell->value.type=FLOAT;
cell->value.u.flt=dbl((unsigned char*)body+5);
putcont(sheet, tmp, t, BASE);
@ -1093,7 +1093,7 @@ const char *loadwk1(Sheet *sheet, const char *name)
assert(bodylen>=6 && bodylen<=245);
tmp[X] = it(body+1); tmp[Y] = it(body+3); tmp[Z] = 0;
cell = initcell(sheet, tmp);
cell = initcellofsheet(sheet, tmp);
t=malloc(2*sizeof(Token*));
t[0]=malloc(sizeof(Token));
t[1]=(Token*)0;