/* onigenc_get_right_adjust_char_head_with_prev
321388
public final int rightAdjustCharHeadWithPrev(byte[]bytes, int p, int s, int end, IntHolder prev) {
        int p_ = leftAdjustCharHead(bytes, p, s, end);
        if (p_ < s) {
            if (prev != null) prev.value = p_;
            p_ += length(bytes, p_, end);
        } else {
            if (prev != null) prev.value = -1; /* Sorry */
        }
        return p_;
    }
222159
function getUpperFunction(node) {
    for (let currentNode = node; currentNode; currentNode = currentNode.parent) {
        if (anyFunctionPattern.test(currentNode.type)) {
            return currentNode;
        }
    }
    return null;
}
297259
private Token token(Token prev) {
    if (curChar == EOF) {
      return null;
    }
    if (curChar == '{') {
      char nextChar = lookahead();
      if (nextChar == '{') {
        return leftCurlyBracket(prev);
      } else if (nextChar >= 'a' && nextChar <= 'z') {
        return key(prev);
      } else {
        throw new IllegalArgumentException(
            "Unexpected first character '" + nextChar + "'; must be lower case a-z.");
      }
    }
    return text(prev);
  }
523607
def set_charset(self, charset):
        """"""
        self.head.charset.attr(charset=charset)
        return self
959315
@Deprecated
    public static void reverseForEach(String string, CharProcedure procedure)
    {
        StringIterate.reverseForEachChar(string, procedure);
    }
571424
def header(head, text, over_char=None, under_char=None, center=True):
    
    lines = list(text.split('\n'))
    width = max(len(l) for l in lines)

    # Center or left-justify
    if center:
        head = head.center(width) + '\n'
    else:
        head = head.ljust(width) + '\n'

    # Underline head
    if under_char:
        head = head + under_char * width + '\n'

    # 'Overline' head
    if over_char:
        head = over_char * width + '\n' + head

    return head + text
1106475
@Override
    public int leftAdjustCharHead(byte[]bytes, int p, int s, int end) {
        if (s <= p) return s;
        int p_ = s;
        while (!utf8IsLead(bytes[p_] & 0xff) && p_ > p) p_--;
        return p_;
    }
702672
public StrPosition getBeforeOfWithDetails(String srcStr, String token) {

        final StrPosition retVal = new StrPosition();

        if (isBlank(srcStr) || isBlank(token)) {
            return retVal;
        }

        int tokenStartIndex = srcStr.indexOf(token);
        if (tokenStartIndex < 0) {
            return null;
        }

        String beforeTokenStr = getLeftOf(srcStr, tokenStartIndex);

        retVal.startIndex = 0;
        retVal.endIndex = tokenStartIndex - 1;
        retVal.str = beforeTokenStr;

        return retVal;

    }
1160291
function findFixedMatchFromHead(el, head) {
        var relativeOp, cur = head;
        do {
            if (!singleMatch(el, cur)) {
                return null;
            }
            cur = cur.prev;
            if (!cur) {
                return true;
            }
            relativeOp = relativeExpr[cur.nextCombinator];
            el = dir(el, relativeOp.dir);
        } while (el && relativeOp.immediate);
        if (!el) {
            return null;
        }
        return {
            el: el,
            match: cur
        };
    }
249936
function precedenceAdjustmentSpecification(word){
    var regex_rules = [
        /^be(.*)lah$/,
        /^be(.*)an$/,
        /^me(.*)i$/,
        /^di(.*)i$/,
        /^pe(.*)i$/,
        /^ter(.*)i$/,
    ];

    for(var i in regex_rules){
        if(word.match(regex_rules[i])){
            return true;
        }
    }
    return false;
}
264564
function (header, prevToken) {
        var options = this.options;

        if (header.depth > options.maxDepth) return;

        var headerText = utils.getHeader(header.text, prevToken);

        if (!headerText) return;

        var anchor = this._getAnchor(header.text, prevToken),
            indent = utils.getIndent(this._usedHeaders, header.depth);

        this._usedHeaders.unshift({
            depth: header.depth,
            indent: indent
        });

        this.data += indent + options.bullet + ' [' + headerText.replace(/\\/g, '\\\\') + '](#' + anchor + ')' + EOL;
    }
1234436
def update_chars(self):
        """"""
        # NOTE: We spoof non-Unix files by returning '\n' on StopIteration
        self.prior_char, self.char = self.char, next(self.characters, '\n')
        self.idx += 1
1266333
private void ensureValidLookahead(CharType... expected) {
        if (!chars.positiveLookahead(expected)) {
            throw new UnexpectedCharacterException(
                chars.lookahead(1),
                chars.currentOffset(),
                expected
            );
        }
    }
907858
private final void _prependOrWriteCharacterEscape(char ch, int escCode)
        throws IOException, JsonGenerationException
    {
        if (escCode >= 0) { // \\N (2 char)
            if (_outputTail >= 2) { // fits, just prepend
                int ptr = _outputTail - 2;
                _outputHead = ptr;
                _outputBuffer[ptr++] = '\\';
                _outputBuffer[ptr] = (char) escCode;
                return;
            }
            // won't fit, write
            char[] buf = _entityBuffer;
            if (buf == null) {
                buf = _allocateEntityBuffer();
            }
            _outputHead = _outputTail;
            buf[1] = (char) escCode;
            _writer.write(buf, 0, 2);
            return;
        }
        if (escCode != CharacterEscapes.ESCAPE_CUSTOM) { // std, \\uXXXX
            if (_outputTail >= 6) { // fits, prepend to buffer
                char[] buf = _outputBuffer;
                int ptr = _outputTail - 6;
                _outputHead = ptr;
                buf[ptr] = '\\';
                buf[++ptr] = 'u';
                // We know it's a control char, so only the last 2 chars are non-0
                if (ch > 0xFF) { // beyond 8 bytes
                    int hi = (ch >> 8) & 0xFF;
                    buf[++ptr] = HEX_CHARS[hi >> 4];
                    buf[++ptr] = HEX_CHARS[hi & 0xF];
                    ch &= 0xFF;
                } else {
                    buf[++ptr] = '0';
                    buf[++ptr] = '0';
                }
                buf[++ptr] = HEX_CHARS[ch >> 4];
                buf[++ptr] = HEX_CHARS[ch & 0xF];
                return;
            }
            // won't fit, flush and write
            char[] buf = _entityBuffer;
            if (buf == null) {
                buf = _allocateEntityBuffer();
            }
            _outputHead = _outputTail;
            if (ch > 0xFF) { // beyond 8 bytes
                int hi = (ch >> 8) & 0xFF;
                int lo = ch & 0xFF;
                buf[10] = HEX_CHARS[hi >> 4];
                buf[11] = HEX_CHARS[hi & 0xF];
                buf[12] = HEX_CHARS[lo >> 4];
                buf[13] = HEX_CHARS[lo & 0xF];
                _writer.write(buf, 8, 6);
            } else { // We know it's a control char, so only the last 2 chars are non-0
                buf[6] = HEX_CHARS[ch >> 4];
                buf[7] = HEX_CHARS[ch & 0xF];
                _writer.write(buf, 2, 6);
            }
            return;
        }
    }
5687
function handlePlainCharacter(element, char) {
  const prefix = element[typedPrefixKey] || '';
  element[typedPrefixKey] = prefix + char;
  element.selectItemWithTextPrefix(element[typedPrefixKey]);
  setPrefixTimeout(element);
}
580731
function (chrs, buffer, pos, strict, opts) {
                        var frontValue = buffer.join('').substr(0, 3);
                        if (frontValue.indexOf(opts.placeholder[0]) != -1) frontValue = "01" + opts.separator;
                        var isValid = opts.regex.val2(opts.separator).test(frontValue + chrs);
                        if (!strict && !isValid) {
                            if (chrs.charAt(1) == opts.separator || "-./".indexOf(chrs.charAt(1)) != -1) {
                                isValid = opts.regex.val2(opts.separator).test(frontValue + "0" + chrs.charAt(0));
                                if (isValid) {
                                    buffer[pos - 1] = "0";
                                    return { "pos": pos, "c": chrs.charAt(0) };
                                }
                            }
                        }
                        return isValid;
                    }
1155972
function replaceInsensitive(chr, dbl) {

		var lower = chr.toLowerCase(),
		    upper = chr.toUpperCase(),
		    result,
		    dbl_result;

		if (lower == upper) {
			return chr;
		}

		result = '[' + lower + upper;

		result += (baseDiacriticsMap[lower]||'');
		result += (baseDiacriticsMap[upper]||'');

		result += ']';

		if (dbl) {
			lower = dbl.toLowerCase();
			upper = dbl.toUpperCase();

			dbl_result = baseDiacriticsMap[lower] || '';
			dbl_result += baseDiacriticsMap[upper] || '';

			if (dbl_result) {
				// Make the previous group optional,
				// but do require one of these groups then
				result = '?(?:' + result + '|[' + dbl_result + '])';
			}
		}

		return result;
	}