Commit 5d9b9669 authored by slevy's avatar slevy
Browse files

CONSTify, and fix other lint found by macosx clang.

parent 6503a1ff
......@@ -131,7 +131,7 @@ Model::~Model()
defined = 0;
}
Model *Model::find( char *name )
Model *Model::find( const char *name )
{
Model *m;
if(name == NULL) return NULL;
......@@ -149,7 +149,7 @@ Model *Model::find( char *name )
return m ? m : maybe;
}
time_t fmodtime(char *fname)
time_t fmodtime(const char *fname)
{
struct stat st;
......@@ -162,7 +162,7 @@ time_t fmodtime(char *fname)
* Do we have an up-to-date copy of "file"?
* Returns 1 if yes, 0 if not seen, -1 if out-of-date.
*/
enum Model::fstatus Model::seenFile( char *fname )
enum Model::fstatus Model::seenFile( const char *fname )
{
Model *m;
......@@ -216,7 +216,7 @@ void Appearance::add( Appearance **list )
}
}
Appearance *Appearance::find( Appearance **list, char *name )
Appearance *Appearance::find( Appearance **list, const char *name )
{
Appearance *ap;
if(list == NULL || name == NULL) return NULL;
......@@ -226,7 +226,7 @@ Appearance *Appearance::find( Appearance **list, char *name )
return ap;
}
Appearance *Appearance::findCreate( Appearance **list, char *name )
Appearance *Appearance::findCreate( Appearance **list, const char *name )
{
Appearance *ap;
if(list == NULL || name == NULL) return NULL;
......@@ -321,7 +321,7 @@ int agetfloats( float *v, int max, int a0, int ac, char **av )
return i;
}
WavObj *WavObj::addObj( char *name, char *group )
WavObj *WavObj::addObj( const char *name, const char *group )
{
WavObj *obj;
char fullname[256];
......@@ -366,7 +366,7 @@ WavObj *WavObj::addObj( char *name, char *group )
return obj;
}
int WavObj::readFile( char *name, char *fname, char *scenename, int complain )
int WavObj::readFile( const char *name, const char *fname, const char *scenename, int complain )
{
FILE *inf = fopen(fname, "r");
char line[1024], tline[1024], *s;
......@@ -375,9 +375,9 @@ int WavObj::readFile( char *name, char *fname, char *scenename, int complain )
Appearance *ap = NULL;
int k;
int lno = 0;
char *err = NULL;
const char *err = NULL;
char errbuf[80];
char *group = NULL;
const char *group = NULL;
WavFaces *curfaces = NULL;
Point tpt[4000], ttx[4000], tnorm[4000];
int tnfv[250], tfv[1000];
......@@ -541,19 +541,22 @@ int WavObj::readFile( char *name, char *fname, char *scenename, int complain )
err = "f: expected series of NN/NN/NN (or just NN) fields for each vertex";
} else {
if(fvp[0] >= me.pt.count) {
sprintf(err = errbuf,
sprintf(errbuf,
"There's no vertex number %d! Only have %d",
fvp[0]+1, me.pt.count);
err = errbuf;
ok = 0;
} else if(fvp[1] >= me.tx.count) {
sprintf(err = errbuf,
sprintf(errbuf,
"There's no texture-vertex number %d! Only have %d",
fvp[1]+1, me.tx.count);
err = errbuf;
ok = 0;
} else if(fvp[2] >= me.norm.count) {
sprintf(err = errbuf,
sprintf(errbuf,
"There's no surface-normal number %d! Only have %d",
fvp[2]+1, me.norm.count);
err = errbuf;
ok = 0;
}
}
......@@ -591,7 +594,7 @@ MayaScene::MayaScene()
#define LINESIZE 1024
char *MayaScene::parseFileNode( char *name, FILE *f, char *reline, int *lno )
const char *MayaScene::parseFileNode( const char *name, FILE *f, char *reline, int *lno )
{
char line[LINESIZE+1], tline[LINESIZE+1];
char *av[8];
......@@ -631,7 +634,7 @@ char *MayaScene::parseFileNode( char *name, FILE *f, char *reline, int *lno )
return "Surprise EOF";
}
char *MayaScene::parseMatNode( char *name, FILE *f, char *reline, int *lno, char *kind )
const char *MayaScene::parseMatNode( const char *name, FILE *f, char *reline, int *lno, const char *kind )
{
char line[LINESIZE+1], tline[LINESIZE+1];
char *av[16];
......@@ -686,14 +689,14 @@ char *MayaScene::parseMatNode( char *name, FILE *f, char *reline, int *lno, char
return NULL;
}
char *MayaScene::parseScrapNode( char *name, FILE *f, char *reline, int *lno ) {
const char *MayaScene::parseScrapNode( const char *name, FILE *f, char *reline, int *lno ) {
Appearance *ap = Appearance::findCreate( &this->partials, name );
fgets(reline, sizeof(reline), f);
ap->defined = -1;
return NULL;
}
char *MayaScene::parseEngineNode( char *name, FILE *f, char *reline, int *lno )
const char *MayaScene::parseEngineNode( const char *name, FILE *f, char *reline, int *lno )
{
Appearance::findCreate( &this->aps, name ); /* just ensure node on list! */
fgets(reline, sizeof(reline), f);
......@@ -704,7 +707,7 @@ char *MayaScene::parseEngineNode( char *name, FILE *f, char *reline, int *lno )
* if str ends with suffix suf, return index in str where suf begins,
* else -1.
*/
int endsWith( char *str, char *suf )
int endsWith( const char *str, const char *suf )
{
if(str == NULL) return 0;
int at = strlen(str) - strlen(suf);
......@@ -712,7 +715,7 @@ int endsWith( char *str, char *suf )
return strcmp( str+at, suf ) == 0 ? at : -1;
}
char *MayaScene::parseConnect( char *from, char *to )
const char *MayaScene::parseConnect( char *from, char *to )
{
int efrom, eto;
Appearance *afrom, *ato;
......@@ -743,7 +746,7 @@ char *MayaScene::parseConnect( char *from, char *to )
}
int MayaScene::readScene( char *scenefname, int complain )
int MayaScene::readScene( const char *scenefname, int complain )
{
char line[LINESIZE+1], tline[LINESIZE+1];
int ac;
......@@ -751,7 +754,7 @@ int MayaScene::readScene( char *scenefname, int complain )
int lno = 0;
int ok = 1;
int rescan = 0;
char *err = NULL;
const char *err = NULL;
if(scenefname == NULL) return 0;
FILE *f = fopen(scenefname, "r");
......@@ -773,8 +776,8 @@ int MayaScene::readScene( char *scenefname, int complain )
ac = tokenize( line, tline, COUNT(av), av, NULL );
if(ac <= 1)
continue;
char *kind = av[1];
char *name = "";
const char *kind = av[1];
const char *name = "";
int i;
for(i = 2; i < ac-1; i++) {
if(!strcmp(av[i], "-n")) {
......
......@@ -42,8 +42,8 @@ typedef int (*TextureHookFunc)( int *txobjno, void *hookdata, class Appearance *
class Model : public Shmem {
public:
char *name; /* model name */
char *fname; /* name of model file */
const char *name; /* model name */
const char *fname; /* name of model file */
long fmtime;
int defined;
Model *next; /* link in list of all Models */
......@@ -52,7 +52,7 @@ class Model : public Shmem {
void init();
virtual ~Model();
static Model *find( char *name );
static Model *find( const char *name );
enum fstatus {
UNREAD = -2, /* file exists, but we haven't loaded it */
......@@ -70,10 +70,10 @@ class Model : public Shmem {
virtual int HookTextures( TextureHookFunc hook, void *data, const char *txnametag ) { return 0; }
static enum fstatus seenFile( char *fname ); /* Seen this model file?*/
static enum fstatus seenFile( const char *fname ); /* Seen this model file?*/
static char **pathdirs; /* Search path for findFile() */
static char *findFile( char *name ); /* returns salloc()ed string */
static char *findFile( const char *name ); /* returns salloc()ed string */
protected:
static Model **allModels; /* List of all Models */
......@@ -91,7 +91,7 @@ class Model : public Shmem {
*/
class Appearance : public Shmem {
public:
char *name; /* Wavefront/Maya name of this appearance (shading group) */
const char *name; /* Wavefront/Maya name of this appearance (shading group) */
Appearance *next;
Appearance *use;
int defined; /* Have we filled the rest of this structure in yet? */
......@@ -106,8 +106,8 @@ class Appearance : public Shmem {
float Cspec[3]; /* specular color */
/* in case we're textured... */
char *txdir; /* directory in which to search for textures */
char *txfname;
const char *txdir; /* directory in which to search for textures */
const char *txfname;
Texture *txim;
int txloaded;
......@@ -122,8 +122,8 @@ class Appearance : public Shmem {
void add( Appearance **list );
static Appearance *find( Appearance **listhead, char *name );
static Appearance *findCreate( Appearance **listhead, char *name );
static Appearance *find( Appearance **listhead, const char *name );
static Appearance *findCreate( Appearance **listhead, const char *name );
static Appearance *create();
void loadTextures();
......@@ -136,16 +136,16 @@ class MayaScene : public Shmem {
MayaScene();
protected:
char *fname;
const char *fname;
Appearance *aps;
int readScene( char *scenefname, int complain );
int readScene( const char *scenefname, int complain );
char *parseFileNode( char *name, FILE *f, char *line, int *lno );
char *parseMatNode( char *name, FILE *f, char *line, int *lno, char *kind );
char *parseEngineNode( char *name, FILE *f, char *line, int *lno );
char *parseScrapNode( char *name, FILE *f, char *line, int *lno );
char *parseConnect( char *from, char *to );
const char *parseFileNode( const char *name, FILE *f, char *line, int *lno );
const char *parseMatNode( const char *name, FILE *f, char *line, int *lno, const char *kind );
const char *parseEngineNode( const char *name, FILE *f, char *line, int *lno );
const char *parseScrapNode( const char *name, FILE *f, char *line, int *lno );
const char *parseConnect( char *from, char *to );
Appearance *partials; /* Used while parsing only */
......@@ -185,7 +185,7 @@ class WavObj : public Model {
void init();
~WavObj();
static WavObj *create();
static int readFile( char *name, char *fname, char *scenename, int complain );
static int readFile( const char *name, const char *fname, const char *scenename, int complain );
void render();
WavObj & operator=( const WavObj &src ) {
......@@ -200,7 +200,7 @@ class WavObj : public Model {
virtual int HookTextures( TextureHookFunc hook, void *data, const char *txnametag );
private:
WavObj *addObj( char *name, char *group );
WavObj *addObj( const char *name, const char *group );
};
class HappyFace : public Model {
......
......@@ -3,7 +3,7 @@
// #include <unistd.h>
static char *sldtypetitles[] = {"alpha", "fov", "censize", "chromarange", "focallength", "lblminpix", "labelsize", "polysides", "polysize", "slum"};
static const char *sldtypetitles[] = {"alpha", "fov", "censize", "chromarange", "focallength", "lblminpix", "labelsize", "polysides", "polysize", "slum"};
static char sidtitles[NUMSLD][30];
static float minrg[NUMSLD][2], maxrg[NUMSLD][2], steprg[NUMSLD][2]; //generic slider's min, max, step, by [slider type][log/linear][data group]
static int loglinsld[NUMSLD]; //toggle = 1 always log = 2 always linear =3 by slider
......
......@@ -32,6 +32,10 @@ extern "C" {
# include <malloc.h> /* for amalloc() */
#endif
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif
#ifdef __cplusplus
# define NewN(type, count) (static_cast <type *>(shmalloc((count) * sizeof(type))))
# define RenewN(p,type,count) (static_cast <type *>(shmrealloc(p, (count) * sizeof(type))))
......@@ -70,7 +74,7 @@ extern void shmrecycler( int (*func)(void *, int, void *), void *data );
# define RenewN(p,type,count) ((type *)realloc(p, (count) * sizeof(type)))
#endif
#define Free(p) free( p )
#define Free(p) free( (void *)(p) )
extern char *shmstrdup( CONST char * );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment