janet-lang / janet-lang.org

Website for janet
https://janet-lang.org
MIT License
91 stars 58 forks source link

`%c` format specifier is not documented with its friends #135

Closed sogaiu closed 2 years ago

sogaiu commented 2 years ago

The "Panicking" section of "Writing C Functions" has a nice table of format specifiers (used by janet_panic* and elsewhere).

I don't see %c in the list though it is used in a few places, e.g.:

janet_panicf("invalid flag %c, expected a, t, d, e, u, y, i, or p", view.bytes[i]);

via: https://github.com/janet-lang/janet/blob/79807bf2aba035525f99003a7c3df6a30aac0691/src/core/fiber.c#L521

I'm willing to make a PR, but don't know what to put for the "Description" and "Type" columns.

Any hints?

pepe commented 2 years ago

Just a wild guess from the usage in code, but I would say char. No authority, just trying to add indices to your search.

Via https://github.com/janet-lang/janet/blob/79807bf2aba035525f99003a7c3df6a30aac0691/src/core/capi.c#L384

sogaiu commented 2 years ago

Thanks for taking a look.

There are three column values in the table. The value for the first column is likely %c.

The question is what are good values for the other 2 columns.

As you mentioned, I think it's possible char might be involved somehow, but my guess is it's not likely to be the answer for both of the remaining columns having looked at what's here in the code and compared to what's in the table. I think %c itself may be handled above the aforementioned code.

Does that make sense?

pepe commented 2 years ago

I guess it does. Thx