Zero-extends a word to a larger width.  It is an error to specify
        a smaller width (use ``extract`` instead to crop off the extra bits).
7023
def zext(self, width):
        
        width = operator.index(width)
        if width < self._width:
            raise ValueError('zero extending to a smaller width')
        return BinWord(width, self._val)
1247481
function deeplyExtendPkg(a, b) {
	if(!a.resolutions) {
		a.resolutions = {};
	}
	utils.extend(a.resolutions, b.resolutions || {});

	if(!a.steal) {
		a.steal = {};
	}
	if(!b.steal) {
		b.steal = {};
	}

	utils.extend(a.steal, b.steal, true);
}
770030
def sign_extend(self, new_length):
        

        msb = self.extract(self.bits - 1, self.bits - 1).eval(2)
        if msb == [ 0 ]:
            # All positive numbers
            return self.zero_extend(new_length)
        if msb == [ 1 ]:
            # All negative numbers
            si = self.copy()
            si._bits = new_length
            mask = (2 ** new_length - 1) - (2 ** self.bits - 1)
            si._lower_bound |= mask
            si._upper_bound |= mask

        else:
            # Both positive numbers and negative numbers
            numbers = self._nsplit()
            # Since there are both positive and negative numbers, there must be two bounds after nsplit
            # assert len(numbers) == 2

            all_resulting_intervals = list()

            assert len(numbers) > 0

            for n in numbers:
                a, b = n.lower_bound, n.upper_bound
                mask_a = 0
                mask_b = 0
                mask_n = ((1 << (new_length - n.bits)) - 1) << n.bits

                if StridedInterval._get_msb(a, n.bits) == 1:
                    mask_a = mask_n
                if StridedInterval._get_msb(b, n.bits) == 1:
                    mask_b = mask_n

                si_ = StridedInterval(bits=new_length, stride=n.stride, lower_bound=a | mask_a, upper_bound=b | mask_b)
                all_resulting_intervals.append(si_)
            si = StridedInterval.least_upper_bound(*all_resulting_intervals).normalize()

        si.uninitialized = self.uninitialized
        return si
566670
def _LineWrap(text, width):
    
    return reduce(lambda line, word, width=width: '%s%s%s' %
                  (line,
                   ' \n'[(len(line) - line.rfind('\n') - 1 +
                         len(word.split('\n', 1)[0]) >= width)],
                   word),
                  text.split(' ')
                 )
1077586
def expand(self, m):
        """"""

        if m is None:
            raise ValueError("Match is None!")

        sep = m.string[:0]
        if isinstance(sep, bytes) != self._bytes:
            raise TypeError('Match string type does not match expander string type!')
        text = []
        # Expand string
        for x in range(0, len(self.literals)):
            index = x
            l = self.literals[x]
            if l is None:
                g_index = self._get_group_index(index)
                span_case, single_case, capture = self._get_group_attributes(index)
                if not self.use_format:
                    # Non format replace
                    try:
                        l = m.group(g_index)
                    except IndexError:  # pragma: no cover
                        raise IndexError("'%d' is out of range!" % capture)
                else:
                    # String format replace
                    try:
                        obj = m.captures(g_index)
                    except IndexError:  # pragma: no cover
                        raise IndexError("'%d' is out of range!" % g_index)
                    l = _util.format_string(m, obj, capture, self._bytes)
                if span_case is not None:
                    if span_case == _LOWER:
                        l = l.lower()
                    else:
                        l = l.upper()
                if single_case is not None:
                    if single_case == _LOWER:
                        l = l[0:1].lower() + l[1:]
                    else:
                        l = l[0:1].upper() + l[1:]
            text.append(l)

        return sep.join(text)
1026438
function(text, length, moreText) {
    return text.length > length ? text.slice(0, length).trim() + moreText : text;
  }
1276024
def __extend_uri(prefixes, short):
    
    for prefix in prefixes:
        if short.startswith(prefix):
            return short.replace(prefix + ':', prefixes[prefix])
    return short
163015
def shorten_string(string, max_width):
    ''' 
    '''
    string_len = len(string)
    if string_len <= max_width:
        return string
    visible = max_width - 16 - int(log10(string_len))
    # expected suffix len "...(and XXXXX more)"
    if not isinstance(string, unistr):
        visstring = unistr(string[:visible], errors='ignore')
    else:
        visstring = string[:visible]
    return u''.join((visstring, u'...(and ',
                     unistr(string_len - visible), u' more)'))
115427
def setExtension(self, ext):
        
        if ext[0] != ".":
            ext = "." + ext
        self._ext = utils.asString(ext)
1373600
def wrap_onspace(self, text):

        '''
        '''

        def _truncate(line, word):
            return '{line}{part}{word}'.format(
                        line=line,
                        part=' \n'[(len(line[line.rfind('\n')+1:]) + len(word.split('\n', 1)[0]) >= self.width)],
                        word=word
                    )

        return reduce(_truncate, text.split(' '))
74735
def extract(self, pos, width):
        
        pos = operator.index(pos)
        width = operator.index(width)
        if width < 0:
            raise ValueError('width must not be negative')
        if pos < 0:
            raise ValueError('extracting out of range')
        return BinWord(width, self >> pos, trunc=True)
375365
def wrap(self, string, width):
        
        if not string or width <= 0:
            logging.error("invalid string: %s or width: %s" % (string, width))
            return False

        tmp = ""
        for line in string.splitlines():
            if len(line) <= width:
                tmp += line + "\n"
                continue

            cur = 0
            length = len(line)
            while cur + width < length:
                cur = line[:cur+width].rfind(self.sep) + len(self.sep) - 1
                line = line[:cur] + "\n" + line[cur+1:]

            tmp += line + "\n\n"

        return tmp
791449
def shorten_text(self, text):
        """"""
        if len(text) > self.width:
            return text[:self.width - 3] + '...'
        return text
349975
def width_aware_slice(s, start, end, replacement_char=u' '):
    # type: (Text, int, int, Text)
    
    divides = [0]
    for c in s:
        divides.append(divides[-1] + wcswidth(c))

    new_chunk_chars = []
    for char, char_start, char_end in zip(s, divides[:-1], divides[1:]):
        if char_start == start and char_end == start:
            continue  # don't use zero-width characters at the beginning of a slice
                      # (combining characters combine with the chars before themselves)
        elif char_start >= start and char_end <= end:
            new_chunk_chars.append(char)
        else:
            new_chunk_chars.extend(replacement_char * interval_overlap(char_start, char_end, start, end))

    return ''.join(new_chunk_chars)
314042
void zeroPad2(StringBuilder b, int value, int width) {
    switch (width) {
      case 2:
        if (value < 10) {
          b.append('0');
        }
        // fall through

      case 1:
        b.append(value);
        break;
    }
  }
1111325
def stretch(from = 0 .. 0xFF, to = 0 .. 0xFF)
      if from.exclude_end?
        raise "Stretching does not support ranges with end value " +
              "excluded (such as #{from})"
      end
      if to.exclude_end?
        raise "Stretching does not support ranges with end value " +
              "excluded (such as #{to})"
      end
      if from.last != from.first
        factor = (to.last - to.first).to_f / (from.last - from.first)
        collect { |x| ((x - from.first) * factor).major(to.first).minor to.last }
      else
        (self <= from.first).conditional to.first, to.last
      end
    end
656045
def forward_word_extend_selection(self, e): # 
        """
        self.l_buffer.forward_word_extend_selection(self.argument_reset)
        self.finalize()