if (!cmdf)
return;
int i = strlen(block->icon);
- fgets(output+i, CMDLENGTH-i-delimLen, cmdf);
+ fgets(output+i, CMDLENGTH-i, cmdf);
i = strlen(output);
if (i == 0) {
//return if block and command output are both empty
pclose(cmdf);
return;
+ } else if (output[i-1] == '\n') {
+ output[i-1] = '\0';
}
- if (delim[0] != '\0') {
- //only chop off newline if one is present at the end
- i = output[i-1] == '\n' ? i-1 : i;
- strncpy(output+i, delim, delimLen);
- }
- else
- output[i++] = '\0';
pclose(cmdf);
}
str[0] = '\0';
for (unsigned int i = 0; i < LENGTH(blocks); i++)
strcat(str, statusbar[i]);
- str[strlen(str)-strlen(delim)] = '\0';
+ str[strlen(str)] = '\0';
return strcmp(str, last);//0 if they are the same
}
int main(int argc, char** argv)
{
for (int i = 0; i < argc; i++) {//Handle command line arguments
- if (!strcmp("-d",argv[i]))
- strncpy(delim, argv[++i], delimLen);
- else if (!strcmp("-p",argv[i]))
+ if (!strcmp("-p",argv[i]))
writestatus = pstdout;
}
#ifndef NO_X
if (!setupX())
return 1;
#endif
- delimLen = MIN(delimLen, strlen(delim));
- delim[delimLen++] = '\0';
signal(SIGTERM, termhandler);
signal(SIGINT, termhandler);
statusloop();