From 4c18180fb59d08f894ef56eb718c76aa92c9deb4 Mon Sep 17 00:00:00 2001 From: satbaby Date: Mon, 24 Dec 2012 16:43:04 +0100 Subject: [PATCH] msgbox: fix sizeof(int) --- io.c | 3 ++- io.h | 1 + msgbox.c | 23 +++++++++-------------- msgbox.h | 2 +- text.c | 28 ++++++++++++++-------------- text.h | 2 +- txtform.c | 7 +------ 7 files changed, 29 insertions(+), 37 deletions(-) diff --git a/io.c b/io.c index b4cdaa2..c450459 100644 --- a/io.c +++ b/io.c @@ -15,6 +15,7 @@ #include #include #include +#include "msgbox.h" #include "io.h" @@ -23,7 +24,7 @@ extern int instance; struct input_event ev; static unsigned short rccode=-1; -static int rc; +static int rc = 0; int InitRC(void) { diff --git a/io.h b/io.h index d7914d4..1619ae7 100644 --- a/io.h +++ b/io.h @@ -7,5 +7,6 @@ int InitRC(void); int CloseRC(void); int RCKeyPressed(void); +int GetRCCode(void); #endif diff --git a/msgbox.c b/msgbox.c index 1b3c52c..3ec7bcb 100644 --- a/msgbox.c +++ b/msgbox.c @@ -38,17 +38,16 @@ static char spres[][5]={"","_crt","_lcd"}; char *line_buffer=NULL, *title=NULL; int size=24, type=0, timeout=0, refresh=3, flash=0, selection=0, tbuttons=0, buttons=0, bpline=3, echo=0, absolute=0, mute=1, header=1, cyclic=1; -char *butmsg[16]; int rbutt[16],hide=0,radius=10; // Misc -char NOMEM[]="msgbox \n"; +const char NOMEM[]="msgbox \n"; char TMP_FILE[64]="/tmp/msgbox.tmp"; unsigned char *lfb = 0, *lbb = 0, *obb = 0, *hbb = 0, *ibb = 0; unsigned char nstr[BUFSIZE]=""; unsigned char *trstr; unsigned rc,sc[8]={'a','o','u','A','O','U','z','d'}, tc[8]={0xE4,0xF6,0xFC,0xC4,0xD6,0xDC,0xDF,0xB0}; -char INST_FILE[]="/tmp/rc.locked"; +const char INST_FILE[]="/tmp/rc.locked"; int instance=0; int get_instance(void) @@ -66,10 +65,9 @@ int rval=0; void put_instance(int pval) { -FILE *fh; - if(pval) { + FILE *fh; if((fh=fopen(INST_FILE,"w"))!=NULL) { fputc(pval,fh); @@ -82,7 +80,7 @@ FILE *fh; } } -static void quit_signal(int sig) +static void quit_signal() { put_instance(get_instance()-1); printf("msgbox Version %.2f killed\n",M_VERSION); @@ -92,13 +90,11 @@ static void quit_signal(int sig) int Read_Neutrino_Cfg(char *entry) { FILE *nfh; -char tstr [512], *cfptr=NULL; int rv=-1; if((nfh=fopen(NCF_FILE,"r"))!=NULL) { - tstr[0]=0; - + char tstr [512]={0}, *cfptr=NULL; while((!feof(nfh)) && ((strstr(tstr,entry)==NULL) || ((cfptr=strchr(tstr,'='))==NULL))) { fgets(tstr,500,nfh); @@ -322,7 +318,7 @@ FILE *xfh; if((xfh=fopen(msg,"r"))!=NULL) { fclose(xfh); - strcpy(TMP_FILE,msg); + snprintf(TMP_FILE,sizeof(TMP_FILE),"%s",msg); } else { @@ -388,11 +384,10 @@ void ShowUsage(void) int main (int argc, char **argv) { -int index,index2,tv,found=0, spr; +int index=0,tv=0,found=0, spr=0; int dloop=1, rcc=-1, cupd=0; -char rstr[BUFSIZE], *rptr, *aptr; -time_t tm1,tm2; -unsigned int alpha; +char rstr[BUFSIZE]={0}, *rptr=NULL, *aptr=NULL; +time_t tm1=0,tm2=0; //clock_t tk1=0; FILE *fh; diff --git a/msgbox.h b/msgbox.h index c3bc57e..ef50388 100644 --- a/msgbox.h +++ b/msgbox.h @@ -124,7 +124,7 @@ extern unsigned char rd[],gn[],bl[],tr[]; int startx, starty, sx, ex, sy, ey, debounce, rblock; extern unsigned sc[8], tc[8]; -extern char *butmsg[MAX_BUTTONS]; +char *butmsg[MAX_BUTTONS]; extern int buttons,selection; extern int instance; int get_instance(void); diff --git a/text.c b/text.c index fb90e07..a54cbf3 100644 --- a/text.c +++ b/text.c @@ -14,7 +14,7 @@ int TABULATOR=72; FT_Error MyFaceRequester(FTC_FaceID face_id, FT_Library library, FT_Pointer request_data, FT_Face *aface) { FT_Error result; - + request_data=request_data;//for unused request_data result = FT_New_Face(library, face_id, 0, aface); if(result) printf("msgbox \n", (char*)face_id); @@ -70,8 +70,9 @@ int RenderChar(FT_ULong currentchar, int sx, int sy, int ex, int color) if(color != -1) /* don't render char, return charwidth only */ { - if(sx + sbit->xadvance >= ex) return -1; /* limit to maxwidth */ - + if(sx + sbit->xadvance >= ex){ + return -1; /* limit to maxwidth */ + } for(row = 0; row < sbit->height; row++) { for(pitch = 0; pitch < sbit->pitch; pitch++) @@ -101,9 +102,9 @@ int RenderChar(FT_ULong currentchar, int sx, int sy, int ex, int color) * GetStringLen ******************************************************************************/ -int GetStringLen(int sx, unsigned char *string, int size) +int GetStringLen(int sx, char *string, int size) { -int i, found; +unsigned int i = 0; int stringlen = 0; //reset kerning @@ -142,8 +143,8 @@ int stringlen = 0; } else { - found=0; - for(i=0; i0) && (fgets(tstr, sizeof(tstr), fh))) @@ -65,10 +64,6 @@ int just, color=CMCT; if(loop>=line) { RenderString(rstr, xs, ys, xw, just, size, color); - if(strlen(rstr)) - { - first=0; - } ys+=dy; } } -- 2.39.5