mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 20:38:08 +01:00
Remove dependency to CPP: removed stuff related to CPP calls
Now that the built-in parser has support for all the feature of CPP being used by WindowMaker's default menu, we can remove the stuff related to calling CPP: - code for preparing and running CPP; - compile-time option to de-activate the call to CPP; - command-line option
This commit is contained in:
committed by
Carlos R. Mafra
parent
4658f4f9a1
commit
139f912e61
118
src/misc.c
118
src/misc.c
@@ -50,124 +50,6 @@
|
||||
/**** global variables *****/
|
||||
extern WPreferences wPreferences;
|
||||
|
||||
#ifdef USECPP
|
||||
static void putdef(char *line, char *name, char *value)
|
||||
{
|
||||
if (!value) {
|
||||
wwarning(_("could not define value for %s for cpp"), name);
|
||||
return;
|
||||
}
|
||||
strcat(line, name);
|
||||
strcat(line, value);
|
||||
}
|
||||
|
||||
static void putidef(char *line, char *name, int value)
|
||||
{
|
||||
char tmp[64];
|
||||
snprintf(tmp, sizeof(tmp), "%i", value);
|
||||
strcat(line, name);
|
||||
strcat(line, tmp);
|
||||
}
|
||||
|
||||
static char *username(void)
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
tmp = getlogin();
|
||||
if (!tmp) {
|
||||
struct passwd *user;
|
||||
|
||||
user = getpwuid(getuid());
|
||||
if (!user) {
|
||||
werror(_("could not get password entry for UID %i"), getuid());
|
||||
return NULL;
|
||||
}
|
||||
if (!user->pw_name) {
|
||||
return NULL;
|
||||
} else {
|
||||
return user->pw_name;
|
||||
}
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
char *MakeCPPArgs(char *path)
|
||||
{
|
||||
char buffer[MAXLINE], *buf, *line;
|
||||
Visual *visual;
|
||||
char *tmp;
|
||||
|
||||
line = wmalloc(MAXLINE);
|
||||
*line = 0;
|
||||
if ((buf = getenv("HOSTNAME")) != NULL) {
|
||||
if (buf[0] == '(') {
|
||||
wwarning(_("your machine is misconfigured. HOSTNAME is set to %s"), buf);
|
||||
} else
|
||||
putdef(line, " -DHOST=", buf);
|
||||
} else if ((buf = getenv("HOST")) != NULL) {
|
||||
if (buf[0] == '(') {
|
||||
wwarning(_("your machine is misconfigured. HOST is set to %s"), buf);
|
||||
} else
|
||||
putdef(line, " -DHOST=", buf);
|
||||
}
|
||||
buf = username();
|
||||
if (buf)
|
||||
putdef(line, " -DUSER=", buf);
|
||||
putidef(line, " -DUID=", getuid());
|
||||
buf = XDisplayName(DisplayString(dpy));
|
||||
putdef(line, " -DDISPLAY=", buf);
|
||||
putdef(line, " -DWM_VERSION=", VERSION);
|
||||
|
||||
visual = DefaultVisual(dpy, DefaultScreen(dpy));
|
||||
putidef(line, " -DVISUAL=", visual->class);
|
||||
|
||||
putidef(line, " -DDEPTH=", DefaultDepth(dpy, DefaultScreen(dpy)));
|
||||
|
||||
putidef(line, " -DSCR_WIDTH=", WidthOfScreen(DefaultScreenOfDisplay(dpy)));
|
||||
putidef(line, " -DSCR_HEIGHT=", HeightOfScreen(DefaultScreenOfDisplay(dpy)));
|
||||
|
||||
/* put the dir where the menu is being read from to the
|
||||
* search path */
|
||||
if (path) {
|
||||
tmp = wstrdup(path);
|
||||
buf = strchr(tmp + 1, ' ');
|
||||
if (buf) {
|
||||
*buf = 0;
|
||||
}
|
||||
buf = strrchr(tmp, '/');
|
||||
if (buf) {
|
||||
*buf = 0; /* trunc filename */
|
||||
putdef(line, " -I", tmp);
|
||||
}
|
||||
wfree(tmp);
|
||||
}
|
||||
|
||||
/* this should be done just once, but it works this way */
|
||||
strcpy(buffer, DEF_CONFIG_PATHS);
|
||||
buf = strtok(buffer, ":");
|
||||
|
||||
do {
|
||||
char fullpath[MAXLINE];
|
||||
|
||||
if (buf[0] != '~') {
|
||||
strcpy(fullpath, buf);
|
||||
} else {
|
||||
/* home is statically allocated. Don't free it! */
|
||||
char *home = wgethomedir();
|
||||
|
||||
strcpy(fullpath, home);
|
||||
strcat(fullpath, &(buf[1]));
|
||||
}
|
||||
|
||||
putdef(line, " -I", fullpath);
|
||||
|
||||
} while ((buf = strtok(NULL, ":")) != NULL);
|
||||
|
||||
#undef arg
|
||||
return line;
|
||||
}
|
||||
#endif /* USECPP */
|
||||
|
||||
/* XFetchName Wrapper */
|
||||
Bool wFetchName(Display *dpy, Window win, char **winname)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user