FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
livecode/util/hash_strings.pl at develop · livecode/livecode · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
This repository was archived by the owner on Aug 31, 2021. It is now read-only.
livecode
/
livecode
Public archive
Notifications
You must be signed in to change notification settings
Fork
223
Star
517
Code
Pull requests
189
Actions
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
livecode
/
util
/
hash_strings.pl
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
86 lines (72 loc) · 1.78 KB
Breadcrumbs
livecode
/
util
/
hash_strings.pl
Copy path
File metadata and controls
executable file
·
86 lines (72 loc) · 1.78 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#
!/usr/bin/env perl
use
warnings;
use
File::Basename;
use
File::Temp
qw(
tempfile
)
;
#
Arguments
my
$sourceFile
=
$ARGV
[0];
my
$targetFile
=
$ARGV
[1];
my
$perfectCmd
=
$ARGV
[2];
#
Get the input
open
SOURCE,
"
<
$sourceFile
"
or
die
"
Could not open source file
\"
$sourceFile
\"
:
$!
"
;
my
@sourceLines
= <SOURCE>;
close
SOURCE;
#
List of tokens
my
%tokens
= ();
#
Look for the lines with the following properties:
#
The first token is "{"
#
The second token is a C-string
foreach
my
$line
(
@sourceLines
)
{
#
Does the line begin with a { token?
if
(!(
$line
=~
s
/
^
\s
*
\{\s
*
//
g
))
{
next
;
}
#
Is the next token a C-string?
if
(
substr
(
$line
, 0, 1)
ne
'
"
'
)
{
next
;
}
#
Scan to the end of the string
#
NOTE: embedded quotation marks are not handled correctly!
my
$end
=
index
(
$line
,
'
"
'
, 1);
if
(
$end
== -1)
{
next
;
}
#
Copied over from hash_strings.rev
if
(
substr
(
$line
, 1, 1)
eq
'
\\
'
)
{
next
;
}
#
Add to the list of tokens
my
$token
=
substr
(
$line
, 1,
$end
-1);
$tokens
{
$token
} = 1;
}
#
Write the list of tokens out to a temporary file
(
$tempFH
,
$tempName
) = tempfile();
(
$tempFH2
,
$tempName2
) = tempfile();
print
$tempFH
join
(
"
\n
"
,
sort
(
keys
%tokens
));
close
$tempFH
;
close
$tempFH2
;
#
Need to close because Win32 opens exclusively
#
Path to the "perfect" executable
my
$perfectExe
=
$perfectCmd
;
#
Execute the appropriate "perfect" executable
my
$result
=
system
(
"
\"
$perfectExe
\"
<
\"
$tempName
\"
>
\"
$tempName2
\"
"
);
die
unless
(
$result
== 0);
#
Strip of any leading warning message
open
$tempFH2
,
"
<
$tempName2
"
;
my
@lines
= <
$tempFH2
>;
close
$tempFH2
;
unlink
$tempName
;
unlink
$tempName2
;
if
(
substr
(
$lines
[0], 0, 1)
ne
'
#
'
)
{
splice
(
@lines
, 0, 1);
}
#
Write to the output file
open
OUTPUT,
"
>
$targetFile
"
or
die
"
Couldn't open output file:
$1
"
;
print
OUTPUT
join
(
'
'
,
@lines
);
close
OUTPUT;
Back
|
FazBrowse Home
|
New Git URL