diff options
author | michael <michael@3ae390bd-cb1e-0410-b409-cd5a39f66f1f> | 2012-04-09 04:45:07 +0000 |
---|---|---|
committer | michael <michael@3ae390bd-cb1e-0410-b409-cd5a39f66f1f> | 2012-04-09 04:45:07 +0000 |
commit | 2c23bdcb1d476a4f2bfb320cdea9df56ae42f9ff (patch) | |
tree | a970fb64619d3af707fd07aef0bce61b9f8774de | |
parent | 13c974ad615ac560569f20b361e82bae98ac77fc (diff) | |
download | lcd4linux-2c23bdcb1d476a4f2bfb320cdea9df56ae42f9ff.tar.gz |
patch to support hex sequences from Marcus Menzel
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@1186 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
Diffstat (limited to '')
-rw-r--r-- | evaluator.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/evaluator.c b/evaluator.c index 343eb7b..e9c8037 100644 --- a/evaluator.c +++ b/evaluator.c @@ -631,6 +631,44 @@ static void Parse(void) Word[length++] = '\r'; ExprPtr += 2; break; + case 'x': + { + int i; + char hexC; + int hex[2]; + + for (i = 0; i < 2; i++) { + hexC = *(ExprPtr + 2 + i); + if (hexC >= '0' && hexC <= '9') + hex[i] = hexC - '0'; + else if (hexC >= 'a' && hexC <= 'f') + hex[i] = hexC - 'a' + 10; + else if (hexC >= 'A' && hexC <= 'F') + hex[i] = hexC - 'A' + 10; + else + break; + } + switch (i) { + case 1: + Word[length] = hex[0]; + ExprPtr += 3; + break; + case 2: + Word[length] = hex[0] * 16 + hex[1]; + ExprPtr += 4; + break; + default: + error("Evaluator: Illegal hex sequence '\\x%c' in <%s> keeps unchanged.", + *(ExprPtr + 2), Expression); + Word[length] = '\\'; + ExprPtr += 1; + } + if (Word[length] == 0) + error("Evaluator: Null character(s) in <%s> will be ignored.", Expression); + else + length++; + } + break; case '0': case '1': case '2': |