Jan Breuer
2015-04-14 781ef98e5441bf6aa12c50657bf2161953a79858
libscpi/src/parser.c
@@ -75,7 +75,7 @@
 */
static size_t writeDelimiter(scpi_t * context) {
    if (context->output_count > 0) {
        return writeData(context, ",", 2);
        return writeData(context, ",", 1);
    } else {
        return 0;
    }
@@ -258,15 +258,16 @@
        while (1) {
            cmdlen = scpiParser_detectProgramMessageUnit(&context->parser_state, context->buffer.data + totcmdlen, context->buffer.position - totcmdlen);
            totcmdlen += cmdlen;
            if (context->parser_state.termination == SCPI_MESSAGE_TERMINATION_NL) break;
            if (context->parser_state.programHeader.type == SCPI_TOKEN_UNKNOWN) break;
            if (totcmdlen >= context->buffer.position) break;
        }
        if (context->parser_state.termination == SCPI_MESSAGE_TERMINATION_NL) {
            result = SCPI_Parse(context, context->buffer.data, totcmdlen);
            memmove(context->buffer.data, context->buffer.data + totcmdlen, context->buffer.position - totcmdlen);
            context->buffer.position -= totcmdlen;
            if (context->parser_state.termination == SCPI_MESSAGE_TERMINATION_NL) {
                result = SCPI_Parse(context, context->buffer.data, totcmdlen);
                memmove(context->buffer.data, context->buffer.data + totcmdlen, context->buffer.position - totcmdlen);
                context->buffer.position -= totcmdlen;
                totcmdlen = 0;
            } else {
                if (context->parser_state.programHeader.type == SCPI_TOKEN_UNKNOWN) break;
                if (totcmdlen >= context->buffer.position) break;
            }
        }
    }