1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-02-13 20:35:54 +01:00

Remove wsyserrorwithcode, rename wsyserror to werror

wsyserrorwithcode - Not used, no point either.
wsyserror->werror - qualifying "error" with a "type" hardly makes
sense if there are not at least two "type"s. There are not. Safe trip.

Signed-off-by: Tamas TEVESZ <ice@extreme.hu>
This commit is contained in:
Tamas TEVESZ
2010-09-27 16:12:57 +02:00
committed by Carlos R. Mafra
parent c5f5e0b9c0
commit 1f21919809
20 changed files with 92 additions and 108 deletions

View File

@@ -17,7 +17,7 @@ wmessage converted from function to wrapper macro
wwarning converted from function to wrapper macro
wfatal converted from function to wrapper macro
wsyserror converted from function to wrapper macro
wsyserrorwithcode converted from function to wrapper macro
wsyserrorwithcode removed
wmkdirhier ADDED
wrmdirhier ADDED
wmalloc0 REMOVED

View File

@@ -169,19 +169,16 @@ waborthandler* wsetabort(waborthandler* handler);
enum {
WMESSAGE_TYPE_MESSAGE,
WMESSAGE_TYPE_WARNING,
WMESSAGE_TYPE_FATAL,
WMESSAGE_TYPE_WSYSERROR,
WMESSAGE_TYPE_WSYSERRORWITHCODE
WMESSAGE_TYPE_ERROR,
WMESSAGE_TYPE_FATAL
};
#define wmessage(fmt, args...) __wmessage( WMESSAGE_TYPE_MESSAGE, NULL, fmt, ## args)
#define wwarning(fmt, args...) __wmessage( WMESSAGE_TYPE_WARNING, NULL, fmt, ## args)
#define wfatal(fmt, args...) __wmessage( WMESSAGE_TYPE_FATAL, NULL, fmt, ## args)
#define wsyserror(fmt, args...) __wmessage( WMESSAGE_TYPE_WSYSERROR, NULL, fmt, ## args)
#define wsyserrorwithcode(errno, fmt, args...) \
__wmessage( WMESSAGE_TYPE_WSYSERRORWITHCODE, &errno, fmt, ## args)
#define wmessage(fmt, args...) __wmessage( WMESSAGE_TYPE_MESSAGE, fmt, ## args)
#define wwarning(fmt, args...) __wmessage( WMESSAGE_TYPE_WARNING, fmt, ## args)
#define werror(fmt, args...) __wmessage( WMESSAGE_TYPE_ERROR, fmt, ## args)
#define wfatal(fmt, args...) __wmessage( WMESSAGE_TYPE_FATAL, fmt, ## args)
void __wmessage(int type, void *extra, const char *msg, ...) __attribute__((__format__(printf,3,4)));
void __wmessage(int type, const char *msg, ...) __attribute__((__format__(printf,2,3)));
char* wfindfile(char *paths, char *file);

View File

@@ -20,7 +20,6 @@
#include "wconfig.h"
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
@@ -31,7 +30,7 @@
extern char *_WINGS_progname;
void __wmessage(int type, void *extra, const char *msg, ...)
void __wmessage(int type, const char *msg, ...)
{
va_list args;
char *buf;
@@ -56,40 +55,28 @@ void __wmessage(int type, void *extra, const char *msg, ...)
buf = wmalloc(linemax);
fflush(stdout);
/* message format: <wings_progname>: <qualifier>: <message>[: <extra info>]"\n" */
/* message format: <wings_progname>: <qualifier>: <message>"\n" */
snprintf(buf, linemax, "%s: ", _WINGS_progname ? _WINGS_progname : "WINGs");
va_start(args, msg);
switch (type) {
case WMESSAGE_TYPE_WARNING:
snprintf(buf + strlen(buf), linemax - strlen(buf) - 1,
_("warning: "));
vsnprintf(buf + strlen(buf), linemax - strlen(buf) - 1,
msg, args);
break;
case WMESSAGE_TYPE_FATAL:
snprintf(buf + strlen(buf), linemax - strlen(buf) - 1,
_("fatal error: "));
vsnprintf(buf + strlen(buf), linemax - strlen(buf) - 1,
msg, args);
snprintf(buf + strlen(buf), linemax - strlen(buf) - 1, _("fatal error: "));
break;
case WMESSAGE_TYPE_ERROR:
snprintf(buf + strlen(buf), linemax - strlen(buf) - 1, _("error: "));
break;
case WMESSAGE_TYPE_WARNING:
snprintf(buf + strlen(buf), linemax - strlen(buf) - 1, _("warning: "));
break;
case WMESSAGE_TYPE_WSYSERROR:
case WMESSAGE_TYPE_WSYSERRORWITHCODE:
snprintf(buf + strlen(buf), linemax - strlen(buf) - 1,
_("error: "));
vsnprintf(buf + strlen(buf), linemax - strlen(buf) - 1,
msg, args);
snprintf(buf + strlen(buf), linemax - strlen(buf) - 1,
": %s", type == WMESSAGE_TYPE_WSYSERROR ?
strerror(errno) : strerror(*(int *)extra));
break;
case WMESSAGE_TYPE_MESSAGE:
/* FALLTHROUGH */
default:
default: /* should not happen, but doesn't hurt either */
strncat(buf, ": ", linemax - strlen(buf));
vsnprintf(buf + strlen(buf), linemax - strlen(buf) - 1, msg, args);
break;
}
va_start(args, msg);
vsnprintf(buf + strlen(buf), linemax - strlen(buf) - 1, msg, args);
va_end(args);
strncat(buf, "\n", linemax - strlen(buf));

View File

@@ -43,7 +43,7 @@ char *wgethomedir()
user = getpwuid(getuid());
if (!user) {
wsyserror(_("could not get password entry for UID %i"), getuid());
werror(_("could not get password entry for UID %i"), getuid());
return "/";
}
if (!user->pw_dir) {
@@ -59,7 +59,7 @@ static char *getuserhomedir(const char *username)
user = getpwnam(username);
if (!user) {
wsyserror(_("could not get password entry for user %s"), username);
werror(_("could not get password entry for user %s"), username);
return NULL;
}
if (!user->pw_dir) {
@@ -175,7 +175,7 @@ char *wexpandpath(char *path)
error:
errno = ENAMETOOLONG;
wsyserror(_("could not expand %s"), origpath);
werror(_("could not expand %s"), origpath);
/* FIXME: too many functions handle a return value of NULL incorrectly */
exit(1);
}

View File

@@ -1496,14 +1496,14 @@ WMPropList *WMReadPropListFromFile(char *file)
f = fopen(file, "rb");
if (!f) {
/* let the user print the error message if he really needs to */
/*wsyserror(_("could not open domain file '%s' for reading"), file); */
/*werror(_("could not open domain file '%s' for reading"), file); */
return NULL;
}
if (stat(file, &stbuf) == 0) {
length = (size_t) stbuf.st_size;
} else {
wsyserror(_("could not get size for file '%s'"), file);
werror(_("could not get size for file '%s'"), file);
fclose(f);
return NULL;
}
@@ -1516,7 +1516,7 @@ WMPropList *WMReadPropListFromFile(char *file)
if (fread(pldata->ptr, length, 1, f) != 1) {
if (ferror(f)) {
wsyserror(_("error reading from file '%s'"), file);
werror(_("error reading from file '%s'"), file);
}
plist = NULL;
goto cleanup;
@@ -1567,7 +1567,7 @@ Bool WMWritePropListToFile(WMPropList * plist, char *path)
#ifdef HAVE_MKSTEMP
if ((fd = mkstemp(thePath)) < 0) {
wsyserror(_("mkstemp (%s) failed"), thePath);
werror(_("mkstemp (%s) failed"), thePath);
goto failure;
}
mask = umask(0);
@@ -1578,21 +1578,21 @@ Bool WMWritePropListToFile(WMPropList * plist, char *path)
}
#else
if (mktemp(thePath) == NULL) {
wsyserror(_("mktemp (%s) failed"), thePath);
werror(_("mktemp (%s) failed"), thePath);
goto failure;
}
theFile = fopen(thePath, "wb");
#endif
if (theFile == NULL) {
wsyserror(_("open (%s) failed"), thePath);
werror(_("open (%s) failed"), thePath);
goto failure;
}
desc = indentedDescription(plist, 0);
if (fprintf(theFile, "%s\n", desc) != strlen(desc) + 1) {
wsyserror(_("writing to file: %s failed"), thePath);
werror(_("writing to file: %s failed"), thePath);
wfree(desc);
goto failure;
}
@@ -1601,7 +1601,7 @@ Bool WMWritePropListToFile(WMPropList * plist, char *path)
(void)fsync(fileno(theFile));
if (fclose(theFile) != 0) {
wsyserror(_("fclose (%s) failed"), thePath);
werror(_("fclose (%s) failed"), thePath);
goto failure;
}
@@ -1609,7 +1609,7 @@ Bool WMWritePropListToFile(WMPropList * plist, char *path)
* real file. Also, we need to try to retain the file attributes of
* the original file we are overwriting (if we are) */
if (rename(thePath, path) != 0) {
wsyserror(_("rename ('%s' to '%s') failed"), thePath, path);
werror(_("rename ('%s' to '%s') failed"), thePath, path);
goto failure;
}
@@ -1679,7 +1679,7 @@ int wmkdirhier(const char *path)
strncpy(buf, thePath, p);
if (mkdir(buf, 0777) == -1 && errno == EEXIST &&
stat(buf, &st) == 0 && !S_ISDIR(st.st_mode)) {
wsyserror(_("Could not create component %s"), buf);
werror(_("Could not create component %s"), buf);
wfree(thePath);
return 0;
}

View File

@@ -1144,7 +1144,7 @@ static void readConfiguration(W_ColorPanel * panel)
if (stat(panel->configurationPath, &stat_buf) != 0) {
if (mkdir(panel->configurationPath, S_IRWXU | S_IRGRP | S_IROTH | S_IXGRP | S_IXOTH) != 0) {
wsyserror(_("Color Panel: Could not create directory %s needed"
werror(_("Color Panel: Could not create directory %s needed"
" to store configurations"), panel->configurationPath);
WMSetPopUpButtonEnabled(panel->customPaletteMenuBtn, False);
WMSetPopUpButtonEnabled(panel->colorListColorMenuBtn, False);
@@ -2955,7 +2955,7 @@ static void customPaletteMenuNewFromFile(W_ColorPanel * panel)
WMRunAlertPanel(scr, panel->win, _("File Error"),
_("Invalid file format !"), _("OK"), NULL, NULL);
if (i != 0) {
wsyserror(_("can't remove file %s"), tmp);
werror(_("can't remove file %s"), tmp);
WMRunAlertPanel(scr, panel->win, _("File Error"),
_("Couldn't remove file from Configuration Directory !"),
_("OK"), NULL, NULL);
@@ -3031,7 +3031,7 @@ static void customPaletteMenuRename(W_ColorPanel * panel)
}
if (rename(fromPath, toPath) != 0)
wsyserror(_("Couldn't rename palette %s to %s\n"), fromName, toName);
werror(_("Couldn't rename palette %s to %s\n"), fromName, toName);
else {
WMRemovePopUpButtonItem(panel->customPaletteHistoryBtn, item);
WMInsertPopUpButtonItem(panel->customPaletteHistoryBtn, item, toName);
@@ -3078,7 +3078,7 @@ static void customPaletteMenuRemove(W_ColorPanel * panel)
WMRemovePopUpButtonItem(panel->customPaletteHistoryBtn, item);
} else {
wsyserror(_("Couldn't remove palette %s\n"), tmp);
werror(_("Couldn't remove palette %s\n"), tmp);
}
wfree(tmp);
@@ -3347,14 +3347,14 @@ static int fetchFile(char *toPath, char *srcFile, char *destFile)
RETRY( src = fopen(srcFile, "rb") )
if (src == NULL) {
wsyserror(_("Could not open %s"), srcFile);
werror(_("Could not open %s"), srcFile);
return -1;
}
dstpath = wstrconcat(toPath, destFile);
RETRY( dst = fopen(dstpath, "wb") )
if (dst == NULL) {
wsyserror(_("Could not create %s"), dstpath);
werror(_("Could not create %s"), dstpath);
wfree(dstpath);
RETRY( fclose(src) )
return -1;