static void skipToNonemptyLine(TConn * const connectionP, time_t const deadline, bool * const errorP) { char * const bufferStart = connectionP->buffer.t + connectionP->bufferpos; bool gotNonEmptyLine; bool error; char * lineStart; lineStart = bufferStart; /* initial value */ gotNonEmptyLine = FALSE; /* initial value */ error = FALSE; /* initial value */ while (!gotNonEmptyLine && !error) { char * lineEnd; getLineInBuffer(connectionP, lineStart, deadline, &lineEnd, &error); if (!error) { if (!isEmptyLine(lineStart)) gotNonEmptyLine = TRUE; else lineStart = lineEnd; } } if (!error) { /* Consume all the empty lines; advance buffer pointer to first non-empty line. */ connectionP->bufferpos = lineStart - connectionP->buffer.t; } *errorP = error; }
static int scriptinternalstep(int fromIp) //internal step routine { int maxIp = (int)linemap.size(); //maximum ip if(fromIp >= maxIp) //script end return fromIp; while(isEmptyLine(linemap.at(fromIp).type) && fromIp < maxIp) //skip empty lines fromIp++; fromIp++; return fromIp; }
static void readHeader(TConn * const connectionP, time_t const deadline, bool * const endOfHeadersP, char ** const headerP, bool * const errorP) { /*---------------------------------------------------------------------------- Read an HTTP header, or the end of headers empty line, on connection *connectionP. An HTTP header is basically a line, except that if a line starts with white space, it's a continuation of the previous line. A line is delimited by either LF or CRLF. The first line of an HTTP header is never empty; an empty line signals the end of the HTTP headers and beginning of the HTTP body. We call that empty line the EOH mark. We assume the connection is positioned to a header or EOH mark. In the course of reading, we read at least one character past the line delimiter at the end of the header or EOH mark; we may read much more. But we leave everything after the header or EOH (and its line delimiter) in the internal buffer, with the buffer pointer pointing to it. We use stuff already in the internal buffer (perhaps left by a previous call to this subroutine) before reading any more from from the channel. We return as *headerP the next header as an ASCIIZ string, with no line delimiter. That string is stored in the "unused" portion of the connection's internal buffer. Iff there is no next header, we return *endOfHeadersP == true and nothing meaningful as *headerP. -----------------------------------------------------------------------------*/ char * const bufferStart = connectionP->buffer.t + connectionP->bufferpos; bool error; char * lineEnd; getLineInBuffer(connectionP, bufferStart, deadline, &lineEnd, &error); if (!error) { if (isContinuationLine(bufferStart)) error = TRUE; else if (isEmptyLine(bufferStart)) { /* Consume the EOH mark from the buffer */ connectionP->bufferpos = lineEnd - connectionP->buffer.t; *endOfHeadersP = TRUE; } else { /* We have the first line of a header; there may be more. */ const char * headerEnd; *endOfHeadersP = FALSE; getRestOfHeader(connectionP, lineEnd, deadline, &headerEnd, &error); if (!error) { *headerP = bufferStart; /* Consume the header from the buffer (but be careful -- you can't reuse that part of the buffer because the string we will return is in it! */ connectionP->bufferpos = headerEnd - connectionP->buffer.t; } } } *errorP = error; }
/** * Parses the content, provided by the Preprocessor object and * creates a new Makefile object. */ void Parser::apply(Preprocessor* pp, Makefile* mkfile, const QStringList& activeTargets) { m_makefile = mkfile; m_activeTargets = activeTargets; m_preprocessor = pp; const Options* options = mkfile->options(); m_silentCommands = options->suppressOutputMessages; m_ignoreExitCodes = !options->stopOnErrors; m_suffixes.clear(); m_suffixes << QLatin1String(".exe") << QLatin1String(".obj") << QLatin1String(".asm") << QLatin1String(".c") << QLatin1String(".cpp") << QLatin1String(".cxx") << QLatin1String(".bas") << QLatin1String(".cbl") << QLatin1String(".for") << QLatin1String(".pas") << QLatin1String(".res") << QLatin1String(".rc"); m_syncPoints.clear(); m_ruleIdxByToExtension.clear(); int dbSeparatorPos, dbSeparatorLength, dbCommandSeparatorPos; try { readLine(); while (!m_line.isNull()) { QString expandedLine = m_preprocessor->macroTable()->expandMacros(m_line); if (isEmptyLine(expandedLine)) { readLine(); } else if (isDotDirective(expandedLine)) { m_line = expandedLine; Preprocessor::removeInlineComments(m_line); parseDotDirective(); } else if (isInferenceRule(expandedLine)) { m_line = expandedLine; Preprocessor::removeInlineComments(m_line); parseInferenceRule(); } else if (isDescriptionBlock(dbSeparatorPos, dbSeparatorLength, dbCommandSeparatorPos)) { parseDescriptionBlock(dbSeparatorPos, dbSeparatorLength, dbCommandSeparatorPos); } else { error(QLatin1String("syntax error")); } } } catch (FileException&) { throw; } catch (Exception &e) { // Enrich the error message with filename and line number. error(e.message()); } // if the makefile doesn't contain target, we can stop here if (m_makefile->targets().isEmpty()) return; // make sure that all active targets exist foreach (const QString& targetName, m_activeTargets) { if (!m_makefile->target(targetName)) { QString msg = QLatin1String("Target %1 doesn't exist."); throw Exception(msg.arg(targetName)); } } // if no active target is defined, use the first one if (m_activeTargets.isEmpty()) { m_activeTargets.append(m_makefile->firstTarget()->targetName()); } m_makefile->calculateInferenceRulePriorities(m_suffixes); // translate sync points from .SYNC targets into real dependencies for (QHash<QString, QStringList>::const_iterator it = m_syncPoints.constBegin(); it != m_syncPoints.constEnd(); ++it) { DescriptionBlock *target = m_makefile->target(it.key()); if (!target) break; target->m_dependents += it.value(); target->m_dependents.removeDuplicates(); } // build rule suffix cache for (int i = m_makefile->inferenceRules().count(); --i >= 0;) { InferenceRule *ir = m_makefile->inferenceRules().at(i); m_ruleIdxByToExtension[ir->m_toExtension].prepend(ir); } // check for cycles in active targets foreach (const QString& targetName, m_activeTargets) { DescriptionBlock *target = m_makefile->target(targetName); checkForCycles(target); preselectInferenceRules(target); }