Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -1,17 +0,0 @@
with Config; use Config;
with Ada.Text_IO; use Ada.Text_IO;
procedure Rosetta_Read_Cfg is
cfg: Configuration:= Init("rosetta_read.cfg", Case_Sensitive => False, Variable_Terminator => ' ');
fullname : String := cfg.Value_Of("*", "fullname");
favouritefruit : String := cfg.Value_Of("*", "favouritefruit");
needspeeling : Boolean := cfg.Is_Set("*", "needspeeling");
seedsremoved : Boolean := cfg.Is_Set("*", "seedsremoved");
otherfamily : String := cfg.Value_Of("*", "otherfamily");
begin
Put_Line("fullname = " & fullname);
Put_Line("favouritefruit = " & favouritefruit);
Put_Line("needspeeling = " & Boolean'Image(needspeeling));
Put_Line("seedsremoved = " & Boolean'Image(seedsremoved));
Put_Line("otherfamily = " & otherfamily);
end;

View file

@ -4,16 +4,16 @@ parseConfig: function [f][
'line [not? empty? line]
result: #[]
fields: loop lines 'line [
loop lines 'line [
field: first match line {/^[A-Z]+/}
rest: strip replace line field ""
parts: select map split.by:"," rest => strip 'part -> not? empty? part
val: null
case [(size parts)]
when? [= 0] -> val: true
when? [= 1] -> val: first parts
else -> val: parts
val: case size parts [
0 -> true
1 -> first parts
any -> parts
]
result\[lower field]: val
]
@ -22,6 +22,6 @@ parseConfig: function [f][
]
loop parseConfig relative "config.file" [k,v][
if? block? v -> print [k "->" join.with:", " v]
else -> print [k "->" v]
switch block? v -> print [k "->" join.with:", " v]
-> print [k "->" v]
]

View file

@ -1,96 +0,0 @@
identification division.
program-id. ReadConfiguration.
environment division.
configuration section.
repository.
function all intrinsic.
input-output section.
file-control.
select config-file assign to "Configuration.txt"
organization line sequential.
data division.
file section.
fd config-file.
01 config-record pic is x(128).
working-storage section.
77 idx pic 9(3).
77 pos pic 9(3).
77 last-pos pic 9(3).
77 config-key pic x(32).
77 config-value pic x(64).
77 multi-value pic x(64).
77 full-name pic x(64).
77 favourite-fruit pic x(64).
77 other-family pic x(64) occurs 10.
77 need-speeling pic x(5) value "false".
77 seeds-removed pic x(5) value "false".
procedure division.
main.
open input config-file
perform until exit
read config-file
at end
exit perform
end-read
move trim(config-record) to config-record
if config-record(1:1) = "#" or ";" or spaces
exit perform cycle
end-if
unstring config-record delimited by spaces into config-key
move trim(config-record(length(trim(config-key)) + 1:)) to config-value
if config-value(1:1) = "="
move trim(config-value(2:)) to config-value
end-if
evaluate upper-case(config-key)
when "FULLNAME"
move config-value to full-name
when "FAVOURITEFRUIT"
move config-value to favourite-fruit
when "NEEDSPEELING"
if config-value = spaces
move "true" to config-value
end-if
if config-value = "true" or "false"
move config-value to need-speeling
end-if
when "SEEDSREMOVED"
if config-value = spaces
move "true" to config-value
end-if,
if config-value = "true" or "false"
move config-value to seeds-removed
end-if
when "OTHERFAMILY"
move 1 to idx, pos
perform until exit
unstring config-value delimited by "," into multi-value with pointer pos
on overflow
move trim(multi-value) to other-family(idx)
move pos to last-pos
not on overflow
if config-value(last-pos:) <> spaces
move trim(config-value(last-pos:)) to other-family(idx)
end-if,
exit perform
end-unstring
add 1 to idx
end-perform
end-evaluate
end-perform
close config-file
display "fullname = " full-name
display "favouritefruit = " favourite-fruit
display "needspeeling = " need-speeling
display "seedsremoved = " seeds-removed
perform varying idx from 1 by 1 until idx > 10
if other-family(idx) <> low-values
display "otherfamily(" idx ") = " other-family(idx)
end-if
end-perform
.

View file

@ -1,68 +0,0 @@
function Read-ConfigurationFile
{
[CmdletBinding()]
Param
(
# Path to the configuration file. Default is "C:\ConfigurationFile.cfg"
[Parameter(Mandatory=$false, Position=0)]
[string]
$Path = "C:\ConfigurationFile.cfg"
)
[string]$script:fullName = ""
[string]$script:favouriteFruit = ""
[bool]$script:needsPeeling = $false
[bool]$script:seedsRemoved = $false
[string[]]$script:otherFamily = @()
function Get-Value ([string]$Line)
{
if ($Line -match "=")
{
[string]$value = $Line.Split("=",2).Trim()[1]
}
elseif ($Line -match " ")
{
[string]$value = $Line.Split(" ",2).Trim()[1]
}
$value
}
# Process each line in file that is not a comment.
Get-Content $Path | Select-String -Pattern "^[^#;]" | ForEach-Object {
[string]$line = $_.Line.Trim()
if ($line -eq [String]::Empty)
{
# do nothing for empty lines
}
elseif ($line.ToUpper().StartsWith("FULLNAME"))
{
$script:fullName = Get-Value $line
}
elseif ($line.ToUpper().StartsWith("FAVOURITEFRUIT"))
{
$script:favouriteFruit = Get-Value $line
}
elseif ($line.ToUpper().StartsWith("NEEDSPEELING"))
{
$script:needsPeeling = $true
}
elseif ($line.ToUpper().StartsWith("SEEDSREMOVED"))
{
$script:seedsRemoved = $true
}
elseif ($line.ToUpper().StartsWith("OTHERFAMILY"))
{
$script:otherFamily = (Get-Value $line).Split(',').Trim()
}
}
Write-Verbose -Message ("{0,-15}= {1}" -f "FULLNAME", $script:fullName)
Write-Verbose -Message ("{0,-15}= {1}" -f "FAVOURITEFRUIT", $script:favouriteFruit)
Write-Verbose -Message ("{0,-15}= {1}" -f "NEEDSPEELING", $script:needsPeeling)
Write-Verbose -Message ("{0,-15}= {1}" -f "SEEDSREMOVED", $script:seedsRemoved)
Write-Verbose -Message ("{0,-15}= {1}" -f "OTHERFAMILY", ($script:otherFamily -join ", "))
}

View file

@ -1 +0,0 @@
Read-ConfigurationFile -Path .\temp.txt -Verbose

View file

@ -1 +0,0 @@
Get-Variable -Name fullName, favouriteFruit, needsPeeling, seedsRemoved, otherFamily

View file

@ -1,88 +0,0 @@
Function Read-ConfigurationFile {
[CmdletBinding()]
[OutputType([Collections.Specialized.OrderedDictionary])]
Param (
[Parameter(
Mandatory=$true,
Position=0
)
]
[Alias('LiteralPath')]
[ValidateScript({
Test-Path -LiteralPath $PSItem -PathType 'Leaf'
})
]
[String]
$_LiteralPath
)
Begin {
Function Houdini-Value ([String]$_Text) {
$__Aux = $_Text.Trim()
If ($__Aux.Length -eq 0) {
$__Aux = $true
} ElseIf ($__Aux.Contains(',')) {
$__Aux = $__Aux.Split(',') |
ForEach-Object {
If ($PSItem.Trim().Length -ne 0) {
$PSItem.Trim()
}
}
}
Return $__Aux
}
}
Process {
$__Configuration = [Ordered]@{}
# Config equivalent pattern
# Select-String -Pattern '^\s*[^\s;#=]+.*\s*$' -LiteralPath '.\filename.cfg'
Switch -Regex -File $_LiteralPath {
'^\s*[;#=]|^\s*$' {
Write-Verbose -Message "v$(' '*20)ignored"
Write-Verbose -Message $Matches[0]
Continue
}
'^([^=]+)=(.*)$' {
Write-Verbose -Message '↓← ← ← ← ← ← ← ← ← ← equal pattern'
Write-Verbose -Message $Matches[0]
$__Name,$__Value = $Matches[1..2]
$__Configuration[$__Name.Trim()] = Houdini-Value($__Value)
Continue
}
'^\s*([^\s;#=]+)(.*)(\s*)$' {
Write-Verbose -Message '↓← ← ← ← ← ← ← ← ← ← space or tab pattern or only name'
Write-Verbose -Message $Matches[0]
$__Name,$__Value = $Matches[1..2]
$__Configuration[$__Name.Trim()] = Houdini-Value($__Value)
Continue
}
}
Return $__Configuration
}
}
Function Show-Value ([Collections.Specialized.OrderedDictionary]$_Dictionary, $_Index, $_SubIndex) {
$__Aux = $_Index + ' = '
If ($_Dictionary[$_Index] -eq $null) {
$__Aux += $false
} ElseIf ($_Dictionary[$_Index].Count -gt 1) {
If ($_SubIndex -eq $null) {
$__Aux += $_Dictionary[$_Index] -join ','
} Else {
$__Aux = $_Index + '(' + $_SubIndex + ') = '
If ($_Dictionary[$_Index][$_SubIndex] -eq $null) {
$__Aux += $false
} Else {
$__Aux += $_Dictionary[$_Index][$_SubIndex]
}
}
} Else {
$__Aux += $_Dictionary[$_Index]
}
Return $__Aux
}

View file

@ -1 +0,0 @@
$Configuration = Read-ConfigurationFile -LiteralPath '.\config.cfg'

View file

@ -1,8 +0,0 @@
Show-Value $Configuration 'fullname'
Show-Value $Configuration 'favouritefruit'
Show-Value $Configuration 'needspeeling'
Show-Value $Configuration 'seedsremoved'
Show-Value $Configuration 'otherfamily'
Show-Value $Configuration 'otherfamily' 0
Show-Value $Configuration 'otherfamily' 1
Show-Value $Configuration 'otherfamily' 2

View file

@ -1,45 +0,0 @@
'$Configuration[''fullname'']'
$Configuration['fullname']
'$Configuration.''fullname'''
$Configuration.'fullname'
'$Configuration.Item(''fullname'')'
$Configuration.Item('fullname')
'$Configuration[0]'
$Configuration[0]
'$Configuration.Item(0)'
$Configuration.Item(0)
' '
'=== $Configuration[''otherfamily''] ==='
$Configuration['otherfamily']
'=== $Configuration[''otherfamily''][0] ==='
$Configuration['otherfamily'][0]
'=== $Configuration[''otherfamily''][1] ==='
$Configuration['otherfamily'][1]
' '
'=== $Configuration.''otherfamily'' ==='
$Configuration.'otherfamily'
'=== $Configuration.''otherfamily''[0] ==='
$Configuration.'otherfamily'[0]
'=== $Configuration.''otherfamily''[1] ==='
$Configuration.'otherfamily'[1]
' '
'=== $Configuration.Item(''otherfamily'') ==='
$Configuration.Item('otherfamily')
'=== $Configuration.Item(''otherfamily'')[0] ==='
$Configuration.Item('otherfamily')[0]
'=== $Configuration.Item(''otherfamily'')[1] ==='
$Configuration.Item('otherfamily')[1]
' '
'=== $Configuration[3] ==='
$Configuration[3]
'=== $Configuration[3][0] ==='
$Configuration[3][0]
'=== $Configuration[3][1] ==='
$Configuration[3][1]
' '
'=== $Configuration.Item(3) ==='
$Configuration.Item(3)
'=== $Configuration.Item(3).Item(0) ==='
$Configuration.Item(3).Item(0)
'=== $Configuration.Item(3).Item(1) ==='
$Configuration.Item(3).Item(1)

View file

@ -1,38 +0,0 @@
Set ofso = CreateObject("Scripting.FileSystemObject")
Set config = ofso.OpenTextFile(ofso.GetParentFolderName(WScript.ScriptFullName)&"\config.txt",1)
config_out = ""
Do Until config.AtEndOfStream
line = config.ReadLine
If Left(line,1) <> "#" And Len(line) <> 0 Then
config_out = config_out & parse_var(line) & vbCrLf
End If
Loop
WScript.Echo config_out
Function parse_var(s)
'boolean false
If InStr(s,";") Then
parse_var = Mid(s,InStr(1,s,";")+2,Len(s)-InStr(1,s,";")+2) & " = FALSE"
'boolean true
ElseIf UBound(Split(s," ")) = 0 Then
parse_var = s & " = TRUE"
'multiple parameters
ElseIf InStr(s,",") Then
var = Left(s,InStr(1,s," ")-1)
params = Split(Mid(s,InStr(1,s," ")+1,Len(s)-InStr(1,s," ")+1),",")
n = 1 : tmp = ""
For i = 0 To UBound(params)
parse_var = parse_var & var & "(" & n & ") = " & LTrim(params(i)) & vbCrLf
n = n + 1
Next
'single var and paramater
Else
parse_var = Left(s,InStr(1,s," ")-1) & " = " & Mid(s,InStr(1,s," ")+1,Len(s)-InStr(1,s," ")+1)
End If
End Function
config.Close
Set ofso = Nothing