if (c == '\r' || c == '\n') {
if (c == '\r' || c == '\n' || c == 0x1A) {
PREF_ParseBuf(PrefParseState *ps, const char *buf, int bufLen){    const char *end;    char c;    int state;    state = ps->state;    for (end = buf + bufLen; buf != end; ++buf) {        c = *buf;        switch (state) {        /* initial state */        case PREF_PARSE_INIT:            if (ps->lbcur != ps->lb) { /* reset state */                ps->lbcur = ps->lb;                ps->vb    = NULL;                ps->vtype = PREF_INVALID;                ps->fuser = PR_FALSE;            }            switch (c) {            case '/':       /* begin comment block or line? */                state = PREF_PARSE_COMMENT_MAYBE_START;                break;            case '#':       /* accept shell style comments */                state = PREF_PARSE_UNTIL_EOL;                break;            case 'u':       /* indicating user_pref */            case 'p':       /* indicating pref */                ps->smatch = (c == 'u' ? kUserPref : kPref);                ps->sindex = 1;                ps->nextstate = PREF_PARSE_UNTIL_OPEN_PAREN;                state = PREF_PARSE_MATCH_STRING;                break;            /* else skip char */            }            break;        /* string matching */        case PREF_PARSE_MATCH_STRING:            if (c == ps->smatch[ps->sindex++]) {                /* if we've matched all characters, then move to next state. */                if (ps->smatch[ps->sindex] == '\0') {                    state = ps->nextstate;                    ps->nextstate = PREF_PARSE_INIT; /* reset next state */                }                /* else wait for next char */            }            else {                NS_WARNING("malformed pref file");                return PR_FALSE;            }            break;        /* name parsing */        case PREF_PARSE_UNTIL_NAME:            if (c == '\"') {                ps->fuser = (ps->smatch == kUserPref);                state = PREF_PARSE_NAME;            }            else if (c == '/') {       /* allow embedded comment */                ps->nextstate = state; /* return here when done with comment */                state = PREF_PARSE_COMMENT_MAYBE_START;            }            else if (!isspace(c)) {                NS_WARNING("malformed pref file");                return PR_FALSE;            }            break;        case PREF_PARSE_NAME:            if (ps->lbcur == ps->lbend && !pref_GrowBuf(ps))                return PR_FALSE; /* out of memory */            if (c == '\"') {                *ps->lbcur++ = '\0';                state = PREF_PARSE_UNTIL_COMMA;            }            else                *ps->lbcur++ = c;            break;        /* parse until we find a comma separating name and value */        case PREF_PARSE_UNTIL_COMMA:            if (c == ',') {                ps->vb = ps->lbcur;                state = PREF_PARSE_UNTIL_VALUE;            }            else if (c == '/') {       /* allow embedded comment */                ps->nextstate = state; /* return here when done with comment */                state = PREF_PARSE_COMMENT_MAYBE_START;            }            else if (!isspace(c)) {                NS_WARNING("malformed pref file");                return PR_FALSE;            }            break;        /* value parsing */        case PREF_PARSE_UNTIL_VALUE:            /* the pref value type is unknown.  so, we scan for the first             * character of the value, and determine the type from that. */            if (c == '\"') {                ps->vtype = PREF_STRING;                state = PREF_PARSE_STRING_VALUE;            }            else if (c == 't' || c == 'f') {                ps->vb = (char *) (c == 't' ? kTrue : kFalse);                ps->vtype = PREF_BOOL;                ps->smatch = ps->vb;                ps->sindex = 1;                ps->nextstate = PREF_PARSE_UNTIL_CLOSE_PAREN;                state = PREF_PARSE_MATCH_STRING;            }            else if (isdigit(c) || (c == '-') || (c == '+')) {                ps->vtype = PREF_INT;                /* write c to line buffer... */                if (ps->lbcur == ps->lbend && !pref_GrowBuf(ps))                    return PR_FALSE; /* out of memory */                *ps->lbcur++ = c;                state = PREF_PARSE_INT_VALUE;            }            else if (c == '/') {       /* allow embedded comment */                ps->nextstate = state; /* return here when done with comment */                state = PREF_PARSE_COMMENT_MAYBE_START;            }            else if (!isspace(c)) {                NS_WARNING("malformed pref file");                return PR_FALSE;            }            break;        case PREF_PARSE_STRING_VALUE:            /* grow line buffer if necessary... */            if (ps->lbcur == ps->lbend && !pref_GrowBuf(ps))                return PR_FALSE; /* out of memory */            /* skip char if start of escape sequence.  handle escaped             * characters using a separate state. */            if (c == '\\')                state = PREF_PARSE_ESC_STRING_VALUE;            else if (c != '\"')                *ps->lbcur++ = c;            else {                 *ps->lbcur++ = '\0';                state = PREF_PARSE_UNTIL_CLOSE_PAREN;            }            break;        case PREF_PARSE_ESC_STRING_VALUE:            /* not necessary to resize buffer here since we are only             * writing one character and the resize check would have             * been done for us in the PREF_PARSE_STRING_VALUE state. */            switch (c) {            case '\"':            case '\\':                break;            case 'r':                c = '\r';                break;            case 'n':                c = '\n';                break;            default:                NS_WARNING("preserving unexpected JS escape sequence");                *ps->lbcur++ = '\\'; /* preserve the escape sequence */                break;            }            *ps->lbcur++ = c;            state = PREF_PARSE_STRING_VALUE;            break;        case PREF_PARSE_INT_VALUE:            /* grow line buffer if necessary... */            if (ps->lbcur == ps->lbend && !pref_GrowBuf(ps))                return PR_FALSE; /* out of memory */            if (isdigit(c))                *ps->lbcur++ = c;            else {                *ps->lbcur++ = '\0'; /* stomp null terminator; we are done. */                if (c == ')')                    state = PREF_PARSE_UNTIL_SEMICOLON;                else if (c == '/') { /* allow embedded comment */                    ps->nextstate = PREF_PARSE_UNTIL_CLOSE_PAREN;                    state = PREF_PARSE_COMMENT_MAYBE_START;                }                else if (isspace(c))                    state = PREF_PARSE_UNTIL_CLOSE_PAREN;                else {                    NS_WARNING("malformed pref file");                    return PR_FALSE;                }            }            break;        /* comment parsing */        case PREF_PARSE_COMMENT_MAYBE_START:            switch (c) {            case '*': /* comment block */                state = PREF_PARSE_COMMENT_BLOCK;                break;            case '/': /* comment line */                state = PREF_PARSE_UNTIL_EOL;                break;            default:                /* pref file is malformed */                NS_WARNING("malformed pref file");                return PR_FALSE;            }            break;        case PREF_PARSE_COMMENT_BLOCK:            if (c == '*')                 state = PREF_PARSE_COMMENT_BLOCK_MAYBE_END;            break;        case PREF_PARSE_COMMENT_BLOCK_MAYBE_END:            switch (c) {            case '/':                state = ps->nextstate;                ps->nextstate = PREF_PARSE_INIT;                break;            case '*':       /* stay in this state */                break;            default:                state = PREF_PARSE_COMMENT_BLOCK;            }            break;        /* function open and close parsing */        case PREF_PARSE_UNTIL_OPEN_PAREN:            /* tolerate only whitespace and embedded comments */            if (c == '(')                state = PREF_PARSE_UNTIL_NAME;            else if (c == '/') {                ps->nextstate = state; /* return here when done with comment */                state = PREF_PARSE_COMMENT_MAYBE_START;            }            else if (!isspace(c)) {                NS_WARNING("malformed pref file");                return PR_FALSE;            }            break;        case PREF_PARSE_UNTIL_CLOSE_PAREN:            /* tolerate only whitespace and embedded comments  */            if (c == ')')                state = PREF_PARSE_UNTIL_SEMICOLON;            else if (c == '/') {                ps->nextstate = state; /* return here when done with comment */                state = PREF_PARSE_COMMENT_MAYBE_START;            }            else if (!isspace(c)) {                NS_WARNING("malformed pref file");                return PR_FALSE;            }            break;        /* function terminator ';' parsing */        case PREF_PARSE_UNTIL_SEMICOLON:            /* tolerate only whitespace and embedded comments */            if (c == ';') {                if (!pref_DoCallback(ps))                    return PR_FALSE;                state = PREF_PARSE_INIT;            }            else if (c == '/') {                ps->nextstate = state; /* return here when done with comment */                state = PREF_PARSE_COMMENT_MAYBE_START;            }            else if (!isspace(c)) {                NS_WARNING("malformed pref file");                return PR_FALSE;            }            break;        /* eol parsing */        case PREF_PARSE_UNTIL_EOL:            /* need to handle mac, unix, or dos line endings.             * PREF_PARSE_INIT will eat the next \n in case             * we have \r\n. */            if (c == '\r' || c == '\n') {                state = ps->nextstate;                ps->nextstate = PREF_PARSE_INIT; /* reset next state */            }            break;        }    }    ps->state = state;    return PR_TRUE;}