mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 20:38:08 +01:00
Get rid of cropline(), use wtrimspace() instead
There is code duplication with the cropline() function, so get rid of it and use WINGs wtrimspace() instead. Signed-off-by: Carlos R. Mafra <crmafra@gmail.com>
This commit is contained in:
@@ -473,25 +473,6 @@ static Bool addShortcut(char *file, char *shortcutDefinition, WMenu * menu, WMen
|
|||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************/
|
|
||||||
|
|
||||||
static char *cropline(char *line)
|
|
||||||
{
|
|
||||||
char *end;
|
|
||||||
|
|
||||||
if (strlen(line) == 0)
|
|
||||||
return line;
|
|
||||||
|
|
||||||
end = &(line[strlen(line)]) - 1;
|
|
||||||
while (isspace(*line) && *line != 0)
|
|
||||||
line++;
|
|
||||||
while (end > line && isspace(*end)) {
|
|
||||||
*end = 0;
|
|
||||||
end--;
|
|
||||||
}
|
|
||||||
return line;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *next_token(char *line, char **next)
|
static char *next_token(char *line, char **next)
|
||||||
{
|
{
|
||||||
char *tmp, c;
|
char *tmp, c;
|
||||||
@@ -1020,14 +1001,14 @@ static WMenu *parseCascade(WScreen * scr, WMenu * menu, FILE * file, char *file_
|
|||||||
|
|
||||||
ok = 0;
|
ok = 0;
|
||||||
fgets(linebuf, MAXLINE, file);
|
fgets(linebuf, MAXLINE, file);
|
||||||
line = cropline(linebuf);
|
line = wtrimspace(linebuf);
|
||||||
lsize = strlen(line);
|
lsize = strlen(line);
|
||||||
do {
|
do {
|
||||||
if (line[lsize - 1] == '\\') {
|
if (line[lsize - 1] == '\\') {
|
||||||
char *line2;
|
char *line2;
|
||||||
int lsize2;
|
int lsize2;
|
||||||
fgets(elinebuf, MAXLINE, file);
|
fgets(elinebuf, MAXLINE, file);
|
||||||
line2 = cropline(elinebuf);
|
line2 = wtrimspace(elinebuf);
|
||||||
lsize2 = strlen(line2);
|
lsize2 = strlen(line2);
|
||||||
if (lsize2 + lsize > MAXLINE) {
|
if (lsize2 + lsize > MAXLINE) {
|
||||||
wwarning(_("%s:maximal line size exceeded in menu config: %s"),
|
wwarning(_("%s:maximal line size exceeded in menu config: %s"),
|
||||||
@@ -1129,7 +1110,7 @@ static WMenu *readMenuFile(WScreen * scr, char *file_name)
|
|||||||
while (!feof(file)) {
|
while (!feof(file)) {
|
||||||
if (!fgets(linebuf, MAXLINE, file))
|
if (!fgets(linebuf, MAXLINE, file))
|
||||||
break;
|
break;
|
||||||
line = cropline(linebuf);
|
line = wtrimspace(linebuf);
|
||||||
if (line[0] == 0 || line[0] == '#' || (line[0] == '/' && line[1] == '/'))
|
if (line[0] == 0 || line[0] == '#' || (line[0] == '/' && line[1] == '/'))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -1223,7 +1204,7 @@ static WMenu *readMenuPipe(WScreen * scr, char **file_name)
|
|||||||
while (!feof(file)) {
|
while (!feof(file)) {
|
||||||
if (!fgets(linebuf, MAXLINE, file))
|
if (!fgets(linebuf, MAXLINE, file))
|
||||||
break;
|
break;
|
||||||
line = cropline(linebuf);
|
line = wtrimspace(linebuf);
|
||||||
if (line[0] == 0 || line[0] == '#' || (line[0] == '/' && line[1] == '/'))
|
if (line[0] == 0 || line[0] == '#' || (line[0] == '/' && line[1] == '/'))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
@@ -645,23 +645,6 @@ static void newWSCommand(WMenu * menu, WMenuEntry * foo)
|
|||||||
} */
|
} */
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *cropline(char *line)
|
|
||||||
{
|
|
||||||
char *end;
|
|
||||||
|
|
||||||
if (strlen(line) == 0)
|
|
||||||
return line;
|
|
||||||
|
|
||||||
end = &(line[strlen(line)]) - 1;
|
|
||||||
while (isspace(*line) && *line != 0)
|
|
||||||
line++;
|
|
||||||
while (isspace(*end) && end != line) {
|
|
||||||
*end = 0;
|
|
||||||
end--;
|
|
||||||
}
|
|
||||||
return line;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wWorkspaceRename(WScreen * scr, int workspace, char *name)
|
void wWorkspaceRename(WScreen * scr, int workspace, char *name)
|
||||||
{
|
{
|
||||||
char buf[MAX_WORKSPACENAME_WIDTH + 1];
|
char buf[MAX_WORKSPACENAME_WIDTH + 1];
|
||||||
@@ -671,7 +654,7 @@ void wWorkspaceRename(WScreen * scr, int workspace, char *name)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* trim white spaces */
|
/* trim white spaces */
|
||||||
tmp = cropline(name);
|
tmp = wtrimspace(name);
|
||||||
|
|
||||||
if (strlen(tmp) == 0) {
|
if (strlen(tmp) == 0) {
|
||||||
snprintf(buf, sizeof(buf), _("Workspace %i"), workspace + 1);
|
snprintf(buf, sizeof(buf), _("Workspace %i"), workspace + 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user