pike.git / lib / master.pike.in

version» Context lines:

pike.git/lib/master.pike.in:2107:    program ret = low_cast_to_program(pname, current_file, handler);    DEC_RESOLV_MSG_DEPTH();    resolv_debug ("cast_to_program(%O, %O) => %O\n", pname, current_file, ret);    if (programp (ret)) return ret;    error("Cast %O to program failed%s.\n",    pname,    (current_file && current_file!="-") ? sprintf(" in %O",current_file) : "");   }       + protected string narrowify_string(string s) + { +  if (Builtin.string_width(s) <= 8) return s; +  // Perform Unicode escaping. +  return map(s/"", +  lambda(string s) { +  if (Builtin.string_width(s) <= 8) return s; +  int c = s[0] & 0xffffffff; +  if (c <= 0xffff) return sprintf("\\u%04x", c); +  return sprintf("\\U%08x", c); +  }) * ""; + } +    //! This function is called when an error occurs that is not caught   //! with catch().   void handle_error(array|object trace)   {    // NB: Use predef::trace() to modify trace level here.    // predef::trace(2);    if(mixed x=catch {    werror(call_describe_backtrace(trace));    }) {    // One reason for this might be too little stack space, which    // easily can occur for "out of stack" errors. It should help to    // tune up the STACK_MARGIN values in interpret.c then.    werror("Error in handle_error in master object:\n");    if(catch {    // NB: Splited werror calls to retain some information    // even if/when werror throws.    catch {    if (catch {    string msg = [string]x[0];    array bt = [array]x[1]; -  werror("%s", msg); -  werror("%O\n", bt); +  werror("%s", narrowify_string(msg)); +  werror(narrowify_string(sprintf("%O\n", bt)));    }) { -  werror("%O\n", x); +  werror(narrowify_string(sprintf("%O\n", x)));    }    }; -  werror("Original error:\n" -  "%O\n", trace); +  werror(narrowify_string(sprintf("Original error:\n" +  "%O\n", trace)));    }) {    werror("sprintf() failed to write error.\n");    }    }    // predef::trace(0);   }      /* This array contains the names of the functions    * that a replacing master-object may want to override.    */
pike.git/lib/master.pike.in:4145:   //!   //! @seealso   //! @[compile_warning()], @[compile_exception()],   //! @[get_inhibit_compile_errors()], @[set_inhibit_compile_errors()],   void compile_error(string file,int line,string err)   {    mixed val;    if(! (val = get_inhibit_compile_errors() ))    {    werror( "%s:%s:%s\n",trim_file_name(file), -  line?(string)line:"-",err ); +  line?(string)line:"-",narrowify_string(err) );    }    else if(objectp(val) ||    programp(val) ||    functionp(val))    {    if (objectp(val) && val->compile_error) {    val->compile_error(file, line, err);    } else if (callablep(val)) {    val(file, line, err);    }
pike.git/lib/master.pike.in:4175:   //! @[compile_error()], @[compile_exception()],   //! @[get_inhibit_compile_errors()], @[set_inhibit_compile_errors()],   void compile_warning(string file,int line,string err)   {    mixed val;       if(!(val = get_inhibit_compile_errors() ))    {    if(want_warnings)    werror( "%s:%s: Warning: %s\n",trim_file_name(file), -  line?(string)line:"-",err ); +  line?(string)line:"-",narrowify_string(err) );    }    else if (objectp(val) && val->compile_warning) {    ([function(string,int,string:void)]([object]val)    ->compile_warning)(file, line, err);    }   }         //! This function is called when an exception is caught during   //! compilation. Its message is also reported to @[compile_error] if
pike.git/lib/master.pike.in:4382:    default:    /* object or type. */    if (catch {    if(string tmp=sprintf("%O", m)) res = tmp;    }) {    // Extra paranoia case.    res = sprintf("Instance of %O", _typeof(m));    }    break;    } +  // Objects may have _sprintfs that output wide characters, +  // and function names may be wide, etc... +  res = narrowify_string(res);    if (stringp(ident[m]))    return ident[m] + "=" + res;    return res;    }       string describe_comma_list(array x, int maxlen)    {    string ret="";       if(!sizeof(x)) return "";
pike.git/lib/master.pike.in:5084:    return bt;   }         #ifdef ENCODE_DEBUG   # define ENC_MSG(X...) do werror (X); while (0)   # define ENC_RETURN(val) do { \    mixed _v__ = (val); \    werror (" returned %s\n", \    zero_type (_v__) ? "UNDEFINED" : \ -  sprintf ("%O", _v__)); \ +  narrowify_string(sprintf ("%O", _v__))); \    return _v__; \   } while (0)   #else   # define ENC_MSG(X...) do {} while (0)   # define ENC_RETURN(val) do return (val); while (0)   #endif      #ifdef DECODE_DEBUG   # define DEC_MSG(X...) do werror (X); while (0)   # define DEC_RETURN(val) do { \    mixed _v__ = (val); \    werror (" returned %s\n", \    zero_type (_v__) ? "UNDEFINED" : \ -  sprintf ("%O", _v__)); \ +  narrowify_string(sprintf ("%O", _v__))); \    return _v__; \   } while (0)   #else   # define DEC_MSG(X...) do {} while (0)   # define DEC_RETURN(val) do return (val); while (0)   #endif      class Encoder   //! @appears Pike.Encoder   //!