rem: char *lhs,*rhs;  if(!(data = loadfile(file,&size))){ return NULL; } end = data+size;  while(data < end){ switch(state){ case stSKIPLINE: if(*data == '\n' || *data == '\r'){ state = stNEWLINE; } data++; break;  case stNEWLINE: if(*data == '\n' || *data == '\r'){ data++; break; } if(*data == '['){ lhs = data+1; state = stHEADER; data++; break; } if(*data == '#' || *data <= ' '){ state = stSKIPLINE; data++; break; } lhs = data; data++; state = stLHS; break; case stHEADER: if(*data == ']'){ cur = (section *) malloc(sizeof(section)); cur->name = lhs; cur->firstnv = NULL; cur->next = NULL; if(last){ last->next = cur; last = cur; } else { last = first = cur; } *data = 0; state = stSKIPLINE; } data++; break; case stLHS: if(*data == '\n' || *data == '\r'){ state = stNEWLINE; } if(*data == '='){ *data = 0; rhs = data+1; state = stRHS; } data++; continue; case stRHS: if(*data == '\n' || *data == '\r'){ nvpair *p = (nvpair *) malloc(sizeof(nvpair)); p->name = lhs; p->value = rhs; *data = 0; p->next = cur->firstnv; cur->firstnv = p; state = stNEWLINE; } data++; break; } } return first;
add: char *lhs, *rhs;  if (!(data = loadfile(file, &size))) return NULL;  end = data+size;  while (data < end) { switch (state) { case stSKIPLINE: if (*data == '\n' || *data == '\r') state = stNEWLINE;  data++; break;  case stNEWLINE: if (*data == '\n' || *data == '\r') { data++; break; }  if (*data == '[') { lhs = data+1; state = stHEADER; data++; break; }  if (*data == '#' || *data <= ' ') { state = stSKIPLINE; data++; break; } lhs = data; data++; state = stLHS; break; case stHEADER: if (*data == ']') { cur = (section *) malloc(sizeof(section)); cur->name = lhs; cur->firstnv = NULL; cur->next = NULL; if (last) { last->next = cur; last = cur; } else { last = first = cur; } *data = 0; state = stSKIPLINE; } data++; break; case stLHS: if (*data == '\n' || *data == '\r') state = stNEWLINE;  if (*data == '=') { *data = 0; rhs = data+1; state = stRHS; } data++; continue; case stRHS: if (*data == '\n' || *data == '\r') { nvpair *p = (nvpair *)malloc(sizeof(nvpair)); p->name = lhs; p->value = rhs; *data = 0; p->next = cur->firstnv; cur->firstnv = p; state = stNEWLINE; } data++; break; } } return first;
context: section *load_ini(char *file){    char *data,*end;    int size;    int state = stNEWLINE;	section *cur;	    char *lhs,*rhs;        if(!(data = loadfile(file,&size))){        return NULL;    }    end = data+size;        while(data < end){        switch(state){        case stSKIPLINE:            if(*data == '\n' || *data == '\r'){                state = stNEWLINE;            }            data++;            break;                    case stNEWLINE:            if(*data == '\n' || *data == '\r'){                data++;                break;            }            if(*data == '['){                lhs = data+1;                state = stHEADER;                data++;                break;            }            if(*data == '#' || *data <= ' '){                state = stSKIPLINE;                data++;                break;            }            lhs = data;            data++;            state = stLHS;            break;        case stHEADER:                    if(*data == ']'){                                cur = (section *) malloc(sizeof(section));                cur->name = lhs;                cur->firstnv = NULL;                cur->next = NULL;                if(last){                    last->next = cur;                    last = cur;                } else {                    last = first = cur;                }                *data = 0;                state = stSKIPLINE;            }            data++;            break;        case stLHS:            if(*data == '\n' || *data == '\r'){                state = stNEWLINE;            }            if(*data == '='){                *data = 0;                rhs = data+1;                state = stRHS;            }            data++;            continue;        case stRHS:            if(*data == '\n' || *data == '\r'){                nvpair *p = (nvpair *) malloc(sizeof(nvpair));                p->name = lhs;                p->value = rhs;                *data = 0;                p->next = cur->firstnv;                cur->firstnv = p;                state = stNEWLINE;            }            data++;            break;        }    }    return first;    }