[Issue 5366] New: std.json parseJSON incorrectly parses unicode entities

2010-12-23 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5366

   Summary: std.json parseJSON incorrectly parses unicode entities
   Product: D
   Version: D2
  Platform: All
OS/Version: All
Status: NEW
  Severity: normal
  Priority: P2
 Component: Phobos
AssignedTo: nob...@puremagic.com
ReportedBy: ibuc...@ubuntu.com


--- Comment #0 from Iain Buclaw ibuc...@ubuntu.com 2010-12-23 10:03:20 PST ---
import std.json;
import std.stdio;

void main()
{
auto res = parseJSON(`\u00F6`);
writefln(%s,res.str); // this should write �
}



Patch:
--- d~/phobos/std/json.d
+++ d/phobos/std/json.d
@@ -156,7 +156,7 @@
 foreach_reverse(i; 0 .. 4) {
 auto hex = toupper(getChar());
 if(!isxdigit(hex)) error(Expecting
hex character);
-val += (isdigit(hex) ? hex - '0' : hex
- 'A')  (4 * i);
+val += (isdigit(hex) ? hex - '0' : hex
- '7')  (4 * i);
 }
 char[4] buf = void;
 str.put(toUTF8(buf, val));



Or (somewhat easier to under):
--- d~/phobos2/std/json.d
+++ d/phobos2/std/json.d
@@ -156,7 +156,7 @@
 foreach_reverse(i; 0 .. 4) {
 auto hex = toupper(getChar());
 if(!isxdigit(hex)) error(Expecting
hex character);
-val += (isdigit(hex) ? hex - '0' : hex
- 'A')  (4 * i);
+val += (isdigit(hex) ? hex - '0' : hex
- 'A' + 10)  (4 * i);
 }
 char[4] buf = void;
 str.put(toUTF8(buf, val));


Regards

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


GC.collect() and GC.minimize() not releasing memory

2010-12-23 Thread %u
Hi,

I'm running this piece of code, but the memory isn't getting freed (as judging
from Task Manager). It doesn't help if I call collect() and minimize() in a
loop... is something wrong? Or is Task Manager not a reliable indicator of this?

Thank you!


import std.stdio;
import core.memory;
import core.thread;

void writelnflush(T...)(T args) { writeln(args); stdout.flush(); }
void allocate() { new byte[1024 * 1024 * 64]; }

void main()
{
writelnflush(Sleeping (check the memory usage!)...);
Thread.sleep(4 * 1000);
writelnflush(Allocating...);
allocate();
writelnflush(Collecting...);
GC.collect();
GC.minimize();
writelnflush(Sleeping (check the memory usage!)...);
Thread.sleep(4 * 1000);
}


Re: GC.collect() and GC.minimize() not releasing memory

2010-12-23 Thread torhu
This newsgroup is just for automated use by Bugzilla.  You should post 
to d.D or d.learn instead.  Or use the Bugzilla at 
http://d.puremagic.com/issues/ (search before posting a new issue).