From 31a200df9b84a1a6e778e67632b7b4c509f2270c Mon Sep 17 00:00:00 2001 From: Simon Wood Date: Wed, 22 Mar 2017 20:01:13 -0600 Subject: [PATCH] EDID-Decode: Allow spaces in 'Monitor Name' Allow spaces in 'Monitor Name' detiled block, whilst still checking for correct padding. Trailing spaces before C/R will be flagged as invalid. --- edid-decode.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/edid-decode.c b/edid-decode.c index c18697f..61da646 100644 --- a/edid-decode.c +++ b/edid-decode.c @@ -209,15 +209,21 @@ static char * extract_string(unsigned char *x, int *valid_termination, int len) { static char ret[128]; - int i, seen_newline = 0; + int i, seen_newline = 0, seen_space = 0; memset(ret, 0, sizeof(ret)); for (i = 0; i < len; i++) { - if (isgraph(x[i])) { - ret[i] = x[i]; - } else if (!seen_newline) { - if (x[i] == 0x0a) { + if (!seen_newline) { + if (isgraph(x[i])) { + while (seen_space) { + ret[i-seen_space] = 0x20; + seen_space--; + } + ret[i] = x[i]; + } else if (x[i] == 0x20) { + seen_space++; + } else if (x[i] == 0x0a) { seen_newline = 1; } else { *valid_termination = 0; @@ -231,6 +237,9 @@ extract_string(unsigned char *x, int *valid_termination, int len) } } + if (seen_space) + *valid_termination = 0; + return ret; } -- 2.7.4