mirror of
https://github.com/morgant/mlvwm.git
synced 2024-11-22 01:31:16 +00:00
Convert strcat()s to snprintf()s. Issue #6
This commit is contained in:
parent
7c8f22ff56
commit
5ed03df783
@ -545,10 +545,11 @@ void DoStartFunc( void )
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
char *display_name=NULL;
|
||||
char *display_screen;
|
||||
char *display_string;
|
||||
char *config_file=NULL;
|
||||
char message[255];
|
||||
char num[10];
|
||||
char *cp;
|
||||
Window StartWin;
|
||||
XSetWindowAttributes attributes;
|
||||
int len, lp;
|
||||
@ -614,19 +615,29 @@ int main( int argc, char *argv[] )
|
||||
if(!single){
|
||||
for(lp=0;lp<Scr.NumberOfScreens;lp++){
|
||||
if(lp!= Scr.screen){
|
||||
snprintf(message, sizeof(message), "%s -d %s", argv[0], XDisplayString(dpy));
|
||||
len = strlen(message);
|
||||
message[len-1] = '\0';
|
||||
sprintf(num,"%d",lp);
|
||||
strcat(message,num);
|
||||
strcat(message," -s ");
|
||||
len = strlen(XDisplayString(dpy)) + 10;
|
||||
display_screen = calloc(len, sizeof(char));
|
||||
snprintf(display_screen, len, "%s", XDisplayString(dpy));
|
||||
/*
|
||||
* Truncate the string 'whatever:n.n' to 'whatever:n',
|
||||
* and then append the screen number.
|
||||
*/
|
||||
cp = strchr(display_screen, ':');
|
||||
if (cp != NULL)
|
||||
{
|
||||
cp = strchr(cp, '.');
|
||||
if (cp != NULL)
|
||||
*cp = '\0'; /* truncate at display part */
|
||||
}
|
||||
snprintf(message, sizeof(message), "%s -d %s.%d -s", argv[0], display_screen, lp);
|
||||
free(display_screen);
|
||||
|
||||
if( Scr.flags & DEBUGOUT)
|
||||
strcat(message," -debug");
|
||||
if( config_file!=NULL ){
|
||||
strcat(message," -f ");
|
||||
strcat(message,config_file);
|
||||
}
|
||||
strcat(message," &\n");
|
||||
snprintf(message + strlen(message), sizeof(message) - strlen(message), " -debug");
|
||||
if( config_file != NULL )
|
||||
snprintf(message + strlen(message), sizeof(message) - strlen(message) ," -f %s", config_file);
|
||||
snprintf(message + strlen(message), sizeof(message) - strlen(message), " &\n");
|
||||
|
||||
system(message);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user