From f4f08df9342c723e46f4bcd35cfa2c61a16483fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Fri, 26 Feb 1999 02:08:52 +0100 Subject: [PATCH] Added decode_charset(). Rev: lib/master.pike.in:1.39 --- lib/master.pike.in | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/lib/master.pike.in b/lib/master.pike.in index 7ea5a4d9ba..63e5ecc765 100644 --- a/lib/master.pike.in +++ b/lib/master.pike.in @@ -1,4 +1,4 @@ -/* $Id: master.pike.in,v 1.38 1999/02/04 23:45:12 mast Exp $ +/* $Id: master.pike.in,v 1.39 1999/02/26 01:08:52 grubba Exp $ * * Master-file for Pike. * @@ -473,6 +473,11 @@ class dirnode int _cache_full; void fill_cache() { +#ifdef RESOLV_DEBUG + werror(describe_backtrace(({ sprintf("Filling cache in dirnode %O\n", + dirname), + backtrace() }))); +#endif /* RESOLV_DEBUG */ if (_cache_full) { return; } @@ -569,6 +574,10 @@ class joinnode int _cache_full; void fill_cache() { +#ifdef RESOLV_DEBUG + werror(describe_backtrace(({ "Filling cache in joinnode\n", + backtrace() }))); +#endif /* RESOLV_DEBUG */ if (_cache_full) { return; } @@ -957,6 +966,38 @@ void compile_warning(string file,int line,string err) } +static mixed _charset_mod; +/* This function is called by cpp() when it wants to do + * character code conversion. + */ +string decode_charset(string data, string charset) +{ + werror(sprintf("decode_charset(%O, %O)\n", data, charset)); + + if (!_charset_mod) { + mixed mod = resolv("Locale"); + + _charset_mod = mod && mod["Charset"]; + if (!_charset_mod) { + compile_warning("-", 0, "No Locale.Charset module!"); + return 0; + } + } + + object decoder; + + catch { + decoder = _charset_mod->decoder(charset); + }; + + if (!decoder) { + compile_warning("-", 0, sprintf("Unknown charset %O!", charset)); + return 0; + } + return decoder->feed(data)->drain(); +} + + /* This function is called whenever an #include directive is encountered * it receives the argument for #include and should return the file name * of the file to include -- GitLab