Skip to content

draft: [RFC/WIP] Homogenising the integer and float types in the [posix,glib].vapi files, and removing itoa/atoi family C functions.

Gustav Hartvigsson requested to merge gustav.hartvigsson/vala:fix-int-all into main

I have started working on making the .vapi files that define the integer and types to be more homogenised, and removing itoa/atoi family functions, this as it is not portable and is considered bad form to use in modern applications.

The use of strtol et.al. for fixed width integers will not work, as the length (bit width) of types like long is varies between 32 and 64 bit machines. Thus the sscanf is favourable.

Done:

  • posix.vapi
    • Added the min, max, abs, clamp functions.
    • Added MIN, MAX constants.
    • Added FORMAT constant to relevant types.
    • Make to_string take a format string as input to be like the glib.vapi definitions.
    • try_parse.
    • math.h function macros.
  • glib.vapi
    • Remove itoa/atoi family calls, and replace with strtoi or scanf calls.
    • Make sure that to_string and parse does not use strtoi family calls for fixed-width types, as it is not portable.

Things to consider:

  • Use strtol family for non-fixed-width types.
  • Do we need PRINT_FORMAT in glib.vapi?

Please comment.

Edited by Gustav Hartvigsson

Merge request reports