303 Commits

Author SHA1 Message Date
gingerBill
4e40b808c4 Split of the built-in custom formatters to improve code generation 2025-12-27 12:42:52 +00:00
gingerBill
40eab9991e Split some procedures up 2025-12-27 11:35:13 +00:00
gingerBill
e6827393cf Add raw_union_tag struct tag fields to many types in vendor 2025-12-08 14:35:22 +00:00
gingerBill
3a3239294c raw_union_tag allow for comma separation for multiple mappings 2025-12-08 14:03:13 +00:00
gingerBill
f9f4dcd207 Add raw_union_tag for struct #raw_union fields to improve fmt printing 2025-12-08 13:58:28 +00:00
gingerBill
49634246c5 Merge branch 'master' of https://github.com/odin-lang/Odin 2025-11-27 09:06:36 +00:00
gingerBill
5380cf8b90 core:fmt lvalues in for loops to minimize stack usage 2025-11-27 09:06:30 +00:00
gingerBill
a162626f2b Use BUF_SIZE 2025-11-22 21:18:43 +00:00
gingerBill
e4fcebe4bf Empty -> Unsupported 2025-11-14 11:17:38 +00:00
Jeroen van Rijn
c51f4daa7d Let custom formatter example pass -vet-tabs if copied 2025-10-18 16:25:19 +02:00
Jeroen van Rijn
7a9ea3ee6d Further overhaul of package line comments. 2025-10-09 23:05:29 +02:00
AmedeoAlf
8bb597b9de Specify %m and %M as verbs for integer formatting 2025-09-01 22:44:24 +02:00
gingerBill
ae02d3d02d Begin supporting string16 across the core library 2025-08-02 11:55:16 +01:00
gingerBill
2561427dd3 Add string16 and cstring16 (UTF-16 based strings) 2025-08-02 11:00:15 +01:00
Feoramund
b7de15caa3 Clarify strconv.append_* to strconv.write_* 2025-06-05 16:56:00 -04:00
mtarik34b
c7f9d2b1b7 Correctly capitalize 'E' for the %E format specifier (#5065) 2025-04-22 02:35:02 +02:00
Barinzaya
92ac86ae3c Fixed fmt handling of bit_set[Enum] when min(Enum) != 0.
The lower bound of the `bit_set` was only being applied *after*
searching for a matching enum value, so values wouldn't line up if the
minimum value of the enum wasn't 0.
2025-04-07 15:41:21 -04:00
Adam Zadrożny
7866f7ab2b Update fmt docs for procedures with a default allocator parameter 2025-03-09 13:35:12 +01:00
gingerBill
cae91c9472 Fix rune printing with %b 2025-02-25 15:53:06 +00:00
Barinzaya
dc2c9b5d51 Support use of * in format strings without an index.
This allows `*` to be used in C fashion, without specifying an argument
index to use. Like C, this results in the argument *preceding* the value
for the format specifier itself.
2025-02-14 10:44:42 -05:00
flysand7
7127992625 Fix the '+' sign placement in the presence of '0'-padding 2025-01-24 08:36:01 +11:00
Laytan Laats
9d4fa39daa add ensure and ensuref to fmt and log, fix some inconsistencies 2025-01-13 20:33:49 +01:00
gingerBill
e38a08013e Remove #relative types from the compiler 2024-11-14 16:17:24 +00:00
Laytan Laats
cc3c9bd871 fix thread_unix for Darwin after pthread corrections in posix package
afed3ce removed the sys/unix package and moved over to sys/posix, it has
new bindings for the pthread APIs but should have been equivalent (not).

8fb7182 used `CANCEL_ENABLE :: 0`, `CANCEL_DISABLE :: 1`, `CANCEL_DEFERRED :: 0`, `CANCEL_ASYNCHRONOUS :: 1` for Darwin, while the
correct values are `1`, `0`, `2` and `0` respectively (same mistake was made for
FreeBSD in that commit).

What this meant is that the
`pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS)` was not actually
successful, but because the error wasn't checked it was assumed it was.
It also meant `pthread_setcancelstate(PTHREAD_CANCEL_ENABLE)` would
actually be setting `PTHREAD_CANCEL_DISABLE`.

The code in this PR restores the behaviour by now actually deliberately
setting `PTHREAD_CANCEL_DISABLE` and not setting
`PTHREAD_CANCEL_ASYNCHRONOUS` which was the previous behaviour that does
actually seem to work for some reason.

(I also fixed an issue in fmt where `x` would use uppercase if it was a
pointer.)
2024-10-30 15:51:56 +01:00
Karl Zylinski
19f0127e55 Moved all packages in core, base, vendor, tests and examples to use new #+ file tag syntax. 2024-09-14 18:27:49 +02:00
Tetralux
4f56822204 [fmt] Add bit fields to the pointer printing logic
core:fmt prints pointers to structs as `&StructName{ ... }` but `bit_field`s are currently printed
the same as rawptrs (`0xAABBCCDDEEFF` only).

This commit changes that so they behave the same as structs and unions.
2024-08-12 16:25:22 +00:00
gingerBill
0e91c8368c Add allocator parameters to fmt.caprint* 2024-07-24 09:01:41 +01:00
Laytan Laats
d4d910bcfc fmt: fix optional_len or use_nul_termination being used by both array and elems
```odin
My_Struct :: struct {
	names:      [^]string `fmt:"v,name_count"`,
	name_count: int,
}

main :: proc() {
	name := "hello?"
	foo := My_Struct {
		names = &name,
		name_count = 1,
	}
	fmt.println(foo)
}
```

Before: `My_Struct{names = ["h"], name_count = 1}`
After:  `My_Struct{names = ["hello?"], name_count = 1}`
2024-07-15 18:51:18 +02:00
gingerBill
399c3ab067 Reduce the size of runtime.Type_Info 2024-07-14 21:37:35 +01:00
gingerBill
8642d719f0 Imply #no_capture to all variadic parameters 2024-07-14 12:19:47 +01:00
gingerBill
edc793d7c1 Add #no_capture args: ..T to reuse the backing array stack memory 2024-07-14 11:39:05 +01:00
gingerBill
fc9c995dc4 Fix fmt for code compilation bug with any 2024-07-08 16:39:13 +01:00
gingerBill
e296d6fb90 Fix loads of indentation issues with mixing spaces and tabs 2024-06-29 19:50:51 +01:00
gingerBill
5413a8b744 Even more style fixes 2024-06-29 19:11:36 +01:00
Karl Zylinski
4e2d12c540 Added fmt.ctprint 2024-06-25 22:32:20 +02:00
Matias Fernandez
4baf101f15 Handle empty structs in fmt with hash 2024-06-14 05:36:23 -04:00
Jeroen van Rijn
3d4e23d741 Add example of a custom formatter. 2024-06-13 11:33:37 +02:00
Feoramund
0c9f487783 Fix and document %w verb for core:fmt 2024-06-12 20:35:50 -04:00
Feoramund
61c481bd81 Fix %p pointers not printing leading 0x 2024-06-07 15:27:43 -04:00
Laytan Laats
8455e159f5 improve orca target 2024-06-05 20:57:39 +02:00
Feoramund
eb93779f63 Fix duplicate sign printing of complex and quaternion types
Negative zero wasn't being detected (so it would appear as `+-0`), and
`+Inf` was appearing as `++Inf` when imaginary.
2024-06-03 19:51:17 -04:00
gingerBill
f600562ca5 Improve fmt parsing of struct field tags 2024-05-20 14:45:49 +01:00
Jeroen van Rijn
e0d3d68ce5 Fix the way '%32b' and other prefixed numbers are written. 2024-05-20 14:42:13 +02:00
Matias Fernandez
a9629679ed remove extra newline in enumerated array hash fmt 2024-05-18 23:24:05 -04:00
gingerBill
7cf62f00c3 Correct #soa RTTI usage 2024-05-16 16:30:45 +01:00
Feoramund
11180e36ae Amend fmt documentation 2024-05-09 19:38:44 -04:00
Feoramund
5e149d2cae Refactor wprintf
- Extracts common code between C and Python-like syntax into its own
   sub-procedures.
 - Fixes Python-like syntax from treating `}` as a verb.
 - Makes C-like syntax treat ' ' as a missing verb.
 - Fixes EXTRA arguments being formatted with options that were
   previously set, instead using default options now.
 - Makes error messaging more consistent between C and Python-like
   syntax.
 - Requires argument index to be specified immediately before the verb
   in C-like syntax, per the documentation, instead of after `%` _or_
   before the verb.
 - Tracks argument usage through a `bit_set`, allowing for reporting of
   unused arguments even when reordered.
 - Moves exit for C-like syntax if next byte is `%` to beginning of
   block instead of needlessly trying to parse through all options.
 - Pops next unused argument for unspecified formatters like `%i` or
   `{}`, instead of taking the argument after the last one used.
 - Fixes unspecified precision `%.f` from not setting precision to zero,
   per the documentation.
2024-05-09 19:28:04 -04:00
Feoramund
700f9c94bd Combine adjacent sbprint*/to_string calls
The `sbprint*` procs already return a string conversion.
2024-04-28 17:18:46 -04:00
Feoramund
c712de0cd0 Require results for non-buffered print procs 2024-04-28 17:17:01 -04:00
Laytan Laats
cc5faecced wasm: add the fprint procedures to fmt
This makes the `log` package work on wasm
2024-04-28 16:10:04 +02:00