Skip to content

Commit

Permalink
Update amalgamated sources
Browse files Browse the repository at this point in the history
  • Loading branch information
nekipelov committed Dec 29, 2016
1 parent e45dcce commit 3a0f405
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 58 deletions.
114 changes: 57 additions & 57 deletions amalgamated/redisclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ std::pair<size_t, RedisParser::ParseResult> RedisParser::parseArray(const char *
arrayStack.pop();
valueStack.pop();

size_t i = 0;
size_t position = 0;

if( arrayStack.empty() == false )
{
Expand All @@ -677,43 +677,43 @@ std::pair<size_t, RedisParser::ParseResult> RedisParser::parseArray(const char *
--arraySize;
}

i += pair.first;
position += pair.first;
}

if( i == size )
if( position == size )
{
valueStack.push(std::move(arrayValue));

if( arraySize == 0 )
{
return std::make_pair(i, Completed);
return std::make_pair(position, Completed);
}
else
{
arrayStack.push(arraySize);
return std::make_pair(i, Incompleted);
return std::make_pair(position, Incompleted);
}
}

long int x = 0;
long int arrayIndex = 0;

for(; x < arraySize; ++x)
for(; arrayIndex < arraySize; ++arrayIndex)
{
std::pair<size_t, RedisParser::ParseResult> pair = parse(ptr + i, size - i);
std::pair<size_t, RedisParser::ParseResult> pair = parse(ptr + position, size - position);

i += pair.first;
position += pair.first;

if( pair.second == Error )
{
return std::make_pair(i, Error);
return std::make_pair(position, Error);
}
else if( pair.second == Incompleted )
{
arraySize -= x;
arraySize -= arrayIndex;
valueStack.push(std::move(arrayValue));
arrayStack.push(arraySize);

return std::make_pair(i, Incompleted);
return std::make_pair(position, Incompleted);
}
else
{
Expand All @@ -723,19 +723,19 @@ std::pair<size_t, RedisParser::ParseResult> RedisParser::parseArray(const char *
}
}

assert( x == arraySize );
assert( arrayIndex == arraySize );

valueStack.push(std::move(arrayValue));
return std::make_pair(i, Completed);
return std::make_pair(position, Completed);
}

std::pair<size_t, RedisParser::ParseResult> RedisParser::parseChunk(const char *ptr, size_t size)
{
size_t i = 0;
size_t position = 0;

for(; i < size; ++i)
for(; position < size; ++position)
{
char c = ptr[i];
char c = ptr[position];

switch(state)
{
Expand All @@ -761,7 +761,7 @@ std::pair<size_t, RedisParser::ParseResult> RedisParser::parseChunk(const char *
break;
default:
state = Start;
return std::make_pair(i + 1, Error);
return std::make_pair(position + 1, Error);
}
break;
case String:
Expand All @@ -776,7 +776,7 @@ std::pair<size_t, RedisParser::ParseResult> RedisParser::parseChunk(const char *
else
{
state = Start;
return std::make_pair(i + 1, Error);
return std::make_pair(position + 1, Error);
}
break;
case ErrorString:
Expand All @@ -791,7 +791,7 @@ std::pair<size_t, RedisParser::ParseResult> RedisParser::parseChunk(const char *
else
{
state = Start;
return std::make_pair(i + 1, Error);
return std::make_pair(position + 1, Error);
}
break;
case BulkSize:
Expand All @@ -800,7 +800,7 @@ std::pair<size_t, RedisParser::ParseResult> RedisParser::parseChunk(const char *
if( buf.empty() )
{
state = Start;
return std::make_pair(i + 1, Error);
return std::make_pair(position + 1, Error);
}
else
{
Expand All @@ -814,20 +814,20 @@ std::pair<size_t, RedisParser::ParseResult> RedisParser::parseChunk(const char *
else
{
state = Start;
return std::make_pair(i + 1, Error);
return std::make_pair(position + 1, Error);
}
break;
case StringLF:
if( c == '\n')
{
state = Start;
valueStack.push(buf);
return std::make_pair(i + 1, Completed);
return std::make_pair(position + 1, Completed);
}
else
{
state = Start;
return std::make_pair(i + 1, Error);
return std::make_pair(position + 1, Error);
}
break;
case ErrorLF:
Expand All @@ -836,12 +836,12 @@ std::pair<size_t, RedisParser::ParseResult> RedisParser::parseChunk(const char *
state = Start;
RedisValue::ErrorTag tag;
valueStack.push(RedisValue(buf, tag));
return std::make_pair(i + 1, Completed);
return std::make_pair(position + 1, Completed);
}
else
{
state = Start;
return std::make_pair(i + 1, Error);
return std::make_pair(position + 1, Error);
}
break;
case BulkSizeLF:
Expand All @@ -854,7 +854,7 @@ std::pair<size_t, RedisParser::ParseResult> RedisParser::parseChunk(const char *
{
state = Start;
valueStack.push(RedisValue()); // Nil
return std::make_pair(i + 1, Completed);
return std::make_pair(position + 1, Completed);
}
else if( bulkSize == 0 )
{
Expand All @@ -863,27 +863,27 @@ std::pair<size_t, RedisParser::ParseResult> RedisParser::parseChunk(const char *
else if( bulkSize < 0 )
{
state = Start;
return std::make_pair(i + 1, Error);
return std::make_pair(position + 1, Error);
}
else
{
buf.reserve(bulkSize);

long int available = size - i - 1;
long int available = size - position - 1;
long int canRead = std::min(bulkSize, available);

if( canRead > 0 )
{
buf.assign(ptr + i + 1, ptr + i + canRead + 1);
buf.assign(ptr + position + 1, ptr + position + canRead + 1);
}

i += canRead;
position += canRead;

if( bulkSize > available )
{
bulkSize -= canRead;
state = Bulk;
return std::make_pair(i + 1, Incompleted);
return std::make_pair(position + 1, Incompleted);
}
else
{
Expand All @@ -894,30 +894,30 @@ std::pair<size_t, RedisParser::ParseResult> RedisParser::parseChunk(const char *
else
{
state = Start;
return std::make_pair(i + 1, Error);
return std::make_pair(position + 1, Error);
}
break;
case Bulk: {
assert( bulkSize > 0 );

long int available = size - i;
long int available = size - position;
long int canRead = std::min(available, bulkSize);

buf.insert(buf.end(), ptr + i, ptr + canRead);
buf.insert(buf.end(), ptr + position, ptr + canRead);
bulkSize -= canRead;
i += canRead - 1;
position += canRead - 1;

if( bulkSize > 0 )
{
return std::make_pair(i + 1, Incompleted);
return std::make_pair(position + 1, Incompleted);
}
else
{
state = BulkCR;

if( size == i + 1 )
if( size == position + 1 )
{
return std::make_pair(i + 1, Incompleted);
return std::make_pair(position + 1, Incompleted);
}
}
break;
Expand All @@ -930,20 +930,20 @@ std::pair<size_t, RedisParser::ParseResult> RedisParser::parseChunk(const char *
else
{
state = Start;
return std::make_pair(i + 1, Error);
return std::make_pair(position + 1, Error);
}
break;
case BulkLF:
if( c == '\n')
{
state = Start;
valueStack.push(buf);
return std::make_pair(i + 1, Completed);
return std::make_pair(position + 1, Completed);
}
else
{
state = Start;
return std::make_pair(i + 1, Error);
return std::make_pair(position + 1, Error);
}
break;
case ArraySize:
Expand All @@ -952,7 +952,7 @@ std::pair<size_t, RedisParser::ParseResult> RedisParser::parseChunk(const char *
if( buf.empty() )
{
state = Start;
return std::make_pair(i + 1, Error);
return std::make_pair(position + 1, Error);
}
else
{
Expand All @@ -966,7 +966,7 @@ std::pair<size_t, RedisParser::ParseResult> RedisParser::parseChunk(const char *
else
{
state = Start;
return std::make_pair(i + 1, Error);
return std::make_pair(position + 1, Error);
}
break;
case ArraySizeLF:
Expand All @@ -981,12 +981,12 @@ std::pair<size_t, RedisParser::ParseResult> RedisParser::parseChunk(const char *
{
state = Start;
valueStack.push(std::move(array)); // Empty array
return std::make_pair(i + 1, Completed);
return std::make_pair(position + 1, Completed);
}
else if( arraySize < 0 )
{
state = Start;
return std::make_pair(i + 1, Error);
return std::make_pair(position + 1, Error);
}
else
{
Expand All @@ -996,22 +996,22 @@ std::pair<size_t, RedisParser::ParseResult> RedisParser::parseChunk(const char *

state = Start;

if( i + 1 != size )
if( position + 1 != size )
{
std::pair<size_t, ParseResult> parseResult = parseArray(ptr + i + 1, size - i - 1);
parseResult.first += i + 1;
std::pair<size_t, ParseResult> parseResult = parseArray(ptr + position + 1, size - position - 1);
parseResult.first += position + 1;
return parseResult;
}
else
{
return std::make_pair(i + 1, Incompleted);
return std::make_pair(position + 1, Incompleted);
}
}
}
else
{
state = Start;
return std::make_pair(i + 1, Error);
return std::make_pair(position + 1, Error);
}
break;
case Integer:
Expand All @@ -1020,7 +1020,7 @@ std::pair<size_t, RedisParser::ParseResult> RedisParser::parseChunk(const char *
if( buf.empty() )
{
state = Start;
return std::make_pair(i + 1, Error);
return std::make_pair(position + 1, Error);
}
else
{
Expand All @@ -1034,7 +1034,7 @@ std::pair<size_t, RedisParser::ParseResult> RedisParser::parseChunk(const char *
else
{
state = Start;
return std::make_pair(i + 1, Error);
return std::make_pair(position + 1, Error);
}
break;
case IntegerLF:
Expand All @@ -1047,21 +1047,21 @@ std::pair<size_t, RedisParser::ParseResult> RedisParser::parseChunk(const char *
valueStack.push(value);
state = Start;

return std::make_pair(i + 1, Completed);
return std::make_pair(position + 1, Completed);
}
else
{
state = Start;
return std::make_pair(i + 1, Error);
return std::make_pair(position + 1, Error);
}
break;
default:
state = Start;
return std::make_pair(i + 1, Error);
return std::make_pair(position + 1, Error);
}
}

return std::make_pair(i, Incompleted);
return std::make_pair(position, Incompleted);
}

RedisValue RedisParser::result()
Expand Down
2 changes: 1 addition & 1 deletion amalgamated/redisclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#define REDISCLIENT_VERSION_H

#define REDIS_CLIENT_VERSION 500 // 0.5.0
#define REDIS_CLIENT_VERSION 501 // 0.5.1


/*
Expand Down

0 comments on commit 3a0f405

Please sign in to comment.