Commit bfe85f7c authored by antirez's avatar antirez
Browse files

Merge branch 'unstable'

parents b8513c93 6b52ad87
...@@ -42,6 +42,16 @@ struct sdshdr { ...@@ -42,6 +42,16 @@ struct sdshdr {
char buf[]; char buf[];
}; };
static inline size_t sdslen(const sds s) {
struct sdshdr *sh = (void*)(s-(sizeof(struct sdshdr)));
return sh->len;
}
static inline size_t sdsavail(const sds s) {
struct sdshdr *sh = (void*)(s-(sizeof(struct sdshdr)));
return sh->free;
}
sds sdsnewlen(const void *init, size_t initlen); sds sdsnewlen(const void *init, size_t initlen);
sds sdsnew(const char *init); sds sdsnew(const char *init);
sds sdsempty(); sds sdsempty();
...@@ -74,5 +84,6 @@ void sdstoupper(sds s); ...@@ -74,5 +84,6 @@ void sdstoupper(sds s);
sds sdsfromlonglong(long long value); sds sdsfromlonglong(long long value);
sds sdscatrepr(sds s, char *p, size_t len); sds sdscatrepr(sds s, char *p, size_t len);
sds *sdssplitargs(char *line, int *argc); sds *sdssplitargs(char *line, int *argc);
void sdssplitargs_free(sds *argv, int argc);
#endif #endif
...@@ -199,6 +199,9 @@ void sortCommand(redisClient *c) { ...@@ -199,6 +199,9 @@ void sortCommand(redisClient *c) {
j++; j++;
} }
/* Destructively convert encoded sorted sets for SORT. */
if (sortval->type == REDIS_ZSET) zsetConvert(sortval, REDIS_ENCODING_SKIPLIST);
/* Load the sorting vector with all the objects to sort */ /* Load the sorting vector with all the objects to sort */
switch(sortval->type) { switch(sortval->type) {
case REDIS_LIST: vectorlen = listTypeLength(sortval); break; case REDIS_LIST: vectorlen = listTypeLength(sortval); break;
......
...@@ -107,6 +107,7 @@ int syncReadLine(int fd, char *ptr, ssize_t size, int timeout) { ...@@ -107,6 +107,7 @@ int syncReadLine(int fd, char *ptr, ssize_t size, int timeout) {
int fwriteBulkString(FILE *fp, char *s, unsigned long len) { int fwriteBulkString(FILE *fp, char *s, unsigned long len) {
char cbuf[128]; char cbuf[128];
int clen; int clen;
cbuf[0] = '$'; cbuf[0] = '$';
clen = 1+ll2string(cbuf+1,sizeof(cbuf)-1,len); clen = 1+ll2string(cbuf+1,sizeof(cbuf)-1,len);
cbuf[clen++] = '\r'; cbuf[clen++] = '\r';
...@@ -117,6 +118,19 @@ int fwriteBulkString(FILE *fp, char *s, unsigned long len) { ...@@ -117,6 +118,19 @@ int fwriteBulkString(FILE *fp, char *s, unsigned long len) {
return 1; return 1;
} }
/* Write a multi bulk count in the form "*<count>\r\n" */
int fwriteBulkCount(FILE *fp, char prefix, int count) {
char cbuf[128];
int clen;
cbuf[0] = prefix;
clen = 1+ll2string(cbuf+1,sizeof(cbuf)-1,count);
cbuf[clen++] = '\r';
cbuf[clen++] = '\n';
if (fwrite(cbuf,clen,1,fp) == 0) return 0;
return 1;
}
/* Write a double value in bulk format $<count>\r\n<payload>\r\n */ /* Write a double value in bulk format $<count>\r\n<payload>\r\n */
int fwriteBulkDouble(FILE *fp, double d) { int fwriteBulkDouble(FILE *fp, double d) {
char buf[128], dbuf[128]; char buf[128], dbuf[128];
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#ifndef __REDIS_UTIL_H
#define __REDIS_UTIL_H
int stringmatchlen(const char *p, int plen, const char *s, int slen, int nocase);
int stringmatch(const char *p, const char *s, int nocase);
long long memtoll(const char *p, int *err);
int ll2string(char *s, size_t len, long long value);
int string2ll(char *s, size_t slen, long long *value);
int string2l(char *s, size_t slen, long *value);
int d2string(char *buf, size_t len, double value);
#endif
#define REDIS_VERSION "2.3.0" #define REDIS_VERSION "2.9.0"
This diff is collapsed.
This diff is collapsed.
...@@ -214,7 +214,7 @@ proc start_server {options {code undefined}} { ...@@ -214,7 +214,7 @@ proc start_server {options {code undefined}} {
# find out the pid # find out the pid
while {![info exists pid]} { while {![info exists pid]} {
regexp {^\[(\d+)\]} [exec head -n1 $stdout] _ pid regexp {\[(\d+)\]} [exec cat $stdout] _ pid
after 100 after 100
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment