From: a bellenir Date: Tue, 22 Jul 2014 19:16:17 +0000 (+0000) Subject: declare variables at top of functions X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=9a285131da307fea14715b266947349716ad6f1c;p=archive%2Fafm.git declare variables at top of functions --- diff --git a/source/aardvark.c b/source/aardvark.c index dee7a15..25df8cf 100644 --- a/source/aardvark.c +++ b/source/aardvark.c @@ -1,8 +1,9 @@ #include "aardvark.h" +#include #include typedef struct { - char a, b, c; + uint8_t a, b, c; } Triplet_T; static Triplet_T aadata[77] = { @@ -25,10 +26,10 @@ static Triplet_T aadata[77] = { void aardvark_draw(void) { int row, col; - getmaxyx(stdscr, row, col); int i; int trips=sizeof(aadata)/sizeof(Triplet_T); char* aardvark="############################################################"; + getmaxyx(stdscr, row, col); for(i=0; i #include -#include -#include - +#include "vec.h" +#include "mem.h" #include "state.h" #include "workdir.h" @@ -46,8 +45,8 @@ void workdir_next(void) { int index = state_get_focused_frame(); //do nothing if at the end of the file list if(Windows[index].idx < vec_size(Windows[index].vfiles)-1){ - Windows[index].idx += 1; int rows,cols; + Windows[index].idx += 1; getmaxyx(stdscr, rows,cols); (void) cols; if((TopBuffer+Windows[index].idx+BotBuffer) > rows) @@ -99,9 +98,9 @@ void workdir_cd(void) { void workdir_ls(void) { int windex = state_get_focused_frame(); - get_files(windex); int i = Windows[windex].top_index; int rows, cols; + get_files(windex); getmaxyx(stdscr, rows, cols); attron(A_UNDERLINE); mvaddnstr(1, 1, Windows[windex].cwd, cols-2); @@ -123,16 +122,17 @@ void workdir_ls(void) { static void get_files(int windex){ int i=0; - if(Windows[windex].vfiles) mem_release(Windows[windex].vfiles); char* dotdot = mem_allocate(sizeof(char)*3, NULL); - strcpy(dotdot, ".."); - Windows[windex].vfiles = vec_new(1, dotdot); /* TODO: check if cwd = / */ char cmd[1028] = "ls "; - strcpy(&cmd[3], Windows[windex].cwd); - FILE* ls = popen(cmd, "r"); size_t len = 0; //unused. reflects sized allocated for buffer (filename) by getline ssize_t read; char* filename=0; + FILE* ls; + if(Windows[windex].vfiles) mem_release(Windows[windex].vfiles); + strcpy(dotdot, ".."); + Windows[windex].vfiles = vec_new(1, dotdot); /* TODO: check if cwd = / */ + strcpy(&cmd[3], Windows[windex].cwd); + ls = popen(cmd, "r"); i = 1; while ((read = getline(&filename, &len, ls)) != -1){ filename[read-1]=0; //remove ending newline