GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — livecode/util/hash_strings.pl at develop · livecode/livecode
This repository was archived by the owner on Aug 31, 2021. It is now read-only.
Expand file tree/ Copy pathhash_strings.plMore file actions executable file ·86 lines (72 loc) · 1.78 KB / Copy pathhash_strings.plFile metadata and controlsexecutable file ·86 lines (72 loc) · 1.78 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 #!/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; |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |