2015-07-25 11:08:44 -04:00
|
|
|
/* SDSLib 2.0 -- A C dynamic strings library
|
2009-03-22 05:30:00 -04:00
|
|
|
*
|
2015-07-25 11:08:44 -04:00
|
|
|
* Copyright (c) 2006-2015, Salvatore Sanfilippo <antirez at gmail dot com>
|
2015-07-25 11:41:56 -04:00
|
|
|
* Copyright (c) 2015, Oran Agra
|
2015-07-25 11:08:44 -04:00
|
|
|
* Copyright (c) 2015, Redis Labs, Inc
|
2009-03-22 05:30:00 -04:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* * Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* * Neither the name of Redis nor the names of its contributors may be used
|
|
|
|
* to endorse or promote products derived from this software without
|
|
|
|
* specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
2011-11-02 11:50:59 -04:00
|
|
|
#include <assert.h>
|
2016-09-01 05:04:22 -04:00
|
|
|
#include <limits.h>
|
2011-04-19 17:10:45 -04:00
|
|
|
#include "sds.h"
|
2015-07-25 11:25:44 -04:00
|
|
|
#include "sdsalloc.h"
|
2009-03-22 05:30:00 -04:00
|
|
|
|
2017-02-23 06:04:08 -05:00
|
|
|
const char *SDS_NOINIT = "SDS_NOINIT";
|
|
|
|
|
2015-04-09 03:37:01 -04:00
|
|
|
static inline int sdsHdrSize(char type) {
|
|
|
|
switch(type&SDS_TYPE_MASK) {
|
2015-07-15 06:24:49 -04:00
|
|
|
case SDS_TYPE_5:
|
|
|
|
return sizeof(struct sdshdr5);
|
2015-04-09 03:37:01 -04:00
|
|
|
case SDS_TYPE_8:
|
|
|
|
return sizeof(struct sdshdr8);
|
|
|
|
case SDS_TYPE_16:
|
|
|
|
return sizeof(struct sdshdr16);
|
|
|
|
case SDS_TYPE_32:
|
|
|
|
return sizeof(struct sdshdr32);
|
|
|
|
case SDS_TYPE_64:
|
|
|
|
return sizeof(struct sdshdr64);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline char sdsReqType(size_t string_size) {
|
2016-05-09 02:12:38 -04:00
|
|
|
if (string_size < 1<<5)
|
2015-07-15 06:24:49 -04:00
|
|
|
return SDS_TYPE_5;
|
2016-05-09 02:12:38 -04:00
|
|
|
if (string_size < 1<<8)
|
2015-04-09 03:37:01 -04:00
|
|
|
return SDS_TYPE_8;
|
2016-05-09 02:12:38 -04:00
|
|
|
if (string_size < 1<<16)
|
2015-04-09 03:37:01 -04:00
|
|
|
return SDS_TYPE_16;
|
2016-09-01 05:04:22 -04:00
|
|
|
#if (LONG_MAX == LLONG_MAX)
|
2016-05-09 02:12:38 -04:00
|
|
|
if (string_size < 1ll<<32)
|
2015-04-09 03:37:01 -04:00
|
|
|
return SDS_TYPE_32;
|
|
|
|
return SDS_TYPE_64;
|
2018-07-15 11:24:18 -04:00
|
|
|
#else
|
|
|
|
return SDS_TYPE_32;
|
|
|
|
#endif
|
2015-04-09 03:37:01 -04:00
|
|
|
}
|
|
|
|
|
2020-10-02 01:19:44 -04:00
|
|
|
static inline size_t sdsTypeMaxSize(char type) {
|
|
|
|
if (type == SDS_TYPE_5)
|
|
|
|
return (1<<5) - 1;
|
|
|
|
if (type == SDS_TYPE_8)
|
|
|
|
return (1<<8) - 1;
|
|
|
|
if (type == SDS_TYPE_16)
|
|
|
|
return (1<<16) - 1;
|
|
|
|
#if (LONG_MAX == LLONG_MAX)
|
|
|
|
if (type == SDS_TYPE_32)
|
|
|
|
return (1ll<<32) - 1;
|
|
|
|
#endif
|
|
|
|
return -1; /* this is equivalent to the max SDS_TYPE_64 or SDS_TYPE_32 */
|
|
|
|
}
|
|
|
|
|
2013-07-23 10:35:55 -04:00
|
|
|
/* Create a new sds string with the content specified by the 'init' pointer
|
|
|
|
* and 'initlen'.
|
|
|
|
* If NULL is used for 'init' the string is initialized with zero bytes.
|
2017-02-23 06:04:08 -05:00
|
|
|
* If SDS_NOINIT is used, the buffer is left uninitialized;
|
2013-07-23 10:35:55 -04:00
|
|
|
*
|
2021-06-10 08:39:33 -04:00
|
|
|
* The string is always null-terminated (all the sds strings are, always) so
|
2013-07-23 10:35:55 -04:00
|
|
|
* even if you create an sds string with:
|
|
|
|
*
|
2014-07-17 03:25:24 -04:00
|
|
|
* mystring = sdsnewlen("abc",3);
|
2013-07-23 10:35:55 -04:00
|
|
|
*
|
|
|
|
* You can print the string with printf() as there is an implicit \0 at the
|
|
|
|
* end of the string. However the string is binary safe and can contain
|
|
|
|
* \0 characters in the middle, as the length is stored in the sds header. */
|
2020-11-22 14:22:49 -05:00
|
|
|
sds _sdsnewlen(const void *init, size_t initlen, int trymalloc) {
|
2015-04-09 03:37:01 -04:00
|
|
|
void *sh;
|
|
|
|
sds s;
|
|
|
|
char type = sdsReqType(initlen);
|
2015-07-23 03:16:47 -04:00
|
|
|
/* Empty strings are usually created in order to append. Use type 8
|
|
|
|
* since type 5 is not good at this. */
|
|
|
|
if (type == SDS_TYPE_5 && initlen == 0) type = SDS_TYPE_8;
|
2015-04-09 03:37:01 -04:00
|
|
|
int hdrlen = sdsHdrSize(type);
|
2015-07-15 06:24:49 -04:00
|
|
|
unsigned char *fp; /* flags pointer. */
|
2020-10-02 01:19:44 -04:00
|
|
|
size_t usable;
|
2015-07-15 06:24:49 -04:00
|
|
|
|
2021-02-22 08:41:32 -05:00
|
|
|
assert(initlen + hdrlen + 1 > initlen); /* Catch size_t overflow */
|
2020-11-22 14:22:49 -05:00
|
|
|
sh = trymalloc?
|
|
|
|
s_trymalloc_usable(hdrlen+initlen+1, &usable) :
|
|
|
|
s_malloc_usable(hdrlen+initlen+1, &usable);
|
2020-04-16 10:08:37 -04:00
|
|
|
if (sh == NULL) return NULL;
|
2017-02-23 06:04:08 -05:00
|
|
|
if (init==SDS_NOINIT)
|
|
|
|
init = NULL;
|
|
|
|
else if (!init)
|
2015-04-09 03:37:01 -04:00
|
|
|
memset(sh, 0, hdrlen+initlen+1);
|
|
|
|
s = (char*)sh+hdrlen;
|
2015-07-15 06:24:49 -04:00
|
|
|
fp = ((unsigned char*)s)-1;
|
2020-10-02 01:19:44 -04:00
|
|
|
usable = usable-hdrlen-1;
|
|
|
|
if (usable > sdsTypeMaxSize(type))
|
|
|
|
usable = sdsTypeMaxSize(type);
|
2015-04-09 03:37:01 -04:00
|
|
|
switch(type) {
|
2015-07-15 06:24:49 -04:00
|
|
|
case SDS_TYPE_5: {
|
|
|
|
*fp = type | (initlen << SDS_TYPE_BITS);
|
|
|
|
break;
|
|
|
|
}
|
2015-04-09 03:37:01 -04:00
|
|
|
case SDS_TYPE_8: {
|
|
|
|
SDS_HDR_VAR(8,s);
|
|
|
|
sh->len = initlen;
|
2020-10-02 01:19:44 -04:00
|
|
|
sh->alloc = usable;
|
2015-07-15 06:24:49 -04:00
|
|
|
*fp = type;
|
2015-04-09 03:37:01 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SDS_TYPE_16: {
|
|
|
|
SDS_HDR_VAR(16,s);
|
|
|
|
sh->len = initlen;
|
2020-10-02 01:19:44 -04:00
|
|
|
sh->alloc = usable;
|
2015-07-15 06:24:49 -04:00
|
|
|
*fp = type;
|
2015-04-09 03:37:01 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SDS_TYPE_32: {
|
|
|
|
SDS_HDR_VAR(32,s);
|
|
|
|
sh->len = initlen;
|
2020-10-02 01:19:44 -04:00
|
|
|
sh->alloc = usable;
|
2015-07-15 06:24:49 -04:00
|
|
|
*fp = type;
|
2015-04-09 03:37:01 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SDS_TYPE_64: {
|
|
|
|
SDS_HDR_VAR(64,s);
|
|
|
|
sh->len = initlen;
|
2020-10-02 01:19:44 -04:00
|
|
|
sh->alloc = usable;
|
2015-07-15 06:24:49 -04:00
|
|
|
*fp = type;
|
2015-04-09 03:37:01 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-04-01 12:59:28 -04:00
|
|
|
if (initlen && init)
|
2015-04-09 03:37:01 -04:00
|
|
|
memcpy(s, init, initlen);
|
|
|
|
s[initlen] = '\0';
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2020-11-22 14:22:49 -05:00
|
|
|
sds sdsnewlen(const void *init, size_t initlen) {
|
|
|
|
return _sdsnewlen(init, initlen, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
sds sdstrynewlen(const void *init, size_t initlen) {
|
|
|
|
return _sdsnewlen(init, initlen, 1);
|
|
|
|
}
|
|
|
|
|
2013-07-23 10:35:55 -04:00
|
|
|
/* Create an empty (zero length) sds string. Even in this case the string
|
|
|
|
* always has an implicit null term. */
|
2009-03-22 05:30:00 -04:00
|
|
|
sds sdsempty(void) {
|
|
|
|
return sdsnewlen("",0);
|
|
|
|
}
|
|
|
|
|
2015-04-19 11:42:27 -04:00
|
|
|
/* Create a new sds string starting from a null terminated C string. */
|
2009-03-22 05:30:00 -04:00
|
|
|
sds sdsnew(const char *init) {
|
|
|
|
size_t initlen = (init == NULL) ? 0 : strlen(init);
|
|
|
|
return sdsnewlen(init, initlen);
|
|
|
|
}
|
|
|
|
|
2013-07-23 10:35:55 -04:00
|
|
|
/* Duplicate an sds string. */
|
2009-03-22 05:30:00 -04:00
|
|
|
sds sdsdup(const sds s) {
|
|
|
|
return sdsnewlen(s, sdslen(s));
|
|
|
|
}
|
|
|
|
|
2013-07-23 10:35:55 -04:00
|
|
|
/* Free an sds string. No operation is performed if 's' is NULL. */
|
2009-03-22 05:30:00 -04:00
|
|
|
void sdsfree(sds s) {
|
|
|
|
if (s == NULL) return;
|
2015-07-25 11:25:44 -04:00
|
|
|
s_free((char*)s-sdsHdrSize(s[-1]));
|
2009-03-22 05:30:00 -04:00
|
|
|
}
|
|
|
|
|
2013-07-23 10:35:55 -04:00
|
|
|
/* Set the sds string length to the length as obtained with strlen(), so
|
|
|
|
* considering as content only up to the first null term character.
|
|
|
|
*
|
|
|
|
* This function is useful when the sds string is hacked manually in some
|
|
|
|
* way, like in the following example:
|
|
|
|
*
|
|
|
|
* s = sdsnew("foobar");
|
|
|
|
* s[2] = '\0';
|
|
|
|
* sdsupdatelen(s);
|
|
|
|
* printf("%d\n", sdslen(s));
|
|
|
|
*
|
|
|
|
* The output will be "2", but if we comment out the call to sdsupdatelen()
|
|
|
|
* the output will be "6" as the string was modified but the logical length
|
|
|
|
* remains 6 bytes. */
|
2009-03-22 05:30:00 -04:00
|
|
|
void sdsupdatelen(sds s) {
|
2017-12-21 04:10:48 -05:00
|
|
|
size_t reallen = strlen(s);
|
2015-04-09 03:37:01 -04:00
|
|
|
sdssetlen(s, reallen);
|
2009-03-22 05:30:00 -04:00
|
|
|
}
|
|
|
|
|
2013-11-08 18:38:41 -05:00
|
|
|
/* Modify an sds string in-place to make it empty (zero length).
|
2013-07-23 10:35:55 -04:00
|
|
|
* However all the existing buffer is not discarded but set as free space
|
|
|
|
* so that next append operations will not require allocations up to the
|
|
|
|
* number of bytes previously available. */
|
2011-08-18 06:44:30 -04:00
|
|
|
void sdsclear(sds s) {
|
2015-04-09 03:37:01 -04:00
|
|
|
sdssetlen(s, 0);
|
|
|
|
s[0] = '\0';
|
2011-08-18 06:44:30 -04:00
|
|
|
}
|
|
|
|
|
2011-11-02 11:09:14 -04:00
|
|
|
/* Enlarge the free space at the end of the sds string so that the caller
|
|
|
|
* is sure that after calling this function can overwrite up to addlen
|
|
|
|
* bytes after the end of the string, plus one more byte for nul term.
|
2021-06-15 07:46:19 -04:00
|
|
|
* If there's already sufficient free space, this function returns without any
|
|
|
|
* action, if there isn't sufficient free space, it'll allocate what's missing,
|
|
|
|
* and possibly more:
|
|
|
|
* When greedy is 1, enlarge more than needed, to avoid need for future reallocs
|
|
|
|
* on incremental growth.
|
|
|
|
* When greedy is 0, enlarge just enough so that there's free space for 'addlen'.
|
2014-06-26 12:48:40 -04:00
|
|
|
*
|
2013-07-23 10:35:55 -04:00
|
|
|
* Note: this does not change the *length* of the sds string as returned
|
2011-11-02 11:09:14 -04:00
|
|
|
* by sdslen(), but only the free buffer space we have. */
|
2021-06-15 07:46:19 -04:00
|
|
|
sds _sdsMakeRoomFor(sds s, size_t addlen, int greedy) {
|
2015-04-09 03:37:01 -04:00
|
|
|
void *sh, *newsh;
|
|
|
|
size_t avail = sdsavail(s);
|
2021-10-04 04:11:09 -04:00
|
|
|
size_t len, newlen, reqlen;
|
2015-07-15 06:24:49 -04:00
|
|
|
char type, oldtype = s[-1] & SDS_TYPE_MASK;
|
2015-04-09 03:37:01 -04:00
|
|
|
int hdrlen;
|
2020-10-02 01:19:44 -04:00
|
|
|
size_t usable;
|
2009-03-22 05:30:00 -04:00
|
|
|
|
2015-07-23 03:16:47 -04:00
|
|
|
/* Return ASAP if there is enough space left. */
|
2015-04-09 03:37:01 -04:00
|
|
|
if (avail >= addlen) return s;
|
2015-07-23 03:16:47 -04:00
|
|
|
|
2009-03-22 05:30:00 -04:00
|
|
|
len = sdslen(s);
|
2015-04-09 03:37:01 -04:00
|
|
|
sh = (char*)s-sdsHdrSize(oldtype);
|
2021-10-04 04:11:09 -04:00
|
|
|
reqlen = newlen = (len+addlen);
|
2021-02-22 08:41:32 -05:00
|
|
|
assert(newlen > len); /* Catch size_t overflow */
|
2021-06-15 07:46:19 -04:00
|
|
|
if (greedy == 1) {
|
|
|
|
if (newlen < SDS_MAX_PREALLOC)
|
|
|
|
newlen *= 2;
|
|
|
|
else
|
|
|
|
newlen += SDS_MAX_PREALLOC;
|
|
|
|
}
|
2009-10-07 11:34:00 -04:00
|
|
|
|
2015-04-09 03:37:01 -04:00
|
|
|
type = sdsReqType(newlen);
|
2015-07-23 03:16:47 -04:00
|
|
|
|
|
|
|
/* Don't use type 5: the user is appending to the string and type 5 is
|
|
|
|
* not able to remember empty space, so sdsMakeRoomFor() must be called
|
|
|
|
* at every appending operation. */
|
|
|
|
if (type == SDS_TYPE_5) type = SDS_TYPE_8;
|
|
|
|
|
2015-04-09 03:37:01 -04:00
|
|
|
hdrlen = sdsHdrSize(type);
|
2021-10-04 04:11:09 -04:00
|
|
|
assert(hdrlen + newlen + 1 > reqlen); /* Catch size_t overflow */
|
2015-04-09 03:37:01 -04:00
|
|
|
if (oldtype==type) {
|
2020-10-02 01:19:44 -04:00
|
|
|
newsh = s_realloc_usable(sh, hdrlen+newlen+1, &usable);
|
2015-04-09 03:37:01 -04:00
|
|
|
if (newsh == NULL) return NULL;
|
|
|
|
s = (char*)newsh+hdrlen;
|
|
|
|
} else {
|
2015-07-15 06:24:49 -04:00
|
|
|
/* Since the header size changes, need to move the string forward,
|
|
|
|
* and can't use realloc */
|
2020-10-02 01:19:44 -04:00
|
|
|
newsh = s_malloc_usable(hdrlen+newlen+1, &usable);
|
2015-04-09 03:37:01 -04:00
|
|
|
if (newsh == NULL) return NULL;
|
|
|
|
memcpy((char*)newsh+hdrlen, s, len+1);
|
2015-07-25 11:25:44 -04:00
|
|
|
s_free(sh);
|
2015-04-09 03:37:01 -04:00
|
|
|
s = (char*)newsh+hdrlen;
|
|
|
|
s[-1] = type;
|
|
|
|
sdssetlen(s, len);
|
|
|
|
}
|
2020-10-02 01:19:44 -04:00
|
|
|
usable = usable-hdrlen-1;
|
|
|
|
if (usable > sdsTypeMaxSize(type))
|
|
|
|
usable = sdsTypeMaxSize(type);
|
|
|
|
sdssetalloc(s, usable);
|
2015-04-09 03:37:01 -04:00
|
|
|
return s;
|
2009-03-22 05:30:00 -04:00
|
|
|
}
|
|
|
|
|
2021-06-15 07:46:19 -04:00
|
|
|
/* Enlarge the free space at the end of the sds string more than needed,
|
|
|
|
* This is useful to avoid repeated re-allocations when repeatedly appending to the sds. */
|
|
|
|
sds sdsMakeRoomFor(sds s, size_t addlen) {
|
|
|
|
return _sdsMakeRoomFor(s, addlen, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Unlike sdsMakeRoomFor(), this one just grows to the necessary size. */
|
|
|
|
sds sdsMakeRoomForNonGreedy(sds s, size_t addlen) {
|
|
|
|
return _sdsMakeRoomFor(s, addlen, 0);
|
|
|
|
}
|
|
|
|
|
2012-03-14 05:13:23 -04:00
|
|
|
/* Reallocate the sds string so that it has no free space at the end. The
|
|
|
|
* contained string remains not altered, but next concatenation operations
|
2013-07-23 10:35:55 -04:00
|
|
|
* will require a reallocation.
|
|
|
|
*
|
|
|
|
* After the call, the passed sds string is no longer valid and all the
|
|
|
|
* references must be substituted with the new pointer returned by the call. */
|
2012-03-14 05:13:23 -04:00
|
|
|
sds sdsRemoveFreeSpace(sds s) {
|
2015-04-09 03:37:01 -04:00
|
|
|
void *sh, *newsh;
|
2015-07-15 06:24:49 -04:00
|
|
|
char type, oldtype = s[-1] & SDS_TYPE_MASK;
|
2017-11-03 05:19:27 -04:00
|
|
|
int hdrlen, oldhdrlen = sdsHdrSize(oldtype);
|
2015-04-09 03:37:01 -04:00
|
|
|
size_t len = sdslen(s);
|
2019-02-12 08:21:21 -05:00
|
|
|
size_t avail = sdsavail(s);
|
2017-11-03 05:19:27 -04:00
|
|
|
sh = (char*)s-oldhdrlen;
|
2015-04-09 03:37:01 -04:00
|
|
|
|
2019-02-12 08:21:21 -05:00
|
|
|
/* Return ASAP if there is no space left. */
|
|
|
|
if (avail == 0) return s;
|
|
|
|
|
2017-11-03 05:19:27 -04:00
|
|
|
/* Check what would be the minimum SDS header that is just good enough to
|
|
|
|
* fit this string. */
|
2015-04-09 03:37:01 -04:00
|
|
|
type = sdsReqType(len);
|
|
|
|
hdrlen = sdsHdrSize(type);
|
2017-11-03 05:19:27 -04:00
|
|
|
|
|
|
|
/* If the type is the same, or at least a large enough type is still
|
|
|
|
* required, we just realloc(), letting the allocator to do the copy
|
|
|
|
* only if really needed. Otherwise if the change is huge, we manually
|
|
|
|
* reallocate the string to use the different header type. */
|
|
|
|
if (oldtype==type || type > SDS_TYPE_8) {
|
|
|
|
newsh = s_realloc(sh, oldhdrlen+len+1);
|
2015-04-09 03:37:01 -04:00
|
|
|
if (newsh == NULL) return NULL;
|
2017-11-03 05:19:27 -04:00
|
|
|
s = (char*)newsh+oldhdrlen;
|
2015-04-09 03:37:01 -04:00
|
|
|
} else {
|
2015-07-25 11:25:44 -04:00
|
|
|
newsh = s_malloc(hdrlen+len+1);
|
2015-04-09 03:37:01 -04:00
|
|
|
if (newsh == NULL) return NULL;
|
|
|
|
memcpy((char*)newsh+hdrlen, s, len+1);
|
2015-07-25 11:25:44 -04:00
|
|
|
s_free(sh);
|
2015-04-09 03:37:01 -04:00
|
|
|
s = (char*)newsh+hdrlen;
|
|
|
|
s[-1] = type;
|
|
|
|
sdssetlen(s, len);
|
|
|
|
}
|
|
|
|
sdssetalloc(s, len);
|
|
|
|
return s;
|
2012-03-14 05:13:23 -04:00
|
|
|
}
|
|
|
|
|
2021-07-05 02:02:54 -04:00
|
|
|
/* Resize the allocation, this can make the allocation bigger or smaller,
|
|
|
|
* if the size is smaller than currently used len, the data will be truncated */
|
|
|
|
sds sdsResize(sds s, size_t size) {
|
|
|
|
void *sh, *newsh;
|
|
|
|
char type, oldtype = s[-1] & SDS_TYPE_MASK;
|
|
|
|
int hdrlen, oldhdrlen = sdsHdrSize(oldtype);
|
|
|
|
size_t len = sdslen(s);
|
|
|
|
sh = (char*)s-oldhdrlen;
|
|
|
|
|
|
|
|
/* Return ASAP if the size is already good. */
|
|
|
|
if (sdsalloc(s) == size) return s;
|
|
|
|
|
|
|
|
/* Truncate len if needed. */
|
|
|
|
if (size < len) len = size;
|
|
|
|
|
|
|
|
/* Check what would be the minimum SDS header that is just good enough to
|
|
|
|
* fit this string. */
|
|
|
|
type = sdsReqType(size);
|
|
|
|
/* Don't use type 5, it is not good for strings that are resized. */
|
|
|
|
if (type == SDS_TYPE_5) type = SDS_TYPE_8;
|
|
|
|
hdrlen = sdsHdrSize(type);
|
|
|
|
|
|
|
|
/* If the type is the same, or can hold the size in it with low overhead
|
|
|
|
* (larger than SDS_TYPE_8), we just realloc(), letting the allocator
|
|
|
|
* to do the copy only if really needed. Otherwise if the change is
|
|
|
|
* huge, we manually reallocate the string to use the different header
|
|
|
|
* type. */
|
|
|
|
if (oldtype==type || (type < oldtype && type > SDS_TYPE_8)) {
|
|
|
|
newsh = s_realloc(sh, oldhdrlen+size+1);
|
|
|
|
if (newsh == NULL) return NULL;
|
|
|
|
s = (char*)newsh+oldhdrlen;
|
|
|
|
} else {
|
|
|
|
newsh = s_malloc(hdrlen+size+1);
|
|
|
|
if (newsh == NULL) return NULL;
|
|
|
|
memcpy((char*)newsh+hdrlen, s, len);
|
|
|
|
s_free(sh);
|
|
|
|
s = (char*)newsh+hdrlen;
|
|
|
|
s[-1] = type;
|
|
|
|
}
|
|
|
|
s[len] = 0;
|
|
|
|
sdssetlen(s, len);
|
|
|
|
sdssetalloc(s, size);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2018-07-01 01:24:50 -04:00
|
|
|
/* Return the total size of the allocation of the specified sds string,
|
2013-07-23 10:35:55 -04:00
|
|
|
* including:
|
|
|
|
* 1) The sds header before the pointer.
|
|
|
|
* 2) The string.
|
|
|
|
* 3) The free buffer at the end if any.
|
|
|
|
* 4) The implicit null term.
|
|
|
|
*/
|
2012-03-14 09:58:26 -04:00
|
|
|
size_t sdsAllocSize(sds s) {
|
2015-04-09 03:37:01 -04:00
|
|
|
size_t alloc = sdsalloc(s);
|
|
|
|
return sdsHdrSize(s[-1])+alloc+1;
|
|
|
|
}
|
2012-03-14 09:58:26 -04:00
|
|
|
|
2015-07-25 11:25:44 -04:00
|
|
|
/* Return the pointer of the actual SDS allocation (normally SDS strings
|
|
|
|
* are referenced by the start of the string buffer). */
|
|
|
|
void *sdsAllocPtr(sds s) {
|
|
|
|
return (void*) (s-sdsHdrSize(s[-1]));
|
2012-03-14 09:58:26 -04:00
|
|
|
}
|
|
|
|
|
2011-11-02 11:50:59 -04:00
|
|
|
/* Increment the sds length and decrements the left free space at the
|
2013-07-23 10:35:55 -04:00
|
|
|
* end of the string according to 'incr'. Also set the null term
|
2011-11-02 11:50:59 -04:00
|
|
|
* in the new end of the string.
|
|
|
|
*
|
|
|
|
* This function is used in order to fix the string length after the
|
|
|
|
* user calls sdsMakeRoomFor(), writes something after the end of
|
|
|
|
* the current string, and finally needs to set the new length.
|
|
|
|
*
|
|
|
|
* Note: it is possible to use a negative increment in order to
|
|
|
|
* right-trim the string.
|
|
|
|
*
|
2013-07-23 10:35:55 -04:00
|
|
|
* Usage example:
|
|
|
|
*
|
2011-11-02 11:50:59 -04:00
|
|
|
* Using sdsIncrLen() and sdsMakeRoomFor() it is possible to mount the
|
2013-07-23 10:35:55 -04:00
|
|
|
* following schema, to cat bytes coming from the kernel to the end of an
|
|
|
|
* sds string without copying into an intermediate buffer:
|
2011-11-02 11:50:59 -04:00
|
|
|
*
|
|
|
|
* oldlen = sdslen(s);
|
|
|
|
* s = sdsMakeRoomFor(s, BUFFER_SIZE);
|
|
|
|
* nread = read(fd, s+oldlen, BUFFER_SIZE);
|
|
|
|
* ... check for nread <= 0 and handle it ...
|
2013-07-23 10:35:55 -04:00
|
|
|
* sdsIncrLen(s, nread);
|
2011-11-02 11:50:59 -04:00
|
|
|
*/
|
2017-12-21 04:10:48 -05:00
|
|
|
void sdsIncrLen(sds s, ssize_t incr) {
|
2015-07-15 06:24:49 -04:00
|
|
|
unsigned char flags = s[-1];
|
2015-04-09 03:37:01 -04:00
|
|
|
size_t len;
|
|
|
|
switch(flags&SDS_TYPE_MASK) {
|
2015-07-15 06:24:49 -04:00
|
|
|
case SDS_TYPE_5: {
|
|
|
|
unsigned char *fp = ((unsigned char*)s)-1;
|
|
|
|
unsigned char oldlen = SDS_TYPE_5_LEN(flags);
|
|
|
|
assert((incr > 0 && oldlen+incr < 32) || (incr < 0 && oldlen >= (unsigned int)(-incr)));
|
2015-07-20 10:18:06 -04:00
|
|
|
*fp = SDS_TYPE_5 | ((oldlen+incr) << SDS_TYPE_BITS);
|
|
|
|
len = oldlen+incr;
|
2015-07-15 06:24:49 -04:00
|
|
|
break;
|
|
|
|
}
|
2015-04-09 03:37:01 -04:00
|
|
|
case SDS_TYPE_8: {
|
|
|
|
SDS_HDR_VAR(8,s);
|
|
|
|
assert((incr >= 0 && sh->alloc-sh->len >= incr) || (incr < 0 && sh->len >= (unsigned int)(-incr)));
|
|
|
|
len = (sh->len += incr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SDS_TYPE_16: {
|
|
|
|
SDS_HDR_VAR(16,s);
|
|
|
|
assert((incr >= 0 && sh->alloc-sh->len >= incr) || (incr < 0 && sh->len >= (unsigned int)(-incr)));
|
|
|
|
len = (sh->len += incr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SDS_TYPE_32: {
|
|
|
|
SDS_HDR_VAR(32,s);
|
|
|
|
assert((incr >= 0 && sh->alloc-sh->len >= (unsigned int)incr) || (incr < 0 && sh->len >= (unsigned int)(-incr)));
|
|
|
|
len = (sh->len += incr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SDS_TYPE_64: {
|
|
|
|
SDS_HDR_VAR(64,s);
|
|
|
|
assert((incr >= 0 && sh->alloc-sh->len >= (uint64_t)incr) || (incr < 0 && sh->len >= (uint64_t)(-incr)));
|
|
|
|
len = (sh->len += incr);
|
|
|
|
break;
|
|
|
|
}
|
2015-07-24 03:39:12 -04:00
|
|
|
default: len = 0; /* Just to avoid compilation warnings. */
|
2015-04-09 03:37:01 -04:00
|
|
|
}
|
|
|
|
s[len] = '\0';
|
2011-11-02 11:50:59 -04:00
|
|
|
}
|
|
|
|
|
2010-12-10 05:58:14 -05:00
|
|
|
/* Grow the sds to have the specified length. Bytes that were not part of
|
2013-07-23 10:35:55 -04:00
|
|
|
* the original length of the sds will be set to zero.
|
|
|
|
*
|
|
|
|
* if the specified length is smaller than the current length, no operation
|
|
|
|
* is performed. */
|
2010-12-10 06:16:16 -05:00
|
|
|
sds sdsgrowzero(sds s, size_t len) {
|
2015-04-09 03:37:01 -04:00
|
|
|
size_t curlen = sdslen(s);
|
2010-12-10 05:58:14 -05:00
|
|
|
|
|
|
|
if (len <= curlen) return s;
|
|
|
|
s = sdsMakeRoomFor(s,len-curlen);
|
|
|
|
if (s == NULL) return NULL;
|
|
|
|
|
|
|
|
/* Make sure added region doesn't contain garbage */
|
2010-12-10 06:16:16 -05:00
|
|
|
memset(s+curlen,0,(len-curlen+1)); /* also set trailing \0 byte */
|
2015-04-09 03:37:01 -04:00
|
|
|
sdssetlen(s, len);
|
2010-12-10 05:58:14 -05:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2013-07-23 10:35:55 -04:00
|
|
|
/* Append the specified binary-safe string pointed by 't' of 'len' bytes to the
|
|
|
|
* end of the specified sds string 's'.
|
|
|
|
*
|
|
|
|
* After the call, the passed sds string is no longer valid and all the
|
|
|
|
* references must be substituted with the new pointer returned by the call. */
|
2012-03-30 15:19:51 -04:00
|
|
|
sds sdscatlen(sds s, const void *t, size_t len) {
|
2009-03-22 05:30:00 -04:00
|
|
|
size_t curlen = sdslen(s);
|
|
|
|
|
|
|
|
s = sdsMakeRoomFor(s,len);
|
|
|
|
if (s == NULL) return NULL;
|
|
|
|
memcpy(s+curlen, t, len);
|
2015-04-09 03:37:01 -04:00
|
|
|
sdssetlen(s, curlen+len);
|
2009-03-22 05:30:00 -04:00
|
|
|
s[curlen+len] = '\0';
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
Squash merging 125 typo/grammar/comment/doc PRs (#7773)
List of squashed commits or PRs
===============================
commit 66801ea
Author: hwware <wen.hui.ware@gmail.com>
Date: Mon Jan 13 00:54:31 2020 -0500
typo fix in acl.c
commit 46f55db
Author: Itamar Haber <itamar@redislabs.com>
Date: Sun Sep 6 18:24:11 2020 +0300
Updates a couple of comments
Specifically:
* RM_AutoMemory completed instead of pointing to docs
* Updated link to custom type doc
commit 61a2aa0
Author: xindoo <xindoo@qq.com>
Date: Tue Sep 1 19:24:59 2020 +0800
Correct errors in code comments
commit a5871d1
Author: yz1509 <pro-756@qq.com>
Date: Tue Sep 1 18:36:06 2020 +0800
fix typos in module.c
commit 41eede7
Author: bookug <bookug@qq.com>
Date: Sat Aug 15 01:11:33 2020 +0800
docs: fix typos in comments
commit c303c84
Author: lazy-snail <ws.niu@outlook.com>
Date: Fri Aug 7 11:15:44 2020 +0800
fix spelling in redis.conf
commit 1eb76bf
Author: zhujian <zhujianxyz@gmail.com>
Date: Thu Aug 6 15:22:10 2020 +0800
add a missing 'n' in comment
commit 1530ec2
Author: Daniel Dai <764122422@qq.com>
Date: Mon Jul 27 00:46:35 2020 -0400
fix spelling in tracking.c
commit e517b31
Author: Hunter-Chen <huntcool001@gmail.com>
Date: Fri Jul 17 22:33:32 2020 +0800
Update redis.conf
Co-authored-by: Itamar Haber <itamar@redislabs.com>
commit c300eff
Author: Hunter-Chen <huntcool001@gmail.com>
Date: Fri Jul 17 22:33:23 2020 +0800
Update redis.conf
Co-authored-by: Itamar Haber <itamar@redislabs.com>
commit 4c058a8
Author: 陈浩鹏 <chenhaopeng@heytea.com>
Date: Thu Jun 25 19:00:56 2020 +0800
Grammar fix and clarification
commit 5fcaa81
Author: bodong.ybd <bodong.ybd@alibaba-inc.com>
Date: Fri Jun 19 10:09:00 2020 +0800
Fix typos
commit 4caca9a
Author: Pruthvi P <pruthvi@ixigo.com>
Date: Fri May 22 00:33:22 2020 +0530
Fix typo eviciton => eviction
commit b2a25f6
Author: Brad Dunbar <dunbarb2@gmail.com>
Date: Sun May 17 12:39:59 2020 -0400
Fix a typo.
commit 12842ae
Author: hwware <wen.hui.ware@gmail.com>
Date: Sun May 3 17:16:59 2020 -0400
fix spelling in redis conf
commit ddba07c
Author: Chris Lamb <chris@chris-lamb.co.uk>
Date: Sat May 2 23:25:34 2020 +0100
Correct a "conflicts" spelling error.
commit 8fc7bf2
Author: Nao YONASHIRO <yonashiro@r.recruit.co.jp>
Date: Thu Apr 30 10:25:27 2020 +0900
docs: fix EXPIRE_FAST_CYCLE_DURATION to ACTIVE_EXPIRE_CYCLE_FAST_DURATION
commit 9b2b67a
Author: Brad Dunbar <dunbarb2@gmail.com>
Date: Fri Apr 24 11:46:22 2020 -0400
Fix a typo.
commit 0746f10
Author: devilinrust <63737265+devilinrust@users.noreply.github.com>
Date: Thu Apr 16 00:17:53 2020 +0200
Fix typos in server.c
commit 92b588d
Author: benjessop12 <56115861+benjessop12@users.noreply.github.com>
Date: Mon Apr 13 13:43:55 2020 +0100
Fix spelling mistake in lazyfree.c
commit 1da37aa
Merge: 2d4ba28 af347a8
Author: hwware <wen.hui.ware@gmail.com>
Date: Thu Mar 5 22:41:31 2020 -0500
Merge remote-tracking branch 'upstream/unstable' into expiretypofix
commit 2d4ba28
Author: hwware <wen.hui.ware@gmail.com>
Date: Mon Mar 2 00:09:40 2020 -0500
fix typo in expire.c
commit 1a746f7
Author: SennoYuki <minakami1yuki@gmail.com>
Date: Thu Feb 27 16:54:32 2020 +0800
fix typo
commit 8599b1a
Author: dongheejeong <donghee950403@gmail.com>
Date: Sun Feb 16 20:31:43 2020 +0000
Fix typo in server.c
commit f38d4e8
Author: hwware <wen.hui.ware@gmail.com>
Date: Sun Feb 2 22:58:38 2020 -0500
fix typo in evict.c
commit fe143fc
Author: Leo Murillo <leonardo.murillo@gmail.com>
Date: Sun Feb 2 01:57:22 2020 -0600
Fix a few typos in redis.conf
commit 1ab4d21
Author: viraja1 <anchan.viraj@gmail.com>
Date: Fri Dec 27 17:15:58 2019 +0530
Fix typo in Latency API docstring
commit ca1f70e
Author: gosth <danxuedexing@qq.com>
Date: Wed Dec 18 15:18:02 2019 +0800
fix typo in sort.c
commit a57c06b
Author: ZYunH <zyunhjob@163.com>
Date: Mon Dec 16 22:28:46 2019 +0800
fix-zset-typo
commit b8c92b5
Author: git-hulk <hulk.website@gmail.com>
Date: Mon Dec 16 15:51:42 2019 +0800
FIX: typo in cluster.c, onformation->information
commit 9dd981c
Author: wujm2007 <jim.wujm@gmail.com>
Date: Mon Dec 16 09:37:52 2019 +0800
Fix typo
commit e132d7a
Author: Sebastien Williams-Wynn <s.williamswynn.mail@gmail.com>
Date: Fri Nov 15 00:14:07 2019 +0000
Minor typo change
commit 47f44d5
Author: happynote3966 <01ssrmikururudevice01@gmail.com>
Date: Mon Nov 11 22:08:48 2019 +0900
fix comment typo in redis-cli.c
commit b8bdb0d
Author: fulei <fulei@kuaishou.com>
Date: Wed Oct 16 18:00:17 2019 +0800
Fix a spelling mistake of comments in defragDictBucketCallback
commit 0def46a
Author: fulei <fulei@kuaishou.com>
Date: Wed Oct 16 13:09:27 2019 +0800
fix some spelling mistakes of comments in defrag.c
commit f3596fd
Author: Phil Rajchgot <tophil@outlook.com>
Date: Sun Oct 13 02:02:32 2019 -0400
Typo and grammar fixes
Redis and its documentation are great -- just wanted to submit a few corrections in the spirit of Hacktoberfest. Thanks for all your work on this project. I use it all the time and it works beautifully.
commit 2b928cd
Author: KangZhiDong <worldkzd@gmail.com>
Date: Sun Sep 1 07:03:11 2019 +0800
fix typos
commit 33aea14
Author: Axlgrep <axlgrep@gmail.com>
Date: Tue Aug 27 11:02:18 2019 +0800
Fixed eviction spelling issues
commit e282a80
Author: Simen Flatby <simen@oms.no>
Date: Tue Aug 20 15:25:51 2019 +0200
Update comments to reflect prop name
In the comments the prop is referenced as replica-validity-factor,
but it is really named cluster-replica-validity-factor.
commit 74d1f9a
Author: Jim Green <jimgreen2013@qq.com>
Date: Tue Aug 20 20:00:31 2019 +0800
fix comment error, the code is ok
commit eea1407
Author: Liao Tonglang <liaotonglang@gmail.com>
Date: Fri May 31 10:16:18 2019 +0800
typo fix
fix cna't to can't
commit 0da553c
Author: KAWACHI Takashi <tkawachi@gmail.com>
Date: Wed Jul 17 00:38:16 2019 +0900
Fix typo
commit 7fc8fb6
Author: Michael Prokop <mika@grml.org>
Date: Tue May 28 17:58:42 2019 +0200
Typo fixes
s/familar/familiar/
s/compatiblity/compatibility/
s/ ot / to /
s/itsef/itself/
commit 5f46c9d
Author: zhumoing <34539422+zhumoing@users.noreply.github.com>
Date: Tue May 21 21:16:50 2019 +0800
typo-fixes
typo-fixes
commit 321dfe1
Author: wxisme <850885154@qq.com>
Date: Sat Mar 16 15:10:55 2019 +0800
typo fix
commit b4fb131
Merge: 267e0e6 3df1eb8
Author: Nikitas Bastas <nikitasbst@gmail.com>
Date: Fri Feb 8 22:55:45 2019 +0200
Merge branch 'unstable' of antirez/redis into unstable
commit 267e0e6
Author: Nikitas Bastas <nikitasbst@gmail.com>
Date: Wed Jan 30 21:26:04 2019 +0200
Minor typo fix
commit 30544e7
Author: inshal96 <39904558+inshal96@users.noreply.github.com>
Date: Fri Jan 4 16:54:50 2019 +0500
remove an extra 'a' in the comments
commit 337969d
Author: BrotherGao <yangdongheng11@gmail.com>
Date: Sat Dec 29 12:37:29 2018 +0800
fix typo in redis.conf
commit 9f4b121
Merge: 423a030 e504583
Author: BrotherGao <yangdongheng@xiaomi.com>
Date: Sat Dec 29 11:41:12 2018 +0800
Merge branch 'unstable' of antirez/redis into unstable
commit 423a030
Merge: 42b02b7 46a51cd
Author: 杨东衡 <yangdongheng@xiaomi.com>
Date: Tue Dec 4 23:56:11 2018 +0800
Merge branch 'unstable' of antirez/redis into unstable
commit 42b02b7
Merge: 68c0e6e b8febe6
Author: Dongheng Yang <yangdongheng11@gmail.com>
Date: Sun Oct 28 15:54:23 2018 +0800
Merge pull request #1 from antirez/unstable
update local data
commit 714b589
Author: Christian <crifei93@gmail.com>
Date: Fri Dec 28 01:17:26 2018 +0100
fix typo "resulution"
commit e23259d
Author: garenchan <1412950785@qq.com>
Date: Wed Dec 26 09:58:35 2018 +0800
fix typo: segfauls -> segfault
commit a9359f8
Author: xjp <jianping_xie@aliyun.com>
Date: Tue Dec 18 17:31:44 2018 +0800
Fixed REDISMODULE_H spell bug
commit a12c3e4
Author: jdiaz <jrd.palacios@gmail.com>
Date: Sat Dec 15 23:39:52 2018 -0600
Fixes hyperloglog hash function comment block description
commit 770eb11
Author: 林上耀 <1210tom@163.com>
Date: Sun Nov 25 17:16:10 2018 +0800
fix typo
commit fd97fbb
Author: Chris Lamb <chris@chris-lamb.co.uk>
Date: Fri Nov 23 17:14:01 2018 +0100
Correct "unsupported" typo.
commit a85522d
Author: Jungnam Lee <jungnam.lee@oracle.com>
Date: Thu Nov 8 23:01:29 2018 +0900
fix typo in test comments
commit ade8007
Author: Arun Kumar <palerdot@users.noreply.github.com>
Date: Tue Oct 23 16:56:35 2018 +0530
Fixed grammatical typo
Fixed typo for word 'dictionary'
commit 869ee39
Author: Hamid Alaei <hamid.a85@gmail.com>
Date: Sun Aug 12 16:40:02 2018 +0430
fix documentations: (ThreadSafeContextStart/Stop -> ThreadSafeContextLock/Unlock), minor typo
commit f89d158
Author: Mayank Jain <mayankjain255@gmail.com>
Date: Tue Jul 31 23:01:21 2018 +0530
Updated README.md with some spelling corrections.
Made correction in spelling of some misspelled words.
commit 892198e
Author: dsomeshwar <someshwar.dhayalan@gmail.com>
Date: Sat Jul 21 23:23:04 2018 +0530
typo fix
commit 8a4d780
Author: Itamar Haber <itamar@redislabs.com>
Date: Mon Apr 30 02:06:52 2018 +0300
Fixes some typos
commit e3acef6
Author: Noah Rosamilia <ivoahivoah@gmail.com>
Date: Sat Mar 3 23:41:21 2018 -0500
Fix typo in /deps/README.md
commit 04442fb
Author: WuYunlong <xzsyeb@126.com>
Date: Sat Mar 3 10:32:42 2018 +0800
Fix typo in readSyncBulkPayload() comment.
commit 9f36880
Author: WuYunlong <xzsyeb@126.com>
Date: Sat Mar 3 10:20:37 2018 +0800
replication.c comment: run_id -> replid.
commit f866b4a
Author: Francesco 'makevoid' Canessa <makevoid@gmail.com>
Date: Thu Feb 22 22:01:56 2018 +0000
fix comment typo in server.c
commit 0ebc69b
Author: 줍 <jubee0124@gmail.com>
Date: Mon Feb 12 16:38:48 2018 +0900
Fix typo in redis.conf
Fix `five behaviors` to `eight behaviors` in [this sentence ](antirez/redis@unstable/redis.conf#L564)
commit b50a620
Author: martinbroadhurst <martinbroadhurst@users.noreply.github.com>
Date: Thu Dec 28 12:07:30 2017 +0000
Fix typo in valgrind.sup
commit 7d8f349
Author: Peter Boughton <peter@sorcerersisle.com>
Date: Mon Nov 27 19:52:19 2017 +0000
Update CONTRIBUTING; refer doc updates to redis-doc repo.
commit 02dec7e
Author: Klauswk <klauswk1@hotmail.com>
Date: Tue Oct 24 16:18:38 2017 -0200
Fix typo in comment
commit e1efbc8
Author: chenshi <baiwfg2@gmail.com>
Date: Tue Oct 3 18:26:30 2017 +0800
Correct two spelling errors of comments
commit 93327d8
Author: spacewander <spacewanderlzx@gmail.com>
Date: Wed Sep 13 16:47:24 2017 +0800
Update the comment for OBJ_ENCODING_EMBSTR_SIZE_LIMIT's value
The value of OBJ_ENCODING_EMBSTR_SIZE_LIMIT is 44 now instead of 39.
commit 63d361f
Author: spacewander <spacewanderlzx@gmail.com>
Date: Tue Sep 12 15:06:42 2017 +0800
Fix <prevlen> related doc in ziplist.c
According to the definition of ZIP_BIG_PREVLEN and other related code,
the guard of single byte <prevlen> should be 254 instead of 255.
commit ebe228d
Author: hanael80 <hanael80@gmail.com>
Date: Tue Aug 15 09:09:40 2017 +0900
Fix typo
commit 6b696e6
Author: Matt Robenolt <matt@ydekproductions.com>
Date: Mon Aug 14 14:50:47 2017 -0700
Fix typo in LATENCY DOCTOR output
commit a2ec6ae
Author: caosiyang <caosiyang@qiyi.com>
Date: Tue Aug 15 14:15:16 2017 +0800
Fix a typo: form => from
commit 3ab7699
Author: caosiyang <caosiyang@qiyi.com>
Date: Thu Aug 10 18:40:33 2017 +0800
Fix a typo: replicationFeedSlavesFromMaster() => replicationFeedSlavesFromMasterStream()
commit 72d43ef
Author: caosiyang <caosiyang@qiyi.com>
Date: Tue Aug 8 15:57:25 2017 +0800
fix a typo: servewr => server
commit 707c958
Author: Bo Cai <charpty@gmail.com>
Date: Wed Jul 26 21:49:42 2017 +0800
redis-cli.c typo: conut -> count.
Signed-off-by: Bo Cai <charpty@gmail.com>
commit b9385b2
Author: JackDrogon <jack.xsuperman@gmail.com>
Date: Fri Jun 30 14:22:31 2017 +0800
Fix some spell problems
commit 20d9230
Author: akosel <aaronjkosel@gmail.com>
Date: Sun Jun 4 19:35:13 2017 -0500
Fix typo
commit b167bfc
Author: Krzysiek Witkowicz <krzysiekwitkowicz@gmail.com>
Date: Mon May 22 21:32:27 2017 +0100
Fix #4008 small typo in comment
commit 2b78ac8
Author: Jake Clarkson <jacobwclarkson@gmail.com>
Date: Wed Apr 26 15:49:50 2017 +0100
Correct typo in tests/unit/hyperloglog.tcl
commit b0f1cdb
Author: Qi Luo <qiluo-msft@users.noreply.github.com>
Date: Wed Apr 19 14:25:18 2017 -0700
Fix typo
commit a90b0f9
Author: charsyam <charsyam@naver.com>
Date: Thu Mar 16 18:19:53 2017 +0900
fix typos
fix typos
fix typos
commit 8430a79
Author: Richard Hart <richardhart92@gmail.com>
Date: Mon Mar 13 22:17:41 2017 -0400
Fixed log message typo in listenToPort.
commit 481a1c2
Author: Vinod Kumar <kumar003vinod@gmail.com>
Date: Sun Jan 15 23:04:51 2017 +0530
src/db.c: Correct "save" -> "safe" typo
commit 586b4d3
Author: wangshaonan <wshn13@gmail.com>
Date: Wed Dec 21 20:28:27 2016 +0800
Fix typo they->the in helloworld.c
commit c1c4b5e
Author: Jenner <hypxm@qq.com>
Date: Mon Dec 19 16:39:46 2016 +0800
typo error
commit 1ee1a3f
Author: tielei <43289893@qq.com>
Date: Mon Jul 18 13:52:25 2016 +0800
fix some comments
commit 11a41fb
Author: Otto Kekäläinen <otto@seravo.fi>
Date: Sun Jul 3 10:23:55 2016 +0100
Fix spelling in documentation and comments
commit 5fb5d82
Author: francischan <f1ancis621@gmail.com>
Date: Tue Jun 28 00:19:33 2016 +0800
Fix outdated comments about redis.c file.
It should now refer to server.c file.
commit 6b254bc
Author: lmatt-bit <lmatt123n@gmail.com>
Date: Thu Apr 21 21:45:58 2016 +0800
Refine the comment of dictRehashMilliseconds func
SLAVECONF->REPLCONF in comment - by andyli029
commit ee9869f
Author: clark.kang <charsyam@naver.com>
Date: Tue Mar 22 11:09:51 2016 +0900
fix typos
commit f7b3b11
Author: Harisankar H <harisankarh@gmail.com>
Date: Wed Mar 9 11:49:42 2016 +0530
Typo correction: "faield" --> "failed"
Typo correction: "faield" --> "failed"
commit 3fd40fc
Author: Itamar Haber <itamar@redislabs.com>
Date: Thu Feb 25 10:31:51 2016 +0200
Fixes a typo in comments
commit 621c160
Author: Prayag Verma <prayag.verma@gmail.com>
Date: Mon Feb 1 12:36:20 2016 +0530
Fix typo in Readme.md
Spelling mistakes -
`eviciton` > `eviction`
`familar` > `familiar`
commit d7d07d6
Author: WonCheol Lee <toctoc21c@gmail.com>
Date: Wed Dec 30 15:11:34 2015 +0900
Typo fixed
commit a4dade7
Author: Felix Bünemann <buenemann@louis.info>
Date: Mon Dec 28 11:02:55 2015 +0100
[ci skip] Improve supervised upstart config docs
This mentions that "expect stop" is required for supervised upstart
to work correctly. See http://upstart.ubuntu.com/cookbook/#expect-stop
for an explanation.
commit d9caba9
Author: daurnimator <quae@daurnimator.com>
Date: Mon Dec 21 18:30:03 2015 +1100
README: Remove trailing whitespace
commit 72d42e5
Author: daurnimator <quae@daurnimator.com>
Date: Mon Dec 21 18:29:32 2015 +1100
README: Fix typo. th => the
commit dd6e957
Author: daurnimator <quae@daurnimator.com>
Date: Mon Dec 21 18:29:20 2015 +1100
README: Fix typo. familar => familiar
commit 3a12b23
Author: daurnimator <quae@daurnimator.com>
Date: Mon Dec 21 18:28:54 2015 +1100
README: Fix typo. eviciton => eviction
commit 2d1d03b
Author: daurnimator <quae@daurnimator.com>
Date: Mon Dec 21 18:21:45 2015 +1100
README: Fix typo. sever => server
commit 3973b06
Author: Itamar Haber <itamar@garantiadata.com>
Date: Sat Dec 19 17:01:20 2015 +0200
Typo fix
commit 4f2e460
Author: Steve Gao <fu@2token.com>
Date: Fri Dec 4 10:22:05 2015 +0800
Update README - fix typos
commit b21667c
Author: binyan <binbin.yan@nokia.com>
Date: Wed Dec 2 22:48:37 2015 +0800
delete redundancy color judge in sdscatcolor
commit 88894c7
Author: binyan <binbin.yan@nokia.com>
Date: Wed Dec 2 22:14:42 2015 +0800
the example output shoule be HelloWorld
commit 2763470
Author: binyan <binbin.yan@nokia.com>
Date: Wed Dec 2 17:41:39 2015 +0800
modify error word keyevente
Signed-off-by: binyan <binbin.yan@nokia.com>
commit 0847b3d
Author: Bruno Martins <bscmartins@gmail.com>
Date: Wed Nov 4 11:37:01 2015 +0000
typo
commit bbb9e9e
Author: dawedawe <dawedawe@gmx.de>
Date: Fri Mar 27 00:46:41 2015 +0100
typo: zimap -> zipmap
commit 5ed297e
Author: Axel Advento <badwolf.bloodseeker.rev@gmail.com>
Date: Tue Mar 3 15:58:29 2015 +0800
Fix 'salve' typos to 'slave'
commit edec9d6
Author: LudwikJaniuk <ludvig.janiuk@gmail.com>
Date: Wed Jun 12 14:12:47 2019 +0200
Update README.md
Co-Authored-By: Qix <Qix-@users.noreply.github.com>
commit 692a7af
Author: LudwikJaniuk <ludvig.janiuk@gmail.com>
Date: Tue May 28 14:32:04 2019 +0200
grammar
commit d962b0a
Author: Nick Frost <nickfrostatx@gmail.com>
Date: Wed Jul 20 15:17:12 2016 -0700
Minor grammar fix
commit 24fff01aaccaf5956973ada8c50ceb1462e211c6 (typos)
Author: Chad Miller <chadm@squareup.com>
Date: Tue Sep 8 13:46:11 2020 -0400
Fix faulty comment about operation of unlink()
commit 3cd5c1f3326c52aa552ada7ec797c6bb16452355
Author: Kevin <kevin.xgr@gmail.com>
Date: Wed Nov 20 00:13:50 2019 +0800
Fix typo in server.c.
From a83af59 Mon Sep 17 00:00:00 2001
From: wuwo <wuwo@wacai.com>
Date: Fri, 17 Mar 2017 20:37:45 +0800
Subject: [PATCH] falure to failure
From c961896 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=B7=A6=E6=87=B6?= <veficos@gmail.com>
Date: Sat, 27 May 2017 15:33:04 +0800
Subject: [PATCH] fix typo
From e600ef2 Mon Sep 17 00:00:00 2001
From: "rui.zou" <rui.zou@yunify.com>
Date: Sat, 30 Sep 2017 12:38:15 +0800
Subject: [PATCH] fix a typo
From c7d07fa Mon Sep 17 00:00:00 2001
From: Alexandre Perrin <alex@kaworu.ch>
Date: Thu, 16 Aug 2018 10:35:31 +0200
Subject: [PATCH] deps README.md typo
From b25cb67 Mon Sep 17 00:00:00 2001
From: Guy Korland <gkorland@gmail.com>
Date: Wed, 26 Sep 2018 10:55:37 +0300
Subject: [PATCH 1/2] fix typos in header
From ad28ca6 Mon Sep 17 00:00:00 2001
From: Guy Korland <gkorland@gmail.com>
Date: Wed, 26 Sep 2018 11:02:36 +0300
Subject: [PATCH 2/2] fix typos
commit 34924cdedd8552466fc22c1168d49236cb7ee915
Author: Adrian Lynch <adi_ady_ade@hotmail.com>
Date: Sat Apr 4 21:59:15 2015 +0100
Typos fixed
commit fd2a1e7
Author: Jan <jsteemann@users.noreply.github.com>
Date: Sat Oct 27 19:13:01 2018 +0200
Fix typos
Fix typos
commit e14e47c1a234b53b0e103c5f6a1c61481cbcbb02
Author: Andy Lester <andy@petdance.com>
Date: Fri Aug 2 22:30:07 2019 -0500
Fix multiple misspellings of "following"
commit 79b948ce2dac6b453fe80995abbcaac04c213d5a
Author: Andy Lester <andy@petdance.com>
Date: Fri Aug 2 22:24:28 2019 -0500
Fix misspelling of create-cluster
commit 1fffde52666dc99ab35efbd31071a4c008cb5a71
Author: Andy Lester <andy@petdance.com>
Date: Wed Jul 31 17:57:56 2019 -0500
Fix typos
commit 204c9ba9651e9e05fd73936b452b9a30be456cfe
Author: Xiaobo Zhu <xiaobo.zhu@shopee.com>
Date: Tue Aug 13 22:19:25 2019 +0800
fix typos
Squashed commit of the following:
commit 1d9aaf8
Author: danmedani <danmedani@gmail.com>
Date: Sun Aug 2 11:40:26 2015 -0700
README typo fix.
Squashed commit of the following:
commit 32bfa7c
Author: Erik Dubbelboer <erik@dubbelboer.com>
Date: Mon Jul 6 21:15:08 2015 +0200
Fixed grammer
Squashed commit of the following:
commit b24f69c
Author: Sisir Koppaka <sisir.koppaka@gmail.com>
Date: Mon Mar 2 22:38:45 2015 -0500
utils/hashtable/rehashing.c: Fix typos
Squashed commit of the following:
commit 4e04082
Author: Erik Dubbelboer <erik@dubbelboer.com>
Date: Mon Mar 23 08:22:21 2015 +0000
Small config file documentation improvements
Squashed commit of the following:
commit acb8773
Author: ctd1500 <ctd1500@gmail.com>
Date: Fri May 8 01:52:48 2015 -0700
Typo and grammar fixes in readme
commit 2eb75b6
Author: ctd1500 <ctd1500@gmail.com>
Date: Fri May 8 01:36:18 2015 -0700
fixed redis.conf comment
Squashed commit of the following:
commit a8249a2
Author: Masahiko Sawada <sawada.mshk@gmail.com>
Date: Fri Dec 11 11:39:52 2015 +0530
Revise correction of typos.
Squashed commit of the following:
commit 3c02028
Author: zhaojun11 <zhaojun11@jd.com>
Date: Wed Jan 17 19:05:28 2018 +0800
Fix typos include two code typos in cluster.c and latency.c
Squashed commit of the following:
commit 9dba47c
Author: q191201771 <191201771@qq.com>
Date: Sat Jan 4 11:31:04 2020 +0800
fix function listCreate comment in adlist.c
Update src/server.c
commit 2c7c2cb536e78dd211b1ac6f7bda00f0f54faaeb
Author: charpty <charpty@gmail.com>
Date: Tue May 1 23:16:59 2018 +0800
server.c typo: modules system dictionary type comment
Signed-off-by: charpty <charpty@gmail.com>
commit a8395323fb63cb59cb3591cb0f0c8edb7c29a680
Author: Itamar Haber <itamar@redislabs.com>
Date: Sun May 6 00:25:18 2018 +0300
Updates test_helper.tcl's help with undocumented options
Specifically:
* Host
* Port
* Client
commit bde6f9ced15755cd6407b4af7d601b030f36d60b
Author: wxisme <850885154@qq.com>
Date: Wed Aug 8 15:19:19 2018 +0800
fix comments in deps files
commit 3172474ba991532ab799ee1873439f3402412331
Author: wxisme <850885154@qq.com>
Date: Wed Aug 8 14:33:49 2018 +0800
fix some comments
commit 01b6f2b6858b5cf2ce4ad5092d2c746e755f53f0
Author: Thor Juhasz <thor@juhasz.pro>
Date: Sun Nov 18 14:37:41 2018 +0100
Minor fixes to comments
Found some parts a little unclear on a first read, which prompted me to have a better look at the file and fix some minor things I noticed.
Fixing minor typos and grammar. There are no changes to configuration options.
These changes are only meant to help the user better understand the explanations to the various configuration options
2020-09-10 06:43:38 -04:00
|
|
|
/* Append the specified null terminated C string to the sds string 's'.
|
2013-07-23 10:35:55 -04:00
|
|
|
*
|
|
|
|
* After the call, the passed sds string is no longer valid and all the
|
|
|
|
* references must be substituted with the new pointer returned by the call. */
|
2012-03-30 15:19:51 -04:00
|
|
|
sds sdscat(sds s, const char *t) {
|
2009-03-22 05:30:00 -04:00
|
|
|
return sdscatlen(s, t, strlen(t));
|
|
|
|
}
|
|
|
|
|
2013-07-23 10:35:55 -04:00
|
|
|
/* Append the specified sds 't' to the existing sds 's'.
|
|
|
|
*
|
|
|
|
* After the call, the modified sds string is no longer valid and all the
|
|
|
|
* references must be substituted with the new pointer returned by the call. */
|
2012-03-30 15:19:51 -04:00
|
|
|
sds sdscatsds(sds s, const sds t) {
|
2011-11-21 09:34:00 -05:00
|
|
|
return sdscatlen(s, t, sdslen(t));
|
|
|
|
}
|
|
|
|
|
2013-07-23 10:35:55 -04:00
|
|
|
/* Destructively modify the sds string 's' to hold the specified binary
|
|
|
|
* safe string pointed by 't' of length 'len' bytes. */
|
2012-03-30 15:19:51 -04:00
|
|
|
sds sdscpylen(sds s, const char *t, size_t len) {
|
2015-04-09 03:37:01 -04:00
|
|
|
if (sdsalloc(s) < len) {
|
|
|
|
s = sdsMakeRoomFor(s,len-sdslen(s));
|
2009-03-22 05:30:00 -04:00
|
|
|
if (s == NULL) return NULL;
|
|
|
|
}
|
|
|
|
memcpy(s, t, len);
|
|
|
|
s[len] = '\0';
|
2015-04-09 03:37:01 -04:00
|
|
|
sdssetlen(s, len);
|
2009-03-22 05:30:00 -04:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2021-06-10 08:39:33 -04:00
|
|
|
/* Like sdscpylen() but 't' must be a null-terminated string so that the length
|
2013-07-23 10:35:55 -04:00
|
|
|
* of the string is obtained with strlen(). */
|
2012-03-30 15:19:51 -04:00
|
|
|
sds sdscpy(sds s, const char *t) {
|
2009-03-22 05:30:00 -04:00
|
|
|
return sdscpylen(s, t, strlen(t));
|
|
|
|
}
|
|
|
|
|
2014-04-28 04:52:08 -04:00
|
|
|
/* Helper for sdscatlonglong() doing the actual number -> string
|
|
|
|
* conversion. 's' must point to a string with room for at least
|
|
|
|
* SDS_LLSTR_SIZE bytes.
|
|
|
|
*
|
2014-11-03 04:21:54 -05:00
|
|
|
* The function returns the length of the null-terminated string
|
2014-04-28 04:52:08 -04:00
|
|
|
* representation stored at 's'. */
|
|
|
|
#define SDS_LLSTR_SIZE 21
|
|
|
|
int sdsll2str(char *s, long long value) {
|
|
|
|
char *p, aux;
|
|
|
|
unsigned long long v;
|
|
|
|
size_t l;
|
|
|
|
|
|
|
|
/* Generate the string representation, this method produces
|
Squash merging 125 typo/grammar/comment/doc PRs (#7773)
List of squashed commits or PRs
===============================
commit 66801ea
Author: hwware <wen.hui.ware@gmail.com>
Date: Mon Jan 13 00:54:31 2020 -0500
typo fix in acl.c
commit 46f55db
Author: Itamar Haber <itamar@redislabs.com>
Date: Sun Sep 6 18:24:11 2020 +0300
Updates a couple of comments
Specifically:
* RM_AutoMemory completed instead of pointing to docs
* Updated link to custom type doc
commit 61a2aa0
Author: xindoo <xindoo@qq.com>
Date: Tue Sep 1 19:24:59 2020 +0800
Correct errors in code comments
commit a5871d1
Author: yz1509 <pro-756@qq.com>
Date: Tue Sep 1 18:36:06 2020 +0800
fix typos in module.c
commit 41eede7
Author: bookug <bookug@qq.com>
Date: Sat Aug 15 01:11:33 2020 +0800
docs: fix typos in comments
commit c303c84
Author: lazy-snail <ws.niu@outlook.com>
Date: Fri Aug 7 11:15:44 2020 +0800
fix spelling in redis.conf
commit 1eb76bf
Author: zhujian <zhujianxyz@gmail.com>
Date: Thu Aug 6 15:22:10 2020 +0800
add a missing 'n' in comment
commit 1530ec2
Author: Daniel Dai <764122422@qq.com>
Date: Mon Jul 27 00:46:35 2020 -0400
fix spelling in tracking.c
commit e517b31
Author: Hunter-Chen <huntcool001@gmail.com>
Date: Fri Jul 17 22:33:32 2020 +0800
Update redis.conf
Co-authored-by: Itamar Haber <itamar@redislabs.com>
commit c300eff
Author: Hunter-Chen <huntcool001@gmail.com>
Date: Fri Jul 17 22:33:23 2020 +0800
Update redis.conf
Co-authored-by: Itamar Haber <itamar@redislabs.com>
commit 4c058a8
Author: 陈浩鹏 <chenhaopeng@heytea.com>
Date: Thu Jun 25 19:00:56 2020 +0800
Grammar fix and clarification
commit 5fcaa81
Author: bodong.ybd <bodong.ybd@alibaba-inc.com>
Date: Fri Jun 19 10:09:00 2020 +0800
Fix typos
commit 4caca9a
Author: Pruthvi P <pruthvi@ixigo.com>
Date: Fri May 22 00:33:22 2020 +0530
Fix typo eviciton => eviction
commit b2a25f6
Author: Brad Dunbar <dunbarb2@gmail.com>
Date: Sun May 17 12:39:59 2020 -0400
Fix a typo.
commit 12842ae
Author: hwware <wen.hui.ware@gmail.com>
Date: Sun May 3 17:16:59 2020 -0400
fix spelling in redis conf
commit ddba07c
Author: Chris Lamb <chris@chris-lamb.co.uk>
Date: Sat May 2 23:25:34 2020 +0100
Correct a "conflicts" spelling error.
commit 8fc7bf2
Author: Nao YONASHIRO <yonashiro@r.recruit.co.jp>
Date: Thu Apr 30 10:25:27 2020 +0900
docs: fix EXPIRE_FAST_CYCLE_DURATION to ACTIVE_EXPIRE_CYCLE_FAST_DURATION
commit 9b2b67a
Author: Brad Dunbar <dunbarb2@gmail.com>
Date: Fri Apr 24 11:46:22 2020 -0400
Fix a typo.
commit 0746f10
Author: devilinrust <63737265+devilinrust@users.noreply.github.com>
Date: Thu Apr 16 00:17:53 2020 +0200
Fix typos in server.c
commit 92b588d
Author: benjessop12 <56115861+benjessop12@users.noreply.github.com>
Date: Mon Apr 13 13:43:55 2020 +0100
Fix spelling mistake in lazyfree.c
commit 1da37aa
Merge: 2d4ba28 af347a8
Author: hwware <wen.hui.ware@gmail.com>
Date: Thu Mar 5 22:41:31 2020 -0500
Merge remote-tracking branch 'upstream/unstable' into expiretypofix
commit 2d4ba28
Author: hwware <wen.hui.ware@gmail.com>
Date: Mon Mar 2 00:09:40 2020 -0500
fix typo in expire.c
commit 1a746f7
Author: SennoYuki <minakami1yuki@gmail.com>
Date: Thu Feb 27 16:54:32 2020 +0800
fix typo
commit 8599b1a
Author: dongheejeong <donghee950403@gmail.com>
Date: Sun Feb 16 20:31:43 2020 +0000
Fix typo in server.c
commit f38d4e8
Author: hwware <wen.hui.ware@gmail.com>
Date: Sun Feb 2 22:58:38 2020 -0500
fix typo in evict.c
commit fe143fc
Author: Leo Murillo <leonardo.murillo@gmail.com>
Date: Sun Feb 2 01:57:22 2020 -0600
Fix a few typos in redis.conf
commit 1ab4d21
Author: viraja1 <anchan.viraj@gmail.com>
Date: Fri Dec 27 17:15:58 2019 +0530
Fix typo in Latency API docstring
commit ca1f70e
Author: gosth <danxuedexing@qq.com>
Date: Wed Dec 18 15:18:02 2019 +0800
fix typo in sort.c
commit a57c06b
Author: ZYunH <zyunhjob@163.com>
Date: Mon Dec 16 22:28:46 2019 +0800
fix-zset-typo
commit b8c92b5
Author: git-hulk <hulk.website@gmail.com>
Date: Mon Dec 16 15:51:42 2019 +0800
FIX: typo in cluster.c, onformation->information
commit 9dd981c
Author: wujm2007 <jim.wujm@gmail.com>
Date: Mon Dec 16 09:37:52 2019 +0800
Fix typo
commit e132d7a
Author: Sebastien Williams-Wynn <s.williamswynn.mail@gmail.com>
Date: Fri Nov 15 00:14:07 2019 +0000
Minor typo change
commit 47f44d5
Author: happynote3966 <01ssrmikururudevice01@gmail.com>
Date: Mon Nov 11 22:08:48 2019 +0900
fix comment typo in redis-cli.c
commit b8bdb0d
Author: fulei <fulei@kuaishou.com>
Date: Wed Oct 16 18:00:17 2019 +0800
Fix a spelling mistake of comments in defragDictBucketCallback
commit 0def46a
Author: fulei <fulei@kuaishou.com>
Date: Wed Oct 16 13:09:27 2019 +0800
fix some spelling mistakes of comments in defrag.c
commit f3596fd
Author: Phil Rajchgot <tophil@outlook.com>
Date: Sun Oct 13 02:02:32 2019 -0400
Typo and grammar fixes
Redis and its documentation are great -- just wanted to submit a few corrections in the spirit of Hacktoberfest. Thanks for all your work on this project. I use it all the time and it works beautifully.
commit 2b928cd
Author: KangZhiDong <worldkzd@gmail.com>
Date: Sun Sep 1 07:03:11 2019 +0800
fix typos
commit 33aea14
Author: Axlgrep <axlgrep@gmail.com>
Date: Tue Aug 27 11:02:18 2019 +0800
Fixed eviction spelling issues
commit e282a80
Author: Simen Flatby <simen@oms.no>
Date: Tue Aug 20 15:25:51 2019 +0200
Update comments to reflect prop name
In the comments the prop is referenced as replica-validity-factor,
but it is really named cluster-replica-validity-factor.
commit 74d1f9a
Author: Jim Green <jimgreen2013@qq.com>
Date: Tue Aug 20 20:00:31 2019 +0800
fix comment error, the code is ok
commit eea1407
Author: Liao Tonglang <liaotonglang@gmail.com>
Date: Fri May 31 10:16:18 2019 +0800
typo fix
fix cna't to can't
commit 0da553c
Author: KAWACHI Takashi <tkawachi@gmail.com>
Date: Wed Jul 17 00:38:16 2019 +0900
Fix typo
commit 7fc8fb6
Author: Michael Prokop <mika@grml.org>
Date: Tue May 28 17:58:42 2019 +0200
Typo fixes
s/familar/familiar/
s/compatiblity/compatibility/
s/ ot / to /
s/itsef/itself/
commit 5f46c9d
Author: zhumoing <34539422+zhumoing@users.noreply.github.com>
Date: Tue May 21 21:16:50 2019 +0800
typo-fixes
typo-fixes
commit 321dfe1
Author: wxisme <850885154@qq.com>
Date: Sat Mar 16 15:10:55 2019 +0800
typo fix
commit b4fb131
Merge: 267e0e6 3df1eb8
Author: Nikitas Bastas <nikitasbst@gmail.com>
Date: Fri Feb 8 22:55:45 2019 +0200
Merge branch 'unstable' of antirez/redis into unstable
commit 267e0e6
Author: Nikitas Bastas <nikitasbst@gmail.com>
Date: Wed Jan 30 21:26:04 2019 +0200
Minor typo fix
commit 30544e7
Author: inshal96 <39904558+inshal96@users.noreply.github.com>
Date: Fri Jan 4 16:54:50 2019 +0500
remove an extra 'a' in the comments
commit 337969d
Author: BrotherGao <yangdongheng11@gmail.com>
Date: Sat Dec 29 12:37:29 2018 +0800
fix typo in redis.conf
commit 9f4b121
Merge: 423a030 e504583
Author: BrotherGao <yangdongheng@xiaomi.com>
Date: Sat Dec 29 11:41:12 2018 +0800
Merge branch 'unstable' of antirez/redis into unstable
commit 423a030
Merge: 42b02b7 46a51cd
Author: 杨东衡 <yangdongheng@xiaomi.com>
Date: Tue Dec 4 23:56:11 2018 +0800
Merge branch 'unstable' of antirez/redis into unstable
commit 42b02b7
Merge: 68c0e6e b8febe6
Author: Dongheng Yang <yangdongheng11@gmail.com>
Date: Sun Oct 28 15:54:23 2018 +0800
Merge pull request #1 from antirez/unstable
update local data
commit 714b589
Author: Christian <crifei93@gmail.com>
Date: Fri Dec 28 01:17:26 2018 +0100
fix typo "resulution"
commit e23259d
Author: garenchan <1412950785@qq.com>
Date: Wed Dec 26 09:58:35 2018 +0800
fix typo: segfauls -> segfault
commit a9359f8
Author: xjp <jianping_xie@aliyun.com>
Date: Tue Dec 18 17:31:44 2018 +0800
Fixed REDISMODULE_H spell bug
commit a12c3e4
Author: jdiaz <jrd.palacios@gmail.com>
Date: Sat Dec 15 23:39:52 2018 -0600
Fixes hyperloglog hash function comment block description
commit 770eb11
Author: 林上耀 <1210tom@163.com>
Date: Sun Nov 25 17:16:10 2018 +0800
fix typo
commit fd97fbb
Author: Chris Lamb <chris@chris-lamb.co.uk>
Date: Fri Nov 23 17:14:01 2018 +0100
Correct "unsupported" typo.
commit a85522d
Author: Jungnam Lee <jungnam.lee@oracle.com>
Date: Thu Nov 8 23:01:29 2018 +0900
fix typo in test comments
commit ade8007
Author: Arun Kumar <palerdot@users.noreply.github.com>
Date: Tue Oct 23 16:56:35 2018 +0530
Fixed grammatical typo
Fixed typo for word 'dictionary'
commit 869ee39
Author: Hamid Alaei <hamid.a85@gmail.com>
Date: Sun Aug 12 16:40:02 2018 +0430
fix documentations: (ThreadSafeContextStart/Stop -> ThreadSafeContextLock/Unlock), minor typo
commit f89d158
Author: Mayank Jain <mayankjain255@gmail.com>
Date: Tue Jul 31 23:01:21 2018 +0530
Updated README.md with some spelling corrections.
Made correction in spelling of some misspelled words.
commit 892198e
Author: dsomeshwar <someshwar.dhayalan@gmail.com>
Date: Sat Jul 21 23:23:04 2018 +0530
typo fix
commit 8a4d780
Author: Itamar Haber <itamar@redislabs.com>
Date: Mon Apr 30 02:06:52 2018 +0300
Fixes some typos
commit e3acef6
Author: Noah Rosamilia <ivoahivoah@gmail.com>
Date: Sat Mar 3 23:41:21 2018 -0500
Fix typo in /deps/README.md
commit 04442fb
Author: WuYunlong <xzsyeb@126.com>
Date: Sat Mar 3 10:32:42 2018 +0800
Fix typo in readSyncBulkPayload() comment.
commit 9f36880
Author: WuYunlong <xzsyeb@126.com>
Date: Sat Mar 3 10:20:37 2018 +0800
replication.c comment: run_id -> replid.
commit f866b4a
Author: Francesco 'makevoid' Canessa <makevoid@gmail.com>
Date: Thu Feb 22 22:01:56 2018 +0000
fix comment typo in server.c
commit 0ebc69b
Author: 줍 <jubee0124@gmail.com>
Date: Mon Feb 12 16:38:48 2018 +0900
Fix typo in redis.conf
Fix `five behaviors` to `eight behaviors` in [this sentence ](antirez/redis@unstable/redis.conf#L564)
commit b50a620
Author: martinbroadhurst <martinbroadhurst@users.noreply.github.com>
Date: Thu Dec 28 12:07:30 2017 +0000
Fix typo in valgrind.sup
commit 7d8f349
Author: Peter Boughton <peter@sorcerersisle.com>
Date: Mon Nov 27 19:52:19 2017 +0000
Update CONTRIBUTING; refer doc updates to redis-doc repo.
commit 02dec7e
Author: Klauswk <klauswk1@hotmail.com>
Date: Tue Oct 24 16:18:38 2017 -0200
Fix typo in comment
commit e1efbc8
Author: chenshi <baiwfg2@gmail.com>
Date: Tue Oct 3 18:26:30 2017 +0800
Correct two spelling errors of comments
commit 93327d8
Author: spacewander <spacewanderlzx@gmail.com>
Date: Wed Sep 13 16:47:24 2017 +0800
Update the comment for OBJ_ENCODING_EMBSTR_SIZE_LIMIT's value
The value of OBJ_ENCODING_EMBSTR_SIZE_LIMIT is 44 now instead of 39.
commit 63d361f
Author: spacewander <spacewanderlzx@gmail.com>
Date: Tue Sep 12 15:06:42 2017 +0800
Fix <prevlen> related doc in ziplist.c
According to the definition of ZIP_BIG_PREVLEN and other related code,
the guard of single byte <prevlen> should be 254 instead of 255.
commit ebe228d
Author: hanael80 <hanael80@gmail.com>
Date: Tue Aug 15 09:09:40 2017 +0900
Fix typo
commit 6b696e6
Author: Matt Robenolt <matt@ydekproductions.com>
Date: Mon Aug 14 14:50:47 2017 -0700
Fix typo in LATENCY DOCTOR output
commit a2ec6ae
Author: caosiyang <caosiyang@qiyi.com>
Date: Tue Aug 15 14:15:16 2017 +0800
Fix a typo: form => from
commit 3ab7699
Author: caosiyang <caosiyang@qiyi.com>
Date: Thu Aug 10 18:40:33 2017 +0800
Fix a typo: replicationFeedSlavesFromMaster() => replicationFeedSlavesFromMasterStream()
commit 72d43ef
Author: caosiyang <caosiyang@qiyi.com>
Date: Tue Aug 8 15:57:25 2017 +0800
fix a typo: servewr => server
commit 707c958
Author: Bo Cai <charpty@gmail.com>
Date: Wed Jul 26 21:49:42 2017 +0800
redis-cli.c typo: conut -> count.
Signed-off-by: Bo Cai <charpty@gmail.com>
commit b9385b2
Author: JackDrogon <jack.xsuperman@gmail.com>
Date: Fri Jun 30 14:22:31 2017 +0800
Fix some spell problems
commit 20d9230
Author: akosel <aaronjkosel@gmail.com>
Date: Sun Jun 4 19:35:13 2017 -0500
Fix typo
commit b167bfc
Author: Krzysiek Witkowicz <krzysiekwitkowicz@gmail.com>
Date: Mon May 22 21:32:27 2017 +0100
Fix #4008 small typo in comment
commit 2b78ac8
Author: Jake Clarkson <jacobwclarkson@gmail.com>
Date: Wed Apr 26 15:49:50 2017 +0100
Correct typo in tests/unit/hyperloglog.tcl
commit b0f1cdb
Author: Qi Luo <qiluo-msft@users.noreply.github.com>
Date: Wed Apr 19 14:25:18 2017 -0700
Fix typo
commit a90b0f9
Author: charsyam <charsyam@naver.com>
Date: Thu Mar 16 18:19:53 2017 +0900
fix typos
fix typos
fix typos
commit 8430a79
Author: Richard Hart <richardhart92@gmail.com>
Date: Mon Mar 13 22:17:41 2017 -0400
Fixed log message typo in listenToPort.
commit 481a1c2
Author: Vinod Kumar <kumar003vinod@gmail.com>
Date: Sun Jan 15 23:04:51 2017 +0530
src/db.c: Correct "save" -> "safe" typo
commit 586b4d3
Author: wangshaonan <wshn13@gmail.com>
Date: Wed Dec 21 20:28:27 2016 +0800
Fix typo they->the in helloworld.c
commit c1c4b5e
Author: Jenner <hypxm@qq.com>
Date: Mon Dec 19 16:39:46 2016 +0800
typo error
commit 1ee1a3f
Author: tielei <43289893@qq.com>
Date: Mon Jul 18 13:52:25 2016 +0800
fix some comments
commit 11a41fb
Author: Otto Kekäläinen <otto@seravo.fi>
Date: Sun Jul 3 10:23:55 2016 +0100
Fix spelling in documentation and comments
commit 5fb5d82
Author: francischan <f1ancis621@gmail.com>
Date: Tue Jun 28 00:19:33 2016 +0800
Fix outdated comments about redis.c file.
It should now refer to server.c file.
commit 6b254bc
Author: lmatt-bit <lmatt123n@gmail.com>
Date: Thu Apr 21 21:45:58 2016 +0800
Refine the comment of dictRehashMilliseconds func
SLAVECONF->REPLCONF in comment - by andyli029
commit ee9869f
Author: clark.kang <charsyam@naver.com>
Date: Tue Mar 22 11:09:51 2016 +0900
fix typos
commit f7b3b11
Author: Harisankar H <harisankarh@gmail.com>
Date: Wed Mar 9 11:49:42 2016 +0530
Typo correction: "faield" --> "failed"
Typo correction: "faield" --> "failed"
commit 3fd40fc
Author: Itamar Haber <itamar@redislabs.com>
Date: Thu Feb 25 10:31:51 2016 +0200
Fixes a typo in comments
commit 621c160
Author: Prayag Verma <prayag.verma@gmail.com>
Date: Mon Feb 1 12:36:20 2016 +0530
Fix typo in Readme.md
Spelling mistakes -
`eviciton` > `eviction`
`familar` > `familiar`
commit d7d07d6
Author: WonCheol Lee <toctoc21c@gmail.com>
Date: Wed Dec 30 15:11:34 2015 +0900
Typo fixed
commit a4dade7
Author: Felix Bünemann <buenemann@louis.info>
Date: Mon Dec 28 11:02:55 2015 +0100
[ci skip] Improve supervised upstart config docs
This mentions that "expect stop" is required for supervised upstart
to work correctly. See http://upstart.ubuntu.com/cookbook/#expect-stop
for an explanation.
commit d9caba9
Author: daurnimator <quae@daurnimator.com>
Date: Mon Dec 21 18:30:03 2015 +1100
README: Remove trailing whitespace
commit 72d42e5
Author: daurnimator <quae@daurnimator.com>
Date: Mon Dec 21 18:29:32 2015 +1100
README: Fix typo. th => the
commit dd6e957
Author: daurnimator <quae@daurnimator.com>
Date: Mon Dec 21 18:29:20 2015 +1100
README: Fix typo. familar => familiar
commit 3a12b23
Author: daurnimator <quae@daurnimator.com>
Date: Mon Dec 21 18:28:54 2015 +1100
README: Fix typo. eviciton => eviction
commit 2d1d03b
Author: daurnimator <quae@daurnimator.com>
Date: Mon Dec 21 18:21:45 2015 +1100
README: Fix typo. sever => server
commit 3973b06
Author: Itamar Haber <itamar@garantiadata.com>
Date: Sat Dec 19 17:01:20 2015 +0200
Typo fix
commit 4f2e460
Author: Steve Gao <fu@2token.com>
Date: Fri Dec 4 10:22:05 2015 +0800
Update README - fix typos
commit b21667c
Author: binyan <binbin.yan@nokia.com>
Date: Wed Dec 2 22:48:37 2015 +0800
delete redundancy color judge in sdscatcolor
commit 88894c7
Author: binyan <binbin.yan@nokia.com>
Date: Wed Dec 2 22:14:42 2015 +0800
the example output shoule be HelloWorld
commit 2763470
Author: binyan <binbin.yan@nokia.com>
Date: Wed Dec 2 17:41:39 2015 +0800
modify error word keyevente
Signed-off-by: binyan <binbin.yan@nokia.com>
commit 0847b3d
Author: Bruno Martins <bscmartins@gmail.com>
Date: Wed Nov 4 11:37:01 2015 +0000
typo
commit bbb9e9e
Author: dawedawe <dawedawe@gmx.de>
Date: Fri Mar 27 00:46:41 2015 +0100
typo: zimap -> zipmap
commit 5ed297e
Author: Axel Advento <badwolf.bloodseeker.rev@gmail.com>
Date: Tue Mar 3 15:58:29 2015 +0800
Fix 'salve' typos to 'slave'
commit edec9d6
Author: LudwikJaniuk <ludvig.janiuk@gmail.com>
Date: Wed Jun 12 14:12:47 2019 +0200
Update README.md
Co-Authored-By: Qix <Qix-@users.noreply.github.com>
commit 692a7af
Author: LudwikJaniuk <ludvig.janiuk@gmail.com>
Date: Tue May 28 14:32:04 2019 +0200
grammar
commit d962b0a
Author: Nick Frost <nickfrostatx@gmail.com>
Date: Wed Jul 20 15:17:12 2016 -0700
Minor grammar fix
commit 24fff01aaccaf5956973ada8c50ceb1462e211c6 (typos)
Author: Chad Miller <chadm@squareup.com>
Date: Tue Sep 8 13:46:11 2020 -0400
Fix faulty comment about operation of unlink()
commit 3cd5c1f3326c52aa552ada7ec797c6bb16452355
Author: Kevin <kevin.xgr@gmail.com>
Date: Wed Nov 20 00:13:50 2019 +0800
Fix typo in server.c.
From a83af59 Mon Sep 17 00:00:00 2001
From: wuwo <wuwo@wacai.com>
Date: Fri, 17 Mar 2017 20:37:45 +0800
Subject: [PATCH] falure to failure
From c961896 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=B7=A6=E6=87=B6?= <veficos@gmail.com>
Date: Sat, 27 May 2017 15:33:04 +0800
Subject: [PATCH] fix typo
From e600ef2 Mon Sep 17 00:00:00 2001
From: "rui.zou" <rui.zou@yunify.com>
Date: Sat, 30 Sep 2017 12:38:15 +0800
Subject: [PATCH] fix a typo
From c7d07fa Mon Sep 17 00:00:00 2001
From: Alexandre Perrin <alex@kaworu.ch>
Date: Thu, 16 Aug 2018 10:35:31 +0200
Subject: [PATCH] deps README.md typo
From b25cb67 Mon Sep 17 00:00:00 2001
From: Guy Korland <gkorland@gmail.com>
Date: Wed, 26 Sep 2018 10:55:37 +0300
Subject: [PATCH 1/2] fix typos in header
From ad28ca6 Mon Sep 17 00:00:00 2001
From: Guy Korland <gkorland@gmail.com>
Date: Wed, 26 Sep 2018 11:02:36 +0300
Subject: [PATCH 2/2] fix typos
commit 34924cdedd8552466fc22c1168d49236cb7ee915
Author: Adrian Lynch <adi_ady_ade@hotmail.com>
Date: Sat Apr 4 21:59:15 2015 +0100
Typos fixed
commit fd2a1e7
Author: Jan <jsteemann@users.noreply.github.com>
Date: Sat Oct 27 19:13:01 2018 +0200
Fix typos
Fix typos
commit e14e47c1a234b53b0e103c5f6a1c61481cbcbb02
Author: Andy Lester <andy@petdance.com>
Date: Fri Aug 2 22:30:07 2019 -0500
Fix multiple misspellings of "following"
commit 79b948ce2dac6b453fe80995abbcaac04c213d5a
Author: Andy Lester <andy@petdance.com>
Date: Fri Aug 2 22:24:28 2019 -0500
Fix misspelling of create-cluster
commit 1fffde52666dc99ab35efbd31071a4c008cb5a71
Author: Andy Lester <andy@petdance.com>
Date: Wed Jul 31 17:57:56 2019 -0500
Fix typos
commit 204c9ba9651e9e05fd73936b452b9a30be456cfe
Author: Xiaobo Zhu <xiaobo.zhu@shopee.com>
Date: Tue Aug 13 22:19:25 2019 +0800
fix typos
Squashed commit of the following:
commit 1d9aaf8
Author: danmedani <danmedani@gmail.com>
Date: Sun Aug 2 11:40:26 2015 -0700
README typo fix.
Squashed commit of the following:
commit 32bfa7c
Author: Erik Dubbelboer <erik@dubbelboer.com>
Date: Mon Jul 6 21:15:08 2015 +0200
Fixed grammer
Squashed commit of the following:
commit b24f69c
Author: Sisir Koppaka <sisir.koppaka@gmail.com>
Date: Mon Mar 2 22:38:45 2015 -0500
utils/hashtable/rehashing.c: Fix typos
Squashed commit of the following:
commit 4e04082
Author: Erik Dubbelboer <erik@dubbelboer.com>
Date: Mon Mar 23 08:22:21 2015 +0000
Small config file documentation improvements
Squashed commit of the following:
commit acb8773
Author: ctd1500 <ctd1500@gmail.com>
Date: Fri May 8 01:52:48 2015 -0700
Typo and grammar fixes in readme
commit 2eb75b6
Author: ctd1500 <ctd1500@gmail.com>
Date: Fri May 8 01:36:18 2015 -0700
fixed redis.conf comment
Squashed commit of the following:
commit a8249a2
Author: Masahiko Sawada <sawada.mshk@gmail.com>
Date: Fri Dec 11 11:39:52 2015 +0530
Revise correction of typos.
Squashed commit of the following:
commit 3c02028
Author: zhaojun11 <zhaojun11@jd.com>
Date: Wed Jan 17 19:05:28 2018 +0800
Fix typos include two code typos in cluster.c and latency.c
Squashed commit of the following:
commit 9dba47c
Author: q191201771 <191201771@qq.com>
Date: Sat Jan 4 11:31:04 2020 +0800
fix function listCreate comment in adlist.c
Update src/server.c
commit 2c7c2cb536e78dd211b1ac6f7bda00f0f54faaeb
Author: charpty <charpty@gmail.com>
Date: Tue May 1 23:16:59 2018 +0800
server.c typo: modules system dictionary type comment
Signed-off-by: charpty <charpty@gmail.com>
commit a8395323fb63cb59cb3591cb0f0c8edb7c29a680
Author: Itamar Haber <itamar@redislabs.com>
Date: Sun May 6 00:25:18 2018 +0300
Updates test_helper.tcl's help with undocumented options
Specifically:
* Host
* Port
* Client
commit bde6f9ced15755cd6407b4af7d601b030f36d60b
Author: wxisme <850885154@qq.com>
Date: Wed Aug 8 15:19:19 2018 +0800
fix comments in deps files
commit 3172474ba991532ab799ee1873439f3402412331
Author: wxisme <850885154@qq.com>
Date: Wed Aug 8 14:33:49 2018 +0800
fix some comments
commit 01b6f2b6858b5cf2ce4ad5092d2c746e755f53f0
Author: Thor Juhasz <thor@juhasz.pro>
Date: Sun Nov 18 14:37:41 2018 +0100
Minor fixes to comments
Found some parts a little unclear on a first read, which prompted me to have a better look at the file and fix some minor things I noticed.
Fixing minor typos and grammar. There are no changes to configuration options.
These changes are only meant to help the user better understand the explanations to the various configuration options
2020-09-10 06:43:38 -04:00
|
|
|
* a reversed string. */
|
2021-08-08 07:30:47 -04:00
|
|
|
if (value < 0) {
|
|
|
|
/* Since v is unsigned, if value==LLONG_MIN, -LLONG_MIN will overflow. */
|
|
|
|
if (value != LLONG_MIN) {
|
|
|
|
v = -value;
|
|
|
|
} else {
|
|
|
|
v = ((unsigned long long)LLONG_MAX) + 1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
v = value;
|
|
|
|
}
|
|
|
|
|
2014-04-28 04:52:08 -04:00
|
|
|
p = s;
|
|
|
|
do {
|
|
|
|
*p++ = '0'+(v%10);
|
|
|
|
v /= 10;
|
|
|
|
} while(v);
|
|
|
|
if (value < 0) *p++ = '-';
|
|
|
|
|
|
|
|
/* Compute length and add null term. */
|
|
|
|
l = p-s;
|
|
|
|
*p = '\0';
|
|
|
|
|
|
|
|
/* Reverse the string. */
|
|
|
|
p--;
|
|
|
|
while(s < p) {
|
|
|
|
aux = *s;
|
|
|
|
*s = *p;
|
|
|
|
*p = aux;
|
|
|
|
s++;
|
|
|
|
p--;
|
|
|
|
}
|
|
|
|
return l;
|
|
|
|
}
|
|
|
|
|
2014-04-28 10:38:17 -04:00
|
|
|
/* Identical sdsll2str(), but for unsigned long long type. */
|
|
|
|
int sdsull2str(char *s, unsigned long long v) {
|
|
|
|
char *p, aux;
|
|
|
|
size_t l;
|
|
|
|
|
|
|
|
/* Generate the string representation, this method produces
|
Squash merging 125 typo/grammar/comment/doc PRs (#7773)
List of squashed commits or PRs
===============================
commit 66801ea
Author: hwware <wen.hui.ware@gmail.com>
Date: Mon Jan 13 00:54:31 2020 -0500
typo fix in acl.c
commit 46f55db
Author: Itamar Haber <itamar@redislabs.com>
Date: Sun Sep 6 18:24:11 2020 +0300
Updates a couple of comments
Specifically:
* RM_AutoMemory completed instead of pointing to docs
* Updated link to custom type doc
commit 61a2aa0
Author: xindoo <xindoo@qq.com>
Date: Tue Sep 1 19:24:59 2020 +0800
Correct errors in code comments
commit a5871d1
Author: yz1509 <pro-756@qq.com>
Date: Tue Sep 1 18:36:06 2020 +0800
fix typos in module.c
commit 41eede7
Author: bookug <bookug@qq.com>
Date: Sat Aug 15 01:11:33 2020 +0800
docs: fix typos in comments
commit c303c84
Author: lazy-snail <ws.niu@outlook.com>
Date: Fri Aug 7 11:15:44 2020 +0800
fix spelling in redis.conf
commit 1eb76bf
Author: zhujian <zhujianxyz@gmail.com>
Date: Thu Aug 6 15:22:10 2020 +0800
add a missing 'n' in comment
commit 1530ec2
Author: Daniel Dai <764122422@qq.com>
Date: Mon Jul 27 00:46:35 2020 -0400
fix spelling in tracking.c
commit e517b31
Author: Hunter-Chen <huntcool001@gmail.com>
Date: Fri Jul 17 22:33:32 2020 +0800
Update redis.conf
Co-authored-by: Itamar Haber <itamar@redislabs.com>
commit c300eff
Author: Hunter-Chen <huntcool001@gmail.com>
Date: Fri Jul 17 22:33:23 2020 +0800
Update redis.conf
Co-authored-by: Itamar Haber <itamar@redislabs.com>
commit 4c058a8
Author: 陈浩鹏 <chenhaopeng@heytea.com>
Date: Thu Jun 25 19:00:56 2020 +0800
Grammar fix and clarification
commit 5fcaa81
Author: bodong.ybd <bodong.ybd@alibaba-inc.com>
Date: Fri Jun 19 10:09:00 2020 +0800
Fix typos
commit 4caca9a
Author: Pruthvi P <pruthvi@ixigo.com>
Date: Fri May 22 00:33:22 2020 +0530
Fix typo eviciton => eviction
commit b2a25f6
Author: Brad Dunbar <dunbarb2@gmail.com>
Date: Sun May 17 12:39:59 2020 -0400
Fix a typo.
commit 12842ae
Author: hwware <wen.hui.ware@gmail.com>
Date: Sun May 3 17:16:59 2020 -0400
fix spelling in redis conf
commit ddba07c
Author: Chris Lamb <chris@chris-lamb.co.uk>
Date: Sat May 2 23:25:34 2020 +0100
Correct a "conflicts" spelling error.
commit 8fc7bf2
Author: Nao YONASHIRO <yonashiro@r.recruit.co.jp>
Date: Thu Apr 30 10:25:27 2020 +0900
docs: fix EXPIRE_FAST_CYCLE_DURATION to ACTIVE_EXPIRE_CYCLE_FAST_DURATION
commit 9b2b67a
Author: Brad Dunbar <dunbarb2@gmail.com>
Date: Fri Apr 24 11:46:22 2020 -0400
Fix a typo.
commit 0746f10
Author: devilinrust <63737265+devilinrust@users.noreply.github.com>
Date: Thu Apr 16 00:17:53 2020 +0200
Fix typos in server.c
commit 92b588d
Author: benjessop12 <56115861+benjessop12@users.noreply.github.com>
Date: Mon Apr 13 13:43:55 2020 +0100
Fix spelling mistake in lazyfree.c
commit 1da37aa
Merge: 2d4ba28 af347a8
Author: hwware <wen.hui.ware@gmail.com>
Date: Thu Mar 5 22:41:31 2020 -0500
Merge remote-tracking branch 'upstream/unstable' into expiretypofix
commit 2d4ba28
Author: hwware <wen.hui.ware@gmail.com>
Date: Mon Mar 2 00:09:40 2020 -0500
fix typo in expire.c
commit 1a746f7
Author: SennoYuki <minakami1yuki@gmail.com>
Date: Thu Feb 27 16:54:32 2020 +0800
fix typo
commit 8599b1a
Author: dongheejeong <donghee950403@gmail.com>
Date: Sun Feb 16 20:31:43 2020 +0000
Fix typo in server.c
commit f38d4e8
Author: hwware <wen.hui.ware@gmail.com>
Date: Sun Feb 2 22:58:38 2020 -0500
fix typo in evict.c
commit fe143fc
Author: Leo Murillo <leonardo.murillo@gmail.com>
Date: Sun Feb 2 01:57:22 2020 -0600
Fix a few typos in redis.conf
commit 1ab4d21
Author: viraja1 <anchan.viraj@gmail.com>
Date: Fri Dec 27 17:15:58 2019 +0530
Fix typo in Latency API docstring
commit ca1f70e
Author: gosth <danxuedexing@qq.com>
Date: Wed Dec 18 15:18:02 2019 +0800
fix typo in sort.c
commit a57c06b
Author: ZYunH <zyunhjob@163.com>
Date: Mon Dec 16 22:28:46 2019 +0800
fix-zset-typo
commit b8c92b5
Author: git-hulk <hulk.website@gmail.com>
Date: Mon Dec 16 15:51:42 2019 +0800
FIX: typo in cluster.c, onformation->information
commit 9dd981c
Author: wujm2007 <jim.wujm@gmail.com>
Date: Mon Dec 16 09:37:52 2019 +0800
Fix typo
commit e132d7a
Author: Sebastien Williams-Wynn <s.williamswynn.mail@gmail.com>
Date: Fri Nov 15 00:14:07 2019 +0000
Minor typo change
commit 47f44d5
Author: happynote3966 <01ssrmikururudevice01@gmail.com>
Date: Mon Nov 11 22:08:48 2019 +0900
fix comment typo in redis-cli.c
commit b8bdb0d
Author: fulei <fulei@kuaishou.com>
Date: Wed Oct 16 18:00:17 2019 +0800
Fix a spelling mistake of comments in defragDictBucketCallback
commit 0def46a
Author: fulei <fulei@kuaishou.com>
Date: Wed Oct 16 13:09:27 2019 +0800
fix some spelling mistakes of comments in defrag.c
commit f3596fd
Author: Phil Rajchgot <tophil@outlook.com>
Date: Sun Oct 13 02:02:32 2019 -0400
Typo and grammar fixes
Redis and its documentation are great -- just wanted to submit a few corrections in the spirit of Hacktoberfest. Thanks for all your work on this project. I use it all the time and it works beautifully.
commit 2b928cd
Author: KangZhiDong <worldkzd@gmail.com>
Date: Sun Sep 1 07:03:11 2019 +0800
fix typos
commit 33aea14
Author: Axlgrep <axlgrep@gmail.com>
Date: Tue Aug 27 11:02:18 2019 +0800
Fixed eviction spelling issues
commit e282a80
Author: Simen Flatby <simen@oms.no>
Date: Tue Aug 20 15:25:51 2019 +0200
Update comments to reflect prop name
In the comments the prop is referenced as replica-validity-factor,
but it is really named cluster-replica-validity-factor.
commit 74d1f9a
Author: Jim Green <jimgreen2013@qq.com>
Date: Tue Aug 20 20:00:31 2019 +0800
fix comment error, the code is ok
commit eea1407
Author: Liao Tonglang <liaotonglang@gmail.com>
Date: Fri May 31 10:16:18 2019 +0800
typo fix
fix cna't to can't
commit 0da553c
Author: KAWACHI Takashi <tkawachi@gmail.com>
Date: Wed Jul 17 00:38:16 2019 +0900
Fix typo
commit 7fc8fb6
Author: Michael Prokop <mika@grml.org>
Date: Tue May 28 17:58:42 2019 +0200
Typo fixes
s/familar/familiar/
s/compatiblity/compatibility/
s/ ot / to /
s/itsef/itself/
commit 5f46c9d
Author: zhumoing <34539422+zhumoing@users.noreply.github.com>
Date: Tue May 21 21:16:50 2019 +0800
typo-fixes
typo-fixes
commit 321dfe1
Author: wxisme <850885154@qq.com>
Date: Sat Mar 16 15:10:55 2019 +0800
typo fix
commit b4fb131
Merge: 267e0e6 3df1eb8
Author: Nikitas Bastas <nikitasbst@gmail.com>
Date: Fri Feb 8 22:55:45 2019 +0200
Merge branch 'unstable' of antirez/redis into unstable
commit 267e0e6
Author: Nikitas Bastas <nikitasbst@gmail.com>
Date: Wed Jan 30 21:26:04 2019 +0200
Minor typo fix
commit 30544e7
Author: inshal96 <39904558+inshal96@users.noreply.github.com>
Date: Fri Jan 4 16:54:50 2019 +0500
remove an extra 'a' in the comments
commit 337969d
Author: BrotherGao <yangdongheng11@gmail.com>
Date: Sat Dec 29 12:37:29 2018 +0800
fix typo in redis.conf
commit 9f4b121
Merge: 423a030 e504583
Author: BrotherGao <yangdongheng@xiaomi.com>
Date: Sat Dec 29 11:41:12 2018 +0800
Merge branch 'unstable' of antirez/redis into unstable
commit 423a030
Merge: 42b02b7 46a51cd
Author: 杨东衡 <yangdongheng@xiaomi.com>
Date: Tue Dec 4 23:56:11 2018 +0800
Merge branch 'unstable' of antirez/redis into unstable
commit 42b02b7
Merge: 68c0e6e b8febe6
Author: Dongheng Yang <yangdongheng11@gmail.com>
Date: Sun Oct 28 15:54:23 2018 +0800
Merge pull request #1 from antirez/unstable
update local data
commit 714b589
Author: Christian <crifei93@gmail.com>
Date: Fri Dec 28 01:17:26 2018 +0100
fix typo "resulution"
commit e23259d
Author: garenchan <1412950785@qq.com>
Date: Wed Dec 26 09:58:35 2018 +0800
fix typo: segfauls -> segfault
commit a9359f8
Author: xjp <jianping_xie@aliyun.com>
Date: Tue Dec 18 17:31:44 2018 +0800
Fixed REDISMODULE_H spell bug
commit a12c3e4
Author: jdiaz <jrd.palacios@gmail.com>
Date: Sat Dec 15 23:39:52 2018 -0600
Fixes hyperloglog hash function comment block description
commit 770eb11
Author: 林上耀 <1210tom@163.com>
Date: Sun Nov 25 17:16:10 2018 +0800
fix typo
commit fd97fbb
Author: Chris Lamb <chris@chris-lamb.co.uk>
Date: Fri Nov 23 17:14:01 2018 +0100
Correct "unsupported" typo.
commit a85522d
Author: Jungnam Lee <jungnam.lee@oracle.com>
Date: Thu Nov 8 23:01:29 2018 +0900
fix typo in test comments
commit ade8007
Author: Arun Kumar <palerdot@users.noreply.github.com>
Date: Tue Oct 23 16:56:35 2018 +0530
Fixed grammatical typo
Fixed typo for word 'dictionary'
commit 869ee39
Author: Hamid Alaei <hamid.a85@gmail.com>
Date: Sun Aug 12 16:40:02 2018 +0430
fix documentations: (ThreadSafeContextStart/Stop -> ThreadSafeContextLock/Unlock), minor typo
commit f89d158
Author: Mayank Jain <mayankjain255@gmail.com>
Date: Tue Jul 31 23:01:21 2018 +0530
Updated README.md with some spelling corrections.
Made correction in spelling of some misspelled words.
commit 892198e
Author: dsomeshwar <someshwar.dhayalan@gmail.com>
Date: Sat Jul 21 23:23:04 2018 +0530
typo fix
commit 8a4d780
Author: Itamar Haber <itamar@redislabs.com>
Date: Mon Apr 30 02:06:52 2018 +0300
Fixes some typos
commit e3acef6
Author: Noah Rosamilia <ivoahivoah@gmail.com>
Date: Sat Mar 3 23:41:21 2018 -0500
Fix typo in /deps/README.md
commit 04442fb
Author: WuYunlong <xzsyeb@126.com>
Date: Sat Mar 3 10:32:42 2018 +0800
Fix typo in readSyncBulkPayload() comment.
commit 9f36880
Author: WuYunlong <xzsyeb@126.com>
Date: Sat Mar 3 10:20:37 2018 +0800
replication.c comment: run_id -> replid.
commit f866b4a
Author: Francesco 'makevoid' Canessa <makevoid@gmail.com>
Date: Thu Feb 22 22:01:56 2018 +0000
fix comment typo in server.c
commit 0ebc69b
Author: 줍 <jubee0124@gmail.com>
Date: Mon Feb 12 16:38:48 2018 +0900
Fix typo in redis.conf
Fix `five behaviors` to `eight behaviors` in [this sentence ](antirez/redis@unstable/redis.conf#L564)
commit b50a620
Author: martinbroadhurst <martinbroadhurst@users.noreply.github.com>
Date: Thu Dec 28 12:07:30 2017 +0000
Fix typo in valgrind.sup
commit 7d8f349
Author: Peter Boughton <peter@sorcerersisle.com>
Date: Mon Nov 27 19:52:19 2017 +0000
Update CONTRIBUTING; refer doc updates to redis-doc repo.
commit 02dec7e
Author: Klauswk <klauswk1@hotmail.com>
Date: Tue Oct 24 16:18:38 2017 -0200
Fix typo in comment
commit e1efbc8
Author: chenshi <baiwfg2@gmail.com>
Date: Tue Oct 3 18:26:30 2017 +0800
Correct two spelling errors of comments
commit 93327d8
Author: spacewander <spacewanderlzx@gmail.com>
Date: Wed Sep 13 16:47:24 2017 +0800
Update the comment for OBJ_ENCODING_EMBSTR_SIZE_LIMIT's value
The value of OBJ_ENCODING_EMBSTR_SIZE_LIMIT is 44 now instead of 39.
commit 63d361f
Author: spacewander <spacewanderlzx@gmail.com>
Date: Tue Sep 12 15:06:42 2017 +0800
Fix <prevlen> related doc in ziplist.c
According to the definition of ZIP_BIG_PREVLEN and other related code,
the guard of single byte <prevlen> should be 254 instead of 255.
commit ebe228d
Author: hanael80 <hanael80@gmail.com>
Date: Tue Aug 15 09:09:40 2017 +0900
Fix typo
commit 6b696e6
Author: Matt Robenolt <matt@ydekproductions.com>
Date: Mon Aug 14 14:50:47 2017 -0700
Fix typo in LATENCY DOCTOR output
commit a2ec6ae
Author: caosiyang <caosiyang@qiyi.com>
Date: Tue Aug 15 14:15:16 2017 +0800
Fix a typo: form => from
commit 3ab7699
Author: caosiyang <caosiyang@qiyi.com>
Date: Thu Aug 10 18:40:33 2017 +0800
Fix a typo: replicationFeedSlavesFromMaster() => replicationFeedSlavesFromMasterStream()
commit 72d43ef
Author: caosiyang <caosiyang@qiyi.com>
Date: Tue Aug 8 15:57:25 2017 +0800
fix a typo: servewr => server
commit 707c958
Author: Bo Cai <charpty@gmail.com>
Date: Wed Jul 26 21:49:42 2017 +0800
redis-cli.c typo: conut -> count.
Signed-off-by: Bo Cai <charpty@gmail.com>
commit b9385b2
Author: JackDrogon <jack.xsuperman@gmail.com>
Date: Fri Jun 30 14:22:31 2017 +0800
Fix some spell problems
commit 20d9230
Author: akosel <aaronjkosel@gmail.com>
Date: Sun Jun 4 19:35:13 2017 -0500
Fix typo
commit b167bfc
Author: Krzysiek Witkowicz <krzysiekwitkowicz@gmail.com>
Date: Mon May 22 21:32:27 2017 +0100
Fix #4008 small typo in comment
commit 2b78ac8
Author: Jake Clarkson <jacobwclarkson@gmail.com>
Date: Wed Apr 26 15:49:50 2017 +0100
Correct typo in tests/unit/hyperloglog.tcl
commit b0f1cdb
Author: Qi Luo <qiluo-msft@users.noreply.github.com>
Date: Wed Apr 19 14:25:18 2017 -0700
Fix typo
commit a90b0f9
Author: charsyam <charsyam@naver.com>
Date: Thu Mar 16 18:19:53 2017 +0900
fix typos
fix typos
fix typos
commit 8430a79
Author: Richard Hart <richardhart92@gmail.com>
Date: Mon Mar 13 22:17:41 2017 -0400
Fixed log message typo in listenToPort.
commit 481a1c2
Author: Vinod Kumar <kumar003vinod@gmail.com>
Date: Sun Jan 15 23:04:51 2017 +0530
src/db.c: Correct "save" -> "safe" typo
commit 586b4d3
Author: wangshaonan <wshn13@gmail.com>
Date: Wed Dec 21 20:28:27 2016 +0800
Fix typo they->the in helloworld.c
commit c1c4b5e
Author: Jenner <hypxm@qq.com>
Date: Mon Dec 19 16:39:46 2016 +0800
typo error
commit 1ee1a3f
Author: tielei <43289893@qq.com>
Date: Mon Jul 18 13:52:25 2016 +0800
fix some comments
commit 11a41fb
Author: Otto Kekäläinen <otto@seravo.fi>
Date: Sun Jul 3 10:23:55 2016 +0100
Fix spelling in documentation and comments
commit 5fb5d82
Author: francischan <f1ancis621@gmail.com>
Date: Tue Jun 28 00:19:33 2016 +0800
Fix outdated comments about redis.c file.
It should now refer to server.c file.
commit 6b254bc
Author: lmatt-bit <lmatt123n@gmail.com>
Date: Thu Apr 21 21:45:58 2016 +0800
Refine the comment of dictRehashMilliseconds func
SLAVECONF->REPLCONF in comment - by andyli029
commit ee9869f
Author: clark.kang <charsyam@naver.com>
Date: Tue Mar 22 11:09:51 2016 +0900
fix typos
commit f7b3b11
Author: Harisankar H <harisankarh@gmail.com>
Date: Wed Mar 9 11:49:42 2016 +0530
Typo correction: "faield" --> "failed"
Typo correction: "faield" --> "failed"
commit 3fd40fc
Author: Itamar Haber <itamar@redislabs.com>
Date: Thu Feb 25 10:31:51 2016 +0200
Fixes a typo in comments
commit 621c160
Author: Prayag Verma <prayag.verma@gmail.com>
Date: Mon Feb 1 12:36:20 2016 +0530
Fix typo in Readme.md
Spelling mistakes -
`eviciton` > `eviction`
`familar` > `familiar`
commit d7d07d6
Author: WonCheol Lee <toctoc21c@gmail.com>
Date: Wed Dec 30 15:11:34 2015 +0900
Typo fixed
commit a4dade7
Author: Felix Bünemann <buenemann@louis.info>
Date: Mon Dec 28 11:02:55 2015 +0100
[ci skip] Improve supervised upstart config docs
This mentions that "expect stop" is required for supervised upstart
to work correctly. See http://upstart.ubuntu.com/cookbook/#expect-stop
for an explanation.
commit d9caba9
Author: daurnimator <quae@daurnimator.com>
Date: Mon Dec 21 18:30:03 2015 +1100
README: Remove trailing whitespace
commit 72d42e5
Author: daurnimator <quae@daurnimator.com>
Date: Mon Dec 21 18:29:32 2015 +1100
README: Fix typo. th => the
commit dd6e957
Author: daurnimator <quae@daurnimator.com>
Date: Mon Dec 21 18:29:20 2015 +1100
README: Fix typo. familar => familiar
commit 3a12b23
Author: daurnimator <quae@daurnimator.com>
Date: Mon Dec 21 18:28:54 2015 +1100
README: Fix typo. eviciton => eviction
commit 2d1d03b
Author: daurnimator <quae@daurnimator.com>
Date: Mon Dec 21 18:21:45 2015 +1100
README: Fix typo. sever => server
commit 3973b06
Author: Itamar Haber <itamar@garantiadata.com>
Date: Sat Dec 19 17:01:20 2015 +0200
Typo fix
commit 4f2e460
Author: Steve Gao <fu@2token.com>
Date: Fri Dec 4 10:22:05 2015 +0800
Update README - fix typos
commit b21667c
Author: binyan <binbin.yan@nokia.com>
Date: Wed Dec 2 22:48:37 2015 +0800
delete redundancy color judge in sdscatcolor
commit 88894c7
Author: binyan <binbin.yan@nokia.com>
Date: Wed Dec 2 22:14:42 2015 +0800
the example output shoule be HelloWorld
commit 2763470
Author: binyan <binbin.yan@nokia.com>
Date: Wed Dec 2 17:41:39 2015 +0800
modify error word keyevente
Signed-off-by: binyan <binbin.yan@nokia.com>
commit 0847b3d
Author: Bruno Martins <bscmartins@gmail.com>
Date: Wed Nov 4 11:37:01 2015 +0000
typo
commit bbb9e9e
Author: dawedawe <dawedawe@gmx.de>
Date: Fri Mar 27 00:46:41 2015 +0100
typo: zimap -> zipmap
commit 5ed297e
Author: Axel Advento <badwolf.bloodseeker.rev@gmail.com>
Date: Tue Mar 3 15:58:29 2015 +0800
Fix 'salve' typos to 'slave'
commit edec9d6
Author: LudwikJaniuk <ludvig.janiuk@gmail.com>
Date: Wed Jun 12 14:12:47 2019 +0200
Update README.md
Co-Authored-By: Qix <Qix-@users.noreply.github.com>
commit 692a7af
Author: LudwikJaniuk <ludvig.janiuk@gmail.com>
Date: Tue May 28 14:32:04 2019 +0200
grammar
commit d962b0a
Author: Nick Frost <nickfrostatx@gmail.com>
Date: Wed Jul 20 15:17:12 2016 -0700
Minor grammar fix
commit 24fff01aaccaf5956973ada8c50ceb1462e211c6 (typos)
Author: Chad Miller <chadm@squareup.com>
Date: Tue Sep 8 13:46:11 2020 -0400
Fix faulty comment about operation of unlink()
commit 3cd5c1f3326c52aa552ada7ec797c6bb16452355
Author: Kevin <kevin.xgr@gmail.com>
Date: Wed Nov 20 00:13:50 2019 +0800
Fix typo in server.c.
From a83af59 Mon Sep 17 00:00:00 2001
From: wuwo <wuwo@wacai.com>
Date: Fri, 17 Mar 2017 20:37:45 +0800
Subject: [PATCH] falure to failure
From c961896 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=B7=A6=E6=87=B6?= <veficos@gmail.com>
Date: Sat, 27 May 2017 15:33:04 +0800
Subject: [PATCH] fix typo
From e600ef2 Mon Sep 17 00:00:00 2001
From: "rui.zou" <rui.zou@yunify.com>
Date: Sat, 30 Sep 2017 12:38:15 +0800
Subject: [PATCH] fix a typo
From c7d07fa Mon Sep 17 00:00:00 2001
From: Alexandre Perrin <alex@kaworu.ch>
Date: Thu, 16 Aug 2018 10:35:31 +0200
Subject: [PATCH] deps README.md typo
From b25cb67 Mon Sep 17 00:00:00 2001
From: Guy Korland <gkorland@gmail.com>
Date: Wed, 26 Sep 2018 10:55:37 +0300
Subject: [PATCH 1/2] fix typos in header
From ad28ca6 Mon Sep 17 00:00:00 2001
From: Guy Korland <gkorland@gmail.com>
Date: Wed, 26 Sep 2018 11:02:36 +0300
Subject: [PATCH 2/2] fix typos
commit 34924cdedd8552466fc22c1168d49236cb7ee915
Author: Adrian Lynch <adi_ady_ade@hotmail.com>
Date: Sat Apr 4 21:59:15 2015 +0100
Typos fixed
commit fd2a1e7
Author: Jan <jsteemann@users.noreply.github.com>
Date: Sat Oct 27 19:13:01 2018 +0200
Fix typos
Fix typos
commit e14e47c1a234b53b0e103c5f6a1c61481cbcbb02
Author: Andy Lester <andy@petdance.com>
Date: Fri Aug 2 22:30:07 2019 -0500
Fix multiple misspellings of "following"
commit 79b948ce2dac6b453fe80995abbcaac04c213d5a
Author: Andy Lester <andy@petdance.com>
Date: Fri Aug 2 22:24:28 2019 -0500
Fix misspelling of create-cluster
commit 1fffde52666dc99ab35efbd31071a4c008cb5a71
Author: Andy Lester <andy@petdance.com>
Date: Wed Jul 31 17:57:56 2019 -0500
Fix typos
commit 204c9ba9651e9e05fd73936b452b9a30be456cfe
Author: Xiaobo Zhu <xiaobo.zhu@shopee.com>
Date: Tue Aug 13 22:19:25 2019 +0800
fix typos
Squashed commit of the following:
commit 1d9aaf8
Author: danmedani <danmedani@gmail.com>
Date: Sun Aug 2 11:40:26 2015 -0700
README typo fix.
Squashed commit of the following:
commit 32bfa7c
Author: Erik Dubbelboer <erik@dubbelboer.com>
Date: Mon Jul 6 21:15:08 2015 +0200
Fixed grammer
Squashed commit of the following:
commit b24f69c
Author: Sisir Koppaka <sisir.koppaka@gmail.com>
Date: Mon Mar 2 22:38:45 2015 -0500
utils/hashtable/rehashing.c: Fix typos
Squashed commit of the following:
commit 4e04082
Author: Erik Dubbelboer <erik@dubbelboer.com>
Date: Mon Mar 23 08:22:21 2015 +0000
Small config file documentation improvements
Squashed commit of the following:
commit acb8773
Author: ctd1500 <ctd1500@gmail.com>
Date: Fri May 8 01:52:48 2015 -0700
Typo and grammar fixes in readme
commit 2eb75b6
Author: ctd1500 <ctd1500@gmail.com>
Date: Fri May 8 01:36:18 2015 -0700
fixed redis.conf comment
Squashed commit of the following:
commit a8249a2
Author: Masahiko Sawada <sawada.mshk@gmail.com>
Date: Fri Dec 11 11:39:52 2015 +0530
Revise correction of typos.
Squashed commit of the following:
commit 3c02028
Author: zhaojun11 <zhaojun11@jd.com>
Date: Wed Jan 17 19:05:28 2018 +0800
Fix typos include two code typos in cluster.c and latency.c
Squashed commit of the following:
commit 9dba47c
Author: q191201771 <191201771@qq.com>
Date: Sat Jan 4 11:31:04 2020 +0800
fix function listCreate comment in adlist.c
Update src/server.c
commit 2c7c2cb536e78dd211b1ac6f7bda00f0f54faaeb
Author: charpty <charpty@gmail.com>
Date: Tue May 1 23:16:59 2018 +0800
server.c typo: modules system dictionary type comment
Signed-off-by: charpty <charpty@gmail.com>
commit a8395323fb63cb59cb3591cb0f0c8edb7c29a680
Author: Itamar Haber <itamar@redislabs.com>
Date: Sun May 6 00:25:18 2018 +0300
Updates test_helper.tcl's help with undocumented options
Specifically:
* Host
* Port
* Client
commit bde6f9ced15755cd6407b4af7d601b030f36d60b
Author: wxisme <850885154@qq.com>
Date: Wed Aug 8 15:19:19 2018 +0800
fix comments in deps files
commit 3172474ba991532ab799ee1873439f3402412331
Author: wxisme <850885154@qq.com>
Date: Wed Aug 8 14:33:49 2018 +0800
fix some comments
commit 01b6f2b6858b5cf2ce4ad5092d2c746e755f53f0
Author: Thor Juhasz <thor@juhasz.pro>
Date: Sun Nov 18 14:37:41 2018 +0100
Minor fixes to comments
Found some parts a little unclear on a first read, which prompted me to have a better look at the file and fix some minor things I noticed.
Fixing minor typos and grammar. There are no changes to configuration options.
These changes are only meant to help the user better understand the explanations to the various configuration options
2020-09-10 06:43:38 -04:00
|
|
|
* a reversed string. */
|
2014-04-28 10:38:17 -04:00
|
|
|
p = s;
|
|
|
|
do {
|
|
|
|
*p++ = '0'+(v%10);
|
|
|
|
v /= 10;
|
|
|
|
} while(v);
|
|
|
|
|
|
|
|
/* Compute length and add null term. */
|
|
|
|
l = p-s;
|
|
|
|
*p = '\0';
|
|
|
|
|
|
|
|
/* Reverse the string. */
|
|
|
|
p--;
|
|
|
|
while(s < p) {
|
|
|
|
aux = *s;
|
|
|
|
*s = *p;
|
|
|
|
*p = aux;
|
|
|
|
s++;
|
|
|
|
p--;
|
|
|
|
}
|
|
|
|
return l;
|
|
|
|
}
|
|
|
|
|
2014-04-28 04:52:08 -04:00
|
|
|
/* Create an sds string from a long long value. It is much faster than:
|
|
|
|
*
|
|
|
|
* sdscatprintf(sdsempty(),"%lld\n", value);
|
|
|
|
*/
|
|
|
|
sds sdsfromlonglong(long long value) {
|
|
|
|
char buf[SDS_LLSTR_SIZE];
|
|
|
|
int len = sdsll2str(buf,value);
|
|
|
|
|
|
|
|
return sdsnewlen(buf,len);
|
|
|
|
}
|
|
|
|
|
2014-11-03 04:21:54 -05:00
|
|
|
/* Like sdscatprintf() but gets va_list instead of being variadic. */
|
2010-09-02 13:35:07 -04:00
|
|
|
sds sdscatvprintf(sds s, const char *fmt, va_list ap) {
|
|
|
|
va_list cpy;
|
2014-03-24 05:20:33 -04:00
|
|
|
char staticbuf[1024], *buf = staticbuf, *t;
|
|
|
|
size_t buflen = strlen(fmt)*2;
|
2020-11-04 06:38:46 -05:00
|
|
|
int bufstrlen;
|
2009-03-22 05:30:00 -04:00
|
|
|
|
2014-03-24 05:20:33 -04:00
|
|
|
/* We try to start using a static buffer for speed.
|
|
|
|
* If not possible we revert to heap allocation. */
|
|
|
|
if (buflen > sizeof(staticbuf)) {
|
2015-07-25 11:25:44 -04:00
|
|
|
buf = s_malloc(buflen);
|
2009-03-22 05:30:00 -04:00
|
|
|
if (buf == NULL) return NULL;
|
2014-03-24 05:20:33 -04:00
|
|
|
} else {
|
|
|
|
buflen = sizeof(staticbuf);
|
|
|
|
}
|
|
|
|
|
2020-11-04 06:38:46 -05:00
|
|
|
/* Alloc enough space for buffer and \0 after failing to
|
2014-03-24 05:20:33 -04:00
|
|
|
* fit the string in the current buffer size. */
|
|
|
|
while(1) {
|
2010-09-02 13:35:07 -04:00
|
|
|
va_copy(cpy,ap);
|
2020-11-04 06:38:46 -05:00
|
|
|
bufstrlen = vsnprintf(buf, buflen, fmt, cpy);
|
2014-11-01 22:42:26 -04:00
|
|
|
va_end(cpy);
|
2020-11-04 06:38:46 -05:00
|
|
|
if (bufstrlen < 0) {
|
2015-07-25 11:25:44 -04:00
|
|
|
if (buf != staticbuf) s_free(buf);
|
2020-11-04 06:38:46 -05:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (((size_t)bufstrlen) >= buflen) {
|
|
|
|
if (buf != staticbuf) s_free(buf);
|
|
|
|
buflen = ((size_t)bufstrlen) + 1;
|
2015-07-25 11:25:44 -04:00
|
|
|
buf = s_malloc(buflen);
|
2014-03-24 05:20:33 -04:00
|
|
|
if (buf == NULL) return NULL;
|
2009-03-22 05:30:00 -04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2014-03-24 05:20:33 -04:00
|
|
|
|
|
|
|
/* Finally concat the obtained string to the SDS string and return it. */
|
2020-11-04 06:38:46 -05:00
|
|
|
t = sdscatlen(s, buf, bufstrlen);
|
2015-07-25 11:25:44 -04:00
|
|
|
if (buf != staticbuf) s_free(buf);
|
2009-03-22 05:30:00 -04:00
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
2013-07-23 10:35:55 -04:00
|
|
|
/* Append to the sds string 's' a string obtained using printf-alike format
|
|
|
|
* specifier.
|
|
|
|
*
|
|
|
|
* After the call, the modified sds string is no longer valid and all the
|
|
|
|
* references must be substituted with the new pointer returned by the call.
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
*
|
2014-11-01 22:40:28 -04:00
|
|
|
* s = sdsnew("Sum is: ");
|
2013-07-23 10:35:55 -04:00
|
|
|
* s = sdscatprintf(s,"%d+%d = %d",a,b,a+b).
|
|
|
|
*
|
|
|
|
* Often you need to create a string from scratch with the printf-alike
|
|
|
|
* format. When this is the need, just use sdsempty() as the target string:
|
|
|
|
*
|
|
|
|
* s = sdscatprintf(sdsempty(), "... your format ...", args);
|
|
|
|
*/
|
2010-09-02 13:35:07 -04:00
|
|
|
sds sdscatprintf(sds s, const char *fmt, ...) {
|
|
|
|
va_list ap;
|
|
|
|
char *t;
|
|
|
|
va_start(ap, fmt);
|
|
|
|
t = sdscatvprintf(s,fmt,ap);
|
|
|
|
va_end(ap);
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
2014-04-28 04:52:08 -04:00
|
|
|
/* This function is similar to sdscatprintf, but much faster as it does
|
|
|
|
* not rely on sprintf() family functions implemented by the libc that
|
|
|
|
* are often very slow. Moreover directly handling the sds string as
|
|
|
|
* new data is concatenated provides a performance improvement.
|
|
|
|
*
|
|
|
|
* However this function only handles an incompatible subset of printf-alike
|
|
|
|
* format specifiers:
|
|
|
|
*
|
|
|
|
* %s - C String
|
|
|
|
* %S - SDS string
|
2014-04-28 10:38:17 -04:00
|
|
|
* %i - signed int
|
2014-04-28 04:52:08 -04:00
|
|
|
* %I - 64 bit signed integer (long long, int64_t)
|
2014-04-28 10:38:17 -04:00
|
|
|
* %u - unsigned int
|
|
|
|
* %U - 64 bit unsigned integer (unsigned long long, uint64_t)
|
2014-04-28 04:52:08 -04:00
|
|
|
* %% - Verbatim "%" character.
|
|
|
|
*/
|
|
|
|
sds sdscatfmt(sds s, char const *fmt, ...) {
|
|
|
|
size_t initlen = sdslen(s);
|
|
|
|
const char *f = fmt;
|
2017-12-21 04:10:48 -05:00
|
|
|
long i;
|
2014-04-28 04:52:08 -04:00
|
|
|
va_list ap;
|
|
|
|
|
2019-10-02 05:27:21 -04:00
|
|
|
/* To avoid continuous reallocations, let's start with a buffer that
|
|
|
|
* can hold at least two times the format string itself. It's not the
|
|
|
|
* best heuristic but seems to work in practice. */
|
2021-01-05 11:41:53 -05:00
|
|
|
s = sdsMakeRoomFor(s, strlen(fmt)*2);
|
2014-04-28 04:52:08 -04:00
|
|
|
va_start(ap,fmt);
|
|
|
|
f = fmt; /* Next format specifier byte to process. */
|
|
|
|
i = initlen; /* Position of the next byte to write to dest str. */
|
|
|
|
while(*f) {
|
|
|
|
char next, *str;
|
2015-04-09 03:37:01 -04:00
|
|
|
size_t l;
|
2014-04-28 04:52:08 -04:00
|
|
|
long long num;
|
2014-04-28 10:38:17 -04:00
|
|
|
unsigned long long unum;
|
2014-04-28 04:52:08 -04:00
|
|
|
|
|
|
|
/* Make sure there is always space for at least 1 char. */
|
2015-04-09 03:37:01 -04:00
|
|
|
if (sdsavail(s)==0) {
|
2014-04-28 10:38:17 -04:00
|
|
|
s = sdsMakeRoomFor(s,1);
|
|
|
|
}
|
2014-04-28 04:52:08 -04:00
|
|
|
|
|
|
|
switch(*f) {
|
|
|
|
case '%':
|
|
|
|
next = *(f+1);
|
2021-07-01 01:19:04 -04:00
|
|
|
if (next == '\0') break;
|
2014-04-28 04:52:08 -04:00
|
|
|
f++;
|
|
|
|
switch(next) {
|
|
|
|
case 's':
|
|
|
|
case 'S':
|
|
|
|
str = va_arg(ap,char*);
|
|
|
|
l = (next == 's') ? strlen(str) : sdslen(str);
|
2015-04-09 03:37:01 -04:00
|
|
|
if (sdsavail(s) < l) {
|
2014-04-28 10:38:17 -04:00
|
|
|
s = sdsMakeRoomFor(s,l);
|
|
|
|
}
|
2014-04-28 04:52:08 -04:00
|
|
|
memcpy(s+i,str,l);
|
2015-04-09 03:37:01 -04:00
|
|
|
sdsinclen(s,l);
|
2014-04-28 04:52:08 -04:00
|
|
|
i += l;
|
|
|
|
break;
|
|
|
|
case 'i':
|
|
|
|
case 'I':
|
|
|
|
if (next == 'i')
|
|
|
|
num = va_arg(ap,int);
|
|
|
|
else
|
|
|
|
num = va_arg(ap,long long);
|
|
|
|
{
|
|
|
|
char buf[SDS_LLSTR_SIZE];
|
|
|
|
l = sdsll2str(buf,num);
|
2015-04-09 03:37:01 -04:00
|
|
|
if (sdsavail(s) < l) {
|
2014-04-28 10:38:17 -04:00
|
|
|
s = sdsMakeRoomFor(s,l);
|
|
|
|
}
|
|
|
|
memcpy(s+i,buf,l);
|
2015-04-09 03:37:01 -04:00
|
|
|
sdsinclen(s,l);
|
2014-04-28 10:38:17 -04:00
|
|
|
i += l;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'u':
|
|
|
|
case 'U':
|
|
|
|
if (next == 'u')
|
|
|
|
unum = va_arg(ap,unsigned int);
|
|
|
|
else
|
|
|
|
unum = va_arg(ap,unsigned long long);
|
|
|
|
{
|
|
|
|
char buf[SDS_LLSTR_SIZE];
|
|
|
|
l = sdsull2str(buf,unum);
|
2015-04-09 03:37:01 -04:00
|
|
|
if (sdsavail(s) < l) {
|
2014-04-28 10:38:17 -04:00
|
|
|
s = sdsMakeRoomFor(s,l);
|
|
|
|
}
|
2014-04-28 04:52:08 -04:00
|
|
|
memcpy(s+i,buf,l);
|
2015-04-09 03:37:01 -04:00
|
|
|
sdsinclen(s,l);
|
2014-04-28 04:52:08 -04:00
|
|
|
i += l;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default: /* Handle %% and generally %<unknown>. */
|
|
|
|
s[i++] = next;
|
2015-04-09 03:37:01 -04:00
|
|
|
sdsinclen(s,1);
|
2014-04-28 04:52:08 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
s[i++] = *f;
|
2015-04-09 03:37:01 -04:00
|
|
|
sdsinclen(s,1);
|
2014-04-28 04:52:08 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
f++;
|
|
|
|
}
|
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
/* Add null-term */
|
|
|
|
s[i] = '\0';
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2013-07-23 10:35:55 -04:00
|
|
|
/* Remove the part of the string from left and from right composed just of
|
2021-06-10 08:39:33 -04:00
|
|
|
* contiguous characters found in 'cset', that is a null terminated C string.
|
2013-07-23 10:35:55 -04:00
|
|
|
*
|
|
|
|
* After the call, the modified sds string is no longer valid and all the
|
|
|
|
* references must be substituted with the new pointer returned by the call.
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
*
|
|
|
|
* s = sdsnew("AA...AA.a.aa.aHelloWorld :::");
|
2015-04-20 09:46:48 -04:00
|
|
|
* s = sdstrim(s,"Aa. :");
|
2013-07-23 10:35:55 -04:00
|
|
|
* printf("%s\n", s);
|
|
|
|
*
|
2018-12-05 04:15:02 -05:00
|
|
|
* Output will be just "HelloWorld".
|
2013-07-23 10:35:55 -04:00
|
|
|
*/
|
2009-03-22 05:30:00 -04:00
|
|
|
sds sdstrim(sds s, const char *cset) {
|
2021-04-20 00:37:37 -04:00
|
|
|
char *end, *sp, *ep;
|
2009-03-22 05:30:00 -04:00
|
|
|
size_t len;
|
|
|
|
|
2021-04-20 00:37:37 -04:00
|
|
|
sp = s;
|
2009-03-22 05:30:00 -04:00
|
|
|
ep = end = s+sdslen(s)-1;
|
|
|
|
while(sp <= end && strchr(cset, *sp)) sp++;
|
2014-12-09 22:19:13 -05:00
|
|
|
while(ep > sp && strchr(cset, *ep)) ep--;
|
2021-10-17 13:37:52 -04:00
|
|
|
len = (ep-sp)+1;
|
2015-04-09 03:37:01 -04:00
|
|
|
if (s != sp) memmove(s, sp, len);
|
|
|
|
s[len] = '\0';
|
|
|
|
sdssetlen(s,len);
|
2009-03-22 05:30:00 -04:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2021-06-22 10:22:40 -04:00
|
|
|
/* Changes the input string to be a subset of the original.
|
|
|
|
* It does not release the free space in the string, so a call to
|
|
|
|
* sdsRemoveFreeSpace may be wise after. */
|
|
|
|
void sdssubstr(sds s, size_t start, size_t len) {
|
|
|
|
/* Clamp out of range input */
|
|
|
|
size_t oldlen = sdslen(s);
|
|
|
|
if (start >= oldlen) start = len = 0;
|
|
|
|
if (len > oldlen-start) len = oldlen-start;
|
|
|
|
|
|
|
|
/* Move the data */
|
|
|
|
if (len) memmove(s, s+start, len);
|
|
|
|
s[len] = 0;
|
|
|
|
sdssetlen(s,len);
|
|
|
|
}
|
|
|
|
|
2013-07-23 10:35:55 -04:00
|
|
|
/* Turn the string into a smaller (or equal) string containing only the
|
|
|
|
* substring specified by the 'start' and 'end' indexes.
|
|
|
|
*
|
|
|
|
* start and end can be negative, where -1 means the last character of the
|
|
|
|
* string, -2 the penultimate character, and so forth.
|
|
|
|
*
|
|
|
|
* The interval is inclusive, so the start and end characters will be part
|
|
|
|
* of the resulting string.
|
|
|
|
*
|
|
|
|
* The string is modified in-place.
|
|
|
|
*
|
2021-06-22 10:22:40 -04:00
|
|
|
* NOTE: this function can be misleading and can have unexpected behaviour,
|
|
|
|
* specifically when you want the length of the new string to be 0.
|
|
|
|
* Having start==end will result in a string with one character.
|
|
|
|
* please consider using sdssubstr instead.
|
|
|
|
*
|
2013-07-23 10:35:55 -04:00
|
|
|
* Example:
|
|
|
|
*
|
|
|
|
* s = sdsnew("Hello World");
|
2013-12-12 03:33:29 -05:00
|
|
|
* sdsrange(s,1,-1); => "ello World"
|
2013-07-23 10:35:55 -04:00
|
|
|
*/
|
2017-12-21 04:10:48 -05:00
|
|
|
void sdsrange(sds s, ssize_t start, ssize_t end) {
|
2009-03-22 05:30:00 -04:00
|
|
|
size_t newlen, len = sdslen(s);
|
2013-07-24 05:21:39 -04:00
|
|
|
if (len == 0) return;
|
2021-06-22 10:22:40 -04:00
|
|
|
if (start < 0)
|
|
|
|
start = len + start;
|
|
|
|
if (end < 0)
|
|
|
|
end = len + end;
|
2009-03-22 05:30:00 -04:00
|
|
|
newlen = (start > end) ? 0 : (end-start)+1;
|
2021-06-22 10:22:40 -04:00
|
|
|
sdssubstr(s, start, newlen);
|
2009-03-22 05:30:00 -04:00
|
|
|
}
|
|
|
|
|
2013-07-23 10:35:55 -04:00
|
|
|
/* Apply tolower() to every character of the sds string 's'. */
|
2009-03-22 05:30:00 -04:00
|
|
|
void sdstolower(sds s) {
|
2017-12-21 04:10:48 -05:00
|
|
|
size_t len = sdslen(s), j;
|
2009-03-22 05:30:00 -04:00
|
|
|
|
|
|
|
for (j = 0; j < len; j++) s[j] = tolower(s[j]);
|
|
|
|
}
|
|
|
|
|
2013-07-23 10:35:55 -04:00
|
|
|
/* Apply toupper() to every character of the sds string 's'. */
|
2009-03-22 05:30:00 -04:00
|
|
|
void sdstoupper(sds s) {
|
2017-12-21 04:10:48 -05:00
|
|
|
size_t len = sdslen(s), j;
|
2009-03-22 05:30:00 -04:00
|
|
|
|
|
|
|
for (j = 0; j < len; j++) s[j] = toupper(s[j]);
|
|
|
|
}
|
|
|
|
|
2013-07-23 10:35:55 -04:00
|
|
|
/* Compare two sds strings s1 and s2 with memcmp().
|
|
|
|
*
|
|
|
|
* Return value:
|
|
|
|
*
|
2014-11-01 22:40:28 -04:00
|
|
|
* positive if s1 > s2.
|
|
|
|
* negative if s1 < s2.
|
2013-07-23 10:35:55 -04:00
|
|
|
* 0 if s1 and s2 are exactly the same binary string.
|
|
|
|
*
|
|
|
|
* If two strings share exactly the same prefix, but one of the two has
|
|
|
|
* additional characters, the longer string is considered to be greater than
|
|
|
|
* the smaller one. */
|
2012-03-30 15:19:51 -04:00
|
|
|
int sdscmp(const sds s1, const sds s2) {
|
2009-03-22 05:30:00 -04:00
|
|
|
size_t l1, l2, minlen;
|
|
|
|
int cmp;
|
|
|
|
|
|
|
|
l1 = sdslen(s1);
|
|
|
|
l2 = sdslen(s2);
|
|
|
|
minlen = (l1 < l2) ? l1 : l2;
|
|
|
|
cmp = memcmp(s1,s2,minlen);
|
2017-12-21 04:10:48 -05:00
|
|
|
if (cmp == 0) return l1>l2? 1: (l1<l2? -1: 0);
|
2009-03-22 05:30:00 -04:00
|
|
|
return cmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Split 's' with separator in 'sep'. An array
|
|
|
|
* of sds strings is returned. *count will be set
|
|
|
|
* by reference to the number of tokens returned.
|
|
|
|
*
|
|
|
|
* On out of memory, zero length string, zero length
|
|
|
|
* separator, NULL is returned.
|
|
|
|
*
|
|
|
|
* Note that 'sep' is able to split a string using
|
|
|
|
* a multi-character separator. For example
|
|
|
|
* sdssplit("foo_-_bar","_-_"); will return two
|
|
|
|
* elements "foo" and "bar".
|
|
|
|
*
|
|
|
|
* This version of the function is binary-safe but
|
|
|
|
* requires length arguments. sdssplit() is just the
|
|
|
|
* same function but for zero-terminated strings.
|
|
|
|
*/
|
2017-12-21 04:10:48 -05:00
|
|
|
sds *sdssplitlen(const char *s, ssize_t len, const char *sep, int seplen, int *count) {
|
|
|
|
int elements = 0, slots = 5;
|
|
|
|
long start = 0, j;
|
2011-04-27 08:32:56 -04:00
|
|
|
sds *tokens;
|
2009-03-22 05:30:00 -04:00
|
|
|
|
2011-04-27 08:32:56 -04:00
|
|
|
if (seplen < 1 || len < 0) return NULL;
|
|
|
|
|
2015-07-25 11:25:44 -04:00
|
|
|
tokens = s_malloc(sizeof(sds)*slots);
|
2011-04-27 08:32:56 -04:00
|
|
|
if (tokens == NULL) return NULL;
|
|
|
|
|
2009-12-15 09:33:29 -05:00
|
|
|
if (len == 0) {
|
|
|
|
*count = 0;
|
|
|
|
return tokens;
|
|
|
|
}
|
2009-03-22 05:30:00 -04:00
|
|
|
for (j = 0; j < (len-(seplen-1)); j++) {
|
|
|
|
/* make sure there is room for the next element and the final one */
|
|
|
|
if (slots < elements+2) {
|
2009-03-27 15:48:32 -04:00
|
|
|
sds *newtokens;
|
|
|
|
|
2009-03-22 05:30:00 -04:00
|
|
|
slots *= 2;
|
2015-07-25 11:25:44 -04:00
|
|
|
newtokens = s_realloc(tokens,sizeof(sds)*slots);
|
2012-01-16 04:08:33 -05:00
|
|
|
if (newtokens == NULL) goto cleanup;
|
2009-03-22 05:30:00 -04:00
|
|
|
tokens = newtokens;
|
|
|
|
}
|
|
|
|
/* search the separator */
|
|
|
|
if ((seplen == 1 && *(s+j) == sep[0]) || (memcmp(s+j,sep,seplen) == 0)) {
|
|
|
|
tokens[elements] = sdsnewlen(s+start,j-start);
|
2012-01-16 04:08:33 -05:00
|
|
|
if (tokens[elements] == NULL) goto cleanup;
|
2009-03-22 05:30:00 -04:00
|
|
|
elements++;
|
|
|
|
start = j+seplen;
|
|
|
|
j = j+seplen-1; /* skip the separator */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Add the final element. We are sure there is room in the tokens array. */
|
|
|
|
tokens[elements] = sdsnewlen(s+start,len-start);
|
2012-01-16 04:08:33 -05:00
|
|
|
if (tokens[elements] == NULL) goto cleanup;
|
2009-03-22 05:30:00 -04:00
|
|
|
elements++;
|
|
|
|
*count = elements;
|
|
|
|
return tokens;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < elements; i++) sdsfree(tokens[i]);
|
2015-07-25 11:25:44 -04:00
|
|
|
s_free(tokens);
|
2011-01-27 04:27:25 -05:00
|
|
|
*count = 0;
|
2009-03-22 05:30:00 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2010-05-10 12:50:55 -04:00
|
|
|
|
2013-07-23 10:35:55 -04:00
|
|
|
/* Free the result returned by sdssplitlen(), or do nothing if 'tokens' is NULL. */
|
2010-05-10 12:50:55 -04:00
|
|
|
void sdsfreesplitres(sds *tokens, int count) {
|
|
|
|
if (!tokens) return;
|
|
|
|
while(count--)
|
|
|
|
sdsfree(tokens[count]);
|
2015-07-25 11:25:44 -04:00
|
|
|
s_free(tokens);
|
2010-05-10 12:50:55 -04:00
|
|
|
}
|
2010-05-11 08:13:53 -04:00
|
|
|
|
2013-07-23 10:35:55 -04:00
|
|
|
/* Append to the sds string "s" an escaped string representation where
|
|
|
|
* all the non-printable characters (tested with isprint()) are turned into
|
|
|
|
* escapes in the form "\n\r\a...." or "\x<hex-number>".
|
|
|
|
*
|
|
|
|
* After the call, the modified sds string is no longer valid and all the
|
|
|
|
* references must be substituted with the new pointer returned by the call. */
|
2012-03-30 15:19:51 -04:00
|
|
|
sds sdscatrepr(sds s, const char *p, size_t len) {
|
2010-06-21 18:07:48 -04:00
|
|
|
s = sdscatlen(s,"\"",1);
|
|
|
|
while(len--) {
|
|
|
|
switch(*p) {
|
|
|
|
case '\\':
|
|
|
|
case '"':
|
|
|
|
s = sdscatprintf(s,"\\%c",*p);
|
|
|
|
break;
|
2011-03-20 13:24:49 -04:00
|
|
|
case '\n': s = sdscatlen(s,"\\n",2); break;
|
|
|
|
case '\r': s = sdscatlen(s,"\\r",2); break;
|
|
|
|
case '\t': s = sdscatlen(s,"\\t",2); break;
|
|
|
|
case '\a': s = sdscatlen(s,"\\a",2); break;
|
|
|
|
case '\b': s = sdscatlen(s,"\\b",2); break;
|
2010-06-21 18:07:48 -04:00
|
|
|
default:
|
|
|
|
if (isprint(*p))
|
|
|
|
s = sdscatprintf(s,"%c",*p);
|
|
|
|
else
|
|
|
|
s = sdscatprintf(s,"\\x%02x",(unsigned char)*p);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
return sdscatlen(s,"\"",1);
|
|
|
|
}
|
2010-08-05 05:36:39 -04:00
|
|
|
|
2011-03-22 17:49:12 -04:00
|
|
|
/* Helper function for sdssplitargs() that returns non zero if 'c'
|
|
|
|
* is a valid hex digit. */
|
|
|
|
int is_hex_digit(char c) {
|
|
|
|
return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') ||
|
|
|
|
(c >= 'A' && c <= 'F');
|
|
|
|
}
|
|
|
|
|
2013-12-05 10:35:32 -05:00
|
|
|
/* Helper function for sdssplitargs() that converts a hex digit into an
|
2011-03-22 17:49:12 -04:00
|
|
|
* integer from 0 to 15 */
|
|
|
|
int hex_digit_to_int(char c) {
|
|
|
|
switch(c) {
|
|
|
|
case '0': return 0;
|
|
|
|
case '1': return 1;
|
|
|
|
case '2': return 2;
|
|
|
|
case '3': return 3;
|
|
|
|
case '4': return 4;
|
|
|
|
case '5': return 5;
|
|
|
|
case '6': return 6;
|
|
|
|
case '7': return 7;
|
|
|
|
case '8': return 8;
|
|
|
|
case '9': return 9;
|
|
|
|
case 'a': case 'A': return 10;
|
|
|
|
case 'b': case 'B': return 11;
|
|
|
|
case 'c': case 'C': return 12;
|
|
|
|
case 'd': case 'D': return 13;
|
|
|
|
case 'e': case 'E': return 14;
|
|
|
|
case 'f': case 'F': return 15;
|
|
|
|
default: return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-05 05:36:39 -04:00
|
|
|
/* Split a line into arguments, where every argument can be in the
|
|
|
|
* following programming-language REPL-alike form:
|
|
|
|
*
|
|
|
|
* foo bar "newline are supported\n" and "\xff\x00otherstuff"
|
|
|
|
*
|
|
|
|
* The number of arguments is stored into *argc, and an array
|
2013-03-06 06:34:43 -05:00
|
|
|
* of sds is returned.
|
|
|
|
*
|
|
|
|
* The caller should free the resulting array of sds strings with
|
|
|
|
* sdsfreesplitres().
|
2010-08-05 05:36:39 -04:00
|
|
|
*
|
|
|
|
* Note that sdscatrepr() is able to convert back a string into
|
|
|
|
* a quoted string in the same format sdssplitargs() is able to parse.
|
2013-03-06 06:14:42 -05:00
|
|
|
*
|
|
|
|
* The function returns the allocated tokens on success, even when the
|
|
|
|
* input string is empty, or NULL if the input contains unbalanced
|
|
|
|
* quotes or closed quotes followed by non space characters
|
|
|
|
* as in: "foo"bar or "foo'
|
2010-08-05 05:36:39 -04:00
|
|
|
*/
|
2012-03-30 15:19:51 -04:00
|
|
|
sds *sdssplitargs(const char *line, int *argc) {
|
|
|
|
const char *p = line;
|
2010-08-05 05:36:39 -04:00
|
|
|
char *current = NULL;
|
|
|
|
char **vector = NULL;
|
|
|
|
|
|
|
|
*argc = 0;
|
|
|
|
while(1) {
|
|
|
|
/* skip blanks */
|
|
|
|
while(*p && isspace(*p)) p++;
|
|
|
|
if (*p) {
|
|
|
|
/* get a token */
|
2011-10-28 11:31:40 -04:00
|
|
|
int inq=0; /* set to 1 if we are in "quotes" */
|
|
|
|
int insq=0; /* set to 1 if we are in 'single quotes' */
|
2010-08-25 03:54:02 -04:00
|
|
|
int done=0;
|
2010-08-05 05:36:39 -04:00
|
|
|
|
|
|
|
if (current == NULL) current = sdsempty();
|
|
|
|
while(!done) {
|
|
|
|
if (inq) {
|
2011-03-22 17:49:12 -04:00
|
|
|
if (*p == '\\' && *(p+1) == 'x' &&
|
|
|
|
is_hex_digit(*(p+2)) &&
|
|
|
|
is_hex_digit(*(p+3)))
|
|
|
|
{
|
|
|
|
unsigned char byte;
|
|
|
|
|
|
|
|
byte = (hex_digit_to_int(*(p+2))*16)+
|
|
|
|
hex_digit_to_int(*(p+3));
|
|
|
|
current = sdscatlen(current,(char*)&byte,1);
|
|
|
|
p += 3;
|
|
|
|
} else if (*p == '\\' && *(p+1)) {
|
2010-08-05 05:36:39 -04:00
|
|
|
char c;
|
|
|
|
|
|
|
|
p++;
|
|
|
|
switch(*p) {
|
|
|
|
case 'n': c = '\n'; break;
|
|
|
|
case 'r': c = '\r'; break;
|
|
|
|
case 't': c = '\t'; break;
|
|
|
|
case 'b': c = '\b'; break;
|
|
|
|
case 'a': c = '\a'; break;
|
|
|
|
default: c = *p; break;
|
|
|
|
}
|
|
|
|
current = sdscatlen(current,&c,1);
|
|
|
|
} else if (*p == '"') {
|
2011-10-28 11:31:40 -04:00
|
|
|
/* closing quote must be followed by a space or
|
|
|
|
* nothing at all. */
|
|
|
|
if (*(p+1) && !isspace(*(p+1))) goto err;
|
|
|
|
done=1;
|
|
|
|
} else if (!*p) {
|
|
|
|
/* unterminated quotes */
|
|
|
|
goto err;
|
|
|
|
} else {
|
|
|
|
current = sdscatlen(current,p,1);
|
|
|
|
}
|
|
|
|
} else if (insq) {
|
|
|
|
if (*p == '\\' && *(p+1) == '\'') {
|
|
|
|
p++;
|
|
|
|
current = sdscatlen(current,"'",1);
|
|
|
|
} else if (*p == '\'') {
|
|
|
|
/* closing quote must be followed by a space or
|
|
|
|
* nothing at all. */
|
2010-08-25 03:54:02 -04:00
|
|
|
if (*(p+1) && !isspace(*(p+1))) goto err;
|
|
|
|
done=1;
|
|
|
|
} else if (!*p) {
|
|
|
|
/* unterminated quotes */
|
|
|
|
goto err;
|
2010-08-05 05:36:39 -04:00
|
|
|
} else {
|
|
|
|
current = sdscatlen(current,p,1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
switch(*p) {
|
|
|
|
case ' ':
|
|
|
|
case '\n':
|
|
|
|
case '\r':
|
|
|
|
case '\t':
|
|
|
|
case '\0':
|
|
|
|
done=1;
|
|
|
|
break;
|
|
|
|
case '"':
|
|
|
|
inq=1;
|
|
|
|
break;
|
2011-10-28 11:31:40 -04:00
|
|
|
case '\'':
|
|
|
|
insq=1;
|
|
|
|
break;
|
2010-08-05 05:36:39 -04:00
|
|
|
default:
|
|
|
|
current = sdscatlen(current,p,1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (*p) p++;
|
|
|
|
}
|
|
|
|
/* add the token to the vector */
|
2015-07-25 11:25:44 -04:00
|
|
|
vector = s_realloc(vector,((*argc)+1)*sizeof(char*));
|
2010-08-05 05:36:39 -04:00
|
|
|
vector[*argc] = current;
|
|
|
|
(*argc)++;
|
|
|
|
current = NULL;
|
|
|
|
} else {
|
2013-03-06 06:34:43 -05:00
|
|
|
/* Even on empty input string return something not NULL. */
|
2015-07-25 11:25:44 -04:00
|
|
|
if (vector == NULL) vector = s_malloc(sizeof(void*));
|
2010-08-05 05:36:39 -04:00
|
|
|
return vector;
|
|
|
|
}
|
|
|
|
}
|
2010-08-25 03:54:02 -04:00
|
|
|
|
|
|
|
err:
|
2010-08-26 07:18:19 -04:00
|
|
|
while((*argc)--)
|
2010-08-25 03:54:02 -04:00
|
|
|
sdsfree(vector[*argc]);
|
2015-07-25 11:25:44 -04:00
|
|
|
s_free(vector);
|
2010-08-25 03:54:02 -04:00
|
|
|
if (current) sdsfree(current);
|
2013-03-06 06:19:38 -05:00
|
|
|
*argc = 0;
|
2010-08-25 03:54:02 -04:00
|
|
|
return NULL;
|
2010-08-05 05:36:39 -04:00
|
|
|
}
|
2010-09-23 10:05:17 -04:00
|
|
|
|
2011-05-24 13:43:11 -04:00
|
|
|
/* Modify the string substituting all the occurrences of the set of
|
2013-01-16 12:00:20 -05:00
|
|
|
* characters specified in the 'from' string to the corresponding character
|
2011-05-24 13:43:11 -04:00
|
|
|
* in the 'to' array.
|
|
|
|
*
|
|
|
|
* For instance: sdsmapchars(mystring, "ho", "01", 2)
|
|
|
|
* will have the effect of turning the string "hello" into "0ell1".
|
|
|
|
*
|
|
|
|
* The function returns the sds string pointer, that is always the same
|
|
|
|
* as the input pointer since no resize is needed. */
|
2012-03-30 15:19:51 -04:00
|
|
|
sds sdsmapchars(sds s, const char *from, const char *to, size_t setlen) {
|
2011-05-24 13:43:11 -04:00
|
|
|
size_t j, i, l = sdslen(s);
|
|
|
|
|
|
|
|
for (j = 0; j < l; j++) {
|
|
|
|
for (i = 0; i < setlen; i++) {
|
|
|
|
if (s[j] == from[i]) {
|
|
|
|
s[j] = to[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2013-07-04 12:30:59 -04:00
|
|
|
/* Join an array of C strings using the specified separator (also a C string).
|
|
|
|
* Returns the result as an sds string. */
|
|
|
|
sds sdsjoin(char **argv, int argc, char *sep) {
|
|
|
|
sds join = sdsempty();
|
|
|
|
int j;
|
|
|
|
|
|
|
|
for (j = 0; j < argc; j++) {
|
|
|
|
join = sdscat(join, argv[j]);
|
|
|
|
if (j != argc-1) join = sdscat(join,sep);
|
|
|
|
}
|
|
|
|
return join;
|
|
|
|
}
|
|
|
|
|
2015-07-25 11:05:20 -04:00
|
|
|
/* Like sdsjoin, but joins an array of SDS strings. */
|
|
|
|
sds sdsjoinsds(sds *argv, int argc, const char *sep, size_t seplen) {
|
|
|
|
sds join = sdsempty();
|
|
|
|
int j;
|
|
|
|
|
|
|
|
for (j = 0; j < argc; j++) {
|
|
|
|
join = sdscatsds(join, argv[j]);
|
|
|
|
if (j != argc-1) join = sdscatlen(join,sep,seplen);
|
|
|
|
}
|
|
|
|
return join;
|
|
|
|
}
|
|
|
|
|
2015-11-16 04:29:35 -05:00
|
|
|
/* Wrappers to the allocators used by SDS. Note that SDS will actually
|
|
|
|
* just use the macros defined into sdsalloc.h in order to avoid to pay
|
|
|
|
* the overhead of function calls. Here we define these wrappers only for
|
|
|
|
* the programs SDS is linked to, if they want to touch the SDS internals
|
|
|
|
* even if they use a different allocator. */
|
|
|
|
void *sds_malloc(size_t size) { return s_malloc(size); }
|
|
|
|
void *sds_realloc(void *ptr, size_t size) { return s_realloc(ptr,size); }
|
|
|
|
void sds_free(void *ptr) { s_free(ptr); }
|
|
|
|
|
2021-01-28 11:17:39 -05:00
|
|
|
/* Perform expansion of a template string and return the result as a newly
|
|
|
|
* allocated sds.
|
|
|
|
*
|
|
|
|
* Template variables are specified using curly brackets, e.g. {variable}.
|
|
|
|
* An opening bracket can be quoted by repeating it twice.
|
|
|
|
*/
|
|
|
|
sds sdstemplate(const char *template, sdstemplate_callback_t cb_func, void *cb_arg)
|
|
|
|
{
|
|
|
|
sds res = sdsempty();
|
|
|
|
const char *p = template;
|
|
|
|
|
|
|
|
while (*p) {
|
|
|
|
/* Find next variable, copy everything until there */
|
|
|
|
const char *sv = strchr(p, '{');
|
|
|
|
if (!sv) {
|
|
|
|
/* Not found: copy till rest of template and stop */
|
|
|
|
res = sdscat(res, p);
|
|
|
|
break;
|
|
|
|
} else if (sv > p) {
|
2021-06-10 08:39:33 -04:00
|
|
|
/* Found: copy anything up to the beginning of the variable */
|
2021-01-28 11:17:39 -05:00
|
|
|
res = sdscatlen(res, p, sv - p);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Skip into variable name, handle premature end or quoting */
|
|
|
|
sv++;
|
|
|
|
if (!*sv) goto error; /* Premature end of template */
|
|
|
|
if (*sv == '{') {
|
|
|
|
/* Quoted '{' */
|
|
|
|
p = sv + 1;
|
|
|
|
res = sdscat(res, "{");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Find end of variable name, handle premature end of template */
|
|
|
|
const char *ev = strchr(sv, '}');
|
|
|
|
if (!ev) goto error;
|
|
|
|
|
|
|
|
/* Pass variable name to callback and obtain value. If callback failed,
|
|
|
|
* abort. */
|
|
|
|
sds varname = sdsnewlen(sv, ev - sv);
|
|
|
|
sds value = cb_func(varname, cb_arg);
|
|
|
|
sdsfree(varname);
|
|
|
|
if (!value) goto error;
|
|
|
|
|
|
|
|
/* Append value to result and continue */
|
|
|
|
res = sdscat(res, value);
|
|
|
|
sdsfree(value);
|
|
|
|
p = ev + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
|
|
|
error:
|
|
|
|
sdsfree(res);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-09-28 04:27:26 -04:00
|
|
|
#ifdef REDIS_TEST
|
2010-09-23 10:05:17 -04:00
|
|
|
#include <stdio.h>
|
2020-12-23 12:16:49 -05:00
|
|
|
#include <limits.h>
|
2010-09-23 10:05:17 -04:00
|
|
|
#include "testhelp.h"
|
|
|
|
|
2014-11-12 21:58:57 -05:00
|
|
|
#define UNUSED(x) (void)(x)
|
2021-01-28 11:17:39 -05:00
|
|
|
|
|
|
|
static sds sdsTestTemplateCallback(sds varname, void *arg) {
|
|
|
|
UNUSED(arg);
|
|
|
|
static const char *_var1 = "variable1";
|
|
|
|
static const char *_var2 = "variable2";
|
|
|
|
|
|
|
|
if (!strcmp(varname, _var1)) return sdsnew("value1");
|
|
|
|
else if (!strcmp(varname, _var2)) return sdsnew("value2");
|
|
|
|
else return NULL;
|
|
|
|
}
|
|
|
|
|
2021-03-10 02:13:11 -05:00
|
|
|
int sdsTest(int argc, char **argv, int accurate) {
|
2020-09-28 04:27:26 -04:00
|
|
|
UNUSED(argc);
|
|
|
|
UNUSED(argv);
|
2021-03-10 02:13:11 -05:00
|
|
|
UNUSED(accurate);
|
2020-09-28 04:27:26 -04:00
|
|
|
|
2010-09-23 10:05:17 -04:00
|
|
|
{
|
2010-09-23 10:39:02 -04:00
|
|
|
sds x = sdsnew("foo"), y;
|
|
|
|
|
|
|
|
test_cond("Create a string and obtain the length",
|
2020-12-23 12:16:49 -05:00
|
|
|
sdslen(x) == 3 && memcmp(x,"foo\0",4) == 0);
|
2010-09-23 10:39:02 -04:00
|
|
|
|
|
|
|
sdsfree(x);
|
|
|
|
x = sdsnewlen("foo",2);
|
|
|
|
test_cond("Create a string with specified length",
|
2020-12-23 12:16:49 -05:00
|
|
|
sdslen(x) == 2 && memcmp(x,"fo\0",3) == 0);
|
2010-09-23 10:39:02 -04:00
|
|
|
|
|
|
|
x = sdscat(x,"bar");
|
|
|
|
test_cond("Strings concatenation",
|
|
|
|
sdslen(x) == 5 && memcmp(x,"fobar\0",6) == 0);
|
|
|
|
|
|
|
|
x = sdscpy(x,"a");
|
|
|
|
test_cond("sdscpy() against an originally longer string",
|
2020-12-23 12:16:49 -05:00
|
|
|
sdslen(x) == 1 && memcmp(x,"a\0",2) == 0);
|
2010-09-23 10:39:02 -04:00
|
|
|
|
|
|
|
x = sdscpy(x,"xyzxxxxxxxxxxyyyyyyyyyykkkkkkkkkk");
|
|
|
|
test_cond("sdscpy() against an originally shorter string",
|
|
|
|
sdslen(x) == 33 &&
|
2020-12-23 12:16:49 -05:00
|
|
|
memcmp(x,"xyzxxxxxxxxxxyyyyyyyyyykkkkkkkkkk\0",33) == 0);
|
2010-09-23 10:39:02 -04:00
|
|
|
|
|
|
|
sdsfree(x);
|
|
|
|
x = sdscatprintf(sdsempty(),"%d",123);
|
|
|
|
test_cond("sdscatprintf() seems working in the base case",
|
2020-12-23 12:16:49 -05:00
|
|
|
sdslen(x) == 3 && memcmp(x,"123\0",4) == 0);
|
2014-04-28 04:52:08 -04:00
|
|
|
|
2020-11-04 06:38:46 -05:00
|
|
|
sdsfree(x);
|
|
|
|
x = sdscatprintf(sdsempty(),"a%cb",0);
|
|
|
|
test_cond("sdscatprintf() seems working with \\0 inside of result",
|
2020-12-23 12:16:49 -05:00
|
|
|
sdslen(x) == 3 && memcmp(x,"a\0""b\0",4) == 0);
|
2020-11-04 06:38:46 -05:00
|
|
|
|
|
|
|
{
|
|
|
|
sdsfree(x);
|
|
|
|
char etalon[1024*1024];
|
|
|
|
for (size_t i = 0; i < sizeof(etalon); i++) {
|
|
|
|
etalon[i] = '0';
|
|
|
|
}
|
|
|
|
x = sdscatprintf(sdsempty(),"%0*d",(int)sizeof(etalon),0);
|
|
|
|
test_cond("sdscatprintf() can print 1MB",
|
2020-12-23 12:16:49 -05:00
|
|
|
sdslen(x) == sizeof(etalon) && memcmp(x,etalon,sizeof(etalon)) == 0);
|
2020-11-04 06:38:46 -05:00
|
|
|
}
|
|
|
|
|
2014-04-28 04:52:08 -04:00
|
|
|
sdsfree(x);
|
|
|
|
x = sdsnew("--");
|
|
|
|
x = sdscatfmt(x, "Hello %s World %I,%I--", "Hi!", LLONG_MIN,LLONG_MAX);
|
|
|
|
test_cond("sdscatfmt() seems working in the base case",
|
|
|
|
sdslen(x) == 60 &&
|
|
|
|
memcmp(x,"--Hello Hi! World -9223372036854775808,"
|
2020-12-23 12:16:49 -05:00
|
|
|
"9223372036854775807--",60) == 0);
|
2015-07-15 06:24:49 -04:00
|
|
|
printf("[%s]\n",x);
|
2010-09-23 10:39:02 -04:00
|
|
|
|
2014-04-28 10:38:17 -04:00
|
|
|
sdsfree(x);
|
|
|
|
x = sdsnew("--");
|
|
|
|
x = sdscatfmt(x, "%u,%U--", UINT_MAX, ULLONG_MAX);
|
|
|
|
test_cond("sdscatfmt() seems working with unsigned numbers",
|
|
|
|
sdslen(x) == 35 &&
|
2020-12-23 12:16:49 -05:00
|
|
|
memcmp(x,"--4294967295,18446744073709551615--",35) == 0);
|
2014-04-28 10:38:17 -04:00
|
|
|
|
2014-12-10 03:48:56 -05:00
|
|
|
sdsfree(x);
|
|
|
|
x = sdsnew(" x ");
|
|
|
|
sdstrim(x," x");
|
|
|
|
test_cond("sdstrim() works when all chars match",
|
2020-12-23 12:16:49 -05:00
|
|
|
sdslen(x) == 0);
|
2014-12-10 03:48:56 -05:00
|
|
|
|
|
|
|
sdsfree(x);
|
|
|
|
x = sdsnew(" x ");
|
|
|
|
sdstrim(x," ");
|
|
|
|
test_cond("sdstrim() works when a single char remains",
|
2020-12-23 12:16:49 -05:00
|
|
|
sdslen(x) == 1 && x[0] == 'x');
|
2014-12-10 03:48:56 -05:00
|
|
|
|
2010-09-23 10:39:02 -04:00
|
|
|
sdsfree(x);
|
2014-04-28 04:52:08 -04:00
|
|
|
x = sdsnew("xxciaoyyy");
|
|
|
|
sdstrim(x,"xy");
|
2010-09-23 10:39:02 -04:00
|
|
|
test_cond("sdstrim() correctly trims characters",
|
2020-12-23 12:16:49 -05:00
|
|
|
sdslen(x) == 4 && memcmp(x,"ciao\0",5) == 0);
|
2010-09-23 10:39:02 -04:00
|
|
|
|
2014-04-28 04:52:08 -04:00
|
|
|
y = sdsdup(x);
|
|
|
|
sdsrange(y,1,1);
|
2010-09-23 10:39:02 -04:00
|
|
|
test_cond("sdsrange(...,1,1)",
|
2020-12-23 12:16:49 -05:00
|
|
|
sdslen(y) == 1 && memcmp(y,"i\0",2) == 0);
|
2010-09-23 10:39:02 -04:00
|
|
|
|
|
|
|
sdsfree(y);
|
2014-04-28 04:52:08 -04:00
|
|
|
y = sdsdup(x);
|
|
|
|
sdsrange(y,1,-1);
|
2010-09-23 10:39:02 -04:00
|
|
|
test_cond("sdsrange(...,1,-1)",
|
2020-12-23 12:16:49 -05:00
|
|
|
sdslen(y) == 3 && memcmp(y,"iao\0",4) == 0);
|
2010-09-23 10:39:02 -04:00
|
|
|
|
|
|
|
sdsfree(y);
|
2014-04-28 04:52:08 -04:00
|
|
|
y = sdsdup(x);
|
|
|
|
sdsrange(y,-2,-1);
|
2010-09-23 10:39:02 -04:00
|
|
|
test_cond("sdsrange(...,-2,-1)",
|
2020-12-23 12:16:49 -05:00
|
|
|
sdslen(y) == 2 && memcmp(y,"ao\0",3) == 0);
|
2010-09-23 10:39:02 -04:00
|
|
|
|
|
|
|
sdsfree(y);
|
2014-04-28 04:52:08 -04:00
|
|
|
y = sdsdup(x);
|
|
|
|
sdsrange(y,2,1);
|
2010-09-23 10:39:02 -04:00
|
|
|
test_cond("sdsrange(...,2,1)",
|
2020-12-23 12:16:49 -05:00
|
|
|
sdslen(y) == 0 && memcmp(y,"\0",1) == 0);
|
2010-09-23 10:39:02 -04:00
|
|
|
|
|
|
|
sdsfree(y);
|
2014-04-28 04:52:08 -04:00
|
|
|
y = sdsdup(x);
|
|
|
|
sdsrange(y,1,100);
|
2010-09-23 10:39:02 -04:00
|
|
|
test_cond("sdsrange(...,1,100)",
|
2020-12-23 12:16:49 -05:00
|
|
|
sdslen(y) == 3 && memcmp(y,"iao\0",4) == 0);
|
2010-09-23 10:39:02 -04:00
|
|
|
|
|
|
|
sdsfree(y);
|
2014-04-28 04:52:08 -04:00
|
|
|
y = sdsdup(x);
|
|
|
|
sdsrange(y,100,100);
|
2010-09-23 10:39:02 -04:00
|
|
|
test_cond("sdsrange(...,100,100)",
|
2020-12-23 12:16:49 -05:00
|
|
|
sdslen(y) == 0 && memcmp(y,"\0",1) == 0);
|
2010-09-23 10:39:02 -04:00
|
|
|
|
2021-06-22 10:22:40 -04:00
|
|
|
sdsfree(y);
|
|
|
|
y = sdsdup(x);
|
|
|
|
sdsrange(y,4,6);
|
|
|
|
test_cond("sdsrange(...,4,6)",
|
|
|
|
sdslen(y) == 0 && memcmp(y,"\0",1) == 0);
|
|
|
|
|
|
|
|
sdsfree(y);
|
|
|
|
y = sdsdup(x);
|
|
|
|
sdsrange(y,3,6);
|
|
|
|
test_cond("sdsrange(...,3,6)",
|
|
|
|
sdslen(y) == 1 && memcmp(y,"o\0",2) == 0);
|
|
|
|
|
2010-09-23 10:39:02 -04:00
|
|
|
sdsfree(y);
|
|
|
|
sdsfree(x);
|
|
|
|
x = sdsnew("foo");
|
|
|
|
y = sdsnew("foa");
|
2020-12-23 12:16:49 -05:00
|
|
|
test_cond("sdscmp(foo,foa)", sdscmp(x,y) > 0);
|
2010-09-23 10:39:02 -04:00
|
|
|
|
|
|
|
sdsfree(y);
|
|
|
|
sdsfree(x);
|
|
|
|
x = sdsnew("bar");
|
|
|
|
y = sdsnew("bar");
|
2020-12-23 12:16:49 -05:00
|
|
|
test_cond("sdscmp(bar,bar)", sdscmp(x,y) == 0);
|
2010-09-23 10:39:02 -04:00
|
|
|
|
|
|
|
sdsfree(y);
|
|
|
|
sdsfree(x);
|
|
|
|
x = sdsnew("aar");
|
|
|
|
y = sdsnew("bar");
|
2020-12-23 12:16:49 -05:00
|
|
|
test_cond("sdscmp(bar,bar)", sdscmp(x,y) < 0);
|
2011-11-02 11:50:59 -04:00
|
|
|
|
2014-04-28 04:52:08 -04:00
|
|
|
sdsfree(y);
|
|
|
|
sdsfree(x);
|
|
|
|
x = sdsnewlen("\a\n\0foo\r",7);
|
|
|
|
y = sdscatrepr(sdsempty(),x,sdslen(x));
|
|
|
|
test_cond("sdscatrepr(...data...)",
|
2020-12-23 12:16:49 -05:00
|
|
|
memcmp(y,"\"\\a\\n\\x00foo\\r\"",15) == 0);
|
2014-04-28 04:52:08 -04:00
|
|
|
|
2011-11-02 11:50:59 -04:00
|
|
|
{
|
2014-11-12 21:58:57 -05:00
|
|
|
unsigned int oldfree;
|
2015-07-20 10:18:06 -04:00
|
|
|
char *p;
|
2020-09-28 04:27:26 -04:00
|
|
|
int i;
|
|
|
|
size_t step = 10, j;
|
2011-11-02 11:50:59 -04:00
|
|
|
|
|
|
|
sdsfree(x);
|
2015-04-20 11:03:34 -04:00
|
|
|
sdsfree(y);
|
2011-11-02 11:50:59 -04:00
|
|
|
x = sdsnew("0");
|
2015-07-20 10:18:06 -04:00
|
|
|
test_cond("sdsnew() free/len buffers", sdslen(x) == 1 && sdsavail(x) == 0);
|
|
|
|
|
|
|
|
/* Run the test a few times in order to hit the first two
|
|
|
|
* SDS header types. */
|
|
|
|
for (i = 0; i < 10; i++) {
|
2020-09-28 04:27:26 -04:00
|
|
|
size_t oldlen = sdslen(x);
|
2015-07-20 10:18:06 -04:00
|
|
|
x = sdsMakeRoomFor(x,step);
|
|
|
|
int type = x[-1]&SDS_TYPE_MASK;
|
|
|
|
|
|
|
|
test_cond("sdsMakeRoomFor() len", sdslen(x) == oldlen);
|
|
|
|
if (type != SDS_TYPE_5) {
|
|
|
|
test_cond("sdsMakeRoomFor() free", sdsavail(x) >= step);
|
|
|
|
oldfree = sdsavail(x);
|
2020-09-28 04:27:26 -04:00
|
|
|
UNUSED(oldfree);
|
2015-07-20 10:18:06 -04:00
|
|
|
}
|
|
|
|
p = x+oldlen;
|
|
|
|
for (j = 0; j < step; j++) {
|
|
|
|
p[j] = 'A'+j;
|
|
|
|
}
|
|
|
|
sdsIncrLen(x,step);
|
|
|
|
}
|
|
|
|
test_cond("sdsMakeRoomFor() content",
|
|
|
|
memcmp("0ABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJ",x,101) == 0);
|
|
|
|
test_cond("sdsMakeRoomFor() final length",sdslen(x)==101);
|
2015-04-20 11:03:34 -04:00
|
|
|
|
|
|
|
sdsfree(x);
|
2011-11-02 11:50:59 -04:00
|
|
|
}
|
2021-01-28 11:17:39 -05:00
|
|
|
|
|
|
|
/* Simple template */
|
|
|
|
x = sdstemplate("v1={variable1} v2={variable2}", sdsTestTemplateCallback, NULL);
|
|
|
|
test_cond("sdstemplate() normal flow",
|
|
|
|
memcmp(x,"v1=value1 v2=value2",19) == 0);
|
|
|
|
sdsfree(x);
|
|
|
|
|
|
|
|
/* Template with callback error */
|
|
|
|
x = sdstemplate("v1={variable1} v3={doesnotexist}", sdsTestTemplateCallback, NULL);
|
|
|
|
test_cond("sdstemplate() with callback error", x == NULL);
|
|
|
|
|
|
|
|
/* Template with empty var name */
|
|
|
|
x = sdstemplate("v1={", sdsTestTemplateCallback, NULL);
|
|
|
|
test_cond("sdstemplate() with empty var name", x == NULL);
|
|
|
|
|
|
|
|
/* Template with truncated var name */
|
|
|
|
x = sdstemplate("v1={start", sdsTestTemplateCallback, NULL);
|
|
|
|
test_cond("sdstemplate() with truncated var name", x == NULL);
|
|
|
|
|
|
|
|
/* Template with quoting */
|
|
|
|
x = sdstemplate("v1={{{variable1}} {{} v2={variable2}", sdsTestTemplateCallback, NULL);
|
|
|
|
test_cond("sdstemplate() with quoting",
|
|
|
|
memcmp(x,"v1={value1} {} v2=value2",24) == 0);
|
|
|
|
sdsfree(x);
|
2021-07-05 02:02:54 -04:00
|
|
|
|
|
|
|
/* Test sdsresize - extend */
|
|
|
|
x = sdsnew("1234567890123456789012345678901234567890");
|
|
|
|
x = sdsResize(x, 200);
|
|
|
|
test_cond("sdsrezie() expand len", sdslen(x) == 40);
|
|
|
|
test_cond("sdsrezie() expand strlen", strlen(x) == 40);
|
|
|
|
test_cond("sdsrezie() expand alloc", sdsalloc(x) == 200);
|
|
|
|
/* Test sdsresize - trim free space */
|
|
|
|
x = sdsResize(x, 80);
|
|
|
|
test_cond("sdsrezie() shrink len", sdslen(x) == 40);
|
|
|
|
test_cond("sdsrezie() shrink strlen", strlen(x) == 40);
|
|
|
|
test_cond("sdsrezie() shrink alloc", sdsalloc(x) == 80);
|
|
|
|
/* Test sdsresize - crop used space */
|
|
|
|
x = sdsResize(x, 30);
|
|
|
|
test_cond("sdsrezie() crop len", sdslen(x) == 30);
|
|
|
|
test_cond("sdsrezie() crop strlen", strlen(x) == 30);
|
|
|
|
test_cond("sdsrezie() crop alloc", sdsalloc(x) == 30);
|
|
|
|
/* Test sdsresize - extend to different class */
|
|
|
|
x = sdsResize(x, 400);
|
|
|
|
test_cond("sdsrezie() expand len", sdslen(x) == 30);
|
|
|
|
test_cond("sdsrezie() expand strlen", strlen(x) == 30);
|
|
|
|
test_cond("sdsrezie() expand alloc", sdsalloc(x) == 400);
|
|
|
|
/* Test sdsresize - shrink to different class */
|
|
|
|
x = sdsResize(x, 4);
|
|
|
|
test_cond("sdsrezie() crop len", sdslen(x) == 4);
|
|
|
|
test_cond("sdsrezie() crop strlen", strlen(x) == 4);
|
|
|
|
test_cond("sdsrezie() crop alloc", sdsalloc(x) == 4);
|
|
|
|
sdsfree(x);
|
2010-09-23 10:05:17 -04:00
|
|
|
}
|
2020-12-23 12:16:49 -05:00
|
|
|
test_report();
|
2011-11-02 11:50:59 -04:00
|
|
|
return 0;
|
2010-09-23 10:05:17 -04:00
|
|
|
}
|
|
|
|
#endif
|