use more safe functions and update #inlcude

This commit is contained in:
Julien Danjou 2007-09-11 14:00:49 +02:00
parent 7064e17726
commit 9f56ade4e9
11 changed files with 6 additions and 25 deletions

View File

@ -3,7 +3,6 @@
#include <errno.h> #include <errno.h>
#include <locale.h> #include <locale.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <sys/select.h> #include <sys/select.h>
#include <X11/cursorfont.h> #include <X11/cursorfont.h>
@ -13,7 +12,6 @@
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include "awesome.h" #include "awesome.h"
#include "util.h"
#include "event.h" #include "event.h"
#include "layout.h" #include "layout.h"
#include "tag.h" #include "tag.h"
@ -345,7 +343,7 @@ main(int argc, char *argv[])
readin = False; readin = False;
break; break;
default: 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'); p >= awesomeconf.statustext && *p == '\n'; *p-- = '\0');
for(; p >= awesomeconf.statustext && *p != '\n'; --p); for(; p >= awesomeconf.statustext && *p != '\n'; --p);
if(p > awesomeconf.statustext) if(p > awesomeconf.statustext)

View File

@ -1,12 +1,10 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
#include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include "awesome.h" #include "awesome.h"
#include "util.h"
#include "layout.h" #include "layout.h"
#include "tag.h" #include "tag.h"

View File

@ -4,12 +4,10 @@
* \defgroup ui_callback * \defgroup ui_callback
*/ */
#include <stdlib.h>
#include <libconfig.h> #include <libconfig.h>
#include <X11/keysym.h> #include <X11/keysym.h>
#include "awesome.h" #include "awesome.h"
#include "util.h"
#include "layout.h" #include "layout.h"
#include "tag.h" #include "tag.h"
#include "layouts/tile.h" #include "layouts/tile.h"

2
draw.c
View File

@ -20,7 +20,7 @@ drawtext(Display *disp, const char *text, unsigned long col[ColLast])
if(!text) if(!text)
return; return;
w = 0; w = 0;
olen = len = strlen(text); olen = len = a_strlen(text);
if(len >= sizeof buf) if(len >= sizeof buf)
len = sizeof buf - 1; len = sizeof buf - 1;
memcpy(buf, text, len); memcpy(buf, text, len);

5
draw.h
View File

@ -3,10 +3,9 @@
#ifndef AWESOME_DRAW_H #ifndef AWESOME_DRAW_H
#define AWESOME_DRAW_H #define AWESOME_DRAW_H
#include <string.h> #include "util.h"
#include "config.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 */ void drawstatus(Display *, awesome_config *); /* draw the bar */
unsigned int textnw(const char *, unsigned int); unsigned int textnw(const char *, unsigned int);

View File

@ -1,11 +1,9 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
#include <stdlib.h>
#include <X11/keysym.h> #include <X11/keysym.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include "awesome.h" #include "awesome.h"
#include "util.h"
#include "event.h" #include "event.h"
#include "layout.h" #include "layout.h"
#include "tag.h" #include "tag.h"

View File

@ -1,6 +1,5 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
#include <stdlib.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
@ -8,7 +7,6 @@
#include "layout.h" #include "layout.h"
#include "tag.h" #include "tag.h"
#include "layouts/floating.h" #include "layouts/floating.h"
#include "util.h"
/* extern */ /* extern */
extern int wax, way, wah, waw; /* windowarea geometry */ extern int wax, way, wah, waw; /* windowarea geometry */

View File

@ -1,7 +1,6 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include "layouts/tile.h" #include "layouts/tile.h"
#include "layout.h" #include "layout.h"

8
tag.c
View File

@ -1,10 +1,8 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include "util.h"
#include "layout.h" #include "layout.h"
#include "tag.h" #include "tag.h"
@ -41,11 +39,7 @@ applyrules(Client * c, awesome_config *awesomeconf)
XClassHint ch = { 0, 0 }; XClassHint ch = { 0, 0 };
char *prop; char *prop;
if(ch.res_class) len += a_strlen(ch.res_class) + a_strlen(ch.res_name) + a_strlen(c->name);
len += strlen(ch.res_class);
if(ch.res_name)
len += strlen(ch.res_name);
len += strlen(c->name);
prop = p_new(char, len + 1); prop = p_new(char, len + 1);

2
util.c
View File

@ -2,10 +2,8 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <unistd.h> #include <unistd.h>
#include <string.h>
#include "util.h" #include "util.h"

1
util.h
View File

@ -4,6 +4,7 @@
#define AWESOME_MEM_H #define AWESOME_MEM_H
#include <string.h> #include <string.h>
#include <stdlib.h>
#include "config.h" #include "config.h"
#define ssizeof(foo) (ssize_t)sizeof(foo) #define ssizeof(foo) (ssize_t)sizeof(foo)