>From de6c13293d7b5c26434eddc4399079df4c5021a8 Mon Sep 17 00:00:00 2001
From: Tamas TEVESZ <[email protected]>
Date: Thu, 18 Mar 2010 01:25:03 +0100
Subject: [PATCH] Collect low-hanging fruits
---
util/setstyle.c | 139 +++++++++++++++---------------------------------------
util/wmagnify.c | 19 +-------
2 files changed, 40 insertions(+), 118 deletions(-)
diff --git a/util/setstyle.c b/util/setstyle.c
index 6734ca4..cfa2b07 100644
--- a/util/setstyle.c
+++ b/util/setstyle.c
@@ -373,16 +373,9 @@ void print_help()
puts(" --no-cursors ignore cursor related options");
puts(" --ignore <option> ignore changes in the specified option");
puts(" --help display this help and exit");
- /*
- puts(" --format <format> specifies the format of the theme to be
converted");
- */
puts(" --version output version information and exit");
- /*puts("");
- puts("Supported formats: blackbox"); */
}
-#define F_BLACKBOX 1
-
int main(int argc, char **argv)
{
WMPropList *prop, *style;
@@ -422,20 +415,6 @@ int main(int argc, char **argv)
} else if (strcmp("--help", argv[i]) == 0) {
print_help();
exit(0);
-#if 0
- } else if (strcmp("--format", argv[i]) == 0) {
- i++;
- if (i == argc) {
- printf("%s: missing argument for option
--format\n", ProgName);
- exit(1);
- }
- if (strcasecmp(argv[i], "blackbox") == 0) {
- format = F_BLACKBOX;
- } else {
- printf("%s: unknown theme format '%s'\n",
ProgName, argv[i]);
- exit(1);
- }
-#endif
} else {
if (file) {
printf("%s: invalid argument '%s'\n", ProgName,
argv[i]);
@@ -461,63 +440,52 @@ int main(int argc, char **argv)
perror(file);
exit(1);
}
-#if 0
- if (format == F_BLACKBOX) {
- style = readBlackBoxStyle(file);
- if (!style) {
- printf("%s: could not open style file\n", ProgName);
- exit(1);
- }
- } else
-#endif
- {
- if (S_ISDIR(statbuf.st_mode)) {
- char buffer[4018];
- char *prefix;
- /* theme pack */
-
- if (*argv[argc - 1] != '/') {
- if (!getcwd(buffer, 4000)) {
- printf("%s: complete path for %s is too
long\n", ProgName, file);
- exit(1);
- }
- if (strlen(buffer) + strlen(file) > 4000) {
- printf("%s: complete path for %s is too
long\n", ProgName, file);
- exit(1);
- }
- strcat(buffer, "/");
- } else {
- buffer[0] = 0;
- }
- strcat(buffer, file);
+ if (S_ISDIR(statbuf.st_mode)) {
+ char buffer[4018];
+ char *prefix;
+ /* theme pack */
- prefix = malloc(strlen(buffer) + 10);
- if (!prefix) {
- printf("%s: out of memory\n", ProgName);
+ if (*argv[argc - 1] != '/') {
+ if (!getcwd(buffer, 4000)) {
+ printf("%s: complete path for %s is too
long\n", ProgName, file);
exit(1);
}
- strcpy(prefix, buffer);
-
- strcat(buffer, "/style");
-
- style = WMReadPropListFromFile(buffer);
- if (!style) {
- perror(buffer);
- printf("%s:could not load style file.\n",
ProgName);
+ if (strlen(buffer) + strlen(file) > 4000) {
+ printf("%s: complete path for %s is too
long\n", ProgName, file);
exit(1);
}
-
- hackPaths(style, prefix);
- free(prefix);
+ strcat(buffer, "/");
} else {
- /* normal style file */
+ buffer[0] = 0;
+ }
+ strcat(buffer, file);
- style = WMReadPropListFromFile(file);
- if (!style) {
- perror(file);
- printf("%s:could not load style file.\n",
ProgName);
- exit(1);
- }
+ prefix = malloc(strlen(buffer) + 10);
+ if (!prefix) {
+ printf("%s: out of memory\n", ProgName);
+ exit(1);
+ }
+ strcpy(prefix, buffer);
+
+ strcat(buffer, "/style");
+
+ style = WMReadPropListFromFile(buffer);
+ if (!style) {
+ perror(buffer);
+ printf("%s:could not load style file.\n", ProgName);
+ exit(1);
+ }
+
+ hackPaths(style, prefix);
+ free(prefix);
+ } else {
+ /* normal style file */
+
+ style = WMReadPropListFromFile(file);
+ if (!style) {
+ perror(file);
+ printf("%s:could not load style file.\n", ProgName);
+ exit(1);
}
}
@@ -561,32 +529,3 @@ int main(int argc, char **argv)
exit(0);
}
-
-#if 0
-char *getToken(char *str, int i, char *buf)
-{
-
-}
-
-static WMPropList *readBlackBoxStyle(char *path)
-{
- FILE *f;
- char buffer[128], char token[128];
- WMPropList *style, *p;
-
- f = fopen(path, "rb");
- if (!f) {
- perror(path);
- return NULL;
- }
-
- while (1) {
- if (!fgets(buffer, 127, f))
- break;
-
- if (strncasecmp(buffer, "menu.title:", 11) == 0) {
-
- }
- }
-}
-#endif
diff --git a/util/wmagnify.c b/util/wmagnify.c
index ef0094d..fb34888 100644
--- a/util/wmagnify.c
+++ b/util/wmagnify.c
@@ -306,21 +306,6 @@ void closeWindow(WMWidget * w, void *d)
}
}
-#if 0
-static void clickHandler(XEvent * event, void *d)
-{
- BufferData *data = (BufferData *) d;
-
- data->win = WMCreateWindow(scr, "setup");
- WMSetWindowTitle(data->win, "Magnify Options");
-
- data->speed = WMCreateSlider(data->win);
-
- data->magnify = WMCreateSlider(data->win);
-
-}
-#endif
-
static void keyHandler(XEvent * event, void *d)
{
BufferData *data = (BufferData *) d;
@@ -417,9 +402,7 @@ int main(int argc, char **argv)
char *display = "";
char *vdisplay = NULL;
int magfactor = 2;
-#if 0
- WMButton *radio, *tradio;
-#endif
+
WMInitializeApplication("Magnify", &argc, argv);
for (i = 1; i < argc; i++) {
--
1.7.0
--
[-]
mkdir /nonexistentFrom de6c13293d7b5c26434eddc4399079df4c5021a8 Mon Sep 17 00:00:00 2001
From: Tamas TEVESZ <[email protected]>
Date: Thu, 18 Mar 2010 01:25:03 +0100
Subject: [PATCH] Collect low-hanging fruits
---
util/setstyle.c | 139 +++++++++++++++---------------------------------------
util/wmagnify.c | 19 +-------
2 files changed, 40 insertions(+), 118 deletions(-)
diff --git a/util/setstyle.c b/util/setstyle.c
index 6734ca4..cfa2b07 100644
--- a/util/setstyle.c
+++ b/util/setstyle.c
@@ -373,16 +373,9 @@ void print_help()
puts(" --no-cursors ignore cursor related options");
puts(" --ignore <option> ignore changes in the specified option");
puts(" --help display this help and exit");
- /*
- puts(" --format <format> specifies the format of the theme to be converted");
- */
puts(" --version output version information and exit");
- /*puts("");
- puts("Supported formats: blackbox"); */
}
-#define F_BLACKBOX 1
-
int main(int argc, char **argv)
{
WMPropList *prop, *style;
@@ -422,20 +415,6 @@ int main(int argc, char **argv)
} else if (strcmp("--help", argv[i]) == 0) {
print_help();
exit(0);
-#if 0
- } else if (strcmp("--format", argv[i]) == 0) {
- i++;
- if (i == argc) {
- printf("%s: missing argument for option --format\n", ProgName);
- exit(1);
- }
- if (strcasecmp(argv[i], "blackbox") == 0) {
- format = F_BLACKBOX;
- } else {
- printf("%s: unknown theme format '%s'\n", ProgName, argv[i]);
- exit(1);
- }
-#endif
} else {
if (file) {
printf("%s: invalid argument '%s'\n", ProgName, argv[i]);
@@ -461,63 +440,52 @@ int main(int argc, char **argv)
perror(file);
exit(1);
}
-#if 0
- if (format == F_BLACKBOX) {
- style = readBlackBoxStyle(file);
- if (!style) {
- printf("%s: could not open style file\n", ProgName);
- exit(1);
- }
- } else
-#endif
- {
- if (S_ISDIR(statbuf.st_mode)) {
- char buffer[4018];
- char *prefix;
- /* theme pack */
-
- if (*argv[argc - 1] != '/') {
- if (!getcwd(buffer, 4000)) {
- printf("%s: complete path for %s is too long\n", ProgName, file);
- exit(1);
- }
- if (strlen(buffer) + strlen(file) > 4000) {
- printf("%s: complete path for %s is too long\n", ProgName, file);
- exit(1);
- }
- strcat(buffer, "/");
- } else {
- buffer[0] = 0;
- }
- strcat(buffer, file);
+ if (S_ISDIR(statbuf.st_mode)) {
+ char buffer[4018];
+ char *prefix;
+ /* theme pack */
- prefix = malloc(strlen(buffer) + 10);
- if (!prefix) {
- printf("%s: out of memory\n", ProgName);
+ if (*argv[argc - 1] != '/') {
+ if (!getcwd(buffer, 4000)) {
+ printf("%s: complete path for %s is too long\n", ProgName, file);
exit(1);
}
- strcpy(prefix, buffer);
-
- strcat(buffer, "/style");
-
- style = WMReadPropListFromFile(buffer);
- if (!style) {
- perror(buffer);
- printf("%s:could not load style file.\n", ProgName);
+ if (strlen(buffer) + strlen(file) > 4000) {
+ printf("%s: complete path for %s is too long\n", ProgName, file);
exit(1);
}
-
- hackPaths(style, prefix);
- free(prefix);
+ strcat(buffer, "/");
} else {
- /* normal style file */
+ buffer[0] = 0;
+ }
+ strcat(buffer, file);
- style = WMReadPropListFromFile(file);
- if (!style) {
- perror(file);
- printf("%s:could not load style file.\n", ProgName);
- exit(1);
- }
+ prefix = malloc(strlen(buffer) + 10);
+ if (!prefix) {
+ printf("%s: out of memory\n", ProgName);
+ exit(1);
+ }
+ strcpy(prefix, buffer);
+
+ strcat(buffer, "/style");
+
+ style = WMReadPropListFromFile(buffer);
+ if (!style) {
+ perror(buffer);
+ printf("%s:could not load style file.\n", ProgName);
+ exit(1);
+ }
+
+ hackPaths(style, prefix);
+ free(prefix);
+ } else {
+ /* normal style file */
+
+ style = WMReadPropListFromFile(file);
+ if (!style) {
+ perror(file);
+ printf("%s:could not load style file.\n", ProgName);
+ exit(1);
}
}
@@ -561,32 +529,3 @@ int main(int argc, char **argv)
exit(0);
}
-
-#if 0
-char *getToken(char *str, int i, char *buf)
-{
-
-}
-
-static WMPropList *readBlackBoxStyle(char *path)
-{
- FILE *f;
- char buffer[128], char token[128];
- WMPropList *style, *p;
-
- f = fopen(path, "rb");
- if (!f) {
- perror(path);
- return NULL;
- }
-
- while (1) {
- if (!fgets(buffer, 127, f))
- break;
-
- if (strncasecmp(buffer, "menu.title:", 11) == 0) {
-
- }
- }
-}
-#endif
diff --git a/util/wmagnify.c b/util/wmagnify.c
index ef0094d..fb34888 100644
--- a/util/wmagnify.c
+++ b/util/wmagnify.c
@@ -306,21 +306,6 @@ void closeWindow(WMWidget * w, void *d)
}
}
-#if 0
-static void clickHandler(XEvent * event, void *d)
-{
- BufferData *data = (BufferData *) d;
-
- data->win = WMCreateWindow(scr, "setup");
- WMSetWindowTitle(data->win, "Magnify Options");
-
- data->speed = WMCreateSlider(data->win);
-
- data->magnify = WMCreateSlider(data->win);
-
-}
-#endif
-
static void keyHandler(XEvent * event, void *d)
{
BufferData *data = (BufferData *) d;
@@ -417,9 +402,7 @@ int main(int argc, char **argv)
char *display = "";
char *vdisplay = NULL;
int magfactor = 2;
-#if 0
- WMButton *radio, *tradio;
-#endif
+
WMInitializeApplication("Magnify", &argc, argv);
for (i = 1; i < argc; i++) {
--
1.7.0