mirror of
https://github.com/dyne/frei0r.git
synced 2025-12-05 14:19:59 +01:00
fix: correct use of snprintf and strtok
This commit is contained in:
@@ -569,11 +569,11 @@ int tokenise(char *string, const char *delimiter, char ***tokens)
|
||||
int count = 0;
|
||||
char *input = strdup(string);
|
||||
char *result = NULL;
|
||||
result = strtok(input, delimiter);
|
||||
result = strtok_r(string, delimiter, &input);
|
||||
while (result != NULL) {
|
||||
*tokens = realloc(*tokens, (count + 1) * sizeof(char *));
|
||||
(*tokens)[count++] = strdup(result);
|
||||
result = strtok(NULL, delimiter);
|
||||
result = strtok_r(NULL, delimiter, &input);
|
||||
}
|
||||
free(input);
|
||||
return count;
|
||||
|
||||
@@ -38,7 +38,7 @@ Copyright (C) 2010 Marko Cebokli http://lea.hamradio.si/~s57uuu
|
||||
double PI=3.14159265358979;
|
||||
|
||||
//---------------------------------------------------------------
|
||||
void draw_rectangle(float_rgba *s, int w, int h, float x, float y, float wr, float hr, float_rgba c)
|
||||
static inline void draw_rectangle(float_rgba *s, int w, int h, float x, float y, float wr, float hr, float_rgba c)
|
||||
{
|
||||
int i,j;
|
||||
int zx,kx,zy,ky;
|
||||
@@ -139,7 +139,7 @@ draw_rectangle(s, w, h, x1, y1+1, v, 1, black);
|
||||
//justified
|
||||
//p=0 one decimal place p=1 three decimal places
|
||||
//m=1 always show sign
|
||||
void forstr(float a, int p, int m, char *s)
|
||||
inline static void forstr(float a, int p, int m, char *s)
|
||||
{
|
||||
float b;
|
||||
char *p3=" %5.3f";
|
||||
@@ -192,14 +192,14 @@ if (mm==1)
|
||||
forstr(s.rms,1-u,0,rs);
|
||||
forstr(s.min,1-u,m,ns);
|
||||
forstr(s.max,1-u,m,xs);
|
||||
sprintf(fs,"%s%s%s %s%s", lab, as, rs, ns, xs);
|
||||
snprintf(fs,255,"%s%s%s %s%s", lab, as, rs, ns, xs);
|
||||
sprintf(str,fs,s.avg,s.rms,s.min,s.max);
|
||||
}
|
||||
else
|
||||
{
|
||||
forstr(s.avg,1-u,m,as);
|
||||
forstr(s.rms,1-u,0,rs);
|
||||
sprintf(fs,"%s%s%s", lab, as, rs);
|
||||
snprintf(fs,255,"%s%s%s", lab, as, rs);
|
||||
sprintf(str,fs,s.avg,s.rms);
|
||||
}
|
||||
}
|
||||
@@ -251,7 +251,7 @@ if (sx>np)
|
||||
s[w*y+x]=white;
|
||||
x=x0+(np+2)*vp-i-1;
|
||||
s[w*y+x]=white;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sy>np)
|
||||
{
|
||||
@@ -263,7 +263,7 @@ if (sy>np)
|
||||
s[w*y+x]=white;
|
||||
y=y0+(np+2)*vp-i-1;
|
||||
s[w*y+x]=white;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -301,7 +301,7 @@ y0=h/20;
|
||||
if (bw==1) //big window
|
||||
{
|
||||
vx=240;
|
||||
vy = (m<=2) ? 320 : 300;
|
||||
vy = (m<=2) ? 320 : 300;
|
||||
x0 = (*poz==0) ? h/20 : w-h/20-vx;
|
||||
np=25; //size of magnifier
|
||||
xn = (m<=2) ? x0+8 : x0+70;
|
||||
@@ -745,4 +745,3 @@ crosshair(in->sl, in->w, in->h, in->x, in->y, 2*in->sx+1, 2*in->sy+1, 15);
|
||||
|
||||
floatrgba2color(in->sl, outframe, in->w , in->h);
|
||||
}
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ while (c[i]!=0)
|
||||
//justified
|
||||
//p=0 one decimal place p=1 three decimal places
|
||||
//m=1 always show sign
|
||||
void forstr(float a, int p, int m, char *s)
|
||||
inline static void forstr(float a, int p, int m, char *s)
|
||||
{
|
||||
float b;
|
||||
char *p3=" %5.3f";
|
||||
@@ -320,7 +320,7 @@ if ((dit&0x00000001)!=0) //marker 1 value
|
||||
if (m1>0)
|
||||
{
|
||||
forstr(data[0],1-u,0,frs);
|
||||
sprintf(fs,"%%s Mk1=%s", frs);
|
||||
snprintf(fs,255,"%%s Mk1=%s", frs);
|
||||
sprintf(str,fs,str,data[0]);
|
||||
}
|
||||
else
|
||||
@@ -331,7 +331,7 @@ if ((dit&0x00000004)!=0) //marker 2 value
|
||||
if (m2>0)
|
||||
{
|
||||
forstr(data[1],1-u,0,frs);
|
||||
sprintf(fs,"%%s Mk2=%s", frs);
|
||||
snprintf(fs,255,"%%s Mk2=%s", frs);
|
||||
sprintf(str,fs,str,data[1]);
|
||||
}
|
||||
else
|
||||
@@ -342,7 +342,7 @@ if ((dit&0x00000010)!=0) //difference marker2-marker1
|
||||
if ((m2>0)&&(m1>0))
|
||||
{
|
||||
forstr(data[2],1-u,0,frs);
|
||||
sprintf(fs,"%%s D=%s", frs);
|
||||
snprintf(fs,255,"%%s D=%s", frs);
|
||||
sprintf(str,fs,str,data[2]);
|
||||
}
|
||||
else
|
||||
@@ -351,25 +351,25 @@ if ((dit&0x00000010)!=0) //difference marker2-marker1
|
||||
if ((dit&0x00000020)!=0) //average of profile
|
||||
{
|
||||
forstr(data[3],1-u,0,frs);
|
||||
sprintf(fs,"%%s Avg=%s", frs);
|
||||
snprintf(fs,255,"%%s Avg=%s", frs);
|
||||
sprintf(str,fs,str,data[3]);
|
||||
}
|
||||
if ((dit&0x00000040)!=0) //RMS of profile
|
||||
{
|
||||
forstr(data[4],1-u,0,frs);
|
||||
sprintf(fs,"%%s RMS=%s", frs);
|
||||
snprintf(fs,255,"%%s RMS=%s", frs);
|
||||
sprintf(str,fs,str,data[4]);
|
||||
}
|
||||
if ((dit&0x00000080)!=0) //MIN of profile
|
||||
{
|
||||
forstr(data[5],1-u,0,frs);
|
||||
sprintf(fs,"%%s Min=%s", frs);
|
||||
snprintf(fs,255,"%%s Min=%s", frs);
|
||||
sprintf(str,fs,str,data[5]);
|
||||
}
|
||||
if ((dit&0x00000100)!=0) //MAX of profile
|
||||
{
|
||||
forstr(data[6],1-u,0,frs);
|
||||
sprintf(fs,"%%s Max=%s", frs);
|
||||
snprintf(fs,255,"%%s Max=%s", frs);
|
||||
sprintf(str,fs,str,data[6]);
|
||||
}
|
||||
}
|
||||
@@ -408,7 +408,7 @@ if (y<h/2-20) *poz=1; //bottom
|
||||
if (y>h/2+20) *poz=0; //top
|
||||
x0=h/20;
|
||||
vx=w*15/16;
|
||||
vy = h*6/16;
|
||||
vy = h*6/16;
|
||||
y0 = (*poz==0) ? h/20 : h-h/20-vy;
|
||||
|
||||
//end points of profile
|
||||
@@ -1035,4 +1035,3 @@ prof(in->sl, in->w, in->h, &in->poz, in->x, in->y, in->tilt, in->len, 1, in->mer
|
||||
|
||||
floatrgba2color(in->sl, outframe, in->w , in->h);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user