Commit 432f1c08 authored by Bernhard Link's avatar Bernhard Link

some cleanups

parent 2a71988b
2005-04-10 Bernhard R. Link <brlink@debian.org>
* apply some clean ups:
- distinguish between boolean and non-boolean values
- split globals from error.h in globals.h
* fix bug in signature.c to not treat config error like valid key.
2005-04-07 Bernhard R. Link <brlink@debian.org>
* fix wrong handling of bugs in update specifications
* adopt short-howto to present
......
......@@ -7,6 +7,6 @@ bin_PROGRAMS = reprepro
AM_CPPFLAGS = -D_GNU_SOURCE=1 -DPKGDATADIR=\"$(pkgdatadir)\" -Wall
reprepro_SOURCES = guesscomponent.c files.c md5.c md5sum.c dirs.c chunks.c reference.c packages.c binaries.c sources.c names.c dpkgversions.c release.c mprintf.c updates.c strlist.c signature.c distribution.c extractcontrol.c checkindeb.c checkindsc.c checkin.c copyfile.c upgradelist.c target.c aptmethod.c downloadcache.c main.c override.c terms.c ignore.c filterlist.c exports.c
noinst_HEADERS = guesscomponent.h md5.h md5sum.h dirs.h files.h chunks.h reference.h packages.h binaries.h sources.h names.h release.h error.h mprintf.h updates.h strlist.h signature.h distribution.h extractcontrol.h checkindeb.h checkindsc.h copyfile.h upgradelist.h target.h aptmethod.h downloadcache.h override.h terms.h ignore.h filterlist.h dpkgversions.h checkin.h exports.h
noinst_HEADERS = guesscomponent.h md5.h md5sum.h dirs.h files.h chunks.h reference.h packages.h binaries.h sources.h names.h release.h error.h mprintf.h updates.h strlist.h signature.h distribution.h extractcontrol.h checkindeb.h checkindsc.h copyfile.h upgradelist.h target.h aptmethod.h downloadcache.h override.h terms.h ignore.h filterlist.h dpkgversions.h checkin.h exports.h globals.h
MAINTAINERCLEANFILES = Makefile.in configure install-sh stamp-h.in aclocal.m4 config.h.in mkinstalldirs
......@@ -72,7 +72,7 @@ static void aptmethod_free(/*@only@*/struct aptmethod *method) {
free(method->inputbuffer);
free(method->command);
while( method->tobedone ) {
while( method->tobedone != NULL ) {
struct tobedone *todo;
todo = method->tobedone;
......@@ -92,7 +92,7 @@ retvalue aptmethod_shutdown(struct aptmethodrun *run) {
/* first get rid of everything not running: */
method = run->methods; lastmethod = NULL;
while( method ) {
while( method != NULL ) {
struct aptmethod *h;
if( method->child > 0 ) {
......@@ -103,7 +103,7 @@ retvalue aptmethod_shutdown(struct aptmethodrun *run) {
continue;
} else {
h = method->next;
if( lastmethod )
if( lastmethod != NULL )
lastmethod->next = h;
else
run->methods = h;
......@@ -113,7 +113,7 @@ retvalue aptmethod_shutdown(struct aptmethodrun *run) {
}
/* finally get rid of all the processes: */
for( method = run->methods ; method ; method = method->next ) {
for( method = run->methods ; method != NULL ; method = method->next ) {
if( method->stdin >= 0 ) {
(void)close(method->stdin);
if( verbose > 30 )
......@@ -127,16 +127,16 @@ retvalue aptmethod_shutdown(struct aptmethodrun *run) {
}
method->stdout = -1;
}
while( run->methods ) {
while( run->methods != NULL ) {
pid_t pid;int status;
pid = wait(&status);
lastmethod = NULL; method = run->methods;
while( method ) {
while( method != NULL ) {
if( method->child == pid ) {
struct aptmethod *next = method->next;
if( lastmethod ) {
if( lastmethod != NULL ) {
lastmethod->next = next;
} else
run->methods = next;
......@@ -211,7 +211,7 @@ retvalue aptmethod_newmethod(struct aptmethodrun *run,const char *uri,const char
free(method);
return RET_ERROR_OOM;
}
if( config ) {
if( config != NULL ) {
method->config = strdup(config);
if( method->config == NULL ) {
free(method->baseuri);
......@@ -294,7 +294,7 @@ inline static retvalue aptmethod_startup(struct aptmethodrun *run,struct aptmeth
} else {
/* closeat least the ones definitly causing problems*/
const struct aptmethod *m;
for( m = run->methods; m ; m = m->next ) {
for( m = run->methods; m != NULL ; m = m->next ) {
if( m != method ) {
(void)close(m->stdin);
(void)close(m->stdout);
......@@ -369,7 +369,7 @@ static inline retvalue sendconfig(struct aptmethod *method) {
wasnewline = TRUE;
for( p = method->config; *p != '\0' ; p++ ) {
if( *p != '\n' ) {
if( !wasnewline || !isspace(*p) )
if( !wasnewline || !xisspace(*p) )
*(c++) = *p;
wasnewline = FALSE;
} else {
......@@ -402,11 +402,11 @@ static inline retvalue sendconfig(struct aptmethod *method) {
todo->next = NULL;
todo->uri = calc_dirconcat(baseuri,origfile);
todo->filename = strdup(destfile);
if( filekey )
if( filekey != NULL )
todo->filekey = strdup(filekey);
else
todo->filekey = NULL;
if( md5sum ) {
if( md5sum != NULL ) {
todo->md5sum = strdup(md5sum);
} else
todo->md5sum = NULL;
......@@ -436,7 +436,7 @@ retvalue aptmethod_queuefile(struct aptmethod *method,const char *origfile,const
method->lasttobedone->next = todo;
method->lasttobedone = todo;
}
if( t )
if( t != NULL )
*t = todo;
return RET_OK;
......@@ -487,14 +487,14 @@ static inline retvalue todo_done(const struct tobedone *todo,const char *filenam
}
/* if we know what it should be, check it: */
if( todo->md5sum ) {
if( todo->md5sum != NULL ) {
if( md5sum == NULL || strcmp(md5sum,todo->md5sum) != 0) {
fprintf(stderr,"Receiving '%s' wrong md5sum: got '%s' expected '%s'!\n",todo->uri,md5sum,todo->md5sum);
return RET_ERROR_WRONG_MD5;
}
}
if( todo->filekey ) {
if( todo->filekey != NULL ) {
retvalue r;
assert(filesdb != NULL);
......@@ -514,7 +514,7 @@ static retvalue urierror(struct aptmethod *method,const char *uri) {
struct tobedone *todo,*lasttodo;
lasttodo = NULL; todo = method->tobedone;
while( todo ) {
while( todo != NULL ) {
if( strcmp(todo->uri,uri) == 0) {
/* remove item: */
......@@ -550,7 +550,7 @@ static retvalue uridone(struct aptmethod *method,const char *uri,const char *fil
struct tobedone *todo,*lasttodo;
lasttodo = NULL; todo = method->tobedone;
while( todo ) {
while( todo != NULL ) {
if( strcmp(todo->uri,uri) == 0) {
retvalue r;
r = todo_done(todo,filename,md5sum,filesdb);
......@@ -793,7 +793,7 @@ static retvalue receivedata(struct aptmethod *method,filesdb filesdb) {
char *p;
int consecutivenewlines;
assert( method->status != ams_ok || method->tobedone );
assert( method->status != ams_ok || method->tobedone != NULL );
if( method->status != ams_waitforcapabilities && method->status != ams_ok )
return RET_NOTHING;
......@@ -972,8 +972,9 @@ static retvalue readwrite(struct aptmethodrun *run,int *workleft,filesdb filesdb
FD_ZERO(&writefds);
maxfd = 0;
*workleft = 0;
for( method = run->methods ; method ; method = method->next ) {
if( method->status == ams_ok && ( method->command || method->nexttosend)) {
for( method = run->methods ; method != NULL ; method = method->next ) {
if( method->status == ams_ok &&
( method->command != NULL || method->nexttosend != NULL )) {
FD_SET(method->stdin,&writefds);
if( method->stdin > maxfd )
maxfd = method->stdin;
......@@ -983,7 +984,7 @@ static retvalue readwrite(struct aptmethodrun *run,int *workleft,filesdb filesdb
}
if( method->status == ams_waitforcapabilities ||
(method->status == ams_ok &&
method->tobedone) ) {
method->tobedone != NULL ) ) {
FD_SET(method->stdout,&readfds);
if( method->stdout > maxfd )
maxfd = method->stdout;
......@@ -1009,7 +1010,7 @@ static retvalue readwrite(struct aptmethodrun *run,int *workleft,filesdb filesdb
result = RET_NOTHING;
maxfd = 0;
for( method = run->methods ; method ; method = method->next ) {
for( method = run->methods ; method != NULL ; method = method->next ) {
if( FD_ISSET(method->stdout,&readfds) ) {
r = receivedata(method,filesdb);
RET_UPDATE(result,r);
......
......@@ -82,7 +82,7 @@ static retvalue binaries_parse_chunk(const char *chunk,const char *packagename,c
r = chunk_getname(chunk,"Source",&mysourcename,TRUE);
if( r == RET_NOTHING ) {
mysourcename = strdup(packagename);
if( !mysourcename )
if( mysourcename == NULL )
r = RET_ERROR_OOM;
}
if( RET_WAS_ERROR(r) ) {
......@@ -106,7 +106,7 @@ static retvalue binaries_parse_chunk(const char *chunk,const char *packagename,c
}
mybasename = calc_binary_basename(packagename,version,parch,packagetype);
free(parch);
if( !mybasename ) {
if( mybasename == NULL ) {
free(mysourcename);
return RET_ERROR_OOM;
}
......@@ -143,7 +143,7 @@ retvalue binaries_calcfilekeys(const char *component,const char *sourcename,cons
return r;
}
filekey = calc_filekey(component,sourcename,basename);
if( !filekey )
if( filekey == NULL )
return RET_ERROR_OOM;
r = strlist_init_singleton(filekey,filekeys);
return r;
......
......@@ -107,7 +107,7 @@ struct changes {
static void freeentries(/*@only@*/struct fileentry *entry) {
struct fileentry *h;
while( entry ) {
while( entry != NULL ) {
h = entry->next;
free(entry->filekey);
free(entry->component);
......@@ -149,37 +149,37 @@ static retvalue newentry(struct fileentry **entry,const char *fileline,const cha
filetype type;
p = fileline;
while( *p !='\0' && isspace(*p) )
while( *p !='\0' && xisspace(*p) )
p++;
md5start = p;
while( *p !='\0' && !isspace(*p) )
while( *p !='\0' && !xisspace(*p) )
p++;
md5end = p;
while( *p !='\0' && isspace(*p) )
while( *p !='\0' && xisspace(*p) )
p++;
sizestart = p;
while( *p !='\0' && !isspace(*p) )
while( *p !='\0' && !xisspace(*p) )
p++;
sizeend = p;
while( *p !='\0' && isspace(*p) )
while( *p !='\0' && xisspace(*p) )
p++;
sectionstart = p;
while( *p !='\0' && !isspace(*p) )
while( *p !='\0' && !xisspace(*p) )
p++;
sectionend = p;
while( *p !='\0' && isspace(*p) )
while( *p !='\0' && xisspace(*p) )
p++;
priostart = p;
while( *p !='\0' && !isspace(*p) )
while( *p !='\0' && !xisspace(*p) )
p++;
prioend = p;
while( *p !='\0' && isspace(*p) )
while( *p !='\0' && xisspace(*p) )
p++;
filestart = p;
while( *p !='\0' && !isspace(*p) )
while( *p !='\0' && !xisspace(*p) )
p++;
fileend = p;
while( *p !='\0' && isspace(*p) )
while( *p !='\0' && xisspace(*p) )
p++;
if( *p != '\0' ) {
fprintf(stderr,"Unexpected sixth argument in '%s'!\n",fileline);
......@@ -192,7 +192,7 @@ static retvalue newentry(struct fileentry **entry,const char *fileline,const cha
}
p = filestart;
while( *p != '\0' && *p != '_' && !isspace(*p) )
while( *p != '\0' && *p != '_' && !xisspace(*p) )
p++;
if( *p != '_' ) {
if( *p == '\0' )
......@@ -226,7 +226,7 @@ static retvalue newentry(struct fileentry **entry,const char *fileline,const cha
archend = p;
p++;
typestart = p;
while( *p !='\0' && !isspace(*p) )
while( *p !='\0' && !xisspace(*p) )
p++;
if( p-typestart == 3 && strncmp(typestart,"deb",3) == 0 )
type = fe_DEB;
......@@ -243,7 +243,7 @@ static retvalue newentry(struct fileentry **entry,const char *fileline,const cha
} else {
/* this looks like some source-package, we will have
* to look for the packagetype ourself... */
while( *p !='\0' && !isspace(*p) ) {
while( *p !='\0' && !xisspace(*p) ) {
p++;
}
if( p-versionstart > 12 && strncmp(p-12,".orig.tar.gz",12) == 0 )
......@@ -283,11 +283,12 @@ static retvalue newentry(struct fileentry **entry,const char *fileline,const cha
e->name = strndup(filestart,nameend-filestart);
e->type = type;
if( !e->basename || !e->md5sum || !e->section || !e->priority || !e->architecture || !e->name ) {
if( e->basename == NULL || e->md5sum == NULL || e->section == NULL ||
e->priority == NULL || e->architecture == NULL || e->name == NULL ) {
freeentries(e);
return RET_ERROR_OOM;
}
if( forcearchitecture ) {
if( forcearchitecture != NULL ) {
if( strcmp(forcearchitecture,"source") != 0 &&
strcmp(e->architecture,"all") == 0 ) {
if( verbose > 2 )
......@@ -340,7 +341,7 @@ static retvalue check(const char *filename,struct changes *changes,const char *f
r = chunk_checkfield(changes->control,field);
if( r == RET_NOTHING ) {
fprintf(stderr,"In '%s': Missing '%s' field!\n",filename,field);
if( !force )
if( force <= 0 )
return RET_ERROR;
}
return r;
......@@ -438,20 +439,20 @@ static retvalue changes_fixfields(const struct distribution *distribution,const
return RET_ERROR;
}
while( e ) {
while( e != NULL ) {
const struct overrideinfo *oinfo = NULL;
const char *force = NULL;
if( !forcesection || !forcepriority ) {
if( forcesection == NULL || forcepriority == NULL ) {
oinfo = override_search(
FE_BINARY(e->type)?(e->type==fe_UDEB?ao->udeb:ao->deb):ao->dsc,
e->name);
}
if( forcesection )
if( forcesection != NULL )
force = forcesection;
else
force = override_get(oinfo,SECTION_FIELDNAME);
if( force ) {
if( force != NULL ) {
free(e->section);
e->section = strdup(force);
if( e->section == NULL )
......@@ -469,11 +470,11 @@ static retvalue changes_fixfields(const struct distribution *distribution,const
fprintf(stderr,"No section specified for '%s'!\n",filename);
return RET_ERROR;
}
if( forcepriority )
if( forcepriority != NULL )
force = forcepriority;
else
force = override_get(oinfo,PRIORITY_FIELDNAME);
if( force ) {
if( force != NULL ) {
free(e->priority);
e->priority = strdup(force);
if( e->priority == NULL )
......@@ -558,7 +559,7 @@ static retvalue changes_check(const char *filename,struct changes *changes,/*@nu
bool_t havedsc=FALSE, haveorig=FALSE, havetar=FALSE, havediff=FALSE;
/* First check for each given architecture, if it has files: */
if( forcearchitecture ) {
if( forcearchitecture != NULL ) {
if( !strlist_in(&changes->architectures,forcearchitecture) ){
fprintf(stderr,"Architecture-header does not list the"
" architecture '%s' to be forced in!\n",
......@@ -579,7 +580,7 @@ static retvalue changes_check(const char *filename,struct changes *changes,/*@nu
/* Then check for each file, if its architecture is sensible
* and listed. */
e = changes->files;
while( e ) {
while( e != NULL ) {
if( !strlist_in(&changes->architectures,e->architecture) ) {
fprintf(stderr,"'%s' looks like architecture '%s', but this is not listed in the Architecture-Header!\n",filename,e->architecture);
r = RET_ERROR;
......@@ -655,7 +656,7 @@ static retvalue changes_includefiles(filesdb filesdb,const char *filename,struct
r = RET_NOTHING;
e = changes->files;
while( e ) {
while( e != NULL ) {
if( FE_SOURCE(e->type) ) {
assert(changes->srcdirectory!=NULL);
e->filekey = calc_dirconcat(changes->srcdirectory,e->basename);
......@@ -695,7 +696,7 @@ static retvalue changes_includepkgs(const char *dbdir,references refs,filesdb fi
r = RET_NOTHING;
e = changes->files;
while( e ) {
while( e != NULL ) {
char *fullfilename;
if( e->type != fe_DEB && e->type != fe_DSC && e->type != fe_UDEB) {
e = e->next;
......
......@@ -104,13 +104,13 @@ struct debpackage {
};
static void deb_free(/*@only@*/struct debpackage *pkg) {
if( pkg ) {
if( pkg != NULL ) {
free(pkg->package);free(pkg->version);
free(pkg->source);free(pkg->architecture);
free(pkg->control);
free(pkg->section);free(pkg->component);
free(pkg->priority);
if( pkg->filekey )
if( pkg->filekey != NULL )
strlist_done(&pkg->filekeys);
free(pkg->md5sum);
}
......@@ -214,28 +214,28 @@ static retvalue deb_complete(struct debpackage *pkg,const struct overrideinfo *o
assert( pkg->section != NULL && pkg->priority != NULL);
size = pkg->md5sum;
while( !isblank(*size) && *size )
while( !xisblank(*size) && *size != '\0' )
size++;
replace = addfield_newn("MD5sum",pkg->md5sum, size-pkg->md5sum,NULL);
if( !replace )
if( replace == NULL )
return RET_ERROR_OOM;
while( *size && isblank(*size) )
while( *size != '\0' && xisblank(*size) )
size++;
replace = addfield_new("Size",size,replace);
if( !replace )
if( replace == NULL )
return RET_ERROR_OOM;
replace = addfield_new("Filename",pkg->filekey,replace);
if( !replace )
if( replace == NULL )
return RET_ERROR_OOM;
replace = addfield_new(SECTION_FIELDNAME,pkg->section ,replace);
if( !replace )
if( replace == NULL )
return RET_ERROR_OOM;
replace = addfield_new(PRIORITY_FIELDNAME,pkg->priority, replace);
if( !replace )
if( replace == NULL )
return RET_ERROR_OOM;
replace = override_addreplacefields(override,replace);
if( !replace )
if( replace == NULL )
return RET_ERROR_OOM;
newchunk = chunk_replacefields(pkg->control,replace,"Description");
......@@ -323,7 +323,7 @@ retvalue deb_add(const char *dbdir,references refs,filesdb filesdb,const char *f
forcepriority = override_get(oinfo,PRIORITY_FIELDNAME);
}
if( forcesection ) {
if( forcesection != NULL ) {
free(pkg->section);
pkg->section = strdup(forcesection);
if( pkg->section == NULL ) {
......@@ -331,7 +331,7 @@ retvalue deb_add(const char *dbdir,references refs,filesdb filesdb,const char *f
return RET_ERROR_OOM;
}
}
if( forcepriority ) {
if( forcepriority != NULL ) {
free(pkg->priority);
pkg->priority = strdup(forcepriority);
if( pkg->priority == NULL ) {
......@@ -442,7 +442,7 @@ retvalue deb_add(const char *dbdir,references refs,filesdb filesdb,const char *f
RET_ENDUPDATE(r,r2);
}
RET_UPDATE(result,r);
} else if( forcearchitecture ) {
} else if( forcearchitecture != NULL ) {
struct target *t = distribution_getpart(distribution,pkg->component,forcearchitecture,packagetype);
r = target_initpackagesdb(t,dbdir);
if( !RET_WAS_ERROR(r) ) {
......
......@@ -129,7 +129,7 @@ struct dscpackage {
};
static void dsc_free(/*@only@*/struct dscpackage *pkg) {
if( pkg ) {
if( pkg != NULL ) {
free(pkg->package);free(pkg->version);
free(pkg->control);
strlist_done(&pkg->basenames);strlist_done(&pkg->md5sums);
......@@ -139,8 +139,8 @@ static void dsc_free(/*@only@*/struct dscpackage *pkg) {
free(pkg->dscmd5sum);
free(pkg->directory);free(pkg->dscbasename);free(pkg->dscfilekey);
strlist_done(&pkg->filekeys);
free(pkg);
}
free(pkg);
}
static retvalue dsc_read(/*@out@*/struct dscpackage **pkg, const char *filename, bool_t onlysigned) {
......@@ -283,10 +283,10 @@ static retvalue dsc_complete(struct dscpackage *pkg,const struct overrideinfo *o
/* first replace the "Source" with a "Package": */
name = addfield_new("Package",pkg->package,NULL);
if( !name )
if( name == NULL )
return RET_ERROR_OOM;
name = deletefield_new("Source",name);
if( !name )
if( name == NULL )
return RET_ERROR_OOM;
newchunk2 = chunk_replacefields(pkg->control,name,"Format");
addfield_free(name);
......@@ -300,17 +300,17 @@ static retvalue dsc_complete(struct dscpackage *pkg,const struct overrideinfo *o
return RET_ERROR_OOM;
}
replace = addfield_new("Files",newfilelines,NULL);
if( replace )
if( replace != NULL )
replace = addfield_new("Directory",pkg->directory,replace);
if( replace )
if( replace != NULL )
replace = deletefield_new("Status",replace);
if( replace )
if( replace != NULL )
replace = addfield_new(SECTION_FIELDNAME,pkg->section,replace);
if( replace )
if( replace != NULL )
replace = addfield_new(PRIORITY_FIELDNAME,pkg->priority,replace);
if( replace )
if( replace != NULL )
replace = override_addreplacefields(override,replace);
if( !replace ) {
if( replace == NULL ) {
free(newfilelines);
free(newchunk2);
return RET_ERROR_OOM;
......@@ -405,7 +405,7 @@ retvalue dsc_add(const char *dbdir,references refs,filesdb filesdb,const char *f
forcepriority = override_get(oinfo,PRIORITY_FIELDNAME);
}
if( forcesection ) {
if( forcesection != NULL ) {
free(pkg->section);
pkg->section = strdup(forcesection);
if( pkg->section == NULL ) {
......@@ -413,7 +413,7 @@ retvalue dsc_add(const char *dbdir,references refs,filesdb filesdb,const char *f
return RET_ERROR_OOM;
}
}
if( forcepriority ) {
if( forcepriority != NULL ) {
free(pkg->priority);
pkg->priority = strdup(forcepriority);
if( pkg->priority == NULL ) {
......
......@@ -78,7 +78,7 @@ retvalue chunk_read(gzFile f,char **chunk) {
bhead = buffer = (char*)malloc(size);
if( buffer == NULL )
return RET_ERROR_OOM;
while( gzgets(f,bhead,size-1-already) ) {
while( gzgets(f,bhead,size-1-already) != NULL ) {
char *p;
p = bhead;
while( *p != '\0' ) {
......@@ -141,7 +141,7 @@ retvalue chunk_read(gzFile f,char **chunk) {
static const char *chunk_getfield(const char *name,const char *chunk) {
size_t l;
if( !chunk)
if( chunk == NULL )
return NULL;
l = strlen(name);
while( *chunk != '\0' ) {
......@@ -167,12 +167,12 @@ retvalue chunk_getcontent(const char *chunk,const char *name,char **value) {
assert(value != NULL);
field = chunk_getfield(name,chunk);
if( !field )
if( field == NULL )
return RET_NOTHING;
b = field;
/* jump over spaces at the beginning */
if( isspace(*b) )
if( xisspace(*b) )
b++;
/* search for the end */
......@@ -193,7 +193,7 @@ retvalue chunk_getcontent(const char *chunk,const char *name,char **value) {
val = strndup(b,e-b+1);
else
val = strdup("");
if( !val )
if( val == NULL )
return RET_ERROR_OOM;
*value = val;
return RET_OK;
......@@ -207,25 +207,25 @@ retvalue chunk_getvalue(const char *chunk,const char *name,char **value) {
assert(value != NULL);
field = chunk_getfield(name,chunk);
if( !field )
if( field == NULL )
return RET_NOTHING;
b = field;
/* jump over spaces at the beginning */
if( isspace(*b) )
if( xisspace(*b) )
b++;
/* search for the end */
e = b;
while( *e != '\n' && *e != '\0' )
e++;
/* remove trailing spaces */
while( e > b && isspace(*e) )
while( e > b && xisspace(*e) )
e--;
if( !isspace(*e) )
if( !xisspace(*e) )
val = strndup(b,e-b+1);
else
val = strdup("");
if( !val )
if( val == NULL )
return RET_ERROR_OOM;
*value = val;
return RET_OK;
......@@ -238,17 +238,17 @@ retvalue chunk_getfirstword(const char *chunk,const char *name,char **value) {
assert(value != NULL);
field = chunk_getfield(name,chunk);
if( !field )
if( field == NULL )
return RET_NOTHING;
b = field;
if( isspace(*b) )
if( xisspace(*b) )
b++;
e = b;
while( !isspace(*e) && *e != '\n' && *e != '\0' )
while( !xisspace(*e) && *e != '\n' && *e != '\0' )
e++;
val = strndup(b,e-b);
if( !val )
if( val == NULL )
return RET_ERROR_OOM;
*value = val;
return RET_OK;
......@@ -260,7 +260,7 @@ retvalue chunk_getextralinelist(const char *chunk,const char *name,struct strlis
char *v;
f = chunk_getfield(name,chunk);
if( !f )
if( f == NULL )
return RET_NOTHING;
r = strlist_init(strlist);
if( RET_WAS_ERROR(r) )
......@@ -274,19 +274,19 @@ retvalue chunk_getextralinelist(const char *chunk,const char *name,struct strlis
f++;
/* while lines begin with ' ' or '\t', add them */
while( *f == ' ' || *f == '\t' ) {
while( *f != '\0' && isblank(*f) )
while( *f != '\0' && xisblank(*f) )
f++;
b = f;
while( *f != '\0' && *f != '\n' )
f++;
e = f;
while( e > b && *e != '\0' && isspace(*e) )
while( e > b && *e != '\0' && xisspace(*e) )
e--;
if( !isspace(*e) )
if( !xisspace(*e) )
v = strndup(b,e-b+1);
else
v = strdup("");
if( !v ) {
if( v == NULL ) {
strlist_done(strlist);
return RET_ERROR_OOM;
}
......@@ -308,7 +308,7 @@ retvalue chunk_getwholedata(const char *chunk,const char *name,char **value) {
char *v;
f = chunk_getfield(name,chunk);
if( !f )
if( f == NULL )
return RET_NOTHING;
for ( e = p = f ; *p != '\0' ; p++ ) {
if( afternewline ) {
......@@ -338,14 +338,14 @@ retvalue chunk_getwordlist(const char *chunk,const char *name,struct strlist *st
char *v;
f = chunk_getfield(name,chunk);
if( !f )
if( f == NULL )
return RET_NOTHING;
r = strlist_init(strlist);
if( RET_WAS_ERROR(r) )
return r;
while( *f != '\0' ) {
/* walk over spaces */
while( *f != '\0' && isspace(*f) ) {
while( *f != '\0' && xisspace(*f) ) {
if( *f == '\n' ) {
f++;
if( *f != ' ' && *f != '\t' )
......@@ -357,10 +357,10 @@ retvalue chunk_getwordlist(const char *chunk,const char *name,struct strlist *st
return RET_OK;
b = f;
/* search for end of word */
while( *f != '\0' && !isspace(*f) )
while( *f != '\0' && !xisspace(*f) )
f++;
v = strndup(b,f-b);
if( !v ) {
if( v == NULL ) {
strlist_done(strlist);
return RET_ERROR_OOM;
}
......@@ -377,7 +377,7 @@ retvalue chunk_gettruth(const char *chunk,const char *name) {
const char *field;
field = chunk_getfield(name,chunk);
if( !field )
if( field == NULL )
return RET_NOTHING;
// TODO: check for things like Yes and No...
......@@ -388,7 +388,7 @@ retvalue chunk_checkfield(const char *chunk,const char *name){
const char *field;
field = chunk_getfield(name,chunk);
if( !field )
if( field == NULL )
return RET_NOTHING;
return RET_OK;
......@@ -400,18 +400,18 @@ retvalue chunk_getname(const char *chunk,const char *name,
const char *field,*name_end,*p;
field = chunk_getfield(name,chunk);