Wiimm's ISO/SZS Tools don't compile under musl libc

      Wiimm's ISO/SZS Tools don't compile under musl libc

      I ran into this problem when trying to compile Wiimm's tools on Alpine Linux, a musl-based distro.

      More specifically, dclib -- Wiimm's library which is bundled in to the source of his programs -- relies on stdout and stderr being mutable, behavior which is not mandated by the C standard. This is fine on glibc, where stdout and stderr are declared as mutable, but musl declares them as const.

      The offending code is in dclib/dclib-color.c. I've marked the offending lines with comments saying HERE.

      C-Quellcode: dclib/dclib-color.c

      1. void RestoreStdFiles ( SavedStdFiles_t *ssf )
      2. {
      3. DASSERT(ssf);
      4. stdout = ssf->std_out; // HERE
      5. stderr = ssf->std_err; // HERE
      6. stdlog = ssf->std_log;
      7. stdmsg = ssf->std_msg;
      8. stdwrn = ssf->std_wrn;
      9. colout = ssf->col_out;
      10. colerr = ssf->col_err;
      11. collog = ssf->col_log;
      12. colmsg = ssf->col_msg;
      13. colwrn = ssf->col_wrn;
      14. stdout_seq_count = ssf->stdout_seq_count;
      15. }
      16. ///////////////////////////////////////////////////////////////////////////////
      17. void RedirectStdFiles
      18. (
      19. SavedStdFiles_t *ssf, // not NULL: save old output here
      20. FILE *f, // use this as out,err,log and msg, never NULL
      21. const ColorSet_t *colset,// new colset; if NULL: use GetFileColorSet(f)
      22. bool err_too // true: redirect stderr too
      23. )
      24. {
      25. DASSERT(f);
      26. if (ssf)
      27. SaveStdFiles(ssf);
      28. stdout = stdwrn = stdmsg = f; // HERE
      29. colout = colwrn = colmsg = colset ? colset : GetFileColorSet(f);
      30. // special handling for stdlog
      31. if (stdlog)
      32. {
      33. stdlog = stdout;
      34. collog = colout;
      35. }
      36. if (err_too)
      37. {
      38. stderr = stdout; // HERE
      39. colerr = colout;
      40. }
      41. }
      Alles anzeigen
      If Wiimm is okay with it, I'm willing to try to create and submit a patch fixing the problem. I haven't found any place where I could submit a patch or contact Wiimm though, so if Wiimm wishes to fix the problem himself, that's also fine. Alternatively, if there's a workaround that I can use to get the programs to compile, please let me know. Thanks in advance!