pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: builtin_functions.c,v 1.505 2003/09/04 16:00:29 grubba Exp $ + || $Id: builtin_functions.c,v 1.506 2003/09/05 11:56:24 grubba Exp $   */      #include "global.h" - RCSID("$Id: builtin_functions.c,v 1.505 2003/09/04 16:00:29 grubba Exp $"); + RCSID("$Id: builtin_functions.c,v 1.506 2003/09/05 11:56:24 grubba Exp $");   #include "interpret.h"   #include "svalue.h"   #include "pike_macros.h"   #include "object.h"   #include "program.h"   #include "array.h"   #include "pike_error.h"   #include "constants.h"   #include "mapping.h"   #include "stralloc.h"
pike.git/src/builtin_functions.c:418:    case CIM_NONE: case CIM_UPPERDELTA: break; \    case CIM_LOWERDELTA: C = c - ci->data; break; \    case CIM_CASEBIT: C = c & ~ci->data; break; \    case CIM_CASEBITOFF: C = ((c - ci->data)& ~ci->data) + ci->data; break; \    default: Pike_fatal("lower_case(): Unknown case_info mode: %d\n", ci->mode); \    } \    } \    } while(0)      /*! @decl string lower_case(string s) +  *! @decl int lower_case(int c)    *! -  *! Convert a string to lower case. +  *! Convert a string or character to lower case.    *!    *! @returns    *! Returns a copy of the string @[s] with all upper case characters -  *! converted to lower case. +  *! converted to lower case, or the character @[c] converted to lower +  *! case.    *! -  +  *! @note +  *! Assumes the string or character to be coded according to +  *! ISO-10646 (aka Unicode). +  *! +  *! @note +  *! Prior to Pike 7.5 this function only accepted strings. +  *!    *! @seealso    *! @[upper_case()]    */   PMOD_EXPORT void f_lower_case(INT32 args)   {    ptrdiff_t i;    struct pike_string *orig;    struct pike_string *ret; -  +  +  check_all_args("lower_case", args, BIT_STRING|BIT_INT, 0); +  +  if (Pike_sp[-args].type == T_INT) { +  /* NOTE: Performs the case change in place. */ +  DO_LOWER_CASE(Pike_sp[-args].u.integer); +  pop_n_elems(args-1); +  return; +  } +     get_all_args("lower_case", args, "%W", &orig);       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);
pike.git/src/builtin_functions.c:468:    }    } else {    Pike_fatal("lower_case(): Bad string shift:%d\n", orig->size_shift);    }       pop_n_elems(args);    push_string(end_shared_string(ret));   }      /*! @decl string upper_case(string s) +  *! @decl int upper_case(int c)    *! -  *! Convert a string to upper case. +  *! 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. +  *! converted to upper case, or the character @[c] converted to upper +  *! case.    *! -  +  *! @note +  *! Assumes the string or character to be coded according to +  *! ISO-10646 (aka Unicode). +  *! +  *! @note +  *! Prior to Pike 7.5 this function only accepted strings. +  *!    *! @seealso    *! @[lower_case()]    */   PMOD_EXPORT void f_upper_case(INT32 args)   {    ptrdiff_t i;    struct pike_string *orig;    struct pike_string *ret;    int widen = 0; -  +  check_all_args("upper_case", args, BIT_STRING|BIT_INT, 0); +  +  if (Pike_sp[-args].type == T_INT) { +  /* NOTE: Performs the case change in place. */ +  DO_UPPER_CASE(Pike_sp[-args].u.integer); +  pop_n_elems(args-1); +  return; +  } +     get_all_args("upper_case",args,"%W",&orig);       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);   
pike.git/src/builtin_functions.c:7952:    tArr(tVar(1))),    tFunc(tOr(tObj,tPrg(tObj)),tArr(tStr))),    OPT_TRY_OPTIMIZE,fix_indices_type,0);      /* function(mixed:int) */    ADD_EFUN("intp", f_intp,tFunc(tMix,tInt),OPT_TRY_OPTIMIZE);      /* function(mixed:int) */    ADD_EFUN("multisetp", f_multisetp,tFunc(tMix,tInt),OPT_TRY_OPTIMIZE);    - /* function(string:string) */ -  ADD_EFUN("lower_case",f_lower_case,tFunc(tStr,tStr),OPT_TRY_OPTIMIZE); + /* function(string:string)|function(int:int) */ +  ADD_EFUN("lower_case",f_lower_case, +  tOr(tFunc(tStr,tStr), tFunc(tInt,tInt)),OPT_TRY_OPTIMIZE);      /* function(mixed:int) */    ADD_EFUN("mappingp",f_mappingp,tFunc(tMix,tInt),OPT_TRY_OPTIMIZE);      /* function(1=mixed,int:1) */    ADD_EFUN("set_weak_flag",f_set_weak_flag,    tFunc(tSetvar(1,tMix) tInt,tVar(1)),OPT_SIDE_EFFECT);       ADD_INT_CONSTANT("PIKE_WEAK_INDICES", PIKE_WEAK_INDICES, 0);    ADD_INT_CONSTANT("PIKE_WEAK_VALUES", PIKE_WEAK_VALUES, 0);
pike.git/src/builtin_functions.c:8109:    ADD_EFUN("time",f_time,    tOr(tFunc(tOr(tVoid,tInt01),tInt2Plus),    tFunc(tInt2Plus,tFlt)),    OPT_EXTERNAL_DEPEND);       /* function(array(0=mixed):array(0)) */    ADD_FUNCTION2("transpose",f_transpose,    tFunc(tArr(tSetvar(0,tMix)),tArr(tVar(0))), 0,    OPT_TRY_OPTIMIZE);    - /* function(string:string) */ -  ADD_EFUN("upper_case",f_upper_case,tFunc(tStr,tStr),0); + /* function(string:string)|function(int:int) */ +  ADD_EFUN("upper_case",f_upper_case, +  tOr(tFunc(tStr,tStr),tFunc(tInt,tInt)),OPT_TRY_OPTIMIZE);      /* function(string|multiset:array(int))|function(array(0=mixed)|mapping(mixed:0=mixed)|object|program:array(0)) */    ADD_EFUN2("values",f_values,    tOr(tFunc(tOr(tStr,tMultiset),tArr(tInt)),    tFunc(tOr4(tArr(tSetvar(0,tMix)),    tMap(tMix,tSetvar(0,tMix)),    tObj,tPrg(tObj)),    tArr(tVar(0)))),0,fix_values_type,0);      /* function(mixed:int) */