Examples of ByteList


Examples of org.jruby.util.ByteList

                break;
            }
            p += enc.length(s, p, pend);
        }
        if (!need_escape) {
            sb.append(new ByteList(s,start,len,false).toString());
        } else {
            p = 0;
            while (p < pend) {
                if (s[p] == '\\') {
                    int n = enc.length(s, p + 1, pend) + 1;
                    sb.append(new ByteList(s,p,n,false).toString());
                    p += n;
                    continue;
                } else if (s[p] == '/') {
                    sb.append("\\/");
                } else if (enc.length(s, p, pend) != 1) {
                    sb.append(new ByteList(s, p, enc.length(s, p, pend), false).toString());
                    p += enc.length(s, p, pend);
                    continue;
                } else if ((' ' == s[p] || (!Character.isWhitespace(s[p]) &&
                                           !Character.isISOControl(s[p])))) {
                    sb.append((char)(s[p]&0xFF));
View Full Code Here

Examples of org.jruby.util.ByteList

    /** rb_reg_initialize_m
     */
    @JRubyMethod(name = "initialize", optional = 3, visibility = Visibility.PRIVATE)
    public IRubyObject initialize_m(IRubyObject[] args) {
        ByteList bytes;
        int regexFlags = 0;

        if (args[0] instanceof RubyRegexp) {
            if (args.length > 1) {
                getRuntime().getWarnings().warn(ID.REGEXP_IGNORED_FLAGS, "flags" + (args.length == 3 ? " and encoding" : "") + " ignored");
            }
            RubyRegexp regexp = (RubyRegexp)args[0];
            regexp.check();

            regexFlags = (int)regexp.pattern.getOptions() & 0xF;
            if (!regexp.isKCodeDefault() && regexp.kcode != null && regexp.kcode != KCode.NIL) {
                if (regexp.kcode == KCode.NONE) {
                    regexFlags |= 16;
                } else if (regexp.kcode == KCode.EUC) {
                    regexFlags |= 32;
                } else if (regexp.kcode == KCode.SJIS) {
                    regexFlags |= 48;
                } else if (regexp.kcode == KCode.UTF8) {
                    regexFlags |= 64;
                }               
            }
            bytes = regexp.str;
        } else {
            if (args.length >= 2) {
                if (args[1] instanceof RubyFixnum) {
                    regexFlags = RubyNumeric.fix2int(args[1]);
                } else if (args[1].isTrue()) {
                    regexFlags = RE_OPTION_IGNORECASE;
                }
            }
            if (args.length == 3 && !args[2].isNil()) {
                ByteList kcodeBytes = args[2].convertToString().getByteList();
                char first = kcodeBytes.length() > 0 ? kcodeBytes.charAt(0) : 0;
                regexFlags &= ~0x70;
                switch (first) {
                case 'n': case 'N':
                    regexFlags |= 16;
                    break;
View Full Code Here

Examples of org.jruby.util.ByteList

     */
    public int search(ThreadContext context, RubyString str, int pos, boolean reverse) {
        Ruby runtime = context.getRuntime();
        Frame frame = context.getCurrentRubyFrame();

        ByteList value = str.getByteList();
        if (pos > value.realSize || pos < 0) {
            frame.setBackRef(runtime.getNil());
            return -1;
        }

View Full Code Here

Examples of org.jruby.util.ByteList

        int mend = matcher.getEnd();
       
        int p, s;
        p = s = 0;
        int no = -1;
        ByteList bs = str.getByteList();
        ByteList srcbs = src.getByteList();
        int e = bs.realSize;
        RubyString val = null;
        Encoding enc = kcode.getEncoding();

        int beg, end;
        while (s < e) {
            int ss = s;
            int c = bs.charAt(s);
            int l = enc.length(bs.bytes, bs.begin + s++, bs.begin + e);
            if (l != 1) {
                s += l - 1;
                continue;
            }
            if (c != '\\' || s == e) continue;
            if (val == null) val = RubyString.newString(getRuntime(), new ByteList(ss - p));

            val.cat(bs.bytes, bs.begin + p, ss - p);
            c = bs.charAt(s++);
            p = s;
           
View Full Code Here

Examples of org.jruby.util.ByteList

        return val;
    }

    final int adjustStartPos(RubyString str, int pos, boolean reverse) {
        check();
        ByteList value = str.getByteList();
        return pattern.adjustStartPosition(value.bytes, value.begin, value.realSize, pos, reverse);
    }
View Full Code Here

Examples of org.jruby.util.ByteList

    /** rb_reg_quote
     *
     */
    public static ByteList quote(ByteList str, KCode kcode) {
        ByteList bs = str;
        int tix = 0;
        int s = bs.begin;
        int send = s + bs.length();
        Encoding enc = kcode.getEncoding();
        meta_found: do {
            for(; s < send; s++) {
                int c = bs.bytes[s] & 0xff;
                int l = enc.length(bs.bytes, s, send);
                if (l != 1) {
                    int n = l;
                    while (n-- > 0 && s < send) {
                        s++;
                    }
                    s--;
                    continue;
                }
                switch (c) {
                case '[': case ']': case '{': case '}':
                case '(': case ')': case '|': case '-':
                case '*': case '.': case '\\':
                case '?': case '+': case '^': case '$':
                case ' ': case '#':
                case '\t': case '\f': case '\n': case '\r':
                    break meta_found;
                }
            }
            return bs;
        } while (false);
        ByteList b1 = new ByteList(send*2);
        System.arraycopy(bs.bytes,bs.begin,b1.bytes,b1.begin,s-bs.begin);
        tix += (s-bs.begin);

        for(; s<send; s++) {
            int c = bs.bytes[s] & 0xff;
View Full Code Here

Examples of primitive.collection.ByteList

        message_count++;
      }
    }
    boolean has_upgrade = (message_count < 3 || r3.upgrade);

    ByteList blist = new ByteList();
    blist.addAll(r1.raw);
    blist.addAll(r2.raw);
    blist.addAll(r3.raw);

    byte [] raw = blist.toArray();
    ByteBuffer buf   = ByteBuffer.wrap(raw);

    Util.Settings settings = Util.settings();
    HTTPParser parser = new HTTPParser(r1.type);
   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.