Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attempt at using VarArgs annotation for variable arguments list #381

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,19 @@ void test_varargs_invocation() {
ASSERT(varargs_i(1, 91, 92, 93) == 92);
ASSERT(varargs_i(2, 91, 92, 93) == 93);

}
}

char * invoke_vsnprintf(char *fmt, ...) {
char *x = malloc(100);
va_list args;
va_start(args, fmt);
vsnprintf(x, 100, fmt, args);
va_end(args);
return x;
}

void test_vsnprintf() {

ASSERT(strcmp(invoke_vsnprintf("Hello %s, you have %d messages", "Bob", 99), "Hello Bob, you have 99 messages") == 0);

}
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,10 @@ public static int sprintf(BytePtr string, BytePtr format, Object... arguments) {
return snprintf(string, Integer.MAX_VALUE, format, arguments);
}

public static int vsnprintf(BytePtr string, int limit, BytePtr format, Object... arguments) {
return snprintf(string, limit, format, arguments);
}

public static int snprintf(BytePtr string, int limit, BytePtr format, Object... arguments) {

String outputString;
Expand Down