update utilities: list,byte,hash,uri,log

This commit is contained in:
Dennis Heimbigner 2012-08-19 21:54:30 +00:00
parent 2a0d68c530
commit 5380aa5b67
14 changed files with 1753 additions and 1586 deletions

View File

@ -153,11 +153,11 @@ nclistdup(NClist* l)
}
int
nclistcontains(NClist* list, void* elem)
nclistcontains(NClist* l, void* elem)
{
unsigned long i;
for(i=0;i<nclistlength(list);i++) {
if(elem == nclistget(list,i)) return 1;
for(i=0;i<nclistlength(l);i++) {
if(elem == nclistget(l,i)) return 1;
}
return 0;
}
@ -191,13 +191,13 @@ nclistelemremove(NClist* l, void* elem)
*/
int
nclistunique(NClist* list)
nclistunique(NClist* l)
{
unsigned long i,j,k,len;
void** content;
if(list == NULL || list->length == 0) return 1;
len = list->length;
content = list->content;
if(l == NULL || l->length == 0) return 1;
len = l->length;
content = l->content;
for(i=0;i<len;i++) {
for(j=i+1;j<len;j++) {
if(content[i] == content[j]) {
@ -207,15 +207,15 @@ nclistunique(NClist* list)
}
}
}
list->length = len;
l->length = len;
return 1;
}
NClist*
nclistclone(NClist* list)
nclistclone(NClist* l)
{
NClist* clone = nclistnew();
*clone = *list;
clone->content = nclistdup(list);
*clone = *l;
clone->content = nclistdup(l);
return clone;
}

View File

@ -70,9 +70,9 @@ static void ncappendparams(char* newuri, char** p);
/* Do a simple uri parse: return 0 if fail, 1 otherwise*/
int
ncuriparse(const char* uri0, NCURI** ncurip)
ncuriparse(const char* uri0, NCURI** durip)
{
NCURI* ncuri = NULL;
NCURI* duri = NULL;
char* uri = NULL;
char* p;
struct NC_ProtocolInfo* proto;
@ -92,12 +92,12 @@ ncuriparse(const char* uri0, NCURI** ncurip)
if(uri0 == NULL || strlen(uri0) == 0)
{THROW(1); goto fail;}
ncuri = (NCURI*)calloc(1,sizeof(NCURI));
if(ncuri == NULL)
duri = (NCURI*)calloc(1,sizeof(NCURI));
if(duri == NULL)
{THROW(2); goto fail;}
/* save original uri */
ncuri->uri = nulldup(uri0);
duri->uri = nulldup(uri0);
/* make local copy of uri */
uri = (char*)malloc(strlen(uri0)+1+PADDING); /* +1 for trailing null,
@ -108,7 +108,7 @@ ncuriparse(const char* uri0, NCURI** ncurip)
/* strings will be broken into pieces with intermixed '\0; characters;
first char is guaranteed to be '\0' */
ncuri->strings = uri;
duri->strings = uri;
uri++;
/* dup the incoming url */
@ -308,14 +308,14 @@ ncuriparse(const char* uri0, NCURI** ncurip)
if(constraint != NULL && *constraint == EOFCHAR) constraint = NULL;
/* assemble the component pieces */
ncuri->protocol = protocol;
ncuri->user = user;
ncuri->password = pwd;
ncuri->host = host;
ncuri->port = port;
ncuri->file = file;
duri->protocol = protocol;
duri->user = user;
duri->password = pwd;
duri->host = host;
duri->port = port;
duri->file = file;
ncurisetconstraints(ncuri,constraint);
ncurisetconstraints(duri,constraint);
/* concat suffix and prefix params */
if(prefixparams != NULL || suffixparams != NULL) {
@ -324,51 +324,51 @@ ncuriparse(const char* uri0, NCURI** ncurip)
int space = plen + slen + 1;
/* add 1 for an extra comma if both are defined */
space++;
ncuri->params = (char*)malloc(space);
ncuri->params[0] = EOFCHAR; /* so we can use strcat */
duri->params = (char*)malloc(space);
duri->params[0] = EOFCHAR; /* so we can use strcat */
if(plen > 0) {
strcat(ncuri->params,prefixparams);
strcat(duri->params,prefixparams);
if(slen > 0)
strcat(ncuri->params,";");
strcat(duri->params,";");
}
if(slen > 0)
strcat(ncuri->params,suffixparams);
strcat(duri->params,suffixparams);
}
#ifdef NCXDEBUG
{
fprintf(stderr,"ncuri:");
fprintf(stderr," params=|%s|",FIX(ncuri->params));
fprintf(stderr," protocol=|%s|",FIX(ncuri->protocol));
fprintf(stderr," host=|%s|",FIX(ncuri->host));
fprintf(stderr," port=|%s|",FIX(ncuri->port));
fprintf(stderr," file=|%s|",FIX(ncuri->file));
fprintf(stderr," constraint=|%s|",FIX(ncuri->constraint));
fprintf(stderr,"duri:");
fprintf(stderr," params=|%s|",FIX(duri->params));
fprintf(stderr," protocol=|%s|",FIX(duri->protocol));
fprintf(stderr," host=|%s|",FIX(duri->host));
fprintf(stderr," port=|%s|",FIX(duri->port));
fprintf(stderr," file=|%s|",FIX(duri->file));
fprintf(stderr," constraint=|%s|",FIX(duri->constraint));
fprintf(stderr,"\n");
}
#endif
if(ncurip != NULL) *ncurip = ncuri;
if(durip != NULL) *durip = duri;
return 1;
fail:
if(ncuri != NULL) {
ncurifree(ncuri);
if(duri != NULL) {
ncurifree(duri);
}
return 0;
}
void
ncurifree(NCURI* ncuri)
ncurifree(NCURI* duri)
{
if(ncuri == NULL) return;
if(ncuri->uri != NULL) {free(ncuri->uri);}
if(ncuri->params != NULL) {free(ncuri->params);}
if(ncuri->paramlist != NULL) ncparamfree(ncuri->paramlist);
if(ncuri->strings != NULL) {free(ncuri->strings);}
if(ncuri->constraint != NULL) {free(ncuri->constraint);}
if(ncuri->projection != NULL) {free(ncuri->projection);}
if(ncuri->selection != NULL) {free(ncuri->selection);}
free(ncuri);
if(duri == NULL) return;
if(duri->uri != NULL) {free(duri->uri);}
if(duri->params != NULL) {free(duri->params);}
if(duri->paramlist != NULL) ncparamfree(duri->paramlist);
if(duri->strings != NULL) {free(duri->strings);}
if(duri->constraint != NULL) {free(duri->constraint);}
if(duri->projection != NULL) {free(duri->projection);}
if(duri->selection != NULL) {free(duri->selection);}
free(duri);
}
/* Replace the constraints */

View File

@ -182,7 +182,7 @@ c_vlendecl(Generator* generator, Bytebuffer* codebuf, Symbol* tsym, int uid, siz
commify(vlenbuf);
bbCatbuf(decl,vlenbuf);
bbCat(decl,"} ;");
listpush(declstack,(elem_t)decl);
listpush(declstack,(void*)decl);
/* Now generate the reference to buffer */
bbprintf(codebuf,"{%u,(void*)vlen_%u}",count,uid);
return 1;

View File

@ -785,7 +785,7 @@ genf77_writevar(Generator* generator, Symbol* vsym, Bytebuffer* code,
/* save in the generator state */
generator_getstate(generator,(void*)&calllist);
ASSERT(calllist != NULL);
listpush(calllist,(elem_t)bbDup(stmt));
listpush(calllist,(void*)bbDup(stmt));
/* Construct the procedure body and save it */
proctext = bbNew();
@ -871,7 +871,7 @@ genf77_writevar(Generator* generator, Symbol* vsym, Bytebuffer* code,
codeline("end");
/* save the generated procedure(s) */
if(f77procs == NULL) f77procs = listnew();
listpush(f77procs,(elem_t)codebuffer);
listpush(f77procs,(void*)codebuffer);
codebuffer = save;
}
}

View File

@ -1,26 +1,12 @@
/*********************************************************************
* Copyright 2009, UCAR/Unidata
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
*********************************************************************/
/* $Id: list.c,v 1.3 2010/05/24 19:59:58 dmh Exp $ */
/* $Header: /upc/share/CVS/netcdf-3/ncgen/list.c,v 1.3 2010/05/24 19:59:58 dmh Exp $ */
#include "config.h"
/* Copyright 2009, UCAR/Unidata and OPeNDAP, Inc.
See the COPYRIGHT file for more information. */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "list.h"
#include "debug.h"
elem_t DATANULL;
static int qinitialized=0;
#ifdef STRUCT_STACK
int listnull(elem_t e) {return e.f1 = 0 && e.f2 == 0;}
#else
int listnull(elem_t e) {return e == (elem_t)0;}
#endif
int listnull(void* e) {return e == NULL;}
#ifndef TRUE
#define TRUE 1
@ -34,195 +20,202 @@ int listnull(elem_t e) {return e == (elem_t)0;}
List* listnew(void)
{
List* sq;
if(!qinitialized) {
memset((void*)&DATANULL,0,sizeof(elem_t));
qinitialized = 1;
List* l;
/*
if(!initialized) {
memset((void*)&DATANULL,0,sizeof(void*));
initialized = 1;
}
sq = (List*)emalloc(sizeof(List));
if(sq) {
sq->alloc=0;
sq->length=0;
sq->content=NULL;
*/
l = (List*)malloc(sizeof(List));
if(l) {
l->alloc=0;
l->length=0;
l->content=NULL;
}
return sq;
return l;
}
int
listfree(List* sq)
listfree(List* l)
{
if(sq) {
sq->alloc = 0;
if(sq->content != NULL) {free(sq->content); sq->content = NULL;}
efree(sq);
if(l) {
l->alloc = 0;
if(l->content != NULL) {free(l->content); l->content = NULL;}
free(l);
}
return TRUE;
}
int
listsetalloc(List* sq, unsigned int sz)
listsetalloc(List* l, unsigned long sz)
{
elem_t* newcontent;
if(sq == NULL) return FALSE;
if(sz <= 0) {sz = (sq->length?2*sq->length:DEFAULTALLOC);}
else if(sq->alloc >= sz) {return TRUE;}
newcontent=(elem_t*)ecalloc(sz,sizeof(elem_t));
if(sq->alloc > 0 && sq->length > 0 && sq->content != NULL) {
memcpy((void*)newcontent,(void*)sq->content,sizeof(elem_t)*sq->length);
efree(sq->content);
void** newcontent;
if(l == NULL) return FALSE;
if(sz <= 0) {sz = (l->length?2*l->length:DEFAULTALLOC);}
if(l->alloc >= sz) {return TRUE;}
newcontent=(void**)calloc(sz,sizeof(void*));
if(l->alloc > 0 && l->length > 0 && l->content != NULL) {
memcpy((void*)newcontent,(void*)l->content,sizeof(void*)*l->length);
}
sq->content=newcontent;
sq->alloc=sz;
if(l->content != NULL) free(l->content);
l->content=newcontent;
l->alloc=sz;
return TRUE;
}
#ifndef LINLINE
int
listsetlength(List* sq, unsigned int sz)
{
if(sq == NULL) return FALSE;
if(!listsetalloc(sq,sz)) return FALSE;
sq->length = sz;
return TRUE;
}
elem_t
listget(List* sq, unsigned int index)
{
if(sq == NULL || sq->length == 0) return DATANULL;
if(index >= sq->length) return DATANULL;
return sq->content[index];
}
#endif
int
listset(List* sq, unsigned int index, elem_t elem)
listsetlength(List* l, unsigned long sz)
{
if(sq == NULL) return FALSE;
if(index >= sq->length) return FALSE;
sq->content[index] = elem;
if(l == NULL) return FALSE;
if(sz > l->alloc && !listsetalloc(l,sz)) return FALSE;
l->length = sz;
return TRUE;
}
/* Insert at position i of sq; will push up elements i..|seq|. */
int
listinsert(List* sq, unsigned int index, elem_t elem)
void*
listget(List* l, unsigned long index)
{
unsigned int i;
if(sq == NULL) return FALSE;
if(index > sq->length) return FALSE;
listsetalloc(sq,0);
for(i=sq->length;i>index;i--) sq->content[i] = sq->content[i-1];
sq->content[index] = elem;
sq->length++;
return TRUE;
if(l == NULL || l->length == 0) return NULL;
if(index >= l->length) return NULL;
return l->content[index];
}
#ifndef LINLINE
int
listpush(List* sq, elem_t elem)
{
if(sq == NULL) return FALSE;
if(sq->length >= sq->alloc) listsetalloc(sq,0);
sq->content[sq->length] = elem;
sq->length++;
return TRUE;
}
#endif
int
listfpush(List* sq, elem_t elem)
listset(List* l, unsigned long index, void* elem)
{
unsigned int i;
if(sq == NULL) return FALSE;
if(sq->length >= sq->alloc) listsetalloc(sq,0);
/* could we trust bcopy? instead */
for(i=sq->alloc;i>=1;i--) {sq->content[i]=sq->content[i-1];}
sq->content[0] = elem;
sq->length++;
if(l == NULL) return FALSE;
if(index >= l->length) return FALSE;
l->content[index] = elem;
return TRUE;
}
elem_t
listpop(List* sq)
/* Insert at position i of l; will push up elements i..|seq|. */
int
listinsert(List* l, unsigned long index, void* elem)
{
if(sq == NULL || sq->length == 0) return DATANULL;
sq->length--;
return sq->content[sq->length];
int i; /* do not make unsigned */
if(l == NULL) return FALSE;
if(index > l->length) return FALSE;
listsetalloc(l,0);
for(i=(int)l->length;i>index;i--) l->content[i] = l->content[i-1];
l->content[index] = elem;
l->length++;
return TRUE;
}
elem_t
listtop(List* sq)
int
listpush(List* l, void* elem)
{
if(sq == NULL || sq->length == 0) return DATANULL;
return sq->content[sq->length - 1];
if(l == NULL) return FALSE;
if(l->length >= l->alloc) listsetalloc(l,0);
l->content[l->length] = elem;
l->length++;
return TRUE;
}
elem_t
listfpop(List* sq)
void*
listpop(List* l)
{
elem_t elem;
if(sq == NULL || sq->length == 0) return DATANULL;
elem = sq->content[0];
memcpy((void*)&sq->content[0],(void*)&sq->content[1],
sizeof(elem_t)*(sq->length - 1));
sq->length--;
return elem;
if(l == NULL || l->length == 0) return NULL;
l->length--;
return l->content[l->length];
}
elem_t
listfront(List* sq)
void*
listtop(List* l)
{
if(sq == NULL || sq->length == 0) return DATANULL;
return sq->content[0];
if(l == NULL || l->length == 0) return NULL;
return l->content[l->length - 1];
}
elem_t
listremove(List* sq, unsigned int i)
void*
listremove(List* l, unsigned long i)
{
unsigned int len;
elem_t elem;
if(sq == NULL || (len=sq->length) == 0) return DATANULL;
if(i >= len) return DATANULL;
elem = sq->content[i];
for(i++;i<len;i++) sq->content[i-1] = sq->content[i];
sq->length--;
unsigned long len;
void* elem;
if(l == NULL || (len=l->length) == 0) return NULL;
if(i >= len) return NULL;
elem = l->content[i];
for(i+=1;i<len;i++) l->content[i-1] = l->content[i];
l->length--;
return elem;
}
/* Duplicate and return the content (null terminate) */
elem_t*
listdup(List* sq)
void**
listdup(List* l)
{
elem_t* result = (elem_t*)emalloc(sizeof(elem_t)*(sq->length+1));
memcpy((void*)result,(void*)sq->content,sizeof(elem_t)*sq->length);
result[sq->length] = (elem_t)0;
void** result = (void**)malloc(sizeof(void*)*(l->length+1));
memcpy((void*)result,(void*)l->content,sizeof(void*)*l->length);
result[l->length] = (void*)0;
return result;
}
int
listcontains(List* l, elem_t e)
listcontains(List* l, void* elem)
{
if(l != NULL) {
int i;
for(i=0;i<l->length;i++) {
if(l->content[i] == e) return 1;
}
}
unsigned long i;
for(i=0;i<listlength(l);i++) {
if(elem == listget(l,i)) return 1;
}
return 0;
}
/* Remove element by value; only removes first encountered */
int
listdelete(List* l, elem_t e)
listelemremove(List* l, void* elem)
{
int found = 0;
if(l != NULL) {
int i;
/* Walk backward */
for(i=l->length-1;i>=0;i--) {
found = 1;
if(l->content[i] == e) listremove(l,i);
}
}
return found;
unsigned long len;
unsigned long i;
int found = 0;
if(l == NULL || (len=l->length) == 0) return 0;
for(i=0;i<listlength(l);i++) {
void* candidate = l->content[i];
if(elem == candidate) {
for(i+=1;i<len;i++) l->content[i-1] = l->content[i];
l->length--;
found = 1;
break;
}
}
return found;
}
/* Extends list to include a unique operator
which remove duplicate values; NULL values removed
return value is always 1.
*/
int
listunique(List* l)
{
unsigned long i,j,k,len;
void** content;
if(l == NULL || l->length == 0) return 1;
len = l->length;
content = l->content;
for(i=0;i<len;i++) {
for(j=i+1;j<len;j++) {
if(content[i] == content[j]) {
/* compress out jth element */
for(k=j+1;k<len;k++) content[k-1] = content[k];
len--;
}
}
}
l->length = len;
return 1;
}
List*
listclone(List* l)
{
List* clone = listnew();
*clone = *l;
clone->content = listdup(l);
return clone;
}

View File

@ -1,14 +1,9 @@
/*********************************************************************
* Copyright 2009, UCAR/Unidata
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
*********************************************************************/
/* $Id: list.h,v 1.3 2010/05/24 19:59:58 dmh Exp $ */
/* $Header: /upc/share/CVS/netcdf-3/ncgen/list.h,v 1.3 2010/05/24 19:59:58 dmh Exp $ */
/* Copyright 2009, UCAR/Unidata and OPeNDAP, Inc.
See the COPYRIGHT file for more information. */
#ifndef LIST_H
#define LIST_H 1
/* Define the type of the elements in the sequence*/
/* Define the type of the elements in the list*/
#if defined(_CPLUSPLUS_) || defined(__CPLUSPLUS__)
#define EXTERNC extern "C"
@ -16,71 +11,52 @@
#define EXTERNC extern
#endif
typedef unsigned long elem_t;
EXTERNC int listnull(elem_t);
EXTERNC int listnull(void*);
typedef struct List {
unsigned int alloc;
unsigned int length;
elem_t* content;
unsigned long alloc;
unsigned long length;
void** content;
} List;
EXTERNC List* listnew(void);
EXTERNC int listfree(List*);
EXTERNC int listsetalloc(List*,unsigned int);
EXTERNC int listsetalloc(List*,unsigned long);
EXTERNC int listsetlength(List*,unsigned long);
/* Set the ith element of sq */
EXTERNC int listset(List*,unsigned int,elem_t);
/* Insert at position i of sq; will push up elements i..|seq|. */
EXTERNC int listinsert(List*,unsigned int,elem_t);
/* Set the ith element */
EXTERNC int listset(List*,unsigned long,void*);
/* Get value at position i */
EXTERNC void* listget(List*,unsigned long);/* Return the ith element of l */
/* Insert at position i; will push up elements i..|seq|. */
EXTERNC int listinsert(List*,unsigned long,void*);
/* Remove element at position i; will move higher elements down */
EXTERNC void* listremove(List* l, unsigned long i);
/* Tail operations */
EXTERNC int listpush(List*,elem_t); /* Add at Tail */
EXTERNC elem_t listpop(List*);
EXTERNC elem_t listtop(List*);
/* Head operations */
EXTERNC int listfpush(List*,elem_t); /* Add at Head */
EXTERNC elem_t listfpop(List*);
EXTERNC elem_t listfront(List*);
EXTERNC elem_t listremove(List* sq, unsigned int i);
EXTERNC int listpush(List*,void*); /* Add at Tail */
EXTERNC void* listpop(List*);
EXTERNC void* listtop(List*);
/* Duplicate and return the content (null terminate) */
EXTERNC elem_t* listdup(List*);
EXTERNC void** listdup(List*);
/* Search list for a given element */
EXTERNC int listcontains(List*,elem_t);
/* Look for value match */
EXTERNC int listcontains(List*, void*);
/* Remove a list element by value (remove all instances) */
EXTERNC int listdelete(List*,elem_t);
/* Remove element by value; only removes first encountered */
EXTERNC int listelemremove(List* l, void* elem);
/* remove duplicates */
EXTERNC int listunique(List*);
/* Create a clone of a list */
EXTERNC List* listclone(List*);
/* Following are always "in-lined"*/
#define listclear(sq) listsetlength((sq),0U)
#define listextend(sq,len) listsetalloc((sq),(len)+(sq->alloc))
#define listcontents(sq) ((sq)->content)
#define listlength(sq) ((sq)?(sq)->length:0U)
/* Following can be open-coded via macros */
#ifdef LINLINE
EXTERNC elem_t DATANULL;
#define listsetlength(sq,sz) \
(((sq)==NULL||(sz)<0||!listsetalloc((sq),(sz)))?0:((sq)->length=(sz),1))
#define listget(sq,index) \
(((sq)==NULL||(sz)<0||(index)<0||(index)>=(sq)->length)?DATANULL:((sq)->content[index]))
#define listpush(sq,elem) \
(((sq)==NULL||(((sz)->length >= (sq)->alloc)&&!listsetalloc((sq),0)))?0:((sq)->content[(sq)->length++]=(elem),1))
#else
EXTERNC int listsetlength(List*,unsigned int);
EXTERNC elem_t listget(List*,unsigned int);/* Return the ith element of sq */
EXTERNC int listpush(List*,elem_t); /* Add at Tail */
#endif
#define listclear(l) listsetlength((l),0)
#define listextend(l,len) listsetalloc((l),(len)+(l->alloc))
#define listcontents(l) ((l)==NULL?NULL:(l)->content)
#define listlength(l) ((l)==NULL?0:(l)->length)
#endif /*LIST_H*/

View File

@ -605,7 +605,7 @@ makepath(char* text0)
yyerror(errstr);
sym = rootgroup;
} else {
listpush(prefix,(elem_t)sym);
listpush(prefix,(void*)sym);
}
} else
{

View File

@ -255,7 +255,7 @@ typename: ident
if(dupobjectcheck(NC_TYPE,$1))
yyerror("duplicate type declaration for %s",
$1->name);
listpush(typdefs,(elem_t)$1);
listpush(typdefs,(void*)$1);
}
;
@ -293,7 +293,7 @@ enumdecl: primtype ENUM typename
Symbol* eid = (Symbol*)listget(stack,i);
assert(eid->subclass == NC_ECONST);
addtogroup(eid);
listpush($3->subnodes,(elem_t)eid);
listpush($3->subnodes,(void*)eid);
eid->container = $3;
eid->typ.basetype = $3->typ.basetype;
}
@ -302,7 +302,7 @@ enumdecl: primtype ENUM typename
;
enumidlist: enumid
{$$=listlength(stack); listpush(stack,(elem_t)$1);}
{$$=listlength(stack); listpush(stack,(void*)$1);}
| enumidlist ',' enumid
{
int i;
@ -316,7 +316,7 @@ enumidlist: enumid
yyerror("duplicate enum declaration for %s",
elem->name);
}
listpush(stack,(elem_t)$3);
listpush(stack,(void*)$3);
}
;
@ -381,7 +381,7 @@ compounddecl: COMPOUND typename '{' fields '}'
for(i=stackbase;i<stacklen;i++) {
Symbol* fsym = (Symbol*)listget(stack,i);
fsym->container = $2;
listpush($2->subnodes,(elem_t)fsym);
listpush($2->subnodes,(void*)fsym);
}
listsetlength(stack,stackbase);/* remove stack nodes*/
}
@ -484,7 +484,7 @@ dimd: ident
$1->name);
addtogroup($1);
$$=$1;
listpush(dimdefs,(elem_t)$1);
listpush(dimdefs,(void*)$1);
}
;
@ -514,7 +514,7 @@ vardecl: typeref varlist
} else {
sym->typ.basetype = $1;
addtogroup(sym);
listpush(vardefs,(elem_t)sym);
listpush(vardefs,(void*)sym);
}
}
listsetlength(stack,stackbase);/* remove stack nodes*/
@ -523,10 +523,10 @@ vardecl: typeref varlist
varlist: varspec
{$$=listlength(stack);
listpush(stack,(elem_t)$1);
listpush(stack,(void*)$1);
}
| varlist ',' varspec
{$$=$1; listpush(stack,(elem_t)$3);}
{$$=$1; listpush(stack,(void*)$3);}
;
varspec: ident dimspec
@ -560,9 +560,9 @@ dimspec: /* empty */ {$$=listlength(stack);}
| '(' dimlist ')' {$$=$2;}
;
dimlist: dimref {$$=listlength(stack); listpush(stack,(elem_t)$1);}
dimlist: dimref {$$=listlength(stack); listpush(stack,(void*)$1);}
| dimlist ',' dimref
{$$=$1; listpush(stack,(elem_t)$3);}
{$$=$1; listpush(stack,(void*)$3);}
;
dimref: path
@ -581,10 +581,10 @@ dimref: path
fieldlist:
fieldspec
{$$=listlength(stack);
listpush(stack,(elem_t)$1);
listpush(stack,(void*)$1);
}
| fieldlist ',' fieldspec
{$$=$1; listpush(stack,(elem_t)$3);}
{$$=$1; listpush(stack,(void*)$3);}
;
fieldspec:
@ -622,9 +622,9 @@ fielddimspec: /* empty */ {$$=listlength(stack);}
;
fielddimlist:
fielddim {$$=listlength(stack); listpush(stack,(elem_t)$1);}
fielddim {$$=listlength(stack); listpush(stack,(void*)$1);}
| fielddimlist ',' fielddim
{$$=$1; listpush(stack,(elem_t)$3);}
{$$=$1; listpush(stack,(void*)$3);}
;
fielddim:
@ -975,7 +975,7 @@ createrootgroup(void)
gsym->subnodes = listnew();
gsym->grp.is_root = 1;
gsym->prefix = listnew();
listpush(grpdefs,(elem_t)gsym);
listpush(grpdefs,(void*)gsym);
rootgroup = gsym;
return gsym;
}
@ -991,8 +991,8 @@ creategroup(Symbol * gsym)
}
addtogroup(gsym);
gsym->subnodes = listnew();
listpush(groupstack,(elem_t)gsym);
listpush(grpdefs,(elem_t)gsym);
listpush(groupstack,(void*)gsym);
listpush(grpdefs,(void*)gsym);
return gsym;
}
@ -1082,7 +1082,7 @@ addtogroup(Symbol* sym)
{
Symbol* grp = currentgroup();
sym->container = grp;
listpush(grp->subnodes,(elem_t)sym);
listpush(grp->subnodes,(void*)sym);
setpathcurrent(sym);
}
@ -1328,12 +1328,12 @@ makeattribute(Symbol* asym,
case ATTRVAR:
asym->att.var = vsym;
asym->typ.basetype = tsym;
listpush(attdefs,(elem_t)asym);
listpush(attdefs,(void*)asym);
break;
case ATTRGLOBAL:
asym->att.var = NULL; /* NULL => NC_GLOBAL*/
asym->typ.basetype = tsym;
listpush(gattdefs,(elem_t)asym);
listpush(gattdefs,(void*)asym);
break;
default: PANIC1("unexpected attribute type: %d",kind);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -223,7 +223,7 @@ processtypes(void)
}
if(keep) {
sym->touched = 1;
listpush(sorted,(elem_t)sym);
listpush(sorted,(void*)sym);
}
}
/* 2. repeated walk to collect level i types*/
@ -253,7 +253,7 @@ processtypes(void)
default: break;
}
if(keep) {
listpush(sorted,(elem_t)sym);
listpush(sorted,(void*)sym);
sym->touched = 1;
added++;
}
@ -327,7 +327,7 @@ processenums(void)
for(j=0;j<listlength(sym->subnodes);j++) {
Symbol* esym = (Symbol*)listget(sym->subnodes,j);
ASSERT(esym->subclass == NC_ECONST);
listpush(enumids,(elem_t)esym);
listpush(enumids,(void*)esym);
}
}
/* Now walk set of enum ids to look for duplicates with same prefix*/
@ -475,12 +475,12 @@ makespecial(int tag, Symbol* vsym, nc_type typ, Datalist* dlist)
attr->data = dlist;
if(vsym) {
Symbol* grp = vsym->container;
if(grp) listpush(grp->subnodes,(elem_t)attr);
if(grp) listpush(grp->subnodes,(void*)attr);
attr->container = grp;
}
attr->att.var = vsym;
attr->typ.basetype = primsymbols[typ==NC_STRING?NC_CHAR:typ];
listpush(attdefs,(elem_t)attr);
listpush(attdefs,(void*)attr);
}
static void
@ -629,7 +629,7 @@ processattributes(void)
Symbol* asym = (Symbol*)listget(attdefs,j);
ASSERT(asym->att.var != NULL);
if(asym->att.var != vsym) continue;
listpush(list,(elem_t)asym);
listpush(list,(void*)asym);
}
vsym->var.attributes = list;
}

View File

@ -293,7 +293,7 @@ void
collectpath(Symbol* grp, List* grpstack)
{
while(grp != NULL) {
listpush(grpstack,(elem_t)grp);
listpush(grpstack,(void*)grp);
grp = grp->container;
}
}

View File

@ -153,11 +153,11 @@ oclistdup(OClist* l)
}
int
oclistcontains(OClist* list, void* elem)
oclistcontains(OClist* l, void* elem)
{
unsigned long i;
for(i=0;i<oclistlength(list);i++) {
if(elem == oclistget(list,i)) return 1;
for(i=0;i<oclistlength(l);i++) {
if(elem == oclistget(l,i)) return 1;
}
return 0;
}
@ -191,13 +191,13 @@ oclistelemremove(OClist* l, void* elem)
*/
int
oclistunique(OClist* list)
oclistunique(OClist* l)
{
unsigned long i,j,k,len;
void** content;
if(list == NULL || list->length == 0) return 1;
len = list->length;
content = list->content;
if(l == NULL || l->length == 0) return 1;
len = l->length;
content = l->content;
for(i=0;i<len;i++) {
for(j=i+1;j<len;j++) {
if(content[i] == content[j]) {
@ -207,15 +207,15 @@ oclistunique(OClist* list)
}
}
}
list->length = len;
l->length = len;
return 1;
}
OClist*
oclistclone(OClist* list)
oclistclone(OClist* l)
{
OClist* clone = oclistnew();
*clone = *list;
clone->content = oclistdup(list);
*clone = *l;
clone->content = oclistdup(l);
return clone;
}

View File

@ -70,9 +70,9 @@ static void ocappendparams(char* newuri, char** p);
/* Do a simple uri parse: return 0 if fail, 1 otherwise*/
int
ocuriparse(const char* uri0, OCURI** ocurip)
ocuriparse(const char* uri0, OCURI** durip)
{
OCURI* ocuri = NULL;
OCURI* duri = NULL;
char* uri = NULL;
char* p;
struct OC_ProtocolInfo* proto;
@ -92,12 +92,12 @@ ocuriparse(const char* uri0, OCURI** ocurip)
if(uri0 == NULL || strlen(uri0) == 0)
{THROW(1); goto fail;}
ocuri = (OCURI*)calloc(1,sizeof(OCURI));
if(ocuri == NULL)
duri = (OCURI*)calloc(1,sizeof(OCURI));
if(duri == NULL)
{THROW(2); goto fail;}
/* save original uri */
ocuri->uri = nulldup(uri0);
duri->uri = nulldup(uri0);
/* make local copy of uri */
uri = (char*)malloc(strlen(uri0)+1+PADDING); /* +1 for trailing null,
@ -108,7 +108,7 @@ ocuriparse(const char* uri0, OCURI** ocurip)
/* strings will be broken into pieces with intermixed '\0; characters;
first char is guaranteed to be '\0' */
ocuri->strings = uri;
duri->strings = uri;
uri++;
/* dup the incoming url */
@ -308,14 +308,14 @@ ocuriparse(const char* uri0, OCURI** ocurip)
if(constraint != NULL && *constraint == EOFCHAR) constraint = NULL;
/* assemble the component pieces */
ocuri->protocol = protocol;
ocuri->user = user;
ocuri->password = pwd;
ocuri->host = host;
ocuri->port = port;
ocuri->file = file;
duri->protocol = protocol;
duri->user = user;
duri->password = pwd;
duri->host = host;
duri->port = port;
duri->file = file;
ocurisetconstraints(ocuri,constraint);
ocurisetconstraints(duri,constraint);
/* concat suffix and prefix params */
if(prefixparams != NULL || suffixparams != NULL) {
@ -324,51 +324,51 @@ ocuriparse(const char* uri0, OCURI** ocurip)
int space = plen + slen + 1;
/* add 1 for an extra comma if both are defined */
space++;
ocuri->params = (char*)malloc(space);
ocuri->params[0] = EOFCHAR; /* so we can use strcat */
duri->params = (char*)malloc(space);
duri->params[0] = EOFCHAR; /* so we can use strcat */
if(plen > 0) {
strcat(ocuri->params,prefixparams);
strcat(duri->params,prefixparams);
if(slen > 0)
strcat(ocuri->params,";");
strcat(duri->params,";");
}
if(slen > 0)
strcat(ocuri->params,suffixparams);
strcat(duri->params,suffixparams);
}
#ifdef OCXDEBUG
{
fprintf(stderr,"ocuri:");
fprintf(stderr," params=|%s|",FIX(ocuri->params));
fprintf(stderr," protocol=|%s|",FIX(ocuri->protocol));
fprintf(stderr," host=|%s|",FIX(ocuri->host));
fprintf(stderr," port=|%s|",FIX(ocuri->port));
fprintf(stderr," file=|%s|",FIX(ocuri->file));
fprintf(stderr," constraint=|%s|",FIX(ocuri->constraint));
fprintf(stderr,"duri:");
fprintf(stderr," params=|%s|",FIX(duri->params));
fprintf(stderr," protocol=|%s|",FIX(duri->protocol));
fprintf(stderr," host=|%s|",FIX(duri->host));
fprintf(stderr," port=|%s|",FIX(duri->port));
fprintf(stderr," file=|%s|",FIX(duri->file));
fprintf(stderr," constraint=|%s|",FIX(duri->constraint));
fprintf(stderr,"\n");
}
#endif
if(ocurip != NULL) *ocurip = ocuri;
if(durip != NULL) *durip = duri;
return 1;
fail:
if(ocuri != NULL) {
ocurifree(ocuri);
if(duri != NULL) {
ocurifree(duri);
}
return 0;
}
void
ocurifree(OCURI* ocuri)
ocurifree(OCURI* duri)
{
if(ocuri == NULL) return;
if(ocuri->uri != NULL) {free(ocuri->uri);}
if(ocuri->params != NULL) {free(ocuri->params);}
if(ocuri->paramlist != NULL) ocparamfree(ocuri->paramlist);
if(ocuri->strings != NULL) {free(ocuri->strings);}
if(ocuri->constraint != NULL) {free(ocuri->constraint);}
if(ocuri->projection != NULL) {free(ocuri->projection);}
if(ocuri->selection != NULL) {free(ocuri->selection);}
free(ocuri);
if(duri == NULL) return;
if(duri->uri != NULL) {free(duri->uri);}
if(duri->params != NULL) {free(duri->params);}
if(duri->paramlist != NULL) ocparamfree(duri->paramlist);
if(duri->strings != NULL) {free(duri->strings);}
if(duri->constraint != NULL) {free(duri->constraint);}
if(duri->projection != NULL) {free(duri->projection);}
if(duri->selection != NULL) {free(duri->selection);}
free(duri);
}
/* Replace the constraints */