pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.c:663:    check_all_args("lower_case", args, BIT_STRING|BIT_INT, 0);       if (TYPEOF(Pike_sp[-args]) == T_INT) {    /* NOTE: Performs the case change in place. */    DO_LOWER_CASE(Pike_sp[-args].u.integer);    pop_n_elems(args-1);    return;    }       orig = Pike_sp[-args].u.string; +  +  if( orig->flags & STRING_IS_LOWERCASE ) +  return; +     ret = begin_wide_shared_string(orig->len, orig->size_shift);       MEMCPY(ret->str, orig->str, orig->len << orig->size_shift);       i = orig->len;       if (!orig->size_shift) {    p_wchar0 *str = STR0(ret);       while(i--) {
pike.git/src/builtin_functions.c:693:       while(i--) {    DO_LOWER_CASE(str[i]);    }   #ifdef PIKE_DEBUG    } else {    Pike_fatal("lower_case(): Bad string shift:%d\n", orig->size_shift);   #endif    }    +  ret = end_shared_string(ret); +  ret->flags |= STRING_IS_LOWERCASE;    pop_n_elems(args); -  push_string(end_shared_string(ret)); +  push_string(ret);   }      /*! @decl string upper_case(string s)    *! @decl int upper_case(int c)    *!    *! Convert a string or character to upper case.    *!    *! @returns    *! Returns a copy of the string @[s] with all lower case characters    *! converted to upper case, or the character @[c] converted to upper
pike.git/src/builtin_functions.c:733:    check_all_args("upper_case", args, BIT_STRING|BIT_INT, 0);       if (TYPEOF(Pike_sp[-args]) == T_INT) {    /* NOTE: Performs the case change in place. */    DO_UPPER_CASE(Pike_sp[-args].u.integer);    pop_n_elems(args-1);    return;    }       orig = Pike_sp[-args].u.string; +  if( orig->flags & STRING_IS_UPPERCASE ) +  { +  return; +  } +     ret=begin_wide_shared_string(orig->len,orig->size_shift);    MEMCPY(ret->str, orig->str, orig->len << orig->size_shift);       i = orig->len;       if (!orig->size_shift) {    p_wchar0 *str = STR0(ret);       while(i--) {    if(str[i]!=0xff && str[i]!=0xb5) {
pike.git/src/builtin_functions.c:793:    while(i--) {    DO_UPPER_CASE(str[i]);    }   #ifdef PIKE_DEBUG    } else {    Pike_fatal("lower_case(): Bad string shift:%d\n", orig->size_shift);   #endif    }       pop_n_elems(args); -  push_string(end_shared_string(ret)); +  ret = end_shared_string(ret); +  ret->flags |= STRING_IS_UPPERCASE; +  push_string(ret);   }      /*! @decl string random_string(int len)    *!    *! Returns a string of random characters 0-255 with the length @[len].    */   PMOD_EXPORT void f_random_string(INT32 args)   {    struct pike_string *ret;    INT_TYPE len, e;
pike.git/src/builtin_functions.c:948:    if ((TYPEOF(Pike_sp[1-args]) == T_INT) ||    ((TYPEOF(Pike_sp[1-args]) == T_STRING) &&    (Pike_sp[1-args].u.string->len == 1))) {    INT_TYPE val;    if (TYPEOF(Pike_sp[1-args]) == T_INT) {    val = Pike_sp[1-args].u.integer;    } else {    val = index_shared_string(Pike_sp[1-args].u.string, 0);    }    +  if( !string_range_contains( haystack, val ) ) +  { +  pop_n_elems(args); +  push_int( -1 ); +  return; +  }    switch(Pike_sp[-args].u.string->size_shift) {    case 0:    {    p_wchar0 *str = STR0(haystack);    if (val >= 256) {    start = -1;    break;    }    while (start < haystack->len) {    if (str[start] == val) break;