Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Temporary Items
# Zig programming language

zig-cache/
.zig-cache/
zig-out/
build/
build-*/
Expand Down
10 changes: 4 additions & 6 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,14 @@ pub fn build(b: *std.Build) void {
_ = b.addModule(
"jstring",
.{
.root_source_file = .{ .path = "src/jstring.zig" },
.root_source_file = b.path("src/jstring.zig"),
},
);

_ = b.addModule(
"pcre_binding.c",
.{
.root_source_file = .{
.path = b.pathFromRoot("src/pcre/pcre_binding.c"),
},
.root_source_file = b.path("src/pcre/pcre_binding.c"),
},
);

Expand All @@ -47,7 +45,7 @@ pub fn build(b: *std.Build) void {
obj_pcre_binding.linkLibC();
obj_pcre_binding.addCSourceFile(
.{
.file = .{ .path = "src/pcre/pcre_binding.c" },
.file = b.path("src/pcre/pcre_binding.c"),
.flags = &.{"-std=c17"},
},
);
Expand All @@ -66,7 +64,7 @@ pub fn build(b: *std.Build) void {

const jstring_lib = b.addStaticLibrary(.{
.name = "jstring",
.root_source_file = .{ .path = "src/jstring.zig" },
.root_source_file = b.path("src/jstring.zig"),
.target = target,
.optimize = optimize,
});
Expand Down
4 changes: 2 additions & 2 deletions src/jstring.zig
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ pub const JString = struct {

// ** at

pub inline fn at(this: *JString, index: isize) !u21 {
pub inline fn at(this: *const JString, index: isize) !u21 {
return this.unmanaged.at(index);
}

Expand Down Expand Up @@ -948,7 +948,7 @@ pub const JStringUnmanaged = struct {
/// different to Javascript's string.at, return unicode char(u21) of index, as prefer utf-8 string. Same to
/// Javascript, accept index as `i32`: when postive is from beginning; when negative is from ending; when
/// `index == 0`, return the the first char if not empty.
pub fn at(this: *JStringUnmanaged, index: isize) Error!u21 {
pub fn at(this: *const JStringUnmanaged, index: isize) Error!u21 {
const utf8_len = try this.utf8Len();
if (index >= utf8_len) {
return error.IndexOutOfBounds;
Expand Down