Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed bug in packInt

  • Loading branch information...
commit 41c7733d237d1720598e45716e49314cf0b60e93 1 parent 98b6c11
@waveto authored
Showing with 4 additions and 4 deletions.
  1. +4 −4 tyrant.js
View
8 tyrant.js
@@ -161,7 +161,7 @@ function unpackInt(si) {
// Convert an int into a 4 byte binary sting
function packInt(i) {
- return String.fromCharCode(Math.floor(i/(256*3))&0xff) + String.fromCharCode(Math.floor(i/(256*2))&0xff) + String.fromCharCode(Math.floor(i/256)&0xff) + String.fromCharCode(i%256);
+ return String.fromCharCode(Math.floor(i/Math.pow(256,3))&0xff) + String.fromCharCode(Math.floor(i/Math.pow(256,2))&0xff) + String.fromCharCode(Math.floor(i/256)&0xff) + String.fromCharCode(i%256);
}
@@ -215,7 +215,7 @@ function responseNone(data) {
}
function responseInt(data) {
- if (data.charCodeAt(0)!=0) return [null, 1, 'Tyrant Error : '+data.charCodeAt(0)];
+ if (data.charCodeAt(0)!=0) return [null, 1, 'Tyrant Error : '+data.charCodeAt(0)];
if (data.length<5) return [null, -1, null];
var rlen=unpackInt(data.slice(1, 5));
return [rlen, 5, null];
@@ -312,8 +312,8 @@ exports.dict = function (r) {
function onReceive(data) {
- //sys.puts('Received: '+data.length+', response : '+response.length);
- //pprint(data);
+ //sys.puts('Received: '+data.length+', response : '+response.length);
+ //pprint(data);
response += data;
var offset=0;
while (callbacks[0] && (offset>=0) && (response.length>0)) {
Please sign in to comment.
Something went wrong with that request. Please try again.