mirror of
https://github.com/fluffos/fluffos
synced 2026-08-12 18:26:06 -04:00
Source resolution is now explicit-extension-exact: load_object("/foo.c")
probes only foo.c, never foo.lpc (and vice versa); extension-less names
prefer .lpc and fall back to .c. Object identity stays extension-blind:
object names carry no extension, any spelling finds a loaded object, and
the registry is consulted before the filesystem. The caller's raw
spelling now flows through find_object()/inherit/master/simul_efun loads
instead of being pre-stripped away.
- filename_to_obname and otable basename() strip .lpc too (children())
- save_object() strips either source extension before appending .o
- replace_program()/function_exists() handle both suffixes
- testsuite: all LPC sources renamed to .lpc; runner globs, master
get_include_path cases, and program-name assertions updated;
README.md rewritten with the extension rules and suite conventions
- new single/tests/efuns/dual_extension.lpc pins exact-pick, fallback,
no-crossover, identity, and registry-before-filesystem with .c/.lpc
fixture pairs in /clone
Verified: ctest 297/297 and driver-autotest x3 (ASan Debug) plus
RelWithDebInfo ctest + autotest.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
87 lines
2.3 KiB
Text
87 lines
2.3 KiB
Text
int indexing(string str){
|
|
// Count "e" by using a loop looking at character index in string
|
|
int count = 0;
|
|
int sz = strlen(str);
|
|
for(int i=0;i<sz;i++){
|
|
if(str[i]=='e') count++;
|
|
}
|
|
return count;
|
|
}
|
|
|
|
int exploding(string str){
|
|
// Count "e" using a loop looking at index in an array of strings
|
|
int count = 0;
|
|
int sz;
|
|
string *list;
|
|
list = explode(str,"");
|
|
sz = sizeof(list);
|
|
for(int i=0;i<sz;i++){
|
|
if(list[i][0]=='e') count++;
|
|
}
|
|
return count;
|
|
}
|
|
|
|
string count_chart(){
|
|
int w=100, h=25;
|
|
// w,h are characters, each with 4h 2w dots
|
|
// fill below or a dot per column
|
|
int *grid=allocate(8*w*h);
|
|
int pre,mid,post,a,b,scale;
|
|
string input;
|
|
string output="Each column is 5 chars longer string processed via 2 algorithms, top line means instant\n";
|
|
for(int i=0;i<(2*w);i++){ // going across
|
|
input = sprintf("%*'blargle 's",i*5,"");
|
|
pre = perf_counter_ns();
|
|
indexing(input);
|
|
mid = perf_counter_ns();
|
|
exploding(input);
|
|
post = perf_counter_ns();
|
|
scale = 2000000;
|
|
a = min(({w-1, ((mid-pre)/scale) }));
|
|
//scale = 1000000;
|
|
b = min(({w-1, ((post-mid)/scale) }));
|
|
grid[i + min(({w, (a)}))*2*w] = 1;
|
|
grid[i + min(({w, (b)}))*2*w] = 1;
|
|
}
|
|
for(int i=0;i<h;i++){ // going down
|
|
for(int j=0;j<w;j++){ // going across
|
|
output += sprintf("%c", 0x2800 +
|
|
(grid[i*w*2*4 + j*2] ? 1 : 0) +
|
|
(grid[i*w*2*4 + j*2 + 1] ? 8 : 0) +
|
|
(grid[i*w*2*4 + j*2 + w*2] ? 2 : 0) +
|
|
(grid[i*w*2*4 + j*2 + w*2 + 1] ? 16 : 0) +
|
|
(grid[i*w*2*4 + j*2 + w*4] ? 4 : 0) +
|
|
(grid[i*w*2*4 + j*2 + w*4 +1] ? 32 : 0) +
|
|
(grid[i*w*2*4 + j*2 + w*6] ? 64 : 0) +
|
|
(grid[i*w*2*4 + j*2 + w*6 +1] ? 128 : 0) +
|
|
0);
|
|
}
|
|
output += "\n";
|
|
}
|
|
return output;
|
|
}
|
|
|
|
string count_x(int x){
|
|
string input;
|
|
int pre,mid,post;
|
|
|
|
input = sprintf("%*'blargle 's",x,"");
|
|
pre = perf_counter_ns();
|
|
indexing(input);
|
|
mid = perf_counter_ns();
|
|
exploding(input);
|
|
post = perf_counter_ns();
|
|
return sprintf("Input of %d chars, indexing=%1.3f ms, exploding=%1.3f ms\n", strlen(input), (mid-pre)*0.000001, (post-mid)*0.000001);
|
|
}
|
|
|
|
|
|
int main(string arg){
|
|
write(count_chart());
|
|
write(count_x(100));
|
|
write(count_x(500));
|
|
write(count_x(1000));
|
|
write(count_x(2000));
|
|
write(count_x(5000));
|
|
write(count_x(10000));
|
|
return 1;
|
|
}
|