summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8b2ace4)
raw | patch | inline | side by side (parent: 8b2ace4)
author | Max Kellermann <max@duempel.org> | |
Fri, 3 Oct 2008 09:50:42 +0000 (11:50 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Fri, 3 Oct 2008 09:50:42 +0000 (11:50 +0200) |
Don't duplicate code which is already provided by glib.
src/conf.c | patch | blob | history | |
src/support.h | patch | blob | history |
diff --git a/src/conf.c b/src/conf.c
index ff627e0b6612708b38975954806fe0c00ea0d409..a39c49317a2397ec80cd92a04d603b823fa042bf 100644 (file)
--- a/src/conf.c
+++ b/src/conf.c
#include "config.h"
#include "defaults.h"
#include "i18n.h"
-#include "support.h"
#include "command.h"
#include "colors.h"
#include "screen_list.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <glib.h>
#define MAX_LINE_LENGTH 1024
#define COMMENT_TOKEN '#'
i=0;
j=0;
memset(buf, 0, MAX_LINE_LENGTH);
- while( i<len && str[i]!='=' && !IS_WHITESPACE(str[i]) )
+ while (i < len && str[i] != '=' && !g_ascii_isspace(str[i]))
buf[j++] = str[i++];
if( (cmd=get_key_command_from_name(buf)) == CMD_NONE ) {
fprintf(stderr, _("Error: Unknown key command %s\n"), buf);
}
/* skip whitespace */
- while( i<len && (str[i]=='=' || IS_WHITESPACE(str[i])) )
+ while (i < len && (str[i] == '=' || g_ascii_isspace(str[i])))
i++;
/* get the value part */
i=0;
len=strlen(str);
/* get the color name */
- while( i<len && str[i]!='=' && !IS_WHITESPACE(str[i]) )
+ while (i < len && str[i] != '=' && !g_ascii_isspace(str[i]))
i++;
/* skip whitespace */
- while( i<len && (str[i]=='=' || IS_WHITESPACE(str[i])) ) {
+ while (i < len && (str[i] == '=' || g_ascii_isspace(str[i]))) {
str[i]='\0';
i++;
}
i=0;
j=0;
memset(buf, 0, MAX_LINE_LENGTH);
- while( i<len && str[i]!='=' && !IS_WHITESPACE(str[i]) )
+ while (i < len && str[i] != '=' && !g_ascii_isspace(str[i]))
buf[j++] = str[i++];
color=colors_str2color(buf);
if( color<0 ) {
name = g_strdup(buf);
/* skip whitespace */
- while( i<len && (str[i]=='=' || IS_WHITESPACE(str[i])) )
+ while (i < len && (str[i] == '=' || g_ascii_isspace(str[i])))
i++;
/* get the value part */
/* remove trailing whitespace */
line[i] = '\0';
i--;
- while( i>=0 && IS_WHITESPACE(line[i]) )
+ while (i >= 0 && g_ascii_isspace(line[i]))
{
line[i] = '\0';
i--;
{
i = 0;
/* skip whitespace */
- while( i<len && IS_WHITESPACE(line[i]) )
+ while (i < len && g_ascii_isspace(line[i]))
i++;
/* continue if this line is not a comment */
{
/* get the name part */
j=0;
- while( i<len && line[i]!='=' && !IS_WHITESPACE(line[i]) )
+ while (i < len && line[i] != '=' && !g_ascii_isspace(line[i]))
{
name[j++] = line[i++];
}
name[j] = '\0';
/* skip '=' and whitespace */
- while( i<len && (line[i]=='=' || IS_WHITESPACE(line[i])) )
+ while (i < len && (line[i] == '=' || g_ascii_isspace(line[i])))
i++;
/* get the value part */
diff --git a/src/support.h b/src/support.h
index 5d67b8fa7bec91b0e8a1f7b04bad9efb63c6a509..68f746dd3590af88ef8a65e8e31b148cb2428fd5 100644 (file)
--- a/src/support.h
+++ b/src/support.h
char *basename(char *path);
#endif
-#define IS_WHITESPACE(c) (c==' ' || c=='\t' || c=='\r' || c=='\n')
-
char *remove_trailing_slash(char *path);
const char *strcasestr(const char *haystack, const char *needle);