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>
54 lines
1.3 KiB
Text
54 lines
1.3 KiB
Text
/**
|
|
* NAME: number_string
|
|
* SYNOPSIS: string number_string ( int | float num1 number, void | int add_commas )
|
|
* DESCRIPTION: Converts an integer or a float into a string. Optionally, can comma-delimit the results.
|
|
* EXAMPLE: number_string(2500.36) // "2500.360000"
|
|
* EXAMPLE: number_string(2500.36, 1) // "2,500.360000"
|
|
*/
|
|
|
|
#include <lpctypes.h>
|
|
|
|
varargs string number_string( mixed number, int add_commas )
|
|
{
|
|
string int_part = "", decimal_part = "", *parts, part ;
|
|
string work ;
|
|
|
|
if(nullp(number) || ( typeof(number) != INT && typeof(number) != FLOAT ) )
|
|
{
|
|
error("You must specify a number of type int or float.\n") ;
|
|
}
|
|
|
|
work = number + "" ;
|
|
|
|
if( !nullp(add_commas) || add_commas == 1 )
|
|
{
|
|
int decimal_index = strsrch(work, ".") ;
|
|
|
|
if(decimal_index > -1)
|
|
{
|
|
int_part = work[ 0 .. decimal_index - 1] ;
|
|
decimal_part = work[ decimal_index .. ] ;
|
|
}
|
|
else
|
|
{
|
|
int_part = work ;
|
|
}
|
|
|
|
// empty work
|
|
work = "" ;
|
|
|
|
while( strlen( int_part ) > 3 )
|
|
{
|
|
work = "," + int_part[ <3 .. ] + work ;
|
|
int_part = int_part[ 0 .. <4 ] ;
|
|
}
|
|
|
|
int_part = int_part + work ;
|
|
}
|
|
else
|
|
{
|
|
int_part = work ;
|
|
}
|
|
|
|
return sprintf("%s%s", int_part, decimal_part );
|
|
}
|