aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile13
-rw-r--r--TODO2
-rwxr-xr-xcheck/find-errors4
-rw-r--r--check/find-errors.c180
5 files changed, 191 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
index cd82362..a8be5c7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@
*.su
/generated.mk
/check-icon-listing
+/find-errors
diff --git a/Makefile b/Makefile
index 065143f..3bf20e2 100644
--- a/Makefile
+++ b/Makefile
@@ -8,8 +8,8 @@ include $(CONFIGFILE)
all:
-generated.mk: $(CONFIGFILE) icons.mk Makefile check-icon-listing
- $(DEVCHECK) check/find-errors
+generated.mk: $(CONFIGFILE) icons.mk Makefile find-errors check-icon-listing
+ $(DEVCHECK) ./find-errors
$(DEVCHECK) check/find-unlisted-icons
$(DEVCHECK) check/find-duplicates
$(DEVCHECK) ./check-icon-listing
@@ -28,11 +28,14 @@ generated.mk: $(CONFIGFILE) icons.mk Makefile check-icon-listing
printf '\n' >> $@
@chmod -- a-w $@
+find-errors: check/find-errors.c
+ $(CC) -o $@ $< $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
+
check-icon-listing: check/check-icon-listing.c
$(CC) -o $@ $< $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
-check: check-icon-listing
- $(UNIMPORTANT_CHECK) check/find-errors
+check: find-errors check-icon-listing
+ $(UNIMPORTANT_CHECK) ./find-errors
$(UNIMPORTANT_CHECK) check/find-unlisted-icons
$(UNIMPORTANT_CHECK) check/find-duplicates
$(UNIMPORTANT_CHECK) ./check-icon-listing
@@ -40,7 +43,7 @@ check: check-icon-listing
clean:
-rm -rf -- index.theme *.o *.su conv generated.mk scalable-"$(DIR_SUFFIX_)"
- -rm -f -- check-icon-listing
+ -rm -f -- find-errors check-icon-listing
-for s in $(SIZES); do printf "$${s}x$${s}$(DIR_SUFFIX)\n"; done | xargs rm -rf --
-+cd apps && $(MAKE) clean
diff --git a/TODO b/TODO
index 07db943..aa1f1fb 100644
--- a/TODO
+++ b/TODO
@@ -77,6 +77,8 @@ Make it easier to switch between LTR and RTL as the default direction
DEVCHECK shall validate that emblems are not outside emblems/
DEVCHECK shall validate links outside emblems/ are not emblems
+#000000 is not actually stored in the .svg files for the emblems, maybe use #000001 to make sure it shows up, and can be modified
+
add .icon files for user-selectable emblems, these should contain
[Icon Data]
DisplayName=«Name»
diff --git a/check/find-errors b/check/find-errors
deleted file mode 100755
index c557a4b..0000000
--- a/check/find-errors
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-! grep -ro '#[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' scalable/ \
-| tr 'A-F' 'a-f' \
-| grep -v '#\(bebebe\|ef2929\|f57900\|32a679\|cd656c\|d69553\|ccad47\|32a679\|00a09f\|2495be\|a46eb0\|32a678\)'
diff --git a/check/find-errors.c b/check/find-errors.c
new file mode 100644
index 0000000..021f041
--- /dev/null
+++ b/check/find-errors.c
@@ -0,0 +1,180 @@
+#include <sys/stat.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+static int exitstatus = 0;
+static char *path = NULL;
+static size_t pathsize = 0;
+static size_t pathlen = 0;
+static char *buf = NULL;
+static size_t bufsize = 0;
+
+
+static void
+pushname(const char *name, size_t *old_len_out)
+{
+ size_t len = pathlen + strlen(name) + 1;
+
+ if (pathsize < len + 1) {
+ pathsize = len + 1;
+ path = realloc(path, pathsize);
+ if (!path) {
+ perror("find-errors");
+ exit(1);
+ }
+ }
+
+ *old_len_out = pathlen;
+ pathlen = (size_t)(stpcpy(pathlen ? stpcpy(&path[pathlen], "/") : path, name) - path);
+
+}
+
+
+static void
+popname(size_t old_len)
+{
+ pathlen = old_len;
+ path[pathlen] = '\0';
+}
+
+
+static void
+checkfile(const char *name)
+{
+ size_t old;
+ int fd;
+ size_t len = 0;
+ ssize_t r;
+ size_t off;
+ size_t i;
+
+ pushname(name, &old);
+
+ fd = open(path, O_RDONLY);
+ if (fd < 0) {
+ fprintf(stderr, "find-errors: open %s O_RDONLY: %s\n", path, strerror(errno));
+ exit(1);
+ }
+ for (;;) {
+ if (len == bufsize) {
+ bufsize += 1024;
+ buf = realloc(buf, bufsize);
+ if (!buf) {
+ perror("find-errors");
+ exit(1);
+ }
+ }
+ r = read(fd, &buf[len], bufsize - len);
+ if (r <= 0) {
+ if (!r)
+ break;
+ fprintf(stderr, "find-errors: read %s: %s\n", path, strerror(errno));
+ exit(1);
+ }
+ len += (size_t)r;
+ }
+ close(fd);
+
+ if (len < 7)
+ goto out;
+
+ for (off = 0; off < len - 6; off++) {
+ if (buf[off] != '#')
+ continue;
+ for (i = 1; i <= 6; i++) {
+ if ('A' <= buf[off + i] && buf[off + i] <= 'F')
+ buf[off + i] ^= 'A' ^ 'a';
+ else if (!(('a' <= buf[off + i] && buf[off + i] <= 'f') ||
+ ('0' <= buf[off + i] && buf[off + i] <= '9')))
+ goto next;
+ }
+ if (!strncmp(&buf[off + 1], "bebebe", 6) ||
+ !strncmp(&buf[off + 1], "ef2929", 6) ||
+ !strncmp(&buf[off + 1], "f57900", 6) ||
+ !strncmp(&buf[off + 1], "32a678", 6) ||
+ !strncmp(&buf[off + 1], "cd656c", 6) ||
+ !strncmp(&buf[off + 1], "d69553", 6) ||
+ !strncmp(&buf[off + 1], "ccad47", 6) ||
+ !strncmp(&buf[off + 1], "32a679", 6) ||
+ !strncmp(&buf[off + 1], "00a09f", 6) ||
+ !strncmp(&buf[off + 1], "2495be", 6) ||
+ !strncmp(&buf[off + 1], "a46eb0", 6) ||
+ !strncmp(&buf[off + 1], "000000", 6))
+ continue;
+ fprintf(stderr, "%s uses colour not defined in theme: %.7s\n", path, &buf[off]);
+ exitstatus = 1;
+ next:;
+ }
+
+out:
+ popname(old);
+}
+
+
+static void
+checkdir(const char *name)
+{
+ size_t old;
+ DIR *dir;
+ static size_t old2;
+ static struct dirent *f;
+ static struct stat st;
+
+ pushname(name, &old);
+
+ dir = opendir(path);
+ if (!dir) {
+ fprintf(stderr, "find-errors: opendir %s: %s\n", path, strerror(errno));
+ exit(1);
+ }
+
+ errno = 0;
+ while ((f = readdir(dir))) {
+ if (f->d_name[0] == '.')
+ continue;
+ if (f->d_type == DT_DIR) {
+ goto dir;
+ } else if (f->d_type == DT_REG) {
+ goto reg;
+ } else if (f->d_type == DT_UNKNOWN) {
+ pushname(f->d_name, &old2);
+ if (lstat(path, &st)) {
+ fprintf(stderr, "find-errors: lstat %s: %s\n", path, strerror(errno));
+ exit(1);
+ }
+ popname(old2);
+ if (S_ISDIR(st.st_mode)) {
+ dir:
+ checkdir(f->d_name);
+ } else if (S_ISREG(st.st_mode)) {
+ reg:
+ if (strlen(f->d_name) > 4 && !memcmp(&f->d_name[strlen(f->d_name) - 4], ".svg", 4))
+ checkfile(f->d_name);
+ }
+ }
+ }
+
+ if (errno) {
+ fprintf(stderr, "find-errors: readdir %s: %s\n", path, strerror(errno));
+ exit(1);
+ }
+
+ closedir(dir);
+ popname(old);
+}
+
+
+int
+main(void)
+{
+ checkdir("scalable");
+ free(path);
+ free(buf);
+ return exitstatus;
+}