[util] warn() and eprint() now print \n

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-05-23 22:53:59 +02:00
parent db5430420d
commit be108acc32
11 changed files with 50 additions and 48 deletions

View File

@ -63,10 +63,10 @@ send_msg(const char *msg, ssize_t msg_len)
switch (errno)
{
case ENOENT:
warn("can't write to %s\n", addr->sun_path);
warn("can't write to %s", addr->sun_path);
break;
default:
warn("error sending datagram: %s\n", strerror(errno));
warn("error sending datagram: %s", strerror(errno));
}
ret_value = errno;
}

View File

@ -114,7 +114,7 @@ scan()
/* Get the tree of the children Windows of the current root
* Window */
if(!(wins = xcb_query_tree_children(tree_r)))
eprint("E: cannot get tree children\n");
eprint("E: cannot get tree children");
tree_c_len = xcb_query_tree_children_length(tree_r);
attr_wins = p_new(xcb_get_window_attributes_cookie_t, tree_c_len);
@ -206,7 +206,7 @@ xerrorstart(void * data __attribute__ ((unused)),
xcb_connection_t * c __attribute__ ((unused)),
xcb_generic_error_t * error __attribute__ ((unused)))
{
eprint("another window manager is already running\n");
eprint("another window manager is already running");
}
/** Function to exit on some signals.
@ -244,7 +244,7 @@ xerror(void *data __attribute__ ((unused)),
return 0;
}
warn("fatal error: request=%s, error=%s\n", err->request_label, err->error_label);
warn("fatal error: request=%s, error=%s", err->request_label, err->error_label);
xutil_delete_error(err);
/*
@ -334,7 +334,7 @@ main(int argc, char **argv)
if(a_strlen(optarg))
confpath = a_strdup(optarg);
else
eprint("-c option requires a file name\n");
eprint("-c option requires a file name");
break;
}
@ -344,7 +344,7 @@ main(int argc, char **argv)
/* X stuff */
globalconf.connection = xcb_connect(NULL, &globalconf.default_screen);
if(xcb_connection_has_error(globalconf.connection))
eprint("cannot open display\n");
eprint("cannot open display");
/* Get the file descriptor corresponding to the X connection */
xfd = xcb_get_file_descriptor(globalconf.connection);
@ -466,12 +466,12 @@ main(int argc, char **argv)
if(errno == EADDRINUSE)
{
if(unlink(addr->sun_path))
warn("error unlinking existing file: %s\n", strerror(errno));
warn("error unlinking existing file: %s", strerror(errno));
if(bind(csfd, (const struct sockaddr *) addr, SUN_LEN(addr)))
warn("error binding UNIX domain socket: %s\n", strerror(errno));
warn("error binding UNIX domain socket: %s", strerror(errno));
}
else
warn("error binding UNIX domain socket: %s\n", strerror(errno));
warn("error binding UNIX domain socket: %s", strerror(errno));
}
if(!a_dbus_init(&dbusfd))
@ -502,13 +502,13 @@ main(int argc, char **argv)
{
if(errno == EINTR)
continue;
eprint("select failed\n");
eprint("select failed");
}
if(csfd >= 0 && FD_ISSET(csfd, &rd))
switch(r = recv(csfd, buf, sizeof(buf)-1, MSG_TRUNC))
{
case -1:
warn("error reading UNIX domain socket: %s\n", strerror(errno));
warn("error reading UNIX domain socket: %s", strerror(errno));
csfd = -1;
break;
case 0:
@ -558,9 +558,9 @@ main(int argc, char **argv)
a_dbus_cleanup();
if(csfd > 0 && close(csfd))
warn("error closing UNIX domain socket: %s\n", strerror(errno));
warn("error closing UNIX domain socket: %s", strerror(errno));
if(unlink(addr->sun_path))
warn("error unlinking UNIX domain socket: %s\n", strerror(errno));
warn("error unlinking UNIX domain socket: %s", strerror(errno));
p_delete(&addr);
/* remap all clients since some WM won't handle them otherwise */

View File

@ -70,7 +70,7 @@ draw_iso2utf8(const char *iso)
warn("unable to convert text from %s to UTF-8, not available",
nl_langinfo(CODESET));
else
warn("unable to convert text: %s\n", strerror(errno));
warn("unable to convert text: %s", strerror(errno));
return NULL;
}
@ -80,7 +80,7 @@ draw_iso2utf8(const char *iso)
if(iconv(iso2utf8, (char **) &iso, &len, &utf8, &utf8len) == (size_t) -1)
{
warn("text conversion failed: %s\n", strerror(errno));
warn("text conversion failed: %s", strerror(errno));
p_delete(&utf8p);
}
@ -725,7 +725,7 @@ draw_image(draw_context_t *ctx, int x, int y, int wanted_h, const char *filename
GError *error=NULL;
if(!(pixbuf = gdk_pixbuf_new_from_file(filename,&error)))
return warn("cannot load image %s: %s\n", filename, error->message);
return warn("cannot load image %s: %s", filename, error->message);
w = gdk_pixbuf_get_width(pixbuf);
h = gdk_pixbuf_get_height(pixbuf);
@ -763,7 +763,7 @@ draw_get_image_size(const char *filename)
size.height = height;
}
else
warn("cannot load image %s: %s\n", filename, "format unrecognized");
warn("cannot load image %s: %s", filename, "format unrecognized");
return size;
}
@ -828,7 +828,7 @@ draw_image(draw_context_t *ctx, int x, int y, int wanted_h, const char *filename
Imlib_Load_Error e = IMLIB_LOAD_ERROR_NONE;
if(!(image = imlib_load_image_with_error_return(filename, &e)))
return warn("cannot load image %s: %s\n", filename, draw_imlib_load_strerror(e));
return warn("cannot load image %s: %s", filename, draw_imlib_load_strerror(e));
imlib_context_set_image(image);
h = imlib_image_get_height();
@ -877,7 +877,7 @@ draw_get_image_size(const char *filename)
imlib_free_image();
}
else
warn("cannot load image %s: %s\n", filename, draw_imlib_load_strerror(e));
warn("cannot load image %s: %s", filename, draw_imlib_load_strerror(e));
return size;
}
@ -1029,7 +1029,7 @@ draw_color_new(xcb_connection_t *conn, int phys_screen, const char *colstr, xcol
colnum = strtoul(&colstr[1], NULL, 16);
if(errno != 0)
{
warn("awesome: error, invalid color '%s'\n", colstr);
warn("awesome: error, invalid color '%s'", colstr);
return false;
}
@ -1075,7 +1075,7 @@ draw_color_new(xcb_connection_t *conn, int phys_screen, const char *colstr, xcol
}
}
warn("awesome: error, cannot allocate color '%s'\n", colstr);
warn("awesome: error, cannot allocate color '%s'", colstr);
return false;
}

View File

@ -241,7 +241,7 @@ markup_parse(markup_parser_data_t *data, const char *str, ssize_t slen)
|| !g_markup_parse_context_parse(mkp_ctx, "</markup>", -1, &error)
|| !g_markup_parse_context_end_parse(mkp_ctx, &error))
{
warn("unable to parse text \"%s\": %s\n", str, error ? error->message : "unknown error");
warn("unable to parse text \"%s\": %s", str, error ? error->message : "unknown error");
if(error)
g_error_free(error);
g_markup_parse_context_free(mkp_ctx);

View File

@ -89,7 +89,7 @@ socket_getclient(void)
csfd = socket(AF_UNIX, SOCK_DGRAM, 0);
if(csfd < 0)
warn("error opening UNIX domain socket: %s\n", strerror(errno));
warn("error opening UNIX domain socket: %s", strerror(errno));
return csfd;
}

View File

@ -39,6 +39,7 @@ _eprint(int line, const char *fct, const char *fmt, ...)
fprintf(stderr, "E: awesome: %s:%d: ", fct, line);
vfprintf(stderr, fmt, ap);
va_end(ap);
fprintf(stderr, "\n");
exit(EXIT_FAILURE);
}
@ -52,6 +53,7 @@ _warn(int line, const char *fct, const char *fmt, ...)
fprintf(stderr, "W: awesome: %s:%d: ", fct, line);
vfprintf(stderr, fmt, ap);
va_end(ap);
fprintf(stderr, "\n");
}
/** Compute a value from a string containing

16
dbus.c
View File

@ -64,20 +64,20 @@ a_dbus_process_widget_set(DBusMessage *req)
|| a_strcmp(path[2], "widget")
|| a_strcmp(path[4], "property"))
{
warn("invalid object path.\n");
warn("invalid object path.");
dbus_error_free(&err);
return;
}
if(!dbus_message_iter_init(req, &iter))
{
warn("message has no argument: %s\n", err.message);
warn("message has no argument: %s", err.message);
dbus_error_free(&err);
return;
}
else if(DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&iter))
{
warn("argument must be a string\n");
warn("argument must be a string");
dbus_error_free(&err);
return;
}
@ -85,7 +85,7 @@ a_dbus_process_widget_set(DBusMessage *req)
dbus_message_iter_get_basic(&iter, &arg);
if(!(widget = widget_getbyname(path[3])))
return warn("no such widget: %s.\n", path[3]);
return warn("no such widget: %s.", path[3]);
status = widget->tell(widget, path[5], arg);
widget_tell_managestatus(widget, status, path[5]);
@ -140,7 +140,7 @@ a_dbus_init(int *fd)
dbus_connection = dbus_bus_get(DBUS_BUS_SESSION, &err);
if(dbus_error_is_set(&err))
{
warn("DBus system bus connection failed: %s\n", err.message);
warn("DBus system bus connection failed: %s", err.message);
dbus_connection = NULL;
dbus_error_free(&err);
return false;
@ -152,21 +152,21 @@ a_dbus_init(int *fd)
if(dbus_error_is_set(&err))
{
warn("failed to request DBus name: %s\n", err.message);
warn("failed to request DBus name: %s", err.message);
a_dbus_cleanup();
return false;
}
if(ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
{
warn("not primary DBus name owner\n");
warn("not primary DBus name owner");
a_dbus_cleanup();
return false;
}
if(!dbus_connection_get_unix_fd(dbus_connection, fd))
{
warn("cannot get DBus connection file descriptor\n");
warn("cannot get DBus connection file descriptor");
a_dbus_cleanup();
return false;
}

4
lua.h
View File

@ -34,7 +34,7 @@ typedef int luaA_function;
do { \
if(cmd) \
if(luaL_dostring(L, cmd)) \
warn("error executing Lua code: %s\n", \
warn("error executing Lua code: %s", \
lua_tostring(L, -1)); \
} while(0)
@ -46,7 +46,7 @@ typedef int luaA_function;
if(n) \
lua_insert(L, - (n + 1)); \
if(lua_pcall(L, n, 0, 0)) \
warn("error running function: %s\n", \
warn("error running function: %s", \
lua_tostring(L, -1)); \
} \
} while(0)

View File

@ -96,7 +96,7 @@ widget_common_tell(widget_t *widget,
const char *property __attribute__ ((unused)),
const char *new_value __attribute__ ((unused)))
{
warn("%s widget does not accept commands.\n", widget->name);
warn("%s widget does not accept commands.", widget->name);
return WIDGET_ERROR_CUSTOM;
}
@ -227,23 +227,23 @@ widget_tell_managestatus(widget_t *widget, widget_tell_status_t status, const ch
switch(status)
{
case WIDGET_ERROR:
warn("error changing property %s of widget %s\n",
warn("error changing property %s of widget %s",
property, widget->name);
break;
case WIDGET_ERROR_NOVALUE:
warn("error changing property %s of widget %s, no value given\n",
warn("error changing property %s of widget %s, no value given",
property, widget->name);
break;
case WIDGET_ERROR_FORMAT_FONT:
warn("error changing property %s of widget %s, must be a valid font\n",
warn("error changing property %s of widget %s, must be a valid font",
property, widget->name);
break;
case WIDGET_ERROR_FORMAT_COLOR:
warn("error changing property %s of widget %s, must be a valid color\n",
warn("error changing property %s of widget %s, must be a valid color",
property, widget->name);
break;
case WIDGET_ERROR_FORMAT_SECTION:
warn("error changing property %s of widget %s, section/title not found\n",
warn("error changing property %s of widget %s, section/title not found",
property, widget->name);
break;
case WIDGET_NOERROR:

View File

@ -362,7 +362,7 @@ graph_tell(widget_t *widget, const char *property, const char *new_value)
case Right:
break;
default:
warn("error changing property %s of widget %s, must be 'left' or 'right'\n",
warn("error changing property %s of widget %s, must be 'left' or 'right'",
property, widget->name);
return WIDGET_ERROR_CUSTOM;
}
@ -400,14 +400,14 @@ graph_new(alignment_t align)
/*
if(!(d->data_items = cfg_size(config, "data")))
{
warn("graph widget needs at least one data section\n");
warn("graph widget needs at least one data section");
return w;
}
d->grow = cfg_getposition(config, "grow");
if(d->grow != Left && d->grow != Right)
{
warn("graph widget: 'grow' argument must be 'left' or 'right'\n");
warn("graph widget: 'grow' argument must be 'left' or 'right'");
*/
/*
d->data_items = 0; /* disable widget drawing */

View File

@ -133,14 +133,14 @@ check_settings(Data *d, int status_height)
if((d->ticks_count && tmp - (d->ticks_count - 1) * d->ticks_gap - d->ticks_count + 1 < 0)
|| (!d->ticks_count && tmp < 0))
{
warn("progressbar's 'width' is too small for the given configuration options\n");
warn("progressbar's 'width' is too small for the given configuration options");
return false;
}
tmp = h_total - d->data_items * (2 * (d->border_width + d->border_padding) + 1)
- (d->data_items - 1) * d->gap;
if(tmp < 0)
{
warn("progressbar's 'height' is too small for the given configuration options\n");
warn("progressbar's 'height' is too small for the given configuration options");
return false;
}
}
@ -150,14 +150,14 @@ check_settings(Data *d, int status_height)
if((d->ticks_count && tmp - (d->ticks_count - 1) * d->ticks_gap - d->ticks_count + 1 < 0)
|| (!d->ticks_count && tmp < 0))
{
warn("progressbar's 'height' is too small for the given configuration options\n");
warn("progressbar's 'height' is too small for the given configuration options");
return false;
}
tmp = d->width - d->data_items * (2 * (d->border_width + d->border_padding) + 1)
- (d->data_items - 1) * d->gap;
if(tmp < 0)
{
warn("progressbar's 'width' is too small for the given configuration options\n");
warn("progressbar's 'width' is too small for the given configuration options");
return false;
}
}
@ -509,7 +509,7 @@ progressbar_new(alignment_t align)
/*
if(!(d->data_items = cfg_size(config, "data")))
{
warn("progressbar widget needs at least one bar section\n");
warn("progressbar widget needs at least one bar section");
return w;
}