From a35f585f595b0d8859dc70a20d42bb05b5ca634d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Mon, 23 Dec 2013 15:48:51 +0100 Subject: [PATCH] Tools.Standalone.precompile: Support the string(Xbit) syntax. --- .../Tools.pmod/Standalone.pmod/precompile.pike | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike b/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike index 29ab45ab9d..066d6e03b7 100644 --- a/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike +++ b/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike @@ -1089,8 +1089,20 @@ class PikeType tmp=q[1..sizeof(q)-2]/({".."}); /* Workaround for buggy Parser.Pike */ if(sizeof(tmp)==1) tmp=q[1..sizeof(q)-2]/({".. "}); - if(sizeof(tmp[0])) low=tmp[0]->cast("string")*""; - if(sizeof(tmp[1])) high=tmp[1]->cast("string")*""; + if (sizeof(tmp) == 1) { + int bits; + /* Support the string(Xbit) syntax too. */ + if ((sizeof(q) == 4) && (q[2]->cast("string") == "bit") && + ((bits = (int)q[1]->cast("string")) > 0)) { + low = "0"; + high = sprintf("%d", (1 << bits) - 1); + } else { + error("Syntax error in string subtype.\n"); + } + } else { + if(sizeof(tmp[0])) low=tmp[0]->cast("string")*""; + if(sizeof(tmp[1])) high=tmp[1]->cast("string")*""; + } } args=({PikeType(PC.Token(low)),PikeType(PC.Token(high))}); break; -- GitLab