summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2019-07-17 23:08:28 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2019-07-17 23:08:28 (EDT)
commit4aa7fce693904721d89aa92ed01b89266e3bed1a (patch)
tree896f8d4b052e4bdc7e9be74eb2d6820fd66c468b
parent54e97f3899dd747137f972c80c78196299acb3c5 (diff)
sgr(): Add reset code
-rw-r--r--src/sgr.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/sgr.c b/src/sgr.c
index baec803..9e77f18 100644
--- a/src/sgr.c
+++ b/src/sgr.c
@@ -61,7 +61,15 @@ sgr(char *param, png_colorp fg, png_colorp bg)
end = 1;
}
*param = '\0';
- i = atoi(p);
+ if (*p) {
+ i = atoi(p);
+ } else {
+ i = 0;
+ }
+ if (i == 0) { /* Reset */
+ memcpy(fg, &_4bit[7], sizeof(*fg));
+ memcpy(bg, &_4bit[0], sizeof(*bg));
+ }
if (i >= 30 && i <= 37) { /* Set foreground color */
memcpy(fg, &_4bit[i - 30], sizeof(*fg));
}