[libc] Remove global constructor in `getopt` implementation
authorJoseph Huber <jhuber6@vols.utk.edu>
Thu, 20 Jul 2023 00:10:30 +0000 (19:10 -0500)
committerJoseph Huber <jhuber6@vols.utk.edu>
Thu, 20 Jul 2023 13:11:19 +0000 (08:11 -0500)
commited7ade9cfa56acae3c67bdf837dec05555769e3c
tree7c92992767bbdbf6df009a804875b2cd807861f8
parentcc92212d75dff07644e478c55a6f145c020f6f8e
[libc] Remove global constructor in `getopt` implementation

This file required a global constructor due to copying the file stream
and have a non-constexpr constructor for the wrapper type. Also, I
changes the `opterr` to be a pointer, because it seemed like it wasn't
being set correctly as an externally visibile variable if we just
captured it by value.

Reviewed By: abrachet

Differential Revision: https://reviews.llvm.org/D155766
libc/src/unistd/getopt.cpp
libc/src/unistd/getopt.h
libc/test/src/unistd/getopt_test.cpp