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[] )
|
int main( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
char *display_name=NULL;
|
char *display_name=NULL;
|
||||||
|
char *display_screen;
|
||||||
char *display_string;
|
char *display_string;
|
||||||
char *config_file=NULL;
|
char *config_file=NULL;
|
||||||
char message[255];
|
char message[255];
|
||||||
char num[10];
|
char *cp;
|
||||||
Window StartWin;
|
Window StartWin;
|
||||||
XSetWindowAttributes attributes;
|
XSetWindowAttributes attributes;
|
||||||
int len, lp;
|
int len, lp;
|
||||||
@ -614,19 +615,29 @@ int main( int argc, char *argv[] )
|
|||||||
if(!single){
|
if(!single){
|
||||||
for(lp=0;lp<Scr.NumberOfScreens;lp++){
|
for(lp=0;lp<Scr.NumberOfScreens;lp++){
|
||||||
if(lp!= Scr.screen){
|
if(lp!= Scr.screen){
|
||||||
snprintf(message, sizeof(message), "%s -d %s", argv[0], XDisplayString(dpy));
|
len = strlen(XDisplayString(dpy)) + 10;
|
||||||
len = strlen(message);
|
display_screen = calloc(len, sizeof(char));
|
||||||
message[len-1] = '\0';
|
snprintf(display_screen, len, "%s", XDisplayString(dpy));
|
||||||
sprintf(num,"%d",lp);
|
/*
|
||||||
strcat(message,num);
|
* Truncate the string 'whatever:n.n' to 'whatever:n',
|
||||||
strcat(message," -s ");
|
* 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)
|
if( Scr.flags & DEBUGOUT)
|
||||||
strcat(message," -debug");
|
snprintf(message + strlen(message), sizeof(message) - strlen(message), " -debug");
|
||||||
if( config_file!=NULL ){
|
if( config_file != NULL )
|
||||||
strcat(message," -f ");
|
snprintf(message + strlen(message), sizeof(message) - strlen(message) ," -f %s", config_file);
|
||||||
strcat(message,config_file);
|
snprintf(message + strlen(message), sizeof(message) - strlen(message), " &\n");
|
||||||
}
|
|
||||||
strcat(message," &\n");
|
|
||||||
system(message);
|
system(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user