Added support for multiple char delimiter

This commit is contained in:
mackarelfish
2020-05-30 12:36:18 +07:00
parent d1519aa012
commit 9adc4dc1e7
2 changed files with 11 additions and 7 deletions

View File

@@ -75,11 +75,12 @@ void getcmd(const Block *block, char *output)
return;
char c;
int i = strlen(block->icon);
fgets(output+i, CMDLENGTH-2, cmdf);
fgets(output+i, CMDLENGTH-(strlen(delim)+1), cmdf);
remove_all(output, '\n');
i = strlen(output);
if (delim != '\0' && i)
output[i++] = delim;
if ((i > 0 && block != &blocks[LENGTH(blocks) - 1]))
strcat(output, delim);
i+=strlen(delim);
output[i++] = '\0';
pclose(cmdf);
}
@@ -130,8 +131,11 @@ int getstatus(char *str, char *last)
{
strcpy(last, str);
str[0] = '\0';
for(int i = 0; i < LENGTH(blocks); i++)
for(int i = 0; i < LENGTH(blocks); i++) {
strcat(str, statusbar[i]);
if (i == LENGTH(blocks) - 1)
strcat(str, " ");
}
str[strlen(str)-1] = '\0';
return strcmp(str, last);//0 if they are the same
}
@@ -218,7 +222,7 @@ int main(int argc, char** argv)
for(int i = 0; i < argc; i++)
{
if (!strcmp("-d",argv[i]))
delim = argv[++i][0];
delim = argv[++i];
else if(!strcmp("-p",argv[i]))
writestatus = pstdout;
}