FuzzyOS icon indicating copy to clipboard operation
FuzzyOS copied to clipboard

Improve escape sequences support in *printf(...)

Open scopeInfinity opened this issue 4 years ago • 1 comments
trafficstars

Source

  • src/usr/lib/stdio.c

Specification

Source: https://en.wikipedia.org/wiki/Printf_format_string#Format_placeholder_specification

  • syntax for a format placeholder: %[parameter][flags][width][.precision][length]type

To keep things simple we can go with the subset of the following options to build an minimum viable product

  • Type field:
    • [ ] '%'
    • [ ] 'd' 'i'
    • [ ] 'u'
    • [ ] 'f' 'F'
    • [ ] ~'g' 'G'~
    • [ ] 'x' 'X'
    • [ ] 'o'
    • [ ] 's'
    • [ ] 'c'
    • [ ] 'p'
  • Length field:
    • [ ] The field may be omitted (default, current behaviour)
    • [ ] 'l': 4 bytes same as 'not-specified'
    • [ ] 'll': 8 bytes
    • [ ] ~'L': 96 bits? or bits?~
      • https://en.wikipedia.org/wiki/Long_double#Implementations
      • https://godbolt.org/z/EME3zdcjG => 12 bytes == 96 bits
    • [ ] 'z': 4 bytes same as 'not-specified'
  • Flags field:
    • [ ] The field may be omitted (default, current behaviour)
    • [ ] '-' minus
    • [ ] '+' plus
    • [ ] ' ' space
    • [ ] '0'
  • Width field:
    • [ ] The field may be omitted (default, current behaviour)
    • [ ] or a numeric integer value
    • [ ] or a dynamic value when passed as another argument when indicated by an asterisk *.
  • Precision field:
    • [ ] The field may be omitted (default, current behaviour)
    • [ ] or a numeric integer value
    • [ ] or a dynamic value when passed as another argument when indicated by an asterisk *.

Multiple small pull requests are way better than one giant one :)

scopeInfinity avatar Oct 09 '21 20:10 scopeInfinity

Length field sub tasks are blocked on #32

scopeInfinity avatar Oct 09 '21 21:10 scopeInfinity