bartp5 / libtexprintf

Library providing printf-style formatted output routines with tex-like syntax support.
GNU General Public License v3.0
28 stars 2 forks source link

add non-printf texstring(str) #13

Closed stevengj closed 1 year ago

stevengj commented 1 year ago

This adds a new API function char *texstring(const char *str), which is similar to stexprintf but doesn't do any printf formatting. (stexprintf is refactored to call texstring, so there isn't much duplication.)

It is useful to expose this lower-level functionality, e.g. for calling from higher-level languages that have their own printf-like functionality (e.g. Python f-strings) that may or may not use the same syntax. It's not equivalent to simply calling stexprintf with no arguments, because then you have to worry about escaping % characters. cc @Suavesito-Olimpiada

Also added a test script testsprintf.sh to test stexprintf — that function wasn't previously being tested; this involved adding an -S option to utftex so that it calls puts(stexprintf(...)) instead of texprintf(...).

(Will need a rebase/merge once #12 is merged.)

bartp5 commented 1 year ago

I merged all your changes, so I suppose I can close this. Thanks!

stevengj commented 1 year ago

Thanks!