Does NOT look at the locale the way the C functions do.
int isalnum(int c);
int isalpha(int c);
int iscntrl(int c);
int isdigit(int c);
int isgraph(int c);
int islower(int c);
int isprint(int c);
int ispunct(int c);
int isspace(int c);
int isupper(int c);
int isxdigit(int c);
int isascii(int c);
int isblank(int c);
int toupper(int c);
int tolower(int c);
Tested to match glibc (when using C locale) with this program:
const c = @cImport({
// See https://github.com/ziglang/zig/issues/515
@cDefine("_NO_CRT_STDIO_INLINE", "1");
@cInclude("stdio.h");
@cInclude("string.h");
@cInclude("ctype.h");
});
const std = @import("std");
const ascii = std.ascii;
const abort = std.os.abort;
export fn main(argc: c_int, argv: **u8) c_int {
var i: u8 = undefined;
i = 0;
while (true) {
if (ascii.isAlNum(i) != (c.isalnum(i) > 0)) { abort(); }
if (ascii.isAlpha(i) != (c.isalpha(i) > 0)) { abort(); }
if (ascii.isCtrl(i) != (c.iscntrl(i) > 0)) { abort(); }
if (ascii.isDigit(i) != (c.isdigit(i) > 0)) { abort(); }
if (ascii.isGraph(i) != (c.isgraph(i) > 0)) { abort(); }
if (ascii.isLower(i) != (c.islower(i) > 0)) { abort(); }
if (ascii.isPrint(i) != (c.isprint(i) > 0)) { abort(); }
if (ascii.isPunct(i) != (c.ispunct(i) > 0)) { abort(); }
if (ascii.isSpace(i) != (c.isspace(i) > 0)) { abort(); }
if (ascii.isUpper(i) != (c.isupper(i) > 0)) { abort(); }
if (ascii.isXDigit(i) != (c.isxdigit(i) > 0)) { abort(); }
if (i == 255) { break; }
i += 1;
}
_ = c.printf(c"Success!\n");
return 0;
}
Unlike the other glibc source code checked into the repo, `csu/init.c`
did not have a license clause that allowed linking without restrictions.
`_IO_stdin_used` is the only symbol in the file and appears to be a 20
year old compatibility shim for the glibc 2.0 ABI. Obsolete in 2.1.
closes#2024
there's a new cli option `--main-pkg-path` which you can use to choose
a different root package directory besides the one inferred from the
root source file
and a corresponding build.zig API:
foo.setMainPkgPath(path)
* better libc detection
This introduces a new command `zig libc` which prints
the various paths of libc files. It outputs them to stdout
in a simple text file format that it is capable of parsing.
You can use `zig libc libc.txt` to validate a file.
These arguments are gone:
--libc-lib-dir [path] directory where libc crt1.o resides
--libc-static-lib-dir [path] directory where libc crtbegin.o resides
--msvc-lib-dir [path] (windows) directory where vcruntime.lib resides
--kernel32-lib-dir [path] (windows) directory where kernel32.lib resides
Instead we have this argument:
--libc [file] Provide a file which specifies libc paths
This is used to pass a libc text file (which can be generated with
`zig libc`). So it is easier to manage multiple cross compilation
environments.
`--cache on` now works when linking against libc.
`ZigTarget` now has a bool field `is_native`
Better error messaging when you try to link against libc or use
`@cImport` but the various paths cannot be found. It should also be
faster.
* save native_libc.txt in zig-cache
This avoids having to detect libc at runtime on every invocation.
Mostly picking the same paths as FreeBSD.
We need a little special handling for crt files, as netbsd uses its
own (and not GCC's) for those, with slightly different names.
This is not intended to be the long-term implementation as it doesn't
provide various properties that we eventually will want (e.g.
round-tripping, denormal support). It also uses f64 internally so the
wider f128 will be inaccurate.
Previously, std.debug.assert would `@panic` in test builds,
if the assertion failed. Now, it's always `unreachable`.
This makes release mode test builds more accurately test
the actual code that will be run.
However this requires tests to call `std.testing.expect`
rather than `std.debug.assert` to make sure output is correct.
Here is the explanation of when to use either one, copied from
the assert doc comments:
Inside a test block, it is best to use the `std.testing` module
rather than assert, because assert may not detect a test failure
in ReleaseFast and ReleaseSafe mode. Outside of a test block, assert
is the correct function to use.
closes#1304
this should actually improve CI times a bit too
See the description at the top of std/os/startup.zig (deleted in this
commit) for a more detailed understanding of what this commit does.