text:
package org.apache.coyote.http11;

import java.io.EOFException;
import java.io.IOException;
import java.nio.channels.Selector;
import java.nio.charset.Charset;

import org.apache.coyote.InputBuffer;
import org.apache.coyote.Request;
import org.apache.tomcat.util.buf.ByteChunk;
import org.apache.tomcat.util.buf.MessageBytes;
import org.apache.tomcat.util.http.parser.HttpParser;
import org.apache.tomcat.util.net.AbstractEndpoint;
import org.apache.tomcat.util.net.NioChannel;
import org.apache.tomcat.util.net.NioEndpoint;
import org.apache.tomcat.util.net.NioSelectorPool;
import org.apache.tomcat.util.net.SocketWrapper;

/**
 * Implementation of InputBuffer which provides HTTP request header parsing as
 * well as transfer decoding.
 *
 * @author Remy Maucherat
 * @author Filip Hanik
 */
public class InternalNioInputBuffer extends AbstractInputBuffer<NioChannel> {

    private static final org.apache.juli.logging.Log log =
        org.apache.juli.logging.LogFactory.getLog(InternalNioInputBuffer.class);

    private static final Charset DEFAULT_CHARSET =
        Charset.forName("ISO-8859-1");

    // -------------------------------------------------------------- Constants

    enum HeaderParseStatus {
        DONE, HAVE_MORE_HEADERS, NEED_MORE_DATA
    }

    enum HeaderParsePosition {
        /**
         * Start of a new header. A CRLF here means that there are no more
         * headers. Any other character starts a header name.
         */
        HEADER_START,
        /**
         * Reading a header name. All characters of header are HTTP_TOKEN_CHAR.
         * Header name is followed by ':'. No whitespace is allowed.

         * Any non-HTTP_TOKEN_CHAR (this includes any whitespace) encountered
         * before ':' will result in the whole line being ignored.
         */
        HEADER_NAME,
        /**
         * Skipping whitespace before text of header value starts, either on the
         * first line of header value (just after ':') or on subsequent lines
         * when it is known that subsequent line starts with SP or HT.
         */
        HEADER_VALUE_START,
        /**
         * Reading the header value. We are inside the value. Either on the
         * first line or on any subsequent line. We come into this state from
         * HEADER_VALUE_START after the first non-SP/non-HT byte is encountered
         * on the line.
         */
        HEADER_VALUE,
        /**
         * Before reading a new line of a header. Once the next byte is peeked,
         * the state changes without advancing our position. The state becomes
         * either HEADER_VALUE_START (if that first byte is SP or HT), or
         * HEADER_START (otherwise).
         */
        HEADER_MULTI_LINE,
        /**
         * Reading all bytes until the next CRLF. The line is being ignored.
         */
        HEADER_SKIPLINE
    }

    // ----------------------------------------------------------- Constructors

    /**
     * Alternate constructor.
     */
    public InternalNioInputBuffer(Request request, int headerBufferSize,
            boolean rejectIllegalHeaderName) {

        this.request = request;
        headers = request.getMimeHeaders();

        this.headerBufferSize = headerBufferSize;
        this.rejectIllegalHeaderName = rejectIllegalHeaderName;

        inputStreamInputBuffer = new SocketInputBuffer();

        filterLibrary = new InputFilter[0];
        activeFilters = new InputFilter[0];
        lastActiveFilter = -1;

        parsingHeader = true;
        parsingRequestLine = true;
        parsingRequestLinePhase = 0;
        parsingRequestLineEol = false;
        parsingRequestLineStart = 0;
        parsingRequestLineQPos = -1;
        headerParsePos = HeaderParsePosition.HEADER_START;
        headerData.recycle();
        swallowInput = true;

    }

    /**
     * Parsing state - used for non blocking parsing so that
     * when more data arrives, we can pick up where we left off.
     */
    private boolean parsingRequestLine;
    private int parsingRequestLinePhase = 0;
    private boolean parsingRequestLineEol = false;
    private int parsingRequestLineStart = 0;
    private int parsingRequestLineQPos = -1;
    private HeaderParsePosition headerParsePos;

    /**
     * Underlying socket.
     */
    private NioChannel socket;

    /**
     * Selector pool, for blocking reads and blocking writes
     */
    private NioSelectorPool pool;

    /**
     * Maximum allowed size of the HTTP request line plus headers plus any
     * leading blank lines.
     */
    private final int headerBufferSize;

    /**
     * Known size of the NioChannel read buffer.
     */
    private int socketReadBufferSize;

    // --------------------------------------------------------- Public Methods

    /**
     * Recycle the input buffer. This should be called when closing the
     * connection.
     */
    @Override
    public void recycle() {
        super.recycle();
        socket = null;
        headerParsePos = HeaderParsePosition.HEADER_START;
        parsingRequestLine = true;
        parsingRequestLinePhase = 0;
        parsingRequestLineEol = false;
        parsingRequestLineStart = 0;
        parsingRequestLineQPos = -1;
        headerData.recycle();
    }

    /**
     * End processing of current HTTP request.
     * Note: All bytes of the current request should have been already
     * consumed. This method only resets all the pointers so that we are ready
     * to parse the next HTTP request.
     */
    @Override
    public void nextRequest() {
        super.nextRequest();
        headerParsePos = HeaderParsePosition.HEADER_START;
        parsingRequestLine = true;
        parsingRequestLinePhase = 0;
        parsingRequestLineEol = false;
        parsingRequestLineStart = 0;
        parsingRequestLineQPos = -1;
        headerData.recycle();
    }

    /**
     * Read the request line. This function is meant to be used during the
     * HTTP request header parsing. Do NOT attempt to read the request body
     * using it.
     *
     * @throws IOException If an exception occurs during the underlying socket
     * read operations, or if the given buffer is not big enough to accommodate
     * the whole line.
     * @return true if data is properly fed; false if no data is available
     * immediately and thread should be freed
     */
    @Override
    public boolean parseRequestLine(boolean useAvailableDataOnly)
        throws IOException {

        //check state
        if ( !parsingRequestLine ) return true;
        //
        // Skipping blank lines
        //
        if ( parsingRequestLinePhase == 0 ) {
            byte chr = 0;
            do {

                // Read new bytes if needed
                if (pos >= lastValid) {
                    if (useAvailableDataOnly) {
                        return false;
                    }
                    // Do a simple read with a short timeout
                    if (!fill(true, false)) {
                        return false;
                    }
                }
                // Set the start time once we start reading data (even if it is
                // just skipping blank lines)
                if (request.getStartTime() < 0) {
                    request.setStartTime(System.currentTimeMillis());
                }
                chr = buf[pos++];
            } while ((chr == Constants.CR) || (chr == Constants.LF));
            pos--;

            parsingRequestLineStart = pos;
            parsingRequestLinePhase = 2;
            if (log.isDebugEnabled()) {
                log.debug("Received ["
                        + new String(buf, pos, lastValid - pos, DEFAULT_CHARSET)
                        + "]");
            }
        }
        if ( parsingRequestLinePhase == 2 ) {
            //
            // Reading the method name
            // Method name is a token
            //
            boolean space = false;
            while (!space) {
                // Read new bytes if needed
                if (pos >= lastValid) {
                    if (!fill(true, false)) //request line parsing
                        return false;
                }
                // Spec says method name is a token followed by a single SP but
                // also be tolerant of multiple SP and/or HT.
                if (buf[pos] == Constants.SP || buf[pos] == Constants.HT) {
                    space = true;
                    request.method().setBytes(buf, parsingRequestLineStart, pos - parsingRequestLineStart);
                } else if (!HttpParser.isToken(buf[pos])) {
                    throw new IllegalArgumentException(sm.getString("iib.invalidmethod"));
                }
                pos++;
            }
            parsingRequestLinePhase = 3;
        }
        if ( parsingRequestLinePhase == 3 ) {
            // Spec says single SP but also be tolerant of multiple SP and/or HT
            boolean space = true;
            while (space) {
                // Read new bytes if needed
                if (pos >= lastValid) {
                    if (!fill(true, false)) //request line parsing
                        return false;
                }
                if (buf[pos] == Constants.SP || buf[pos] == Constants.HT) {
                    pos++;
                } else {
                    space = false;
                }
            }
            parsingRequestLineStart = pos;
            parsingRequestLinePhase = 4;
        }
        if (parsingRequestLinePhase == 4) {
            // Mark the current buffer position

            int end = 0;
            //
            // Reading the URI
            //
            boolean space = false;
            while (!space) {
                // Read new bytes if needed
                if (pos >= lastValid) {
                    if (!fill(true,false)) //request line parsing
                        return false;
                }
                if (buf[pos] == Constants.SP || buf[pos] == Constants.HT) {
                    space = true;
                    end = pos;
                } else if ((buf[pos] == Constants.CR)
                           || (buf[pos] == Constants.LF)) {
                    // HTTP/0.9 style request
                    parsingRequestLineEol = true;
                    space = true;
                    end = pos;
                } else if ((buf[pos] == Constants.QUESTION) && (parsingRequestLineQPos == -1)) {
                    parsingRequestLineQPos = pos;
                } else if (HttpParser.isNotRequestTarget(buf[pos])) {
                    throw new IllegalArgumentException(sm.getString("iib.invalidRequestTarget"));
                }
                pos++;
            }
            request.unparsedURI().setBytes(buf, parsingRequestLineStart, end - parsingRequestLineStart);
            if (parsingRequestLineQPos >= 0) {
                request.queryString().setBytes(buf, parsingRequestLineQPos + 1,
                                               end - parsingRequestLineQPos - 1);
                request.requestURI().setBytes(buf, parsingRequestLineStart, parsingRequestLineQPos - parsingRequestLineStart);
            } else {
                request.requestURI().setBytes(buf, parsingRequestLineStart, end - parsingRequestLineStart);
            }
            parsingRequestLinePhase = 5;
        }
        if ( parsingRequestLinePhase == 5 ) {
            // Spec says single SP but also be tolerant of multiple and/or HT
            boolean space = true;
            while (space) {
                // Read new bytes if needed
                if (pos >= lastValid) {
                    if (!fill(true, false)) //request line parsing
                        return false;
                }
                if (buf[pos] == Constants.SP || buf[pos] == Constants.HT) {
                    pos++;
                } else {
                    space = false;
                }
            }
            parsingRequestLineStart = pos;
            parsingRequestLinePhase = 6;

            // Mark the current buffer position
            end = 0;
        }
        if (parsingRequestLinePhase == 6) {
            //
            // Reading the protocol
            // Protocol is always "HTTP/" DIGIT "." DIGIT
            //
            while (!parsingRequestLineEol) {
                // Read new bytes if needed
                if (pos >= lastValid) {
                    if (!fill(true, false)) //request line parsing
                        return false;
                }

                if (buf[pos] == Constants.CR) {
                    end = pos;
                } else if (buf[pos] == Constants.LF) {
                    if (end == 0)
                        end = pos;
                    parsingRequestLineEol = true;
                } else if (!HttpParser.isHttpProtocol(buf[pos])) {
                    throw new IllegalArgumentException(sm.getString("iib.invalidHttpProtocol"));
                }
                pos++;
            }

            if ( (end - parsingRequestLineStart) > 0) {
                request.protocol().setBytes(buf, parsingRequestLineStart, end - parsingRequestLineStart);
            } else {
                request.protocol().setString("");
            }
            parsingRequestLine = false;
            parsingRequestLinePhase = 0;
            parsingRequestLineEol = false;
            parsingRequestLineStart = 0;
            return true;
        }
        throw new IllegalStateException("Invalid request line parse phase:"+parsingRequestLinePhase);
    }

    private void expand(int newsize) {
        if ( newsize > buf.length ) {
            if (parsingHeader) {
                throw new IllegalArgumentException(
                        sm.getString("iib.requestheadertoolarge.error"));
            }
            // Should not happen
            log.warn("Expanding buffer size. Old size: " + buf.length
                    + ", new size: " + newsize, new Exception());
            byte[] tmp = new byte[newsize];
            System.arraycopy(buf,0,tmp,0,buf.length);
            buf = tmp;
        }
    }

    /**
     * Perform blocking read with a timeout if desired
     * @param timeout boolean - if we want to use the timeout data
     * @param block - true if the system should perform a blocking read, false otherwise
     * @return boolean - true if data was read, false is no data read, EOFException if EOF is reached
     * @throws IOException if a socket exception occurs
     * @throws EOFException if end of stream is reached
     */

    private int readSocket(boolean timeout, boolean block) throws IOException {
        int nRead = 0;
        socket.getBufHandler().getReadBuffer().clear();
        if ( block ) {
            Selector selector = null;
            try {
                selector = pool.get();
            } catch ( IOException x ) {
                // Ignore
            }
            try {
                NioEndpoint.KeyAttachment att =
                        (NioEndpoint.KeyAttachment) socket.getAttachment();
                if (att == null) {
                    throw new IOException("Key must be cancelled.");
                }
                nRead = pool.read(socket.getBufHandler().getReadBuffer(),
                        socket, selector, att.getTimeout());
            } catch ( EOFException eof ) {
                nRead = -1;
            } finally {
                if ( selector != null ) pool.put(selector);
            }
        } else {
            nRead = socket.read(socket.getBufHandler().getReadBuffer());
        }
        if (nRead > 0) {
            socket.getBufHandler().getReadBuffer().flip();
            socket.getBufHandler().getReadBuffer().limit(nRead);
            expand(nRead + pos);
            socket.getBufHandler().getReadBuffer().get(buf, pos, nRead);
            lastValid = pos + nRead;
            return nRead;
        } else if (nRead == -1) {
            //return false;
            throw new EOFException(sm.getString("iib.eof.error"));
        } else {
            return 0;
        }
    }

    /**
     * Parse the HTTP headers.
     */
    @Override
    public boolean parseHeaders()
        throws IOException {
        if (!parsingHeader) {
            throw new IllegalStateException(
                    sm.getString("iib.parseheaders.ise.error"));
        }

        HeaderParseStatus status = HeaderParseStatus.HAVE_MORE_HEADERS;

        do {
            status = parseHeader();
            // Checking that
            // (1) Headers plus request line size does not exceed its limit
            // (2) There are enough bytes to avoid expanding the buffer when
            // reading body
            // Technically, (2) is technical limitation, (1) is logical
            // limitation to enforce the meaning of headerBufferSize
            // From the way how buf is allocated and how blank lines are being
            // read, it should be enough to check (1) only.
            if (pos > headerBufferSize
                    || buf.length - pos < socketReadBufferSize) {
                throw new IllegalArgumentException(
                        sm.getString("iib.requestheadertoolarge.error"));
            }
        } while ( status == HeaderParseStatus.HAVE_MORE_HEADERS );
        if (status == HeaderParseStatus.DONE) {
            parsingHeader = false;
            end = pos;
            return true;
        } else {
            return false;
        }
    }

    /**
     * Parse an HTTP header.
     *
     * @return false after reading a blank line (which indicates that the
     * HTTP header parsing is done
     */
    private HeaderParseStatus parseHeader()
        throws IOException {

        //
        // Check for blank line
        //

        byte chr = 0;
        while (headerParsePos == HeaderParsePosition.HEADER_START) {

            // Read new bytes if needed
            if (pos >= lastValid) {
                if (!fill(true,false)) {//parse header
                    headerParsePos = HeaderParsePosition.HEADER_START;
                    return HeaderParseStatus.NEED_MORE_DATA;
                }
            }

            chr = buf[pos];

            if (chr == Constants.CR) {
                // Skip
            } else if (chr == Constants.LF) {
                pos++;
                return HeaderParseStatus.DONE;
            } else {
                break;
            }

            pos++;

        }

        if ( headerParsePos == HeaderParsePosition.HEADER_START ) {
            // Mark the current buffer position
            headerData.start = pos;
            headerParsePos = HeaderParsePosition.HEADER_NAME;
        }

        //
        // Reading the header name
        // Header name is always US-ASCII
        //

        while (headerParsePos == HeaderParsePosition.HEADER_NAME) {

            // Read new bytes if needed
            if (pos >= lastValid) {
                if (!fill(true,false)) { //parse header
                    return HeaderParseStatus.NEED_MORE_DATA;
                }
            }

            chr = buf[pos];
            if (chr == Constants.COLON) {
                headerParsePos = HeaderParsePosition.HEADER_VALUE_START;
                headerData.headerValue = headers.addValue(buf, headerData.start, pos - headerData.start);
                pos++;
                // Mark the current buffer position
                headerData.start = pos;
                headerData.realPos = pos;
                headerData.lastSignificantChar = pos;
                break;
            } else if (!HttpParser.isToken(chr)) {
                // Non-token characters are illegal in header names
                // Parsing continues so the error can be reported in context
                headerData.lastSignificantChar = pos;
                // skipLine() will handle the error
                return skipLine();
            }

            // chr is next byte of header name. Convert to lowercase.
            if ((chr >= Constants.A) && (chr <= Constants.Z)) {
                buf[pos] = (byte) (chr - Constants.LC_OFFSET);
            }
            pos++;
        }

        // Skip the line and ignore the header
        if (headerParsePos == HeaderParsePosition.HEADER_SKIPLINE) {
            return skipLine();
        }

        //
        // Reading the header value (which can be spanned over multiple lines)
        //

        while (headerParsePos == HeaderParsePosition.HEADER_VALUE_START ||
               headerParsePos == HeaderParsePosition.HEADER_VALUE ||
               headerParsePos == HeaderParsePosition.HEADER_MULTI_LINE) {

            if ( headerParsePos == HeaderParsePosition.HEADER_VALUE_START ) {
                // Skipping spaces
                while (true) {
                    // Read new bytes if needed
                    if (pos >= lastValid) {
                        if (!fill(true,false)) {//parse header
                            //HEADER_VALUE_START
                            return HeaderParseStatus.NEED_MORE_DATA;
                        }
                    }

                    chr = buf[pos];
                    if (chr == Constants.SP || chr == Constants.HT) {
                        pos++;
                    } else {
                        headerParsePos = HeaderParsePosition.HEADER_VALUE;
                        break;
                    }
                }
            }
            if ( headerParsePos == HeaderParsePosition.HEADER_VALUE ) {

                // Reading bytes until the end of the line
                boolean eol = false;
                while (!eol) {

                    // Read new bytes if needed
                    if (pos >= lastValid) {
                        if (!fill(true,false)) {//parse header
                            //HEADER_VALUE
                            return HeaderParseStatus.NEED_MORE_DATA;
                        }
                    }

                    chr = buf[pos];
                    if (chr == Constants.CR) {
                        // Skip
                    } else if (chr == Constants.LF) {
                        eol = true;
                    } else if (chr == Constants.SP || chr == Constants.HT) {
                        buf[headerData.realPos] = chr;
                        headerData.realPos++;
                    } else {
                        buf[headerData.realPos] = chr;
                        headerData.realPos++;
                        headerData.lastSignificantChar = headerData.realPos;
                    }

                    pos++;
                }

                // Ignore whitespaces at the end of the line
                headerData.realPos = headerData.lastSignificantChar;

                // Checking the first character of the new line. If the character
                // is a LWS, then it's a multiline header
                headerParsePos = HeaderParsePosition.HEADER_MULTI_LINE;
            }
            // Read new bytes if needed
            if (pos >= lastValid) {
                if (!fill(true,false)) {//parse header

                    //HEADER_MULTI_LINE
                    return HeaderParseStatus.NEED_MORE_DATA;
                }
            }

            chr = buf[pos];
            if ( headerParsePos == HeaderParsePosition.HEADER_MULTI_LINE ) {
                if ( (chr != Constants.SP) && (chr != Constants.HT)) {
                    headerParsePos = HeaderParsePosition.HEADER_START;
                    break;
                } else {
                    // Copying one extra space in the buffer (since there must
                    // be at least one space inserted between the lines)
                    buf[headerData.realPos] = chr;
                    headerData.realPos++;
                    headerParsePos = HeaderParsePosition.HEADER_VALUE_START;
                }
            }
        }
        // Set the header value
        headerData.headerValue.setBytes(buf, headerData.start,
                headerData.lastSignificantChar - headerData.start);
        headerData.recycle();
        return HeaderParseStatus.HAVE_MORE_HEADERS;
    }

    public int getParsingRequestLinePhase() {
        return parsingRequestLinePhase;
    }

    private HeaderParseStatus skipLine() throws IOException {
        headerParsePos = HeaderParsePosition.HEADER_SKIPLINE;
        boolean eol = false;

        // Reading bytes until the end of the line
        while (!eol) {

            // Read new bytes if needed
            if (pos >= lastValid) {
                if (!fill(true,false)) {
                    return HeaderParseStatus.NEED_MORE_DATA;
                }
            }

            if (buf[pos] == Constants.CR) {
                // Skip
            } else if (buf[pos] == Constants.LF) {
                eol = true;
            } else {
                headerData.lastSignificantChar = pos;
            }

            pos++;
        }
        if (rejectIllegalHeaderName || log.isDebugEnabled()) {
            String message = sm.getString("iib.invalidheader", new String(buf, headerData.start,
                    headerData.lastSignificantChar - headerData.start + 1, DEFAULT_CHARSET));
            if (rejectIllegalHeaderName) {
                throw new IllegalArgumentException(message);
            }
            log.debug(message);
        }

        headerParsePos = HeaderParsePosition.HEADER_START;
        return HeaderParseStatus.HAVE_MORE_HEADERS;
    }

    private HeaderParseData headerData = new HeaderParseData();
    public static class HeaderParseData {
        /**
         * When parsing header name: first character of the header.

         * When skipping broken header line: first character of the header.

         * When parsing header value: first character after ':'.
         */
        int start = 0;
        /**
         * When parsing header name: not used (stays as 0).

         * When skipping broken header line: not used (stays as 0).

         * When parsing header value: starts as the first character after ':'.
         * Then is increased as far as more bytes of the header are harvested.
         * Bytes from buf[pos] are copied to buf[realPos]. Thus the string from
         * [start] to [realPos-1] is the prepared value of the header, with
         * whitespaces removed as needed.

         */
        int realPos = 0;
        /**
         * When parsing header name: not used (stays as 0).

         * When skipping broken header line: last non-CR/non-LF character.

         * When parsing header value: position after the last not-LWS character.

         */
        int lastSignificantChar = 0;
        /**
         * MB that will store the value of the header. It is null while parsing
         * header name and is created after the name has been parsed.
         */
        MessageBytes headerValue = null;
        public void recycle() {
            start = 0;
            realPos = 0;
            lastSignificantChar = 0;
            headerValue = null;
        }
    }

    // ------------------------------------------------------ Protected Methods

    @Override
    protected void init(SocketWrapper<NioChannel> socketWrapper,
            AbstractEndpoint<NioChannel> endpoint) throws IOException {

        socket = socketWrapper.getSocket();
        socketReadBufferSize =
            socket.getBufHandler().getReadBuffer().capacity();

        int bufLength = headerBufferSize + socketReadBufferSize;
        if (buf == null || buf.length < bufLength) {
            buf = new byte[bufLength];
        }

        pool = ((NioEndpoint)endpoint).getSelectorPool();
    }

    /**
     * Fill the internal buffer using data from the underlying input stream.
     *
     * @return false if at end of stream
     */
    @Override
    protected boolean fill(boolean block) throws IOException, EOFException {
        return fill(true,block);
    }

    protected boolean fill(boolean timeout, boolean block) throws IOException, EOFException {

        boolean read = false;

        if (parsingHeader) {

            if (lastValid > headerBufferSize) {
                throw new IllegalArgumentException
                    (sm.getString("iib.requestheadertoolarge.error"));
            }

            // Do a simple read with a short timeout
            read = readSocket(timeout,block)>0;
        } else {
            lastValid = pos = end;
            // Do a simple read with a short timeout
            read = readSocket(timeout, block)>0;
        }
        return read;
    }

    // ------------------------------------- InputStreamInputBuffer Inner Class

    /**
     * This class is an input buffer which will read its data from an input
     * stream.
     */
    protected class SocketInputBuffer
        implements InputBuffer {

        /**
         * Read bytes into the specified chunk.
         */
        @Override
        public int doRead(ByteChunk chunk, Request req )
            throws IOException {

            if (pos >= lastValid) {
                if (!fill(true,true)) //read body, must be blocking, as the thread is inside the app
                    return -1;
            }

            int length = lastValid - pos;
            chunk.setBytes(buf, pos, length);
            pos = lastValid;

            return (length);
        }
    }
}


text:
<?xml version="1.0" encoding="utf-8"?>
<ldml xmlns:sil="urn://www.sil.org/ldml/0.1">
	<identity>
		<version number="0.0.1"/>
		<generation date="2018-11-20 19:30:01"/>
		<language type="arn"/>
		<special>
			<sil:identity defaultRegion="CL" script="Latn" draft="generated"/>
		</special>
	</identity>
	<localeDisplayNames>
		<languages>
			<language type="arn">Mapudungun</language>
		</languages>
		<special>
			<sil:names>
				<sil:name xml:lang="en">Mapudungun</sil:name>
			</sil:names>
		</special>
	</localeDisplayNames>
	<layout>
		<orientation>
			<characterOrder>left-to-right</characterOrder>
		</orientation>
	</layout>
	<characters>
		<exemplarCharacters>[a b c d e f g h i j k l m n ñ o p r s t u ü v w y]</exemplarCharacters>
		<exemplarCharacters alt="proposed-dbl" draft="suspect">['A-Za-z\u00C1\u00C9\u00CD\u00D1\u00D3\u00DA\u00DC\u00E1\u00E9\u00ED\u00F1\u00F3\u00FA\u00FC{Ch}{LL}{ch}{ll}]</exemplarCharacters>
		<exemplarCharacters type="punctuation">[! ( ) , \- . \: ; ? ¡ ¿ — ― ' ' " "]</exemplarCharacters>
		<exemplarCharacters type="punctuation" alt="proposed-dbl" draft="suspect">[!()+-/\:;?@\u00A1\u00A9\u00BF\u200C\u200D\u2011\u2014\u2015\u2018\u2019\u201C\u201D{...}]</exemplarCharacters>
		<exemplarCharacters type="index">[A B C D E F G H I J K L M N Ñ O P R S T U Ü V W Y]</exemplarCharacters>
	</characters>
	<delimiters>
		<quotationStart>"</quotationStart>
		<quotationEnd>"</quotationEnd>
		<alternateQuotationStart>'</alternateQuotationStart>
		<alternateQuotationEnd>'</alternateQuotationEnd>
		<special>
			<sil:matched-pairs>
				<sil:matched-pair open="(" close=")" paraClose="false"/>
				<sil:matched-pair open="[" close="]" paraClose="false"/>
				<sil:matched-pair open="{" close="}" paraClose="false"/>
			</sil:matched-pairs>
			<sil:punctuation-patterns>
				<sil:punctuation-pattern pattern="!_" context="final"/>
				<sil:punctuation-pattern pattern=")_" context="final"/>
				<sil:punctuation-pattern pattern=",_" context="final"/>
				<sil:punctuation-pattern pattern="-" context="medial"/>
				<sil:punctuation-pattern pattern="." context="medial"/>
				<sil:punctuation-pattern pattern="..._" context="final"/>
				<sil:punctuation-pattern pattern="._" context="final"/>
				<sil:punctuation-pattern pattern="/" context="medial"/>
				<sil:punctuation-pattern pattern=":" context="medial"/>
				<sil:punctuation-pattern pattern=":_" context="final"/>
				<sil:punctuation-pattern pattern=";_" context="final"/>
				<sil:punctuation-pattern pattern="?_" context="final"/>
				<sil:punctuation-pattern pattern="@" context="medial"/>
				<sil:punctuation-pattern pattern="_(" context="init"/>
				<sil:punctuation-pattern pattern="_(_" context="isolate"/>
				<sil:punctuation-pattern pattern="_+" context="init"/>
				<sil:punctuation-pattern pattern="_-_" context="isolate"/>
				<sil:punctuation-pattern pattern="_..." context="init"/>
				<sil:punctuation-pattern pattern="_¡" context="init"/>
				<sil:punctuation-pattern pattern="_©_" context="isolate"/>
				<sil:punctuation-pattern pattern="_¿" context="init"/>
				<sil:punctuation-pattern pattern="_—" context="init"/>
				<sil:punctuation-pattern pattern="_―" context="init"/>
				<sil:punctuation-pattern pattern="_'" context="init"/>
				<sil:punctuation-pattern pattern="_"" context="init"/>
				<sil:punctuation-pattern pattern="_"_" context="isolate"/>
				<sil:punctuation-pattern pattern="" context="medial"/>
				<sil:punctuation-pattern pattern="" context="medial"/>
				<sil:punctuation-pattern pattern="‑" context="medial"/>
				<sil:punctuation-pattern pattern="―_" context="final"/>
				<sil:punctuation-pattern pattern="'_" context="final"/>
				<sil:punctuation-pattern pattern=""_" context="final"/>
			</sil:punctuation-patterns>
			<sil:quotation-marks paraContinueType="all">
				<sil:quotationContinue>"</sil:quotationContinue>
				<sil:alternateQuotationContinue>'</sil:alternateQuotationContinue>
				<sil:quotation open=""" close=""" continue=""" level="3"/>
			</sil:quotation-marks>
		</special>
	</delimiters>
	<special>
		<sil:external-resources>
			<sil:font name="Charis SIL" types="default" features="ss04=1 cv43=2 cv68=1 cv77=1 cv90=1">
				<sil:url>https://wirl.api.sil.org/CharisSIL</sil:url>
			</sil:font>
			<sil:font name="Noto Sans"><!--types="ui"-->
				<sil:url>https://github.com/googlefonts/noto-fonts/raw/main/hinted/ttf/NotoSans/NotoSans-Regular.ttf</sil:url>
			</sil:font>
			<sil:font name="Noto Serif">
				<sil:url>https://github.com/googlefonts/noto-fonts/raw/main/hinted/ttf/NotoSerif/NotoSerif-Regular.ttf</sil:url>
			</sil:font>
			<sil:sampletext type="udhr">
				<sil:url>https://unicode.org/udhr/d/udhr_arn.txt</sil:url>
			</sil:sampletext>
		</sil:external-resources>
	</special>
</ldml>

redpajama_set_name: RedPajamaGithub


text:
AST v2 enhances the original AST with a number of clarifying features.

# Removals

`ASTv1` retains a node for Handlebars' "partial" syntax (`{{> ...}}`). ASTv2 does not include that node (just as neither version of the AST includes a node for Handlebars "decorator" syntax), as it is not supported by Glimmer.

# Naming Changes

There are a number of small naming changes that improve the clarity and precision of the AST:

1. `hash` -> `named`
2. `params` -> `positional`
3. `path` -> `callee`
4. `SubExpression` -> `CallExpression`
5. `BlockStatement` -> `InvokeBlock`
6. `MustacheStatement` -> `AppendContent`

# Literals

In `ASTv1`, there is a separate literal node for each kind of literal. In `ASTv2`, all literals are `ASTv2.Literal`.

# Args

In `ASTv1`, nodes have `params` and `hash` next to each other. In `ASTv2`, those nodes are grouped into an `Args` node that contains the `positional` and `named` arguments.

> Because `ASTv2` nodes are objects, this also allows these nodes to have an `isEmpty()` method, which makes it easy to check if a call node's arguments are totally empty.

# Blocks

All nodes that can have block parameters have a `table: BlockSymbolTable` property in `ASTv2`.

# Named Blocks

Elements that begin with a `:` are represented as `ASTv2.NamedBlock`.

# Components

Elements that satisfy the component heuristics are represented as `ASTv2.InvokeComponent`.

An element is a component if the part of its tag name before any `.`:

- begins with `@`
- is `this`
- is a reference to an in-scope binding
- begins with an uppercase letter

# Simple Elements

Elements that are not named blocks _and_ do not satisfy the component heuristics are represented as `ASTv2.SimpleElement`.

# Strict vs. Loose Mode

The difference between strict and loose mode is entirely encapsulated in the `FreeVarReference`.

Consumers of `ASTv2` don't need to know whether they're looking at a "strict" or "loose" template. They just need to know how to handle the different contexts in `FreeVarReference`.

## Variable References

In `ASTv2`, every variable name is represented as a `VariableReference`.

> The first part of a `PathExpression` is a `VariableReference`.

| type                | description                                                                    |
| ------------------- | ------------------------------------------------------------------------------ |
| `ThisReference`     | the literal `this`                                                             |
| `ArgReference`      | a variable reference that begins with with `@`                                 |
| `LocalVarReference` | a reference to an in-scope variable binding                                    |
| `FreeVarReference`  | a reference to a variable binding that was not introduced by block params (`as | foo | `) |

**Important Note**: The remainder of this README is a description of the loose mode rules for free variable resolution. Strict mode free variable references always refer to an in-scope JavaScript binding, regardless of their syntactic position.

RFC [#496][#496] (Handlebars Strict Mode) rationalized the rules for loose mode. This README describes the semantics of [#496][#496] in terms of namespaced free variable references and fallback semantics.

[#496]: https://emberjs.github.io/rfcs/0496-handlebars-strict-mode.html

### Free Variable References

There are two significant differences between strict and loose mode that affect the AST.

In loose mode:

1. Certain free variable references fall back to a property lookup on `this`.
2. Free variable references in "call" positions are resolved using a contextual namespace. For example, the free variable reference `h` in `(h 123)` is resolved as `helper:h`. The free variable reference `h` in `<p {{h 123}}>` is resolved as `modifier:h`.

In strict mode, all free variable references refer to bindings provided by a JavaScript scope that the template will be embedded within.

To represent this difference, all `FreeVarReference` nodes in ASTv2 are tagged with a `FreeVarResolution`.

### Strict Variable Resolution

The `Strict` resolution applies to all free variables encountered while parsing a template in strict mode.

#### Runtime Error Cases

None. Strict mode templates must be embedded in a JavaScript context where all free variable references are in scope. A compile-time error should be produced if free there are variable references that do not correspond to any in-scope variables.

### Fallback Semantics

When a free variable resolution is said to have "fallback semantics", it means the following algorithm:

1. Attempt to resolve the name in the namespaces for the resolution, if any.
2. If the name could not be resolved, resolve it as a property on `this`.

> Note: A free variable resolution has fallback semantics if it's an append or attribute curly without arguments, or if it's a path in argument position. See the summary table below for full details.

### Eval Mode Semantics

When a free variable resolution has fallback semantics, it is also said to have "eval mode semantics", which means:

1. If the template is evaluated in eval mode (i.e. as a partial), dynamically resolve the free variable in the context of the template that invoked the partial (the "invoker"):
1. If the variable name is in the local scope of the invoker, resolve it as a _local_ variable in the invoker's local scope
1. Otherwise:
1. if the invoker is also in eval mode, repeat the process with the invoker's invoker
1. if the invoker is not in eval mode, resolve the free variable using fallback semantics in the invoker's scope
1. Otherwise, resolve the free variable using fallback semantics in the current scope

### Namespaced Variable Resolution

|                     |                                                   |
| ------------------- | ------------------------------------------------- |
| Syntax Positions    | `SubExpression`, `Block`, `Modifier`, `Component` |
| Path has dots?      | ❌                                                |
| Arguments?          | Any                                               |
|                     |                                                   |
| Namespace           | see table below                                   |
| Fallback semantics? | ⛔                                                |

These resolutions occur in syntaxes that are definitely calls (e.g. subexpressions, blocks, modifiers, etc.).

#### Applicable Situation

| situation      | variable | namespace   |
| -------------- | -------- | ----------- |
| `(x y)`        | `x`      | `Helper`    |
| `{{#x y}}`     | `x`      | `Block`     |
| `<p {{x y}}>`  | `x`      | `Modifier`  |
| `X` in `<X />` | `X`      | `Component` |

#### Runtime Error Cases

If the variable reference cannot be resolved in its namespace.

### Namespaced Resolution: Ambiguous Component or Helper

|                     |                         |
| ------------------- | ----------------------- |
| Syntax Positions    | append                  |
| Path has dots?      | ❌                      |
| Arguments?          | ➕                      |
|                     |                         |
| Namespace           | `helper` or `component` |
| Fallback semantics? | ⛔                      |

This resolution occurs in append nodes with at least one argument, and when the path does not have dots (e.g. `{{hello world}}`).

#### Applicable Situation

| situation           | variable | namespace           |
| ------------------- | -------- | ------------------- |
| `{{x y}}` as append | `x`      | `ComponentOrHelper` |

In this situation, the `x` may refer to:

- a helper `x`
- a component `x`

#### Runtime Error Cases

If the variable reference cannot be resolved in the `helper` or `component` namespaces.

### Ambiguous Resolution: Append Ambiguity

|                     |                       |
| ------------------- | --------------------- |
| Syntax Positions    | append                |
| Path has dots?      | ❌                    |
| Arguments?          | ❌                    |
|                     |                       |
| Namespace           | `helper`, `component` |
| Fallback semantics? | ✅                    |

This resolution occurs in append nodes with zero arguments, and when the path does not have dots (e.g. `{{hello}}`).

#### Applicable Situations

| situation         | variable | ambiguity |
| ----------------- | -------- | --------- |
| `{{x}}` as append | `x`      | `Append`  |

In this situation, the `x` may refer to:

- a helper `x`
- a component `x`
- a local variable in partial scope
- `this.x`.

#### Runtime Error Cases

None.

### Ambiguous Resolution: Attribute Ambiguity

This resolution context occurs in attribute nodes with zero arguments, and when the path does not have dots.

|                     |                          |
| ------------------- | ------------------------ |
| Syntax Positions    | attribute, interpolation |
| Path has dots?      | ❌                       |
| Arguments?          | ❌                       |
|                     |                          |
| Namespace           | `helper`                 |
| Fallback semantics? | ✅                       |

#### Applicable Situations

| situation                                     | variable | ambiguity |
| --------------------------------------------- | -------- | --------- |
| `<p attr={{x}}>` <br> `<a href="{{x}}.html">` | `x`      | `Attr`    |

In this situation, the `x` may refer to:

- a helper `x`
- a local variable in partial scope
- `this.x`.

#### Runtime Error Cases

None.

### Summary

> These tables apply to situations where the head of the callee's path is a free variable. When the head is a local variable, it always uses strict resolution.

#### Syntax Errors 🙅♀

Situations that meet all three of these criteria are syntax errors:

1. Unambiguous invocations
2. The callee contains a `.`
3. The head of the callee is a `FreeVarReference`

| Syntax Position       | Example         | Dots? | Arguments? |
| --------------------- | --------------- | ----- | ---------- |
| `Component`           | `<X.y />`       | ➕    | Any        |
| `Modifier`            | `<p {{x.y}} />` | ➕    | Any        |
| `SubExpression`       | `(x.y)`         | ➕    | Any        |
| `Block`               | `{{#x.y}}`      | ➕    | Any        |
| `Append`, `Attribute` | `{{x.y z}}`     | ➕    | ➕         |

#### Block, Component, Modifier, SubExpression

|                     |     |
| ------------------- | --- |
| Path has dots?      | ❌  |
| Arguments?          | Any |
| Fallback semantics? | ⛔  |

| Syntax Position | Example       |     | Namespace   |
| --------------- | ------------- | --- | ----------- |
| `Block`         | `{{#x}}`      |     | `block`     |
| `Component`     | `<X />`       |     | `component` |
| `Modifier`      | `<p {{x}} />` |     | `modifier`  |
| `SubExpression` | `(x)`         |     | `helper`    |

#### Append

| Syntax Position | Example   | Dots? | Args? |     | Namespace             | Fallback? |
| --------------- | --------- | ----- | ----- | --- | --------------------- | --------- |
| `Append`        | `{{x}}`   | ❌    | ❌    |     | `helper`, `component` | ✅        |
| `Append`        | `{{x.y}}` | ➕    | ❌    |     | None                  | ✅        |
| `Append`        | `{{x y}}` | ❌    | ➕    |     | `helper`, `component` | ⛔        |

#### Attributes

The `Attribute` syntax position includes:

- the value of an HTML attribute (`href={{...}}`)
- the value of an element argument (`@title={{...}}`)
- a part of an interpolation (`href="{{...}}.html"`)

| Syntax Position | Example        | Dots? | Arguments? |     | Namespace | Fallback? |
| --------------- | -------------- | ----- | ---------- | --- | --------- | --------- |
| `Attribute`     | `href={{x}}`   | ❌    | ❌         |     | `helper`  | ✅        |
| `Attribute`     | `href={{x.y}}` | ➕    | ❌         |     | None      | ✅        |
| `Attribute`     | `href={{x y}}` | ❌    | ➕         |     | `helper`  | ⛔        |


text:
using Telerik.Sitefinity.Web.UI.Fields.Config;

namespace Telerik.Sitefinity.Web.UI.Fields.Contracts
{
	/// <summary>
	/// Defines the mandated members that need to be implemented by every type that
	/// represents a field definition for the controls that implements <see cref="IField"/> interface.
	/// </summary>
	public interface IFieldControlDefinition : IFieldDefinition
	{
		/// <summary>
		/// Gets or sets the programmatic identifier assigned to the field control.
		/// </summary>
		/// <returns>
		/// The programmatic identifier assigned to the field control.
		/// </returns>
		string ID { get; set; }
	}
}


text:
import { FormAttrAction, FormAttrState, UPDATE_FORM } from './types'

export const initialState: FormAttrState = {}

export function formAttrReducer(
    state = initialState,
    action: FormAttrAction
): FormAttrState {
    switch (action.type) {
        case UPDATE_FORM:
            return {
                ...action.payload.formData
            };
        default:
            return initialState;
            // TODO: better to throw exception here
            //throw new Error('invalid action');
    }
}


text:
namespace P05.ArrayManipulator
{
    using System;
    using System.Collections.Generic;
    using System.Linq;

    public class StartUp
    {
        public static void Main(string[] args)
        {

            List<long> numbers = Console.ReadLine().Split(' ').Select(long.Parse).ToList();

            string command = Console.ReadLine();

            while (command != "print")
            {
                string[] input = command.Split(' ');

                switch (input[0])
                {
                    case "add":
                        int index = int.Parse(input[1]);
                        long element = long.Parse(input[2]);
                        numbers.Insert(index, element);
                        break;
                    case "addMany":
                        index = int.Parse(input[1]);
                        List<long> manyElements = input.Skip(2).Select(long.Parse).ToList();
                        numbers.InsertRange(index, manyElements);
                        break;
                    case "contains":
                        element = long.Parse(input[1]);
                        Console.WriteLine(numbers.IndexOf(element));
                        break;
                    case "remove":
                        index = int.Parse(input[1]);
                        numbers.RemoveAt(index);
                        break;
                    case "shift":
                        int numberOfPositions = int.Parse(input[1]);
                        for (int i = 0; i < numberOfPositions; i++)
                        {
                            long first = numbers[0];
                            for (int j = 0; j < numbers.Count-1; j++)
                            {
                                numbers[j] = numbers[j + 1];
                            }
                            numbers[numbers.Count - 1] = first;
                        }
                        break;
                    case "sumPairs":
                        List<long> temp = new List<long>();

                        for (int i = 1; i < numbers.Count; i+= 2)
                        {
                            long firstNumber = numbers[i];
                            long secondNumber = numbers[i - 1];
                            temp.Add(firstNumber + secondNumber);
                        }
                        if (numbers.Count % 2 != 0 )
                        {
                            temp.Add(numbers[numbers.Count - 1]);
                        }
                        numbers.Clear();
                        numbers.AddRange(temp);
                        break;
                }
                command = Console.ReadLine();
            }
            Console.WriteLine("[" + string.Join(", ", numbers) + "]");
        }
    }
}


text:
/*
 * Settings.cpp
 *
 *  Created on: 2013-12-3
 *      Author: zp
 */
#include "Settings.h"

bool Settings::isCasualMode = true;
bool Settings::soundEnabled = true;
bool Settings::musicEnabled = true;
bool Settings::showConflictedDigit = true;
bool Settings::showTimer = true;
bool Settings::preventSleeping = true;
bool Settings::autoHighLight = true;
bool Settings::autoRemoveNotes = true;
bool Settings::removeCompleteDigits = true;
bool Settings::isFirstPlay = true;
bool Settings::hasRated = false;

long Stats::bestTime[4] = { 0 };
int Stats::bestRun[4] = { 0 };
int Stats::run[4] = { 0 };
int Stats::finished[4] = { 0 };
int Stats::hintNum = 5;
long Stats::totalLastTime;
long Stats::anHourTime;
long Stats::startTime;


text:
{% extends "base.html" %}

{% block content %}

Contact Us

Step {{ wizard.steps.step1 }} of {{ wizard.steps.count }}

  {% for field in form %}
    {{field.error}}

  {% endfor %}

  <form action="/contact/" method="post">{% csrf_token %}

  {{ wizard.management_form }}
  {% if wizard.form.forms %}
      {{ wizard.form.management_form }}
      {% for form in wizard.form.forms %}
          {{ form }}
      {% endfor %}
  {% else %}
      {{ wizard.form }}
  {% endif %}

  {% if wizard.steps.prev %}
  <button name="wizard_goto_step" type="submit" value="{{ wizard.steps.first }}">"first step"</button>
  <button name="wizard_goto_step" type="submit" value="{{ wizard.steps.prev }}">"prev step"</button>
  {% endif %}

  <input type="submit" value="Submit" />

  </form>

{% endblock %}


text:
package dbinterfacetest;

import junit.framework.TestCase;

import org.junit.Before;

import java.sql.ResultSet;
import java.sql.SQLException;

import dbinterface.DBInterface;
import dbinterface.Query;

/**
 * Created by will on 20/12/15.
 */
public class GlobalDBInterfaceTest extends TestCase {
  public DBInterface dbi;

  @Before
  public void setUp() throws Exception {
    dbi = new DBInterface().open().globalize();
    dbi.runSql(TestRecord.CREATE);
  }

  public void testIsGlobal() {
    assertEquals(DBInterface.getGlobal(), dbi);
  }

  public void testInsertGlobally() throws SQLException {
    TestRecord tr = new TestRecord();
    tr.boolVar = true;
    tr.stringVar = "String";
    tr.save();
    TestRecord tr1 = new Query(dbi).from(TestRecord.class).first();
    assertEquals(tr.boolVar, tr1.boolVar);
    assertEquals(tr.stringVar, tr1.stringVar);
  }

  public void testUpdateGlobally() throws SQLException {
    TestRecord test = new TestRecord();
    test.stringVar = "String";
    test.save();
    test.stringVar = "Another string";
    test.save();
    TestRecord other = new Query().from(TestRecord.class).first();
    assertEquals(other.stringVar, test.stringVar);
  }

  public void testDropGlobally() throws SQLException {
    TestRecord test = new TestRecord();
    test.stringVar = "String";
    test.save();
    test.drop();
    ResultSet rs = new Query().select("count(*)").in(TestRecord.class).firstCursor();
    assertEquals(0, rs.getInt(1));
  }
}


text:
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2020 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#ifndef SYSCOIN_OUTPUTTYPE_H
#define SYSCOIN_OUTPUTTYPE_H

#include <attributes.h>
#include <script/signingprovider.h>
#include <script/standard.h>

#include <array>
#include <optional>
#include <string>
#include <vector>

enum class OutputType {
    LEGACY,
    P2SH_SEGWIT,
    BECH32,
    BECH32M,
};

static constexpr auto OUTPUT_TYPES = std::array{
    OutputType::LEGACY,
    OutputType::P2SH_SEGWIT,
    OutputType::BECH32,
    OutputType::BECH32M,
};

std::optional<OutputType> ParseOutputType(const std::string& str);
const std::string& FormatOutputType(OutputType type);

/**
 * Get a destination of the requested type (if possible) to the specified key.
 * The caller must make sure LearnRelatedScripts has been called beforehand.
 */
CTxDestination GetDestinationForKey(const CPubKey& key, OutputType);

/** Get all destinations (potentially) supported by the wallet for the given key. */
std::vector<CTxDestination> GetAllDestinationsForKey(const CPubKey& key);

/**
 * Get a destination of the requested type (if possible) to the specified script.
 * This function will automatically add the script (and any other
 * necessary scripts) to the keystore.
 */
CTxDestination AddAndGetDestinationForScript(FillableSigningProvider& keystore, const CScript& script, OutputType);

/** Get the OutputType for a CTxDestination */
std::optional<OutputType> OutputTypeFromDestination(const CTxDestination& dest);

#endif // SYSCOIN_OUTPUTTYPE_H


text:
from __future__ import unicode_literals
from django.apps import AppConfig

class FeedMeConfig(AppConfig):
    name = 'feedme'
    verbose_name = "Feed Me"


text:
import validateArguments from '../utils/validate-arguments'

export default element => {
  validateArguments({
    args: [element],
    functionName: 'getParents',
    expectedTypes: ['element']
  })

  let parent = element
  const parents = []

  while (parent !== document.body) {
    parent = parent.parentNode

    if (!parent) {
      break
    }
    parents.push(parent)
  }

  return parents
}


text:
/**
 * @typedef {object} MemberEntryViewEventData
 * @prop {string} memberId
 * @prop {string} memberStatus
 * @prop {string} entryId
 * @prop {string} entryUrl
 */

module.exports = class MemberEntryViewEvent {
    /**
     * @param {MemberEntryViewEventData} data
     * @param {Date} timestamp
     */
    constructor(data, timestamp) {
        this.data = data;
        this.timestamp = timestamp;
    }

    /**
     * @param {MemberEntryViewEventData} data
     * @param {Date} [timestamp]
     */
    static create(data, timestamp) {
        return new MemberEntryViewEvent(data, timestamp || new Date);
    }
};


text:
package unicode

import (
	"reflect"
	"testing"

	"github.com/blevesearch/bleve/analysis"
	"github.com/blevesearch/segment"
)

func TestUnicode(t *testing.T) {

	tests := []struct {
		input  []byte
		output analysis.TokenStream
	}{
		{
			[]byte("Hello World"),
			analysis.TokenStream{
				{
					Start:    0,
					End:      5,
					Term:     []byte("Hello"),
					Position: 1,
					Type:     analysis.AlphaNumeric,
				},
				{
					Start:    6,
					End:      11,
					Term:     []byte("World"),
					Position: 2,
					Type:     analysis.AlphaNumeric,
				},
			},
		},
		{
			[]byte("steven's"),
			analysis.TokenStream{
				{
					Start:    0,
					End:      8,
					Term:     []byte("steven's"),
					Position: 1,
					Type:     analysis.AlphaNumeric,
				},
			},
		},
		{
			[]byte("こんにちは世界"),
			analysis.TokenStream{
				{
					Start:    0,
					End:      3,
					Term:     []byte("こ"),
					Position: 1,
					Type:     analysis.Ideographic,
				},
				{
					Start:    3,
					End:      6,
					Term:     []byte("ん"),
					Position: 2,
					Type:     analysis.Ideographic,
				},
				{
					Start:    6,
					End:      9,
					Term:     []byte("に"),
					Position: 3,
					Type:     analysis.Ideographic,
				},
				{
					Start:    9,
					End:      12,
					Term:     []byte("ち"),
					Position: 4,
					Type:     analysis.Ideographic,
				},
				{
					Start:    12,
					End:      15,
					Term:     []byte("は"),
					Position: 5,
					Type:     analysis.Ideographic,
				},
				{
					Start:    15,
					End:      18,
					Term:     []byte("世"),
					Position: 6,
					Type:     analysis.Ideographic,
				},
				{
					Start:    18,
					End:      21,
					Term:     []byte("界"),
					Position: 7,
					Type:     analysis.Ideographic,
				},
			},
		},
		{
			[]byte("age 25"),
			analysis.TokenStream{
				{
					Start:    0,
					End:      3,
					Term:     []byte("age"),
					Position: 1,
					Type:     analysis.AlphaNumeric,
				},
				{
					Start:    4,
					End:      6,
					Term:     []byte("25"),
					Position: 2,
					Type:     analysis.Numeric,
				},
			},
		},
		{
			[]byte("カ"),
			analysis.TokenStream{
				{
					Start:    0,
					End:      3,
					Term:     []byte("カ"),
					Position: 1,
					Type:     analysis.Ideographic,
				},
			},
		},
	}

	for _, test := range tests {
		tokenizer := NewUnicodeTokenizer()
		actual := tokenizer.Tokenize(test.input)

		if !reflect.DeepEqual(actual, test.output) {
			t.Errorf("Expected %v, got %v for %s", test.output, actual, string(test.input))
		}
	}
}

var sampleLargeInput = []byte(`There are three characteristics of liquids which are relevant to the discussion of a BLEVE:
If a liquid in a sealed container is boiled, the pressure inside the container increases. As the liquid changes to a gas it expands - this expansion in a vented container would cause the gas and liquid to take up more space. In a sealed container the gas and liquid are not able to take up more space and so the pressure rises. Pressurized vessels containing liquids can reach an equilibrium where the liquid stops boiling and the pressure stops rising. This occurs when no more heat is being added to the system (either because it has reached ambient temperature or has had a heat source removed).
The boiling temperature of a liquid is dependent on pressure - high pressures will yield high boiling temperatures, and low pressures will yield low boiling temperatures. A common simple experiment is to place a cup of water in a vacuum chamber, and then reduce the pressure in the chamber until the water boils. By reducing the pressure the water will boil even at room temperature. This works both ways - if the pressure is increased beyond normal atmospheric pressures, the boiling of hot water could be suppressed far beyond normal temperatures. The cooling system of a modern internal combustion engine is a real-world example.
When a liquid boils it turns into a gas. The resulting gas takes up far more space than the liquid did.
Typically, a BLEVE starts with a container of liquid which is held above its normal, atmospheric-pressure boiling temperature. Many substances normally stored as liquids, such as CO2, oxygen, and other similar industrial gases have boiling temperatures, at atmospheric pressure, far below room temperature. In the case of water, a BLEVE could occur if a pressurized chamber of water is heated far beyond the standard 100 °C (212 °F). That container, because the boiling water pressurizes it, is capable of holding liquid water at very high temperatures.
If the pressurized vessel, containing liquid at high temperature (which may be room temperature, depending on the substance) ruptures, the pressure which prevents the liquid from boiling is lost. If the rupture is catastrophic, where the vessel is immediately incapable of holding any pressure at all, then there suddenly exists a large mass of liquid which is at very high temperature and very low pressure. This causes the entire volume of liquid to instantaneously boil, which in turn causes an extremely rapid expansion. Depending on temperatures, pressures and the substance involved, that expansion may be so rapid that it can be classified as an explosion, fully capable of inflicting severe damage on its surroundings.`)

func BenchmarkTokenizeEnglishText(b *testing.B) {

	tokenizer := NewUnicodeTokenizer()
	b.ResetTimer()

	for i := 0; i < b.N; i++ {
		tokenizer.Tokenize(sampleLargeInput)
	}

}

func TestConvertType(t *testing.T) {
	tests := []struct {
		in  int
		out analysis.TokenType
	}{
		{
			segment.Ideo, analysis.Ideographic,
		},
		{
			segment.Kana, analysis.Ideographic,
		},
		{
			segment.Number, analysis.Numeric,
		},
		{
			segment.Letter, analysis.AlphaNumeric,
		},
	}

	for _, test := range tests {
		actual := convertType(test.in)
		if actual != test.out {
			t.Errorf("expected %d, got %d for %d", test.out, actual, test.in)
		}
	}
}


text:
<!DOCTYPE html>
{{ if .Params.onehundredpercent}}

{{ else }}

{{ end }}

    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />

    <meta property="og:title" content="{{ if ne .URL "/" }} {{ .Title }} · {{ end }} {{ .Site.Title }}" />
    <meta property="og:site_name" content="{{ .Site.Title }}" />
    <meta property="og:url" content="{{ .Permalink }}" />

    {{ if .IsPage }}
    <meta property="og:type" content="article" />

    <meta property="og:article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}" />

    {{ range .Params.tags }}
    <meta property="og:article:tag" content="{{ . }}" />
    {{ end }}
    {{ else }}
    <meta property="og:type" content="website" />
    {{ end }}

  <title>
    {{ if ne .URL "/" }} {{ .Title }} · {{ end }} {{ .Site.Title }}
  </title>

    <meta name="description" content="{{ .Site.Params.description }}" />

    <meta name="HandheldFriendly" content="True" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <link rel="stylesheet" type="text/css" href="{{.Site.BaseURL}}css/screen.css" />
    <link rel="stylesheet" type="text/css" href="{{.Site.BaseURL}}css/nav.css" />
    <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Merriweather:300,700,700italic,300italic|Open+Sans:700,400|Inconsolata" />

    {{ if .Site.Params.RSSLink}}
        <link href="{{.Site.Params.RSSLink }}" rel="alternate" type="application/rss+xml" title="{{ .Site.Title }}" />
    {{else}}
      {{ if ne .URL "/" }}
          <link href="{{ .Site.BaseURL }}index.xml" rel="alternate" type="application/rss+xml" title="{{ .Site.Title }}" />
      {{ end }}
      {{if .IsNode}}
        <link href="{{.RSSLink}}" rel="alternate" type="application/rss+xml" title="{{ if ne .URL "/" }}{{ .Title }} · {{ end }}{{ .Site.Title }}" />
      {{end}}
    {{end}}
    {{.Hugo.Generator}}

    <link rel="canonical" href="{{ .Permalink }}" />

    {{with  .Site.Params.googleAnalyticsUserID }}

    {{end}}

    {{ if .Site.Params.customHeaderPartial }}
        {{ partial .Site.Params.customHeaderPartial . }}
    {{ end }}

  {{ partial "navigation.html" . }}

{{if .Site.Params.cover}}

{{else}}

{{end}}

        {{ if .Site.Menus.main }}

              <svg width="100px" height="100px">
                  <path stroke="{{.Site.Params.menucolor}}" id="pathA" d="M 30 40 L 70 40 C 90 40 90 75 60 85 A 40 40 0 0 1 20 20 L 80 80"/>
                  <path stroke="{{.Site.Params.menucolor}}" id="pathB" d="M 30 50 L 70 50"/>
                  <path stroke="{{.Site.Params.menucolor}}" id="pathC" d="M 70 60 L 30 60 C 10 60 10 20 40 15 A 40 38 0 1 1 20 80 L 80 20"/>
              </svg>

              <button id="menu-icon-trigger" class="menu-icon-trigger"></button>

        {{end}}

404 Page Not Found

Back to home

      {{ .Site.Params.photosourcetext }}


text:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>cz.vsb.gis.ruz76</groupId>
    <artifactId>GIS-to-InSite</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <geotools.version>15.1</geotools.version>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>cz.vsb.gis.ruz76.collada.Main</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <!-- mvn assembly:assembly -->
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <appendAssemblyId>false</appendAssemblyId>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <mainClass>cz.vsb.gis.ruz76.collada.Main</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <packaging>jar</packaging>

    <dependencies>

    <!-- https://mvnrepository.com/artifact/com.vividsolutions/jts -->
    <dependency>
        <groupId>com.vividsolutions</groupId>
        <artifactId>jts</artifactId>
        <version>1.13</version>
    </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.8.11</version>
        </dependency>

        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>19.0</version>
        </dependency>

        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>9.4.1208</version>
        </dependency>

        <dependency>
            <groupId>org.geotools</groupId>
            <artifactId>gt-shapefile</artifactId>
            <version>${geotools.version}</version>
        </dependency>
        <dependency>
            <groupId>org.geotools</groupId>
            <artifactId>gt-swing</artifactId>
            <version>${geotools.version}</version>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>maven2-repository.dev.java.net</id>
            <name>Java.net repository</name>
            <url>http://download.java.net/maven/2</url>
        </repository>
        <repository>
            <id>osgeo</id>
            <name>Open Source Geospatial Foundation Repository</name>
            <url>http://download.osgeo.org/webdav/geotools/</url>
        </repository>
    </repositories>

</project>


text:
import forSelect from "../utils/for-select";

export default function (node) {
    node = node || document.body;

    // id постов
    forSelect(node, ".timeline-post-container, .single-post-container", async (node) => {
        var pp = node.querySelector("a.datetime").getAttribute("href").match(/^\/.+?\/([\w-]+)/);
        if (!pp) return; // удивительный случай, когда у поста нет ID в HTML
        var postId = pp[1];
        node.id = `post-${postId}`;
        node.dataset.postId = postId;
    });
}


text:
using System;

using StandardAnalyzer = Lucene.Net.Analysis.Standard.StandardAnalyzer;
using Document = Lucene.Net.Documents.Document;
using IndexReader = Lucene.Net.Index.IndexReader;
using IndexWriter = Lucene.Net.Index.IndexWriter;
using Term = Lucene.Net.Index.Term;
using TermEnum = Lucene.Net.Index.TermEnum;
using FSDirectory = Lucene.Net.Store.FSDirectory;
using Version = Lucene.Net.Util.Version;

namespace Lucene.Net.Demo
{

	/// <summary>Indexer for HTML files. </summary>
	public class IndexHTML
	{
		private IndexHTML()
		{
		}

		private static bool deleting = false; // true during deletion pass
		private static IndexReader reader; // existing index
		private static IndexWriter writer; // new index being built
		private static TermEnum uidIter; // document id iterator

		/// <summary>Indexer for HTML files.</summary>
		[STAThread]
		public static void  Main(System.String[] argv)
		{
			try
			{
				System.IO.FileInfo index = new System.IO.FileInfo("index");
				bool create = false;
				System.IO.FileInfo root = null;

				System.String usage = "IndexHTML [-create] [-index <index>] <root_directory>";

				if (argv.Length == 0)
				{
					System.Console.Error.WriteLine("Usage: " + usage);
					return ;
				}

				for (int i = 0; i < argv.Length; i++)
				{
					if (argv[i].Equals("-index"))
					{
						// parse -index option
						index = new System.IO.FileInfo(argv[++i]);
					}
					else if (argv[i].Equals("-create"))
					{
						// parse -create option
						create = true;
					}
					else if (i != argv.Length - 1)
					{
						System.Console.Error.WriteLine("Usage: " + usage);
						return ;
					}
					else
						root = new System.IO.FileInfo(argv[i]);
				}

				if (root == null)
				{
					System.Console.Error.WriteLine("Specify directory to index");
					System.Console.Error.WriteLine("Usage: " + usage);
					return ;
				}

				System.DateTime start = System.DateTime.Now;

				if (!create)
				{
					// delete stale docs
					deleting = true;
					IndexDocs(root, index, create);
				}
				writer = new IndexWriter(FSDirectory.Open(index), new StandardAnalyzer(Version.LUCENE_CURRENT), create, new IndexWriter.MaxFieldLength(1000000));
				IndexDocs(root, index, create); // add new docs

				System.Console.Out.WriteLine("Optimizing index...");
				writer.Optimize();
				writer.Close();

				System.DateTime end = System.DateTime.Now;

				System.Console.Out.Write(end.Millisecond - start.Millisecond);
				System.Console.Out.WriteLine(" total milliseconds");
			}
			catch (System.Exception e)
			{
				System.Console.Error.WriteLine(e.StackTrace);
			}
		}

		/* Walk directory hierarchy in uid order, while keeping uid iterator from
		/* existing index in sync.  Mismatches indicate one of: (a) old documents to
		/* be deleted; (b) unchanged documents, to be left alone; or (c) new
		/* documents, to be indexed.
		*/

		private static void  IndexDocs(System.IO.FileInfo file, System.IO.FileInfo index, bool create)
		{
			if (!create)
			{
				// incrementally update

				reader = IndexReader.Open(FSDirectory.Open(index), false); // open existing index
				uidIter = reader.Terms(new Term("uid", "")); // init uid iterator

				IndexDocs(file);

				if (deleting)
				{
					// delete rest of stale docs
					while (uidIter.Term() != null && (System.Object) uidIter.Term().Field() == (System.Object) "uid")
					{
						System.Console.Out.WriteLine("deleting " + HTMLDocument.Uid2url(uidIter.Term().Text()));
						reader.DeleteDocuments(uidIter.Term());
						uidIter.Next();
					}
					deleting = false;
				}

				uidIter.Close(); // close uid iterator
				reader.Close(); // close existing index
			}
			// don't have exisiting
			else
				IndexDocs(file);
		}

		private static void  IndexDocs(System.IO.FileInfo file)
		{
			if (System.IO.Directory.Exists(file.FullName))
			{
				// if a directory
				System.String[] files = System.IO.Directory.GetFileSystemEntries(file.FullName); // list its files
				System.Array.Sort(files); // sort the files
				for (int i = 0; i < files.Length; i++)
				// recursively index them
					IndexDocs(new System.IO.FileInfo(System.IO.Path.Combine(file.FullName, files[i])));
			}
			else if (file.FullName.EndsWith(".html") || file.FullName.EndsWith(".htm") || file.FullName.EndsWith(".txt"))
			{
				// index .txt files

				if (uidIter != null)
				{
					System.String uid = HTMLDocument.Uid(file); // construct uid for doc

					while (uidIter.Term() != null && (System.Object) uidIter.Term().Field() == (System.Object) "uid" && String.CompareOrdinal(uidIter.Term().Text(), uid) < 0)
					{
						if (deleting)
						{
							// delete stale docs
							System.Console.Out.WriteLine("deleting " + HTMLDocument.Uid2url(uidIter.Term().Text()));
							reader.DeleteDocuments(uidIter.Term());
						}
						uidIter.Next();
					}
					if (uidIter.Term() != null && (System.Object) uidIter.Term().Field() == (System.Object) "uid" && String.CompareOrdinal(uidIter.Term().Text(), uid) == 0)
					{
						uidIter.Next(); // keep matching docs
					}
					else if (!deleting)
					{
						// add new docs
						Document doc = HTMLDocument.Document(file);
						System.Console.Out.WriteLine("adding " + doc.Get("path"));
						writer.AddDocument(doc);
					}
				}
				else
				{
					// creating a new index
					Document doc = HTMLDocument.Document(file);
					System.Console.Out.WriteLine("adding " + doc.Get("path"));
					writer.AddDocument(doc); // add docs unconditionally
				}
			}
		}
	}
}


text:
#ifndef __itkTernaryMagnitudeSquaredImageFilter_h
#define __itkTernaryMagnitudeSquaredImageFilter_h

#include "itkTernaryFunctorImageFilter.h"

namespace itk
{
/** \class TernaryMagnitudeSquaredImageFilter
 * \brief Implements pixel-wise addition of three images.
 *
 * This class is parametrized over the types of the three
 * input images and the type of the output image.
 * Numeric conversions (castings) are done by the C++ defaults.
 *
 * \ingroup IntensityImageFilters
 * \ingroup ITK-ImageIntensity
 */
namespace Functor
{
template< class TInput1, class TInput2, class TInput3, class TOutput >
class ModulusSquare3
{
public:
  ModulusSquare3() {}
  ~ModulusSquare3() {}
  bool operator!=(const ModulusSquare3 &) const
  {
    return false;
  }

  bool operator==(const ModulusSquare3 & other) const
  {
    return !( *this != other );
  }

  inline TOutput operator()(const TInput1 & A,
                            const TInput2 & B,
                            const TInput3 & C) const
  { return (TOutput)( A * A + B * B + C * C ); }
};
}

template< class TInputImage1, class TInputImage2,
          class TInputImage3, class TOutputImage >
class ITK_EXPORT TernaryMagnitudeSquaredImageFilter:
  public
  TernaryFunctorImageFilter< TInputImage1, TInputImage2,
                             TInputImage3, TOutputImage,
                             Functor::ModulusSquare3<
                               typename TInputImage1::PixelType,
                               typename TInputImage2::PixelType,
                               typename TInputImage3::PixelType,
                               typename TOutputImage::PixelType >   >
{
public:
  /** Standard class typedefs. */
  typedef TernaryMagnitudeSquaredImageFilter Self;
  typedef TernaryFunctorImageFilter<
    TInputImage1, TInputImage2,
    TInputImage3, TOutputImage,
    Functor::ModulusSquare3<
      typename TInputImage1::PixelType,
      typename TInputImage2::PixelType,
      typename TInputImage3::PixelType,
      typename TOutputImage::PixelType >   >  Superclass;

  typedef SmartPointer< Self >       Pointer;
  typedef SmartPointer< const Self > ConstPointer;

  /** Method for creation through the object factory. */
  itkNewMacro(Self);

  /** Runtime information support. */
  itkTypeMacro(TernaryMagnitudeSquaredImageFilter,
               TernaryFunctorImageFilter);
protected:
  TernaryMagnitudeSquaredImageFilter() {}
  virtual ~TernaryMagnitudeSquaredImageFilter() {}
private:
  TernaryMagnitudeSquaredImageFilter(const Self &); //purposely not implemented
  void operator=(const Self &);                     //purposely not implemented
};
} // end namespace itk

#endif


text:
void xxx(int argc) {
  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
#pragma omp for
  for (int i = 0; i < 10; ++i)
    argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
}

// expected-error@+1 {{unexpected OpenMP directive '#pragma omp for'}}
#pragma omp for

// expected-error@+1 {{unexpected OpenMP directive '#pragma omp for'}}
#pragma omp for foo

void test_no_clause() {
  int i;
#pragma omp for
  for (i = 0; i < 16; ++i)
    ;

// expected-error@+2 {{statement after '#pragma omp for' must be a for loop}}
#pragma omp for
  ++i;
}

void test_branch_protected_scope() {
  int i = 0;
L1:
  ++i;

  int x[24];

#pragma omp parallel
#pragma omp for
  for (i = 0; i < 16; ++i) {
    if (i == 5)
      goto L1; // expected-error {{use of undeclared label 'L1'}}
    else if (i == 6)
      return; // expected-error {{cannot return from OpenMP region}}
    else if (i == 7)
      goto L2;
    else if (i == 8) {
    L2:
      x[i]++;
    }
  }

  if (x[0] == 0)
    goto L2; // expected-error {{use of undeclared label 'L2'}}
  else if (x[1] == 1)
    goto L1;
}

void test_invalid_clause() {
  int i;
#pragma omp parallel
// expected-warning@+1 {{extra tokens at the end of '#pragma omp for' are ignored}}
#pragma omp for foo bar
  for (i = 0; i < 16; ++i)
    ;
// At one time, this failed an assert.
// expected-error@+1 {{unexpected OpenMP clause 'num_teams' in directive '#pragma omp for'}}
#pragma omp for num_teams(3)
  for (i = 0; i < 16; ++i)
    ;
// At one time, this error was reported twice.
// expected-error@+1 {{unexpected OpenMP clause 'uniform' in directive '#pragma omp for'}}
#pragma omp for uniform
  for (i = 0; i < 16; ++i)
    ;
// expected-error@+1 {{unexpected OpenMP clause 'if' in directive '#pragma omp for'}}
#pragma omp for if(0)
  for (i = 0; i < 16; ++i)
    ;
}

void test_non_identifiers() {
  int i, x;

#pragma omp parallel
// expected-warning@+1 {{extra tokens at the end of '#pragma omp for' are ignored}}
#pragma omp for;
  for (i = 0; i < 16; ++i)
    ;
// expected-warning@+2 {{extra tokens at the end of '#pragma omp for' are ignored}}
#pragma omp parallel
#pragma omp for linear(x);
  for (i = 0; i < 16; ++i)
    ;

#pragma omp parallel
// expected-warning@+1 {{extra tokens at the end of '#pragma omp for' are ignored}}
#pragma omp for private(x);
  for (i = 0; i < 16; ++i)
    ;

#pragma omp parallel
// expected-warning@+1 {{extra tokens at the end of '#pragma omp for' are ignored}}
#pragma omp for, private(x);
  for (i = 0; i < 16; ++i)
    ;
}

extern int foo();

void test_collapse() {
  int i;
#pragma omp parallel
// expected-error@+1 {{expected '('}}
#pragma omp for collapse
  for (i = 0; i < 16; ++i)
    ;
#pragma omp parallel
// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
#pragma omp for collapse(
  for (i = 0; i < 16; ++i)
    ;
#pragma omp parallel
// expected-error@+1 {{expected expression}}
#pragma omp for collapse()
  for (i = 0; i < 16; ++i)
    ;
#pragma omp parallel
// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
#pragma omp for collapse(,
  for (i = 0; i < 16; ++i)
    ;
#pragma omp parallel
// expected-error@+1 {{expected expression}}  expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
#pragma omp for collapse(, )
  for (i = 0; i < 16; ++i)
    ;
#pragma omp parallel
// expected-warning@+2 {{extra tokens at the end of '#pragma omp for' are ignored}}
// expected-error@+1 {{expected '('}}
#pragma omp for collapse 4)
  for (i = 0; i < 16; ++i)
    ;
#pragma omp parallel
// expected-error@+2 {{expected ')'}}
// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
#pragma omp for collapse(4
  for (i = 0; i < 16; ++i)
    ; // expected-error {{expected 4 for loops after '#pragma omp for', but found only 1}}
#pragma omp parallel
// expected-error@+2 {{expected ')'}}
// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
#pragma omp for collapse(4,
  for (i = 0; i < 16; ++i)
    ; // expected-error {{expected 4 for loops after '#pragma omp for', but found only 1}}
#pragma omp parallel
// expected-error@+2 {{expected ')'}}
// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
#pragma omp for collapse(4, )
  for (i = 0; i < 16; ++i)
    ; // expected-error {{expected 4 for loops after '#pragma omp for', but found only 1}}
#pragma omp parallel
// expected-note@+1 {{as specified in 'collapse' clause}}
#pragma omp for collapse(4)
  for (i = 0; i < 16; ++i)
    ; // expected-error {{expected 4 for loops after '#pragma omp for', but found only 1}}
#pragma omp parallel
// expected-error@+2 {{expected ')'}}
// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
#pragma omp for collapse(4 4)
  for (i = 0; i < 16; ++i)
    ; // expected-error {{expected 4 for loops after '#pragma omp for', but found only 1}}
#pragma omp parallel
// expected-error@+2 {{expected ')'}}
// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
#pragma omp for collapse(4, , 4)
  for (i = 0; i < 16; ++i)
    ; // expected-error {{expected 4 for loops after '#pragma omp for', but found only 1}}
#pragma omp parallel
#pragma omp for collapse(4)
  for (int i1 = 0; i1 < 16; ++i1)
    for (int i2 = 0; i2 < 16; ++i2)
      for (int i3 = 0; i3 < 16; ++i3)
        for (int i4 = 0; i4 < 16; ++i4)
          foo();
#pragma omp parallel
// expected-error@+2 {{expected ')'}}
// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
#pragma omp for collapse(4, 8)
  for (i = 0; i < 16; ++i)
    ; // expected-error {{expected 4 for loops after '#pragma omp for', but found only 1}}
#pragma omp parallel
// expected-error@+1 {{expression is not an integer constant expression}}
#pragma omp for collapse(2.5)
  for (i = 0; i < 16; ++i)
    ;
#pragma omp parallel
// expected-error@+1 {{expression is not an integer constant expression}}
#pragma omp for collapse(foo())
  for (i = 0; i < 16; ++i)
    ;
#pragma omp parallel
// expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
#pragma omp for collapse(-5)
  for (i = 0; i < 16; ++i)
    ;
#pragma omp parallel
// expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
#pragma omp for collapse(0)
  for (i = 0; i < 16; ++i)
    ;
#pragma omp parallel
// expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
#pragma omp for collapse(5 - 5)
  for (i = 0; i < 16; ++i)
    ;
#pragma omp parallel
#pragma omp for collapse(2)
  for (i = 0; i < 16; ++i) // expected-note {{defined as private}}
// expected-note@+1 {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp for' directive into a parallel or another task region?}}
    for (int j = 0; j < 16; ++j)
// expected-error@+2 2 {{reduction variable must be shared}}
// expected-error@+1 {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
#pragma omp for reduction(+ : i, j)
      for (int k = 0; k < 16; ++k)
        i += j;
}

void test_private() {
  int i;
#pragma omp parallel
// expected-error@+2 {{expected expression}}
// expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
#pragma omp for private(
  for (i = 0; i < 16; ++i)
    ;
#pragma omp parallel
// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
// expected-error@+1 2 {{expected expression}}
#pragma omp for private(,
  for (i = 0; i < 16; ++i)
    ;
#pragma omp parallel
// expected-error@+1 2 {{expected expression}}
#pragma omp for private(, )
  for (i = 0; i < 16; ++i)
    ;
#pragma omp parallel
// expected-error@+1 {{expected expression}}
#pragma omp for private()
  for (i = 0; i < 16; ++i)
    ;
#pragma omp parallel
// expected-error@+1 {{expected expression}}
#pragma omp for private(int)
  for (i = 0; i < 16; ++i)
    ;
#pragma omp parallel
// expected-error@+1 {{expected variable name}}
#pragma omp for private(0)
  for (i = 0; i < 16; ++i)
    ;

  int x, y, z;
#pragma omp parallel
#pragma omp for private(x)
  for (i = 0; i < 16; ++i)
    ;
#pragma omp parallel
#pragma omp for private(x, y)
  for (i = 0; i < 16; ++i)
    ;
#pragma omp parallel
#pragma omp for private(x, y, z)
  for (i = 0; i < 16; ++i) {
    x = y * i + z;
  }
}

void test_lastprivate() {
  int i;
#pragma omp parallel
// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
// expected-error@+1 {{expected expression}}
#pragma omp for lastprivate(
  for (i = 0; i < 16; ++i)
    ;

#pragma omp parallel
// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
// expected-error@+1 2 {{expected expression}}
#pragma omp for lastprivate(,
  for (i = 0; i < 16; ++i)
    ;
#pragma omp parallel
// expected-error@+1 2 {{expected expression}}
#pragma omp for lastprivate(, )
  for (i = 0; i < 16; ++i)
    ;
#pragma omp parallel
// expected-error@+1 {{expected expression}}
#pragma omp for lastprivate()
  for (i = 0; i < 16; ++i)
    ;
#pragma omp parallel
// expected-error@+1 {{expected expression}}
#pragma omp for lastprivate(int)
  for (i = 0; i < 16; ++i)
    ;
#pragma omp parallel
// expected-error@+1 {{expected variable name}}
#pragma omp for lastprivate(0)
  for (i = 0; i < 16; ++i)
    ;

  int x, y, z;
#pragma omp parallel
#pragma omp for lastprivate(x)
  for (i = 0; i < 16; ++i)
    ;
#pragma omp parallel
#pragma omp for lastprivate(x, y)
  for (i = 0; i < 16; ++i)
    ;
#pragma omp parallel
#pragma omp for lastprivate(x, y, z)
  for (i = 0; i < 16; ++i)
    ;
}

void test_firstprivate() {
  int i;
#pragma omp parallel
// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
// expected-error@+1 {{expected expression}}
#pragma omp for firstprivate(
  for (i = 0; i < 16; ++i)
    ;

#pragma omp parallel
// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
// expected-error@+1 2 {{expected expression}}
#pragma omp for firstprivate(,
  for (i = 0; i < 16; ++i)
    ;
#pragma omp parallel
// expected-error@+1 2 {{expected expression}}
#pragma omp for firstprivate(, )
  for (i = 0; i < 16; ++i)
    ;
#pragma omp parallel
// expected-error@+1 {{expected expression}}
#pragma omp for firstprivate()
  for (i = 0; i < 16; ++i)
    ;
#pragma omp parallel
// expected-error@+1 {{expected expression}}
#pragma omp for firstprivate(int)
  for (i = 0; i < 16; ++i)
    ;
#pragma omp parallel
// expected-error@+1 {{expected variable name}}
#pragma omp for firstprivate(0)
  for (i = 0; i < 16; ++i)
    ;

  int x, y, z;
#pragma omp parallel
#pragma omp for lastprivate(x) firstprivate(x)
  for (i = 0; i < 16; ++i)
    ;
#pragma omp parallel
#pragma omp for lastprivate(x, y) firstprivate(x, y)
  for (i = 0; i < 16; ++i)
    ;
#pragma omp parallel
#pragma omp for lastprivate(x, y, z) firstprivate(x, y, z)
  for (i = 0; i < 16; ++i)
    ;
}

void test_loop_messages() {
  float a[100], b[100], c[100];
#pragma omp parallel
// expected-error@+2 {{variable must be of integer or pointer type}}
#pragma omp for
  for (float fi = 0; fi < 10.0; fi++) {
    c[(int)fi] = a[(int)fi] + b[(int)fi];
  }
#pragma omp parallel
// expected-error@+2 {{variable must be of integer or pointer type}}
#pragma omp for
  for (double fi = 0; fi < 10.0; fi++) {
    c[(int)fi] = a[(int)fi] + b[(int)fi];
  }

  // expected-warning@+2 {{OpenMP loop iteration variable cannot have more than 64 bits size and will be narrowed}}
  #pragma omp for
  for (__int128 ii = 0; ii < 10; ii++) {
    c[ii] = a[ii] + b[ii];
  }
}


text:
package com.assylias.jbloomberg;

import com.assylias.bigblue.utils.TypedObject;
import com.google.common.collect.Multimap;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

public class IntradayTickDataTest {

    private static final LocalDateTime NOW = LocalDateTime.now();
    private IntradayTickData data;
    private final int[] values = {1, 2, 3, 4, 3, 5, 6, 7};

    @BeforeMethod
    public void beforeMethod() {
        data = new IntradayTickData("ABC");
        int i = 0;
        data.add(NOW.minus(200, ChronoUnit.MILLIS), "value", values[i++]);
        data.add(NOW.minus(150, ChronoUnit.MILLIS), "value", values[i++]);
        data.add(NOW.minus(100, ChronoUnit.MILLIS), "value", values[i++]);
        data.add(NOW.minus(100, ChronoUnit.MILLIS), "value", values[i++]);
        data.add(NOW.minus(100, ChronoUnit.MILLIS), "value", values[i++]);
        data.add(NOW, "value", values[i++]);
        data.add(NOW, "value", values[i++]);
        data.add(NOW.plus(200, ChronoUnit.MILLIS), "value", values[i++]);
    }

    @Test
    public void testIsEmpty() {
        assertTrue(new IntradayTickData("ABC").isEmpty());
    }

    @Test
    public void testGetSecurity() {
        assertEquals(data.getSecurity(), "ABC");
    }

    @Test
    public void testForField_Size() {
        Multimap<LocalDateTime, TypedObject> result = data.forField(IntradayTickField.VALUE);
        assertEquals(result.size(), 8);
    }

    @Test
    public void testForField_Order() {
        Multimap<LocalDateTime, TypedObject> result = data.forField(IntradayTickField.VALUE);
        int i = 0;
        for (TypedObject o : result.values()) {
            assertEquals(o.asInt(), values[i++]);
        }
    }
}


text:
package test.hash;

import krati.util.JenkinsHashFunction;
import krati.util.HashFunction;

public class TestJenkinsHashFunction extends EvalHashFunction {
    public TestJenkinsHashFunction() {
        super(TestJenkinsHashFunction.class.getSimpleName());
    }

    @Override
    protected HashFunction<byte[]> createHashFunction() {
        return new JenkinsHashFunction();
    }
}


text:
<?php

namespace Magium\Magento\Navigators\Catalog;

use Magium\Magento\Navigators\BaseMenu;
use Magium\Magento\Themes\AbstractThemeConfiguration;
use Magium\Navigators\StaticNavigatorInterface;

abstract class AbstractDefaultProduct implements StaticNavigatorInterface
{

    protected $theme;
    protected $product;

    public function __construct(
        AbstractThemeConfiguration $theme,
        Product $product
    )
    {
        $this->theme = $theme;
        $this->product = $product;
    }

}


text:
package com.box.restclientv2.authorization;

import com.box.boxjavalibv2.exceptions.AuthFatalFailureException;
import com.box.restclientv2.exceptions.BoxRestException;
import com.box.restclientv2.requestsbase.DefaultBoxRequest;
import com.box.restclientv2.requestsbase.IBoxRequest;

/**
 * Base class for default Auth to be used for DefaultBoxRequest.
 */
public abstract class DefaultRequestAuth implements IBoxRequestAuth {

    public static final String AUTH_HEADER_NAME = "Authorization";

    @Override
    public void setAuth(final IBoxRequest request) throws BoxRestException, AuthFatalFailureException {
        if (!(request instanceof DefaultBoxRequest)) {
            throw new BoxRestException("class does not match, expected:" + DefaultBoxRequest.class.getCanonicalName() + ";current:"
                                       + request.getClass().getCanonicalName());
        }
    }
}


text:
if defined?(ActiveAdmin)
  ActiveAdmin.register Lentil::Tag do
    actions :index, :create, :new

    permit_params :name

    config.batch_actions = false
    config.sort_order = "name_asc"

    filter :name
    filter :tagsets_title, :as => :string, :label => "Tagsets"

    scope :all, :default => true
    scope "Harvesting", :harvestable
    scope "Not Harvesting", :not_harvestable
    scope "Not in a Tagset", :no_tagsets

    index :download_links => false do
      harvestable_ids = Lentil::Tag.harvestable.map(&:id)

      column :id
      column :name
      column "Harvestable" do |tag|
        if harvestable_ids.include?(tag.id)
          "True"
        else
          "False"
        end
      end
      column "Tagsets" do |tag|
        tag.tagsets.sort_by(&:title).map{ |t| t.title}.join(' | ')
      end
    end

    collection_action :tags_api, method: :get do
      query = params[:q]
      tags = Lentil::Tag.where("name LIKE ?", "#{query}%").limit(20)

      render json: tags
    end

    controller do
      resources_configuration[:self][:instance_name] = 'tag'

      def scoped_collection
        super.includes :taggings, :tagsets
      end
    end
  end
end


text:
package ubic.gemma.core.tasks.analysis.expression;

import ubic.gemma.core.job.TaskCommand;
import ubic.gemma.core.job.TaskResult;
import ubic.gemma.core.tasks.Task;
import ubic.gemma.model.expression.experiment.ExpressionExperiment;

/**
 * @author paul
 */
@SuppressWarnings("unused") // Possible external use
public class SvdTaskCommand extends TaskCommand {
    private static final long serialVersionUID = 1L;

    private boolean postProcessOnly = false;

    private ExpressionExperiment expressionExperiment;

    public SvdTaskCommand( ExpressionExperiment expressionExperiment ) {
        super();
        this.setMaxRuntime( 30 );
        this.expressionExperiment = expressionExperiment;
    }

    public SvdTaskCommand( ExpressionExperiment expressionExperiment, boolean postProcessOnly ) {
        super();
        this.expressionExperiment = expressionExperiment;
        this.postProcessOnly = postProcessOnly;
    }

    public ExpressionExperiment getExpressionExperiment() {
        return expressionExperiment;
    }

    public void setExpressionExperiment( ExpressionExperiment expressionExperiment ) {
        this.expressionExperiment = expressionExperiment;
    }

    @Override
    public Class<? extends Task<TaskResult, ? extends TaskCommand>> getTaskClass() {
        return SvdTask.class;
    }

    public boolean isPostProcessOnly() {
        return postProcessOnly;
    }

    public void setPostProcessOnly( boolean postProcessOnly ) {
        this.postProcessOnly = postProcessOnly;
    }
}


text:
. mail-toaster.sh || exit

export JAIL_START_EXTRA=""
export JAIL_CONF_EXTRA=""

install_postfix()
{
	tell_status "installing postfix"
	stage_pkg_install postfix-sasl opendkim dialog4ports || exit

	if [ -n "$TOASTER_NRPE" ]; then
		tell_status "installing nagios-plugins"
		stage_pkg_install nagios-plugins || exit
	fi
}

configure_opendkim()
{
	stage_sysrc milteropendkim_enable=YES
	stage_sysrc milteropendkim_cfgfile=/data/etc/opendkim.conf

	tell_status "See http://www.opendkim.org/opendkim-README"

	if [ ! -d "$STAGE_MNT/data/etc" ]; then mkdir "$STAGE_MNT/data/etc"; fi
	if [ ! -d "$STAGE_MNT/data/dkim" ]; then mkdir "$STAGE_MNT/data/dkim"; fi

	if [ -f "$STAGE_MNT/data/etc/opendkim.conf" ]; then
		echo "opendkim config retained"
		return
	fi

	sed \
		-e "/^Domain/ s/example.com/$TOASTER_MAIL_DOMAIN/"  \
		-e "/^KeyFile/ s/\/.*$/\/data\/dkim\/$TOASTER_MAIL_DOMAIN.private/"  \
		-e '/^Socket/ s/inet:port@localhost/inet:2016/' \
		-e "/^Selector/ s/my-selector-name/$(date '+%b%Y' | tr '[:upper:]' '[:lower:]')/" \
		"$STAGE_MNT/usr/local/etc/mail/opendkim.conf.sample" \
		> "$STAGE_MNT/data/etc/opendkim.conf"
}

configure_postfix()
{
	stage_sysrc postfix_enable=YES
	stage_exec postconf -e "myhostname = postfix.$TOASTER_HOSTNAME"
	stage_exec postconf -e 'smtp_use_tls=yes'
	stage_exec postconf -e 'smtp_tls_security_level = may'
	stage_exec postconf -e "mynetworks = ${JAIL_NET_PREFIX}.0${JAIL_NET_MASK}"

	if [ -f "$ZFS_DATA_MNT/etc/sasl_passwd" ]; then
		stage_exec postmap /data/etc/sasl_passwd
		stage_exec postconf -e 'smtp_sasl_auth_enable = yes'
		stage_exec postconf -e 'smtp_sasl_password_maps = hash:/data/etc/sasl_passwd'
	fi

	if [ -n "$TOASTER_NRPE" ]; then
		stage_sysrc nrpe3_enable=YES
		stage_sysrc nrpe3_configfile="/data/etc/nrpe.cfg"
	fi

	for _f in master main
	do
		if [ -f "$ZFS_DATA_MNT/postfix/etc/$_f.cf" ]; then
			cp "$ZFS_DATA_MNT/postfix/etc/$_f.cf" "$STAGE_MNT/usr/local/etc/postfix/"
		fi
	done

	if [ -f "$ZFS_JAIL_MNT/postfix/etc/aliases" ]; then
		tell_status "preserving /etc/aliases"
		cp "$ZFS_JAIL_MNT/postfix/etc/aliases" "$STAGE_MNT/etc/aliases"
		stage_exec newaliases
	fi

	if [ ! -f "$ZFS_JAIL_MNT/usr/local/etc/mail/mailer.conf" ]; then
		if [ ! -d "$ZFS_JAIL_MNT/usr/local/etc/mail" ]; then
			mkdir "$ZFS_JAIL_MNT/usr/local/etc/mail"
		fi
		stage_exec install -m 0644 /usr/local/share/postfix/mailer.conf.postfix /usr/local/etc/mail/mailer.conf
	fi

	configure_opendkim
}

start_postfix()
{
	tell_status "starting postfix"
	stage_exec service milter-opendkim start
	stage_exec service postfix start || exit
}

test_postfix()
{
	tell_status "testing opendkim"
	stage_test_running opendkim
	stage_listening 2016

	tell_status "testing postfix"
	stage_test_running master
	stage_listening 25
	echo "it worked."
}

base_snapshot_exists || exit
create_staged_fs postfix
start_staged_jail postfix
install_postfix
configure_postfix
start_postfix
test_postfix
promote_staged_jail postfix


text:
module Mygasfeed

  class << self

    # Retrieves nearby gas stations according to a user's geo location.
    # `Distance` - a number of miles under 50.
    # `fuel_type` - reg, mid, pre, or diesel
    # `sort_by` - distance or price
    def get_stations latitude, longitude, distance, fuel_type, sort_by
        params = [latitude, longitude, distance, fuel_type, sort_by]
        response = request "/stations/radius/", params
        response['stations'].map { |station| Station.build station }
    end

  end

end