Skip to content

Commit

Permalink
Fix: JS compilation and missing symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
ashvardanian committed Jan 18, 2024
1 parent 97d749d commit d86d453
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ Before you ship, please make sure the packaging works.
cibuildwheel --platform linux
```

## Contributing in JavaScript

```bash
npm ci && npm test
```

## Roadmap

The project is in its early stages of development.
Expand Down
8 changes: 7 additions & 1 deletion binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
"target_name": "stringzilla",
"sources": ["javascript/lib.c"],
"include_dirs": ["include"],
"cflags": ["-std=c99", "-Wno-unknown-pragmas", "-Wno-maybe-uninitialized"],
"cflags": [
"-std=c99",
"-Wno-unknown-pragmas",
"-Wno-maybe-uninitialized",
"-Wno-cast-function-type",
"-Wno-unused-function",
],
}
]
}
2 changes: 1 addition & 1 deletion include/stringzilla/stringzilla.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
* Debugging and testing.
*/
#ifndef SZ_DEBUG
#ifndef NDEBUG
#ifndef NDEBUG // This means "Not using DEBUG information".
#define SZ_DEBUG 1
#else
#define SZ_DEBUG 0
Expand Down
7 changes: 4 additions & 3 deletions javascript/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
* @copyright Copyright (c) 2023
* @see NodeJS docs: https://nodejs.org/api/n-api.html
*/
#include <stdio.h> // `printf` for debug builds
#include <stdlib.h> // `malloc` to export strings into UTF-8

#include <node_api.h> // `napi_*` functions

#include <node_api.h> // `napi_*` functions
#include <stdlib.h> // `malloc`
#include <stringzilla/stringzilla.h> // `sz_*` functions

napi_value indexOfAPI(napi_env env, napi_callback_info info) {
Expand Down Expand Up @@ -74,7 +76,6 @@ napi_value countAPI(napi_env env, napi_callback_info info) {

size_t count = 0;
if (needle.length == 0 || haystack.length == 0 || haystack.length < needle.length) { count = 0; }
else if (needle.length == 1) { count = sz_count_char(haystack.start, haystack.length, needle.start); }
else if (overlap) {
while (haystack.length) {
sz_cptr_t ptr = sz_find(haystack.start, haystack.length, needle.start, needle.length);
Expand Down

0 comments on commit d86d453

Please sign in to comment.