From 9f56ade4e9d5835f85d85b5e0acaa218432b94df Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 11 Sep 2007 14:00:49 +0200 Subject: [PATCH] use more safe functions and update #inlcude --- awesome.c | 4 +--- client.c | 2 -- config.c | 2 -- draw.c | 2 +- draw.h | 5 ++--- event.c | 2 -- layout.c | 2 -- layouts/tile.c | 1 - tag.c | 8 +------- util.c | 2 -- util.h | 1 + 11 files changed, 6 insertions(+), 25 deletions(-) diff --git a/awesome.c b/awesome.c index dd7fa9459..921c16cfb 100644 --- a/awesome.c +++ b/awesome.c @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include @@ -13,7 +12,6 @@ #include #include "awesome.h" -#include "util.h" #include "event.h" #include "layout.h" #include "tag.h" @@ -345,7 +343,7 @@ main(int argc, char *argv[]) readin = False; break; default: - for(awesomeconf.statustext[r] = '\0', p = awesomeconf.statustext + strlen(awesomeconf.statustext) - 1; + for(awesomeconf.statustext[r] = '\0', p = awesomeconf.statustext + a_strlen(awesomeconf.statustext) - 1; p >= awesomeconf.statustext && *p == '\n'; *p-- = '\0'); for(; p >= awesomeconf.statustext && *p != '\n'; --p); if(p > awesomeconf.statustext) diff --git a/client.c b/client.c index f250eeba1..560738c76 100644 --- a/client.c +++ b/client.c @@ -1,12 +1,10 @@ /* See LICENSE file for copyright and license details. */ -#include #include #include #include #include "awesome.h" -#include "util.h" #include "layout.h" #include "tag.h" diff --git a/config.c b/config.c index 5b4c88d3a..77569fc6f 100644 --- a/config.c +++ b/config.c @@ -4,12 +4,10 @@ * \defgroup ui_callback */ -#include #include #include #include "awesome.h" -#include "util.h" #include "layout.h" #include "tag.h" #include "layouts/tile.h" diff --git a/draw.c b/draw.c index 4a93ea109..612fa237c 100644 --- a/draw.c +++ b/draw.c @@ -20,7 +20,7 @@ drawtext(Display *disp, const char *text, unsigned long col[ColLast]) if(!text) return; w = 0; - olen = len = strlen(text); + olen = len = a_strlen(text); if(len >= sizeof buf) len = sizeof buf - 1; memcpy(buf, text, len); diff --git a/draw.h b/draw.h index e54ee34fb..f50735f6c 100644 --- a/draw.h +++ b/draw.h @@ -3,10 +3,9 @@ #ifndef AWESOME_DRAW_H #define AWESOME_DRAW_H -#include -#include "config.h" +#include "util.h" -#define textw(text) (textnw(text, strlen(text)) + dc.font.height) +#define textw(text) (textnw(text, a_strlen(text)) + dc.font.height) void drawstatus(Display *, awesome_config *); /* draw the bar */ unsigned int textnw(const char *, unsigned int); diff --git a/event.c b/event.c index 13f68a022..05d85f82d 100644 --- a/event.c +++ b/event.c @@ -1,11 +1,9 @@ /* See LICENSE file for copyright and license details. */ -#include #include #include #include #include "awesome.h" -#include "util.h" #include "event.h" #include "layout.h" #include "tag.h" diff --git a/layout.c b/layout.c index de1a959fe..d49b0c911 100644 --- a/layout.c +++ b/layout.c @@ -1,6 +1,5 @@ /* See LICENSE file for copyright and license details. */ -#include #include #include @@ -8,7 +7,6 @@ #include "layout.h" #include "tag.h" #include "layouts/floating.h" -#include "util.h" /* extern */ extern int wax, way, wah, waw; /* windowarea geometry */ diff --git a/layouts/tile.c b/layouts/tile.c index ee0dac335..f06f7f3a3 100644 --- a/layouts/tile.c +++ b/layouts/tile.c @@ -1,7 +1,6 @@ /* See LICENSE file for copyright and license details. */ #include -#include #include "layouts/tile.h" #include "layout.h" diff --git a/tag.c b/tag.c index 7e159e6af..468de8e67 100644 --- a/tag.c +++ b/tag.c @@ -1,10 +1,8 @@ /* See LICENSE file for copyright and license details. */ #include -#include #include -#include "util.h" #include "layout.h" #include "tag.h" @@ -41,11 +39,7 @@ applyrules(Client * c, awesome_config *awesomeconf) XClassHint ch = { 0, 0 }; char *prop; - if(ch.res_class) - len += strlen(ch.res_class); - if(ch.res_name) - len += strlen(ch.res_name); - len += strlen(c->name); + len += a_strlen(ch.res_class) + a_strlen(ch.res_name) + a_strlen(c->name); prop = p_new(char, len + 1); diff --git a/util.c b/util.c index 695534999..09cf2bb87 100644 --- a/util.c +++ b/util.c @@ -2,10 +2,8 @@ #include #include -#include #include #include -#include #include "util.h" diff --git a/util.h b/util.h index b0abb8573..7bf913ffd 100644 --- a/util.h +++ b/util.h @@ -4,6 +4,7 @@ #define AWESOME_MEM_H #include +#include #include "config.h" #define ssizeof(foo) (ssize_t)sizeof(foo)