mg: port of OpenBSD mg version to Linux

Last modification on

NOTE: this fork is out-dated and is not maintained currently!
Please use the portable mg:

This is the port of the mg editor (OpenBSD version) to Linux. It should be possible to compile it with atleast musl libc and glibc.


git clone git://

Changes vs upstream

I tried to keep the changes minimal to make it easy to synchronize with upstream changes and to not introduce new bugs. However there were some changes that needed to be made because of differences between OpenBSD and Linux and these are:

  • Add OpenBSD libc / libutil functions: strtonum, reallocarray, strlcpy, strlcat, fparseln, arc4random(hack)
  • Timespec changes: for struct stat
  • Ignore REG_STARTEND for compatibility with Musl. At the time of writing it doesn't support the REG_STARTEND flag for regexec() (non-POSIX). NOTE: there are differences in glibc's REG_STARTEND implementation compared to OpenBSD aswell. So expect it to behave a bit differently.
  • Convenience: and Makefile.