Fixing errors and warnings and making the codebase compilable again.

This commit is contained in:
Martin Dvorak 2015-02-13 08:31:09 +01:00
parent c69ee85593
commit 78f7cb2c45
4 changed files with 10 additions and 8 deletions

View file

@ -1,6 +1,7 @@
hstr
====
Shell command history suggest box for Bash and [Zsh](CONFIGURATION.md#zsh-history-settings).
Shell history suggest box for Bash and
[Zsh](CONFIGURATION.md#zsh-history-settings) - easily view, navigate, sort and use your command history.
[![BASH History Suggest Box](http://mindforger.com/projects/images/hh-3.png "BASH History Suggest Box @ YouTube")](http://www.youtube.com/watch?v=sPF29NyXe2U)

View file

@ -129,8 +129,7 @@ HistoryItems *get_prioritized_history()
if(!regexp_match(&regexp, historyList[i]->line)) {
continue;
}
if(line && strlen(historyList[i]->line)>itemOffset) {
if(historyList[i]->line && strlen(historyList[i]->line)>itemOffset) {
line=historyList[i]->line+itemOffset;
} else {
line=historyList[i]->line;

View file

@ -126,18 +126,19 @@ void toggle_case(char *str, bool lowercase) {
}
}
const char* get_process_name_by_pid(const int pid)
char *get_process_name_by_pid(const int pid)
{
char* name = (char*)calloc(256,sizeof(char));
char* name = (char*)calloc(10,sizeof(char));
if(name){
sprintf(name, "/proc/%d/cmdline",pid);
FILE* f = fopen(name,"r");
if(f){
size_t size = fread(name, sizeof(char), 256, f);
size_t size = fread(name, sizeof(char), 10, f);
if(size>0){
if('\n'==name[size-1])
if('\n'==name[size-1]) {
name[size-1]='\0';
}
}
fclose(f);
}
}
@ -146,7 +147,7 @@ const char* get_process_name_by_pid(const int pid)
bool isZshParentShell() {
pid_t parentPid=getppid();
const char* cmdline=get_process_name_by_pid(parentPid);
char* cmdline=get_process_name_by_pid(parentPid);
bool result=cmdline && strstr(cmdline, "zsh");
free(cmdline);
return result;

View file

@ -11,6 +11,7 @@
#define _HSTR_UTILS_H
#include <sys/ioctl.h>
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>