Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9241d92

Browse files
authoredFeb 25, 2025··
Merge pull request #5 from Shopify/fix-c-api-ci
Fix c-api branch's build
2 parents 0b9043c + fb738b4 commit 9241d92

File tree

6 files changed

+27
-12
lines changed

6 files changed

+27
-12
lines changed
 

‎include/rbs/defines.h

+4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@
5151
* Custom defines for RBS *
5252
**********************************************************************************************************************/
5353

54+
#if defined(_MSC_VER)
55+
#define NODISCARD _Check_return_
56+
#else
5457
#define NODISCARD __attribute__((warn_unused_result))
58+
#endif
5559

5660
#endif

‎include/rbs/parserstate.h

+5
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ lexstate *alloc_lexer(rbs_allocator_t *, rbs_string_t string, const rbs_encoding
130130
parserstate *alloc_parser(rbs_string_t string, const rbs_encoding_t *encoding, int start_pos, int end_pos);
131131
void free_parser(parserstate *parser);
132132

133+
/**
134+
* Declare type variables to be used during parsing.
135+
* */
136+
void rbs_parser_declare_type_variables(parserstate *parser, size_t count, const char **variables);
137+
133138
/**
134139
* Advance one token.
135140
* */

‎make_signed_ruby.rb

-2
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ def sign_bundle(bundle_path)
123123
PLIST
124124

125125
Tempfile.create("entitlements.plist") do |entitlements_file|
126-
entitlements_path = entitlements_file.path
127-
128126
args = [
129127
"/usr/bin/codesign",
130128
"--force", # Replace the existing signiture, if any

‎src/parser.c

+16-9
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,16 @@ void set_error(parserstate *state, token tok, bool syntax_error, const char *fmt
130130
return;
131131
}
132132

133-
char *message;
134-
135133
va_list args;
134+
136135
va_start(args, fmt);
137-
vasprintf(&message, fmt, args);
136+
int length = vsnprintf(NULL, 0, fmt, args);
137+
va_end(args);
138+
139+
char *message = (char *) malloc(length + 1);
140+
141+
va_start(args, fmt);
142+
vsnprintf(message, length + 1, fmt, args);
138143
va_end(args);
139144

140145
state->error = (error *)malloc(sizeof(error));
@@ -202,15 +207,15 @@ static bool parse_type_name(parserstate *state, TypeNameKind kind, range *rg, rb
202207
switch (state->current_token.type) {
203208
case tLIDENT:
204209
if (kind & ALIAS_NAME) goto success;
205-
goto error;
210+
goto error_handling;
206211
case tULIDENT:
207212
if (kind & INTERFACE_NAME) goto success;
208-
goto error;
213+
goto error_handling;
209214
case tUIDENT:
210215
if (kind & CLASS_NAME) goto success;
211-
goto error;
216+
goto error_handling;
212217
default:
213-
goto error;
218+
goto error_handling;
214219
}
215220

216221
success: {
@@ -225,8 +230,8 @@ static bool parse_type_name(parserstate *state, TypeNameKind kind, range *rg, rb
225230
return true;
226231
}
227232

228-
error: {
229-
const char *ids;
233+
error_handling: {
234+
const char *ids = NULL;
230235
if (kind & ALIAS_NAME) {
231236
ids = "alias name";
232237
}
@@ -237,6 +242,8 @@ static bool parse_type_name(parserstate *state, TypeNameKind kind, range *rg, rb
237242
ids = "class/module/constant name";
238243
}
239244

245+
assert(ids != NULL && "Unknown kind of type");
246+
240247
set_error(state, state->current_token, true, "expected one of %s", ids);
241248
return false;
242249
}

‎src/parserstate.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ parserstate *alloc_parser(rbs_string_t string, const rbs_encoding_t *encoding, i
355355
return parser;
356356
}
357357

358-
void rbs_parser_declare_type_variables(parserstate *parser, size_t count, const char *variables[count]) {
358+
void rbs_parser_declare_type_variables(parserstate *parser, size_t count, const char **variables) {
359359
if (variables == NULL) return; // Nothing to do.
360360

361361
parser_push_typevar_table(parser, true);

‎src/util/rbs_allocator.c

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <stdlib.h>
2020
#include <assert.h>
2121
#include <string.h> // for memset()
22+
#include <stdint.h>
2223

2324
#ifdef _WIN32
2425
#include <windows.h>

0 commit comments

Comments
 (0)
Please sign in to comment.