summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/add_window.c13
-rw-r--r--src/cursor.c13
-rw-r--r--src/iconmgr.c13
-rw-r--r--src/menus.c36
-rw-r--r--src/parse.c27
-rw-r--r--src/util.c55
6 files changed, 70 insertions, 87 deletions
diff --git a/src/add_window.c b/src/add_window.c
index e6bde43..b4189e1 100644
--- a/src/add_window.c
+++ b/src/add_window.c
@@ -170,9 +170,7 @@ AddWindow(Window w, int iconm, IconMgr *iconp)
/* allocate space for the twm window */
tmp_win = calloc(1, sizeof(TwmWindow));
if (tmp_win == NULL) {
- fprintf(stderr,
- "%s: Unable to allocate memory to manage window ID %lx.\n",
- ProgramName, w);
+ twmWarning("Unable to allocate memory to manage window ID %lx.", w);
return NULL;
}
tmp_win->w = w;
@@ -1304,8 +1302,7 @@ CreateWindowTitlebarButtons(TwmWindow *tmp_win)
if (nb > 0) {
tmp_win->titlebuttons = malloc((size_t) nb * sizeof(TBWindow));
if (!tmp_win->titlebuttons) {
- fprintf(stderr, "%s: unable to allocate %d titlebuttons\n",
- ProgramName, nb);
+ twmWarning("unable to allocate %d titlebuttons", nb);
}
else {
TBWindow *tbw;
@@ -1497,9 +1494,9 @@ FetchWmColormapWindows(TwmWindow *tmp)
malloc(sizeof(Window) * (size_t) (number_cmap_windows + 1));
if (!new_cmap_windows) {
- fprintf(stderr,
- "%s: unable to allocate %d element colormap window array\n",
- ProgramName, number_cmap_windows + 1);
+ twmWarning
+ ("unable to allocate %d element colormap window array",
+ number_cmap_windows + 1);
goto done;
}
new_cmap_windows[0] = tmp->w; /* add to front */
diff --git a/src/cursor.c b/src/cursor.c
index 98a1256..84d3f0c 100644
--- a/src/cursor.c
+++ b/src/cursor.c
@@ -133,15 +133,13 @@ NewFontCursor(Cursor *cp, const char *str)
i++) {
if (strcmp(str, cursor_names[i].name) == 0) {
if (cursor_names[i].cursor == None)
- cursor_names[i].cursor = XCreateFontCursor(dpy,
- cursor_names[i].
- shape);
+ cursor_names[i].cursor =
+ XCreateFontCursor(dpy, cursor_names[i].shape);
*cp = cursor_names[i].cursor;
return;
}
}
- fprintf(stderr, "%s: unable to find font cursor \"%s\"\n",
- ProgramName, str);
+ twmWarning("unable to find font cursor \"%s\"", str);
}
void
@@ -164,9 +162,8 @@ NewBitmapCursor(Cursor *cp, char *source, char *mask)
XGetGeometry(dpy, spm, &JunkRoot, &sx, &sy, &sw, &sh, &JunkBW, &JunkDepth);
XGetGeometry(dpy, mpm, &JunkRoot, &mx, &my, &mw, &mh, &JunkBW, &JunkDepth);
if (sw != mw || sh != mh) {
- fprintf(stderr,
- "%s: cursor bitmaps \"%s\" and \"%s\" not the same size\n",
- ProgramName, source, mask);
+ twmWarning("cursor bitmaps \"%s\" and \"%s\" not the same size\n",
+ source, mask);
return;
}
*cp = XCreatePixmapCursor(dpy, spm, mpm, &Scr->PointerForeground,
diff --git a/src/iconmgr.c b/src/iconmgr.c
index dcf0881..48a2931 100644
--- a/src/iconmgr.c
+++ b/src/iconmgr.c
@@ -249,9 +249,8 @@ MoveIconManager(int dir)
}
if (!got_it) {
- fprintf(stderr,
- "%s: unable to find window (%d, %d) in icon manager\n",
- ProgramName, new_row, new_col);
+ twmWarning("unable to find window (%d, %d) in icon manager",
+ new_row, new_col);
return;
}
@@ -461,8 +460,8 @@ InsertInIconManager(IconMgr *ip, WList *tmp, TwmWindow *tmp_win)
{
WList *tmp1;
int added;
- int (*compar)(const char *, const char *)
- =(Scr->CaseSensitive ? strcmp : XmuCompareISOLatin1);
+ int (*compar) (const char *, const char *)
+ = (Scr->CaseSensitive ? strcmp : XmuCompareISOLatin1);
added = FALSE;
if (ip->first == NULL) {
@@ -594,8 +593,8 @@ SortIconManager(IconMgr *ip)
{
WList *tmp1, *tmp2;
int done;
- int (*compar)(const char *, const char *)
- =(Scr->CaseSensitive ? strcmp : XmuCompareISOLatin1);
+ int (*compar) (const char *, const char *)
+ = (Scr->CaseSensitive ? strcmp : XmuCompareISOLatin1);
if (ip == NULL)
ip = Active->iconmgr;
diff --git a/src/menus.c b/src/menus.c
index a0e5c0f..5ffaa3f 100644
--- a/src/menus.c
+++ b/src/menus.c
@@ -216,9 +216,8 @@ CreateTitleButton(const char *name, int func, const char *action,
TitleButton *tb = malloc(sizeof(TitleButton));
if (!tb) {
- fprintf(stderr,
- "%s: unable to allocate %lu bytes for title button\n",
- ProgramName, (unsigned long) sizeof(TitleButton));
+ twmWarning("unable to allocate %lu bytes for title button",
+ (unsigned long) sizeof(TitleButton));
return 0;
}
@@ -307,11 +306,11 @@ InitTitlebarButtons(void)
/* insert extra buttons */
if (!CreateTitleButton(TBPM_ICONIFY, F_ICONIFY, "", (MenuRoot *) NULL,
False, False)) {
- fprintf(stderr, "%s: unable to add iconify button\n", ProgramName);
+ twmWarning("unable to add iconify button");
}
if (!CreateTitleButton(TBPM_RESIZE, F_RESIZE, "", (MenuRoot *) NULL,
True, True)) {
- fprintf(stderr, "%s: unable to add resize button\n", ProgramName);
+ twmWarning("unable to add resize button");
}
AddDefaultBindings();
}
@@ -326,9 +325,7 @@ InitTitlebarButtons(void)
if (!tb->bitmap) {
tb->bitmap = FindBitmap(TBPM_QUESTION, &tb->width, &tb->height);
if (!tb->bitmap) { /* cannot happen (see util.c) */
- fprintf(stderr,
- "%s: unable to add titlebar button \"%s\"\n",
- ProgramName, tb->name);
+ twmWarning("unable to add titlebar button \"%s\"", tb->name);
}
}
@@ -923,7 +920,7 @@ PopUpMenu(MenuRoot *menu, int x, int y, Bool center)
{
TwmWindow **WindowNames;
TwmWindow *tmp_win2, *tmp_win3;
- int (*compar)(const char *, const char *) =
+ int (*compar) (const char *, const char *) =
(Scr->CaseSensitive ? strcmp : XmuCompareISOLatin1);
if (!menu)
@@ -1294,7 +1291,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win,
if (smcConn)
SmcCloseConnection(smcConn, 0, NULL);
execvp(*Argv, Argv);
- fprintf(stderr, "%s: unable to restart: %s\n", ProgramName, *Argv);
+ twmWarning("unable to restart: %s", *Argv);
break;
}
@@ -1782,8 +1779,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win,
MenuItem *mitem;
if ((mroot = FindMenuRoot(action)) == NULL) {
- fprintf(stderr, "%s: couldn't find function \"%s\"\n",
- ProgramName, action);
+ twmWarning("couldn't find function \"%s\"", action);
return TRUE;
}
@@ -1952,9 +1948,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win,
close(fd);
}
else {
- fprintf(stderr,
- "%s: unable to open cut file \"%s\"\n",
- ProgramName, tmp);
+ twmWarning("unable to open cut file \"%s\"", tmp);
}
free(ptr);
}
@@ -1964,7 +1958,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win,
}
}
else {
- fprintf(stderr, "%s: cut buffer is empty\n", ProgramName);
+ twmWarning("cut buffer is empty");
}
break;
@@ -2143,13 +2137,12 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win,
close(fd);
}
else {
- fprintf(stderr, "%s: unable to open file \"%s\"\n",
- ProgramName, ptr);
+ twmWarning("unable to open file \"%s\"", ptr);
}
free(ptr);
}
else {
- fprintf(stderr, "%s: error expanding filename\n", ProgramName);
+ twmWarning("error expanding filename");
}
break;
@@ -2205,7 +2198,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win,
break;
case F_STARTWM:
execlp("/bin/sh", "sh", "-c", action, (void *) NULL);
- fprintf(stderr, "%s: unable to start: %s\n", ProgramName, *Argv);
+ twmWarning("unable to start: %s", *Argv);
break;
}
@@ -2675,8 +2668,7 @@ WarpToScreen(int n, int inc)
n += inc;
continue;
}
- fprintf(stderr, "%s: unable to warp to unmanaged screen %d\n",
- ProgramName, n);
+ twmWarning("unable to warp to unmanaged screen %d", n);
Bell(XkbBI_MinorError, 0, None);
return;
}
diff --git a/src/parse.c b/src/parse.c
index df6cce3..18ed6b0 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -82,7 +82,7 @@ static unsigned char overflowbuff[20]; /* really only need one */
static int overflowlen;
static unsigned char **stringListSource, *currentString;
-static int doparse(int (*ifunc)(void), const char *srctypename,
+static int doparse(int (*ifunc) (void), const char *srctypename,
const char *srcname);
static int twmFileInput(void);
static int twmStringListInput(void);
@@ -93,14 +93,14 @@ extern int yylineno;
int ConstrainedMoveTime = 400; /* milliseconds, event times */
-int (*twmInputFunc)(void);
+int (*twmInputFunc) (void);
/**
* parse the .twmrc file
* \param filename the filename to parse. NULL indicates $HOME/.twmrc
*/
static int
-doparse(int (*ifunc)(void), const char *srctypename, const char *srcname)
+doparse(int (*ifunc) (void), const char *srctypename, const char *srcname)
{
mods = 0;
ptr = 0;
@@ -146,11 +146,12 @@ doparse(int (*ifunc)(void), const char *srctypename, const char *srcname)
&Scr->PointerForeground, &Scr->PointerBackground);
}
if (ParseError) {
- fprintf(stderr, "%s: errors found in twm %s",
- ProgramName, srctypename);
- if (srcname)
- fprintf(stderr, " \"%s\"", srcname);
- fprintf(stderr, "\n");
+ if (srcname) {
+ twmWarning("errors found in twm %s \"%s\"", srctypename, srcname);
+ }
+ else {
+ twmWarning("errors found in twm %s", srctypename);
+ }
}
return (ParseError ? 0 : 1);
}
@@ -206,9 +207,8 @@ ParseTwmrc(char *filename)
int status;
if (filename && cp != filename) {
- fprintf(stderr,
- "%s: unable to open twmrc file %s, using %s instead\n",
- ProgramName, filename, cp);
+ twmWarning("unable to open twmrc file %s, using %s instead",
+ filename, cp);
}
status = doparse(twmFileInput, "file", cp);
fclose(twmrc);
@@ -216,9 +216,8 @@ ParseTwmrc(char *filename)
}
else {
if (filename) {
- fprintf(stderr,
- "%s: unable to open twmrc file %s, using built-in defaults instead\n",
- ProgramName, filename);
+ twmWarning("unable to open twmrc file %s,"
+ " using built-in defaults instead", filename);
}
return ParseStringList(defTwmrc);
}
diff --git a/src/util.c b/src/util.c
index 7b611d3..e15c31a 100644
--- a/src/util.c
+++ b/src/util.c
@@ -259,11 +259,9 @@ ExpandFilename(const char *name)
newname = malloc((size_t) HomeLen + strlen(name) + 2);
if (!newname) {
- fprintf(stderr,
- "%s: unable to allocate %lu bytes to expand filename %s/%s\n",
- ProgramName,
- (unsigned long) HomeLen + (unsigned long) strlen(name) + 2,
- Home, &name[1]);
+ twmWarning("unable to allocate %lu bytes to expand filename %s/%s",
+ (unsigned long) HomeLen + (unsigned long) strlen(name) + 2,
+ Home, &name[1]);
}
else {
(void) sprintf(newname, "%s/%s", Home, &name[1]);
@@ -331,8 +329,7 @@ FindBitmap(const char *name, unsigned *widthp, unsigned *heightp)
if (XmuCompareISOLatin1(pmtab[i].name, name) == 0)
return (*pmtab[i].proc) (widthp, heightp);
}
- fprintf(stderr, "%s: no such built-in bitmap \"%s\"\n",
- ProgramName, name);
+ twmWarning("no such built-in bitmap \"%s\"", name);
return None;
}
@@ -357,9 +354,8 @@ FindBitmap(const char *name, unsigned *widthp, unsigned *heightp)
*/
bigname = malloc(strlen(name) + strlen(Scr->IconDirectory) + 2);
if (!bigname) {
- fprintf(stderr,
- "%s: unable to allocate memory for \"%s/%s\"\n",
- ProgramName, Scr->IconDirectory, name);
+ twmWarning("unable to allocate memory for \"%s/%s\"",
+ Scr->IconDirectory, name);
return None;
}
(void) sprintf(bigname, "%s/%s", Scr->IconDirectory, name);
@@ -370,8 +366,7 @@ FindBitmap(const char *name, unsigned *widthp, unsigned *heightp)
}
free(bigname);
if (pm == None) {
- fprintf(stderr, "%s: unable to find bitmap \"%s\"\n",
- ProgramName, name);
+ twmWarning("unable to find bitmap \"%s\"", name);
}
return pm;
@@ -398,8 +393,8 @@ InsertRGBColormap(Atom a, XStandardColormap *maps, int nmaps, Bool replace)
if (!sc) { /* no existing, allocate new */
sc = malloc(sizeof(StdCmap));
if (!sc) {
- fprintf(stderr, "%s: unable to allocate %lu bytes for StdCmap\n",
- ProgramName, (unsigned long) sizeof(StdCmap));
+ twmWarning("unable to allocate %lu bytes for StdCmap",
+ (unsigned long) sizeof(StdCmap));
return;
}
replace = False;
@@ -501,8 +496,7 @@ GetColor(int kind, Pixel *what, const char *name)
if (name[0] != '#')
stat = XParseColor(dpy, cmap, name, &color);
if (!stat) {
- fprintf(stderr, "%s: invalid color name \"%s\"\n",
- ProgramName, name);
+ twmWarning("invalid color name \"%s\"", name);
return;
}
@@ -545,8 +539,7 @@ GetColor(int kind, Pixel *what, const char *name)
stdcmap->blue_mult));
}
else {
- fprintf(stderr, "%s: unable to allocate color \"%s\"\n",
- ProgramName, name);
+ twmWarning("unable to allocate color \"%s\"", name);
return;
}
}
@@ -569,7 +562,7 @@ GetColorValue(int kind, XColor *what, const char *name)
return;
if (!XLookupColor(dpy, cmap, name, what, &junkcolor)) {
- fprintf(stderr, "%s: invalid color name \"%s\"\n", ProgramName, name);
+ twmWarning("invalid color name \"%s\"", name);
}
else {
what->pixel = AllPlanes;
@@ -602,9 +595,13 @@ FindFontSet(MyFont *font, const char *fontname)
&def_string_return)) == NULL) {
return False;
}
- for (i = 0; i < missing_charset_count_return; i++) {
- printf("%s: warning: font for charset %s is lacking.\n",
- ProgramName, missing_charset_list_return[i]);
+ if (missing_charset_count_return) {
+ twmVerbose("%d fonts are missing from fontset",
+ missing_charset_count_return);
+ for (i = 0; i < missing_charset_count_return; i++) {
+ twmVerbose("font for charset %s is lacking.",
+ missing_charset_list_return[i]);
+ }
}
font_extents = XExtentsOfFontSet(font->fontset);
@@ -620,6 +617,9 @@ FindFontSet(MyFont *font, const char *fontname)
font->y = ascent;
font->ascent = ascent;
font->descent = descent;
+ twmMessage("created fontset with %d fonts (%d missing) for \"%s\"",
+ fnum, missing_charset_count_return,
+ fontname ? fontname : "NULL");
return True;
}
@@ -661,9 +661,8 @@ GetFont(MyFont *font)
deffontname = Scr->DefaultFont.name;
}
if (!FindFontSet(font, deffontname)) {
- fprintf(stderr, "%s: unable to open %s \"%s\" or \"%s\"\n",
- ProgramName, what, font->name, deffontname);
- exit(1);
+ twmError("unable to open %s \"%s\" or \"%s\"",
+ what, font->name, deffontname);
}
}
}
@@ -780,11 +779,11 @@ SetFocus(TwmWindow *tmp_win, Time time)
#ifdef TRACE
if (tmp_win) {
- printf("Focusing on window \"%s\"\n", tmp_win->full_name);
+ twmMessage("Focusing on window \"%s\"", tmp_win->full_name);
}
else {
- printf("Unfocusing; Scr->Focus was \"%s\"\n",
- Scr->Focus ? Scr->Focus->full_name : "(nil)");
+ twmMessage("Unfocusing; Scr->Focus was \"%s\"",
+ Scr->Focus ? Scr->Focus->full_name : "(nil)");
}
#endif