Skip to content

Commit 03e89fd

Browse files
[libc] Add vsscanf function
1 parent 3402a1a commit 03e89fd

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed

libc/spec/stdc.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,13 @@ def StdC : StandardSpec<"stdc"> {
968968
RetValSpec<IntType>,
969969
[ArgSpec<IntType>, ArgSpec<FILEPtr>]
970970
>,
971+
FunctionSpec<
972+
"vsscanf",
973+
RetValSpec<IntType>,
974+
[ArgSpec<ConstCharPtr>,
975+
ArgSpec<ConstCharPtr>,
976+
ArgSpec<VaListType>]
977+
>,
971978
],
972979
[
973980
ObjectSpec<

libc/src/stdio/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,16 @@ add_entrypoint_object(
203203
libc.src.stdio.printf_core.vfprintf_internal
204204
)
205205

206+
add_entrypoint_object(
207+
vsscanf
208+
SRCS
209+
vsscanf.cpp
210+
HDRS
211+
vsscanf.h
212+
DEPENDS
213+
libc.src.__support.arg_list
214+
)
215+
206216
add_stdio_entrypoint_object(
207217
fileno
208218
SRCS

libc/src/stdio/vsscanf.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//===-- Implementation of vsscanf -------------------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "src/stdio/vsscanf.h"
10+
11+
#include "src/__support/arg_list.h"
12+
13+
#include <stdarg.h>
14+
15+
namespace LIBC_NAMESPACE {
16+
17+
LLVM_LIBC_FUNCTION(int, vsscanf, (const char *, const char *, va_list vlist)) {
18+
internal::ArgList args(vlist); // This holder class allows for easier copying
19+
// and pointer semantics, as well as handling
20+
// destruction automatically.
21+
22+
return -1;
23+
}
24+
25+
} // namespace LIBC_NAMESPACE

libc/src/stdio/vsscanf.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===-- Implementation header of vsscanf ------------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIBC_SRC_STDIO_VSSCANF_H
10+
#define LLVM_LIBC_SRC_STDIO_VSSCANF_H
11+
12+
#include <stdarg.h>
13+
14+
namespace LIBC_NAMESPACE {
15+
16+
int vsscanf(const char *s, const char *format, va_list vlist);
17+
18+
} // namespace LIBC_NAMESPACE
19+
20+
#endif // LLVM_LIBC_SRC_STDIO_VSSCANF_H

0 commit comments

Comments
 (0)