#include "dat.h"
#include "fns.h"
+char *whitespace = " \t\r\n";
+
void*
emalloc(int n)
{
return h;
}
-char*
-lookkey(Key *k, char *key)
+Key*
+getkey(Key *k, char *key)
{
while(k){
if(!cistrcmp(k->key, key))
- return k->val;
+ break;
k = k->next;
}
+ return k;
+}
+
+char*
+lookkey(Key *k, char *key)
+{
+ if(k = getkey(k, key))
+ return k->val;
return nil;
}
{
char *v;
+ if(*s == 0)
+ return nil;
v = strchr(s, 0)-1;
- while(v >= s && strchr("\n\r\t ", *v))
+ while(v >= s && strchr(whitespace, *v))
*v-- = 0;
if(v = strchr(s, ':')){
*v++ = 0;
- while(strchr("\t ", *v))
+ while(*v == ' ' || *v == '\t')
v++;
if(*s && *v)
return addkey(0, s, v);