]> git.lizzy.rs Git - linenoise.git/commitdiff
Fix for an history bug
authorantirez <antirez@gmail.com>
Sun, 21 Mar 2010 21:27:09 +0000 (22:27 +0100)
committerantirez <antirez@gmail.com>
Sun, 21 Mar 2010 21:27:09 +0000 (22:27 +0100)
README.markdown
linenoise.c

index 9f62ea67687ce157ed3d1bc12ab41f0d05b4686f..edbf03f147f375317359216eeedf1816724a8121 100644 (file)
@@ -1,6 +1,6 @@
 # Linenoise
 
-A minimal, zero-config, readline replacement.
+A minimal, zero-config, BSD licensed, readline replacement.
 
 ## Can a line editing library be 20k lines of code?
 
index aebe39830f2701d8a8f80f77756c0465f302bba5..386ab6c69620b73368da4070151d73a7f0ce84a4 100644 (file)
@@ -308,7 +308,7 @@ int linenoiseHistoryAdd(char *line) {
     line = strdup(line);
     if (!line) return 0;
     if (history_len == history_max_len) {
-        memmove(history,history+sizeof(char*),sizeof(char*)*history_max_len-1);
+        memmove(history,history+1,sizeof(char*)*(history_max_len-1));
         history_len--;
     }
     history[history_len] = line;
@@ -326,7 +326,7 @@ int linenoiseHistorySetMaxLen(int len) {
         new = malloc(sizeof(char*)*len);
         if (new == NULL) return 0;
         if (len < tocopy) tocopy = len;
-        memcpy(new,history-sizeof(char*)*tocopy, sizeof(char*)*tocopy);
+        memcpy(new,history+(history_max_len-tocopy), sizeof(char*)*tocopy);
         free(history);
         history = new;
     }