This repository was archived by the owner on Aug 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 226
Expand file tree
/
Copy pathhash_strings.rev
More file actions
89 lines (72 loc) · 2.19 KB
/
hash_strings.rev
File metadata and controls
89 lines (72 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
on startup
try
generate $1, $2, $3
catch tError
write tError to stderr
end try
end startup
on generate pSource, pTarget, pPerfect
local tInput
put url ("file:" & pSource) into tInput
-- Normalize input to ensure { appear as individual words
replace "{" with " { " in tInput
-- Normalize input to ensure , appear as individual words
replace "," with " , " in tInput
local tTokens
-- We look for all the lines in lextable.cpp where:
-- word 1 is "{"
-- word 2 is a C-string
--
-- The C-strings are put into tTokens as keys of an array.
--
repeat for each line tLine in tInput
if word 1 of tLine is not "{" then
next repeat
end if
if char 1 of word 2 of tLine is not quote then
next repeat
end if
if char -1 of word 2 of tLine is not quote then
next repeat
end if
if char 2 of word 2 of tLine is "\" then
next repeat
end if
put true into tTokens[char 2 to -2 of word 2 of tLine]
end repeat
local tTokensFile
put the tempName into tTokensFile
-- If we are on Mac OS X, then we need to output with UNIX line endings
if the platform is "MacOS" then
put the keys of tTokens into url ("binfile:" & tTokensFile)
else
put the keys of tTokens into url ("file:" & tTokensFile)
end if
/*local tPerfectCmd
set the itemDelimiter to ":"
get item 2 to -1 of the address
set the itemDelimiter to slash
local tOldFolder
put the folder into tOldFolder
set the folder to (item 1 to -2 of it)
put "perfect" into tPerfectCmd
switch the platform
case "win32"
put tPerfectCmd & ".exe" into tPerfectCmd
break
case "macos"
put pPerfect into tPerfectCmd
replace space with "\ " in tPerfectCmd
break
default
put quote & pPerfect & quote into tPerfectCmd
break
end switch*/
get shell(pPerfect && "<" & quote & tTokensFile & quote)
if char 1 of it is not "#" then
delete line 1 of it
end if
set the folder to tOldFolder
put it into url ("binfile:" & pTarget)
delete file tTokensFile
end generate