xaizek / hstr (License: Apachev2) (since 2018-12-07)
Bash and Zsh shell history suggest box - easily view, navigate, search and manage your command history.
Commit dd18ef4dc8aaa4f73819b9daa3b0b1a7d23c8253

Fixed #63 - SIGSEG on radix sort key overflow: maxkey must be -1 to index within slot array.
Author: Martin Dvorak
Author date (UTC): 2014-03-16 17:18
Committer name: Martin Dvorak
Committer date (UTC): 2014-03-16 17:18
Parent(s): 17db6de9ce5ff41809f5aff2da0efa0a4471e424
Signing key:
Tree: 3f396ec76f4babbc1b24af7d18b893b181b6b7da
File Lines added Lines deleted
src/radixsort.c 2 2
tests/_ranking 0 0
tests/monster/monster-hh-env.sh 2 3
tests/src/test_ranking.c 25 3
File src/radixsort.c changed (mode: 100644) (index fb11ec8..b8a01dc)
... ... RadixItem **radixsort_get_slot(RadixSorter *rs, unsigned topIndex)
48 48 void radixsort_add(RadixSorter *rs, RadixItem *item) void radixsort_add(RadixSorter *rs, RadixItem *item)
49 49 { {
50 50 if(item->key > rs->keyLimit) { if(item->key > rs->keyLimit) {
51 if(RADIX_DEBUG) fprintf(stderr, "ERROR: Radix sort overflow - inserted key is bigger than limit (%i): %i\n", rs->keyLimit, item->key);
51 if(RADIX_DEBUG) fprintf(stderr, "ERROR: Radix sort overflow - inserted key is bigger than limit (%u): %u\n", rs->keyLimit, item->key);
52 52 if(rs->optFloorAndInsertBigKeys) { if(rs->optFloorAndInsertBigKeys) {
53 item->key = rs->keyLimit;
53 item->key = rs->keyLimit-1;
54 54 } else { } else {
55 55 if(rs->optIgnoreBigKeys) { if(rs->optIgnoreBigKeys) {
56 56 return; return;
File tests/_ranking changed (mode: 100755) (index 27ba1e3..bef97a8)
File tests/monster/monster-hh-env.sh changed (mode: 100755) (index 051d80c..83bb601)
1 1 #!/bin/bash #!/bin/bash
2 2
3 3 export HISTCONTROL=ignorespace export HISTCONTROL=ignorespace
4 export HISTFILE=/home/dvorka/p/hstr/monster/.bash_history_50M
4 export HISTFILE=/home/dvorka/p/hstr/monster/.bash_history_same
5 #export HISTFILE=/home/dvorka/p/hstr/monster/.bash_history_50M
5 6 #export HISTFILE=/home/dvorka/p/hstr/monster/.bash_history_23M #export HISTFILE=/home/dvorka/p/hstr/monster/.bash_history_23M
6 7 #export HISTFILE=/home/dvorka/p/hstr/monster/.bash_history_500k #export HISTFILE=/home/dvorka/p/hstr/monster/.bash_history_500k
7 8 #export HISTFILE=/home/dvorka/p/hstr/monster/.bash_history #export HISTFILE=/home/dvorka/p/hstr/monster/.bash_history
8 9 export HISTFILESIZE=10000000 export HISTFILESIZE=10000000
9 10 export HISTSIZE=1000000 export HISTSIZE=1000000
10 11
11 PS1="\$? \$(if [[ \$? == 0 ]]; then echo \"\[\033[0;32m\];)\"; else echo \"\[\033[0;31m\];(\"; fi)\[\033[00m\] : "
12
13 12 # eof # eof
File tests/src/test_ranking.c changed (mode: 100644) (index d055bf4..86815b1)
... ... void testLog() {
15 15 #define MAX_CHARACTER_CODE 10000 #define MAX_CHARACTER_CODE 10000
16 16 static char line[MAX_CHARACTER_CODE]; static char line[MAX_CHARACTER_CODE];
17 17
18 void testGenerateCrazyHistoryFile()
18 void testGenerateHugeHistoryFileWithDifferentLines()
19 19 { {
20 FILE *file = fopen(".bash_history_crazy","a");
20 FILE *file = fopen(".bash_history_huge","a");
21 21 fseek(file,0, SEEK_END); fseek(file,0, SEEK_END);
22 22
23 23 line[0]=0; line[0]=0;
 
... ... void testGenerateCrazyHistoryFile()
26 26 sprintf(line,"%s%c",line,i); sprintf(line,"%s%c",line,i);
27 27 fprintf(file,"%s\n",line); fprintf(file,"%s\n",line);
28 28 } }
29 fclose(file);
30 }
31
29 32
33 void testGenerateHugeHistoryFileWithSameLines()
34 {
35 FILE *file = fopen(".bash_history_same","a");
36 fseek(file,0, SEEK_END);
37
38 int i;
39 for(i=0; i<100000; i++) {
40 fprintf(file,"find . | while read X; do echo $X; cat $X | grep -i ctrl; done | less\n",line);
41 fprintf(file,
42 "git commit -a -m \"Code review and stabilization.\" && git push origin master#"
43 "git commit -a -m \"Code review and stabilization.\" && git push origin master#"
44 "git commit -a -m \"Code review and stabilization.\" && git push origin master#"
45 "git commit -a -m \"Code review and stabilization.\" && git push origin master#"
46 "git commit -a -m \"Code review and stabilization.\" && git push origin master#"
47 "git commit -a -m \"Code review and stabilization.\" && git push origin master#"
48 "git commit -a -m \"Code review and stabilization.\" && git push origin master\n",
49 line);
50 }
30 51 fclose(file); fclose(file);
31 52 } }
32 53
54
33 55 int main(int argc, char *argv[]) int main(int argc, char *argv[])
34 56 { {
35 testGenerateCrazyHistoryFile();
57 testGenerateHugeHistoryFileWithSameLines();
36 58 } }
37 59
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/hstr

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/hstr

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master