summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--bin/gfxx.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/bin/gfxx.c b/bin/gfxx.c
index 26f9f675..2b2f803c 100644
--- a/bin/gfxx.c
+++ b/bin/gfxx.c
@@ -152,9 +152,10 @@ static uint8_t get(size_t i) {
 
 static /**/ int init(int argc, char *argv[]) {
     const char *path = NULL;
+    const char *palPath = NULL;
 
     int opt;
-    while (0 < (opt = getopt(argc, argv, "c:b:ern:mw:z:"))) {
+    while (0 < (opt = getopt(argc, argv, "c:p:b:ern:mw:z:"))) {
         switch (opt) {
             case 'c': switch (optarg[0]) {
                 case 'g': space = COLOR_GRAYSCALE; break;
@@ -162,6 +163,7 @@ static /**/ int init(int argc, char *argv[]) {
                 case 'r': space = COLOR_RGB; break;
                 default: return EX_USAGE;
             } break;
+            case 'p': palPath  = optarg; break;
             case 'b': bits     = strtoul(optarg, NULL, 0); break;
             case 'e': endian  ^= true; break;
             case 'r': reverse ^= true; break;
@@ -175,6 +177,16 @@ static /**/ int init(int argc, char *argv[]) {
     if (argc > optind) path = argv[optind];
     if (!bits || !width || !scale) return EX_USAGE;
 
+    if (palPath) {
+        FILE *pal = fopen(palPath, "r");
+        if (!pal) err(EX_NOINPUT, "%s", palPath);
+
+        fread(palette, 1, sizeof(palette), pal);
+        if (ferror(pal)) err(EX_IOERR, "%s", palPath);
+
+        fclose(pal);
+    }
+
     FILE *file = path ? fopen(path, "r") : stdin;
     if (!file) err(EX_NOINPUT, "%s", path);
 
@@ -191,6 +203,8 @@ static /**/ int init(int argc, char *argv[]) {
     size = fread(data, 1, size, file);
     if (ferror(file)) err(EX_IOERR, "%s", path);
 
+    fclose(file);
+
     return EX_OK;
 }
 
@@ -345,7 +359,7 @@ static /**/ void input(char in) {
         break; case '[': if (!space--) space = COLOR__MAX - 1;
         break; case ']': if (++space == COLOR__MAX) space = 0;
         break; case '{': if (bits > 16) bits -= 8; else bits = (bits + 1) / 2;
-        break; case '}': if (bits < 16) bits *= 2; else bits += 8;
+        break; case '}': if (bits < 16) bits *= 2; else if (bits < 32) bits += 8;
         break; case 'e': endian ^= true;
         break; case 'r': reverse ^= true;
         break; case 'h': if (offset) offset--;
/t0001-validate-git-versions.sh?h=1.4.1&id=8d07ad3388429b6c1361074cbac5dec6afee79d7&follow=1'>t0001: validate Git -rcN version numbers correctlyJohn Keeping 2013-04-27git: update to 1.8.2.2John Keeping 2013-04-17scan-tree: fix regression in section-from-path=-1John Keeping 2013-04-15t0001: ignore ".dirty" suffix on Git versionJohn Keeping 2013-04-15tests: set TEST_OUTPUT_DIRECTORY to the CGit test directoryJohn Keeping 2013-04-15t0109: test more URLsJohn Keeping 2013-04-10cgitrc.5.txt: Specify when scan-path must be defined before.Jason A. Donenfeld 2013-04-10ui-snapshot.c: Prepend "V" when guessing ref namesLukas Fleischer 2013-04-10t0107: Skip ZIP tests if unzip(1) isn't availableLukas Fleischer 2013-04-10tests/: Do not use `sed -i`Lukas Fleischer 2013-04-10Add branch-sort and repo.branch-sort options.Jason A. Donenfeld 2013-04-10t0109: chain operations with &&John Keeping 2013-04-10cgit.c: Do not restore unset environment variablesLukas Fleischer 2013-04-09t0107: Use `tar -z` for gzip'ed archivesLukas Fleischer