mirror of
https://github.com/morgant/mlvwm.git
synced 2024-11-22 01:31:16 +00:00
Convert sprintf()s to snprintf()s. Issue #6
This commit is contained in:
parent
67e74cbdd1
commit
7c8f22ff56
@ -13,6 +13,7 @@
|
||||
#include "screen.h"
|
||||
#include "misc.h"
|
||||
#include "event.h"
|
||||
#include "balloon.h"
|
||||
|
||||
#include <X11/extensions/shape.h>
|
||||
|
||||
@ -156,7 +157,7 @@ void ShapeBalloon( int fx, int fy, int xoff, int yoff, int woff, int hoff, int w
|
||||
void BalloonSize( int *lh, int *lw, int *offset, int *w, int *h, MlvwmWindow *mw )
|
||||
{
|
||||
int lp;
|
||||
char contents[256];
|
||||
char contents[MAX_BALLOON_STR_LEN];
|
||||
int contents_width=0, strw, strh;
|
||||
int xinc, yinc;
|
||||
|
||||
@ -223,7 +224,7 @@ void BalloonSize( int *lh, int *lw, int *offset, int *w, int *h, MlvwmWindow *mw
|
||||
void DrawWindowBalloon( int xoff, int yoff, int lh, int offset, int lw, MlvwmWindow *mw )
|
||||
{
|
||||
int lp;
|
||||
char contents[255];
|
||||
char contents[MAX_BALLOON_STR_LEN];
|
||||
int xinc, yinc;
|
||||
|
||||
for( lp=0; WinLabel[lp]!=NULL; lp++ ){
|
||||
|
@ -8,5 +8,7 @@
|
||||
#ifndef _BALLOON_
|
||||
#define _BALLOON_
|
||||
|
||||
#define MAX_BALLOON_STR_LEN 255
|
||||
|
||||
extern void BalloonHelp( void );
|
||||
#endif /* _BALLOON_ */
|
||||
|
@ -966,6 +966,7 @@ void DrawAllDecorations( MlvwmWindow *t, Bool on_off )
|
||||
void SetFocus( MlvwmWindow *t )
|
||||
{
|
||||
char *str, action[24], *winname;
|
||||
size_t str_size;
|
||||
unsigned long mask, valuemask;
|
||||
XSetWindowAttributes attributes;
|
||||
XGCValues xgcv;
|
||||
@ -1016,8 +1017,9 @@ void SetFocus( MlvwmWindow *t )
|
||||
ChangeMenuLabel( &(Scr.IconMenu), NULL,
|
||||
t->miniicon==NULL?Scr.SystemIcon:t->miniicon );
|
||||
if( !(t->flags&TRANSIENT) ){
|
||||
str = calloc( strlen(t->name)+6, 1 );
|
||||
sprintf( str, "Hide %s", t->name );
|
||||
str_size = strlen(t->name)+6;
|
||||
str = calloc( str_size, 1 );
|
||||
snprintf( str, str_size, "Hide %s", t->name );
|
||||
ChangeMenuItemLabel( "ICON", Scr.IconMenu.m_item->label,
|
||||
str, NULL, SELECTON, M_COPY );
|
||||
ChangeMenuItemLabel( "ICON", "Hide Others", "Hide Others",
|
||||
|
@ -761,6 +761,7 @@ void ReadConfigFile( char *configfile )
|
||||
int lp;
|
||||
#ifdef MLVWMLIBDIR
|
||||
char *sysrc;
|
||||
size_t sysrc_size;
|
||||
#endif
|
||||
|
||||
if( (file = LookUpFiles( NULL, configfile, R_OK ))==NULL )
|
||||
@ -768,12 +769,14 @@ void ReadConfigFile( char *configfile )
|
||||
#ifdef MLVWMLIBDIR
|
||||
if( !file ){
|
||||
if( strcmp( configfile, CONFIGNAME) ){
|
||||
sysrc = calloc( strlen(MLVWMLIBDIR)+strlen(configfile)+2, 1 );
|
||||
sprintf( sysrc, "%s/%s", MLVWMLIBDIR, configfile );
|
||||
sysrc_size = strlen(MLVWMLIBDIR)+strlen(configfile)+2;
|
||||
sysrc = calloc( sysrc_size, 1 );
|
||||
snprintf( sysrc, sysrc_size, "%s/%s", MLVWMLIBDIR, configfile );
|
||||
}
|
||||
else{
|
||||
sysrc = calloc( strlen(MLVWMLIBDIR)+strlen(configfile)+9, 1 );
|
||||
sprintf( sysrc, "%s/system%s", MLVWMLIBDIR, configfile );
|
||||
sysrc_size = strlen(MLVWMLIBDIR)+strlen(configfile)+9;
|
||||
sysrc = calloc( sysrc_size, 1 );
|
||||
snprintf( sysrc, sysrc_size, "%s/system%s", MLVWMLIBDIR, configfile );
|
||||
}
|
||||
file = LookUpFiles( NULL, sysrc, R_OK );
|
||||
free( sysrc );
|
||||
|
@ -1596,6 +1596,7 @@ void handle_property_request( XEvent *ev )
|
||||
XTextProperty text_prop;
|
||||
unsigned int JunkWidth, JunkHeight, JunkBW, JunkDepth;
|
||||
char desk[8], *str, action[24];
|
||||
size_t str_size;
|
||||
#ifdef USE_LOCALE
|
||||
int num;
|
||||
char **list;
|
||||
@ -1640,8 +1641,9 @@ void handle_property_request( XEvent *ev )
|
||||
ChangeMenuItemLabel( "ICON", oldWinName, winname,
|
||||
action, M_ALLSET, M_AND );
|
||||
if( tmp_win==Scr.ActiveWin ){
|
||||
str = calloc( strlen( tmp_win->name )+6, 1 );
|
||||
sprintf( str, "Hide %s", tmp_win->name );
|
||||
str_size = strlen(tmp_win->name)+6;
|
||||
str = calloc( str_size, 1 );
|
||||
snprintf( str, str_size, "Hide %s", tmp_win->name );
|
||||
ChangeMenuItemLabel( "ICON", Scr.IconMenu.m_item->label,
|
||||
str, NULL, SELECTON, M_COPY );
|
||||
free( str );
|
||||
|
25
mlvwm/misc.c
25
mlvwm/misc.c
@ -43,7 +43,8 @@ char *fgetline( char *str, int size, FILE *fp )
|
||||
|
||||
char *LookUpFiles( char *path, char *filename, int mode )
|
||||
{
|
||||
char *find;
|
||||
char *find, *separator;
|
||||
size_t find_size;
|
||||
|
||||
if( !access( filename, mode ) ){
|
||||
find = strdup( filename );
|
||||
@ -52,14 +53,16 @@ char *LookUpFiles( char *path, char *filename, int mode )
|
||||
if( path==NULL ) return NULL;
|
||||
do{
|
||||
path=SkipSpace( path );
|
||||
find = calloc( strlen(path)+strlen(filename)+2, 1 );
|
||||
find_size = strlen(path)+strlen(filename)+2;
|
||||
find = calloc( find_size, 1 );
|
||||
if( strchr( path, ':' )==NULL ){
|
||||
sprintf( find, "%s/%s", path, filename );
|
||||
snprintf( find, find_size, "%s/%s", path, filename );
|
||||
path += strlen( path );
|
||||
}
|
||||
else{
|
||||
strcpy( find, path );
|
||||
sprintf( strchr( find, ':' ), "/%s", filename );
|
||||
separator = strchr( find, ':' );
|
||||
snprintf( separator, strlen(separator)+strlen(filename)+2, "/%s", filename );
|
||||
path = strchr( path, ':') + 1;
|
||||
}
|
||||
if( !access(find, mode ) ){
|
||||
@ -120,12 +123,14 @@ void sleep_a_little(int n)
|
||||
void DrawErrMsgOnMenu( char *str1, char *str2 )
|
||||
{
|
||||
char *str;
|
||||
size_t str_size;
|
||||
static int call=0;
|
||||
int wait_s;
|
||||
|
||||
call++;
|
||||
str = calloc( strlen(str1)+strlen(str2)+1, 1 );
|
||||
sprintf( str, "%s%s", str1, str2 );
|
||||
str_size = strlen(str1)+strlen(str2)+1;
|
||||
str = calloc( str_size, 1 );
|
||||
snprintf( str, str_size, "%s%s", str1, str2 );
|
||||
if( call<5 ) XBell( dpy, 30 );
|
||||
DrawStringMenuBar( str );
|
||||
wait_s = 3000000-call/5*500000;
|
||||
@ -274,13 +279,15 @@ void RaiseMlvwmWindow( MlvwmWindow *win )
|
||||
char *WinListName( MlvwmWindow *mw )
|
||||
{
|
||||
char *winname;
|
||||
size_t winname_size;
|
||||
|
||||
winname = calloc( strlen( mw->name )+1+(Scr.flags&DISPDESK?3:0), 1 );
|
||||
winname_size = strlen( mw->name )+1+(Scr.flags&DISPDESK?3:0);
|
||||
winname = calloc( winname_size, 1 );
|
||||
if( Scr.flags&DISPDESK ){
|
||||
if( mw->flags&STICKY )
|
||||
sprintf( winname, "S:%s", mw->name );
|
||||
snprintf( winname, winname_size, "S:%s", mw->name );
|
||||
else
|
||||
sprintf( winname, "%d:%s", mw->Desk, mw->name );
|
||||
snprintf( winname, winname_size, "%d:%s", mw->Desk, mw->name );
|
||||
}
|
||||
else
|
||||
strcpy( winname, mw->name );
|
||||
|
@ -614,7 +614,7 @@ int main( int argc, char *argv[] )
|
||||
if(!single){
|
||||
for(lp=0;lp<Scr.NumberOfScreens;lp++){
|
||||
if(lp!= Scr.screen){
|
||||
sprintf(message,"%s -d %s",argv[0],XDisplayString(dpy));
|
||||
snprintf(message, sizeof(message), "%s -d %s", argv[0], XDisplayString(dpy));
|
||||
len = strlen(message);
|
||||
message[len-1] = '\0';
|
||||
sprintf(num,"%d",lp);
|
||||
@ -633,7 +633,7 @@ int main( int argc, char *argv[] )
|
||||
}
|
||||
len = strlen( XDisplayString( dpy ) );
|
||||
display_string = calloc( len+10, sizeof( char ) );
|
||||
sprintf( display_string, "DISPLAY=%s", XDisplayString( dpy ) );
|
||||
snprintf( display_string, len+10, "DISPLAY=%s", XDisplayString(dpy) );
|
||||
putenv( display_string );
|
||||
|
||||
XShapeQueryExtension( dpy, &ShapeEventBase, &ShapeErrorBase );
|
||||
|
Loading…
Reference in New Issue
Block a user