Skip to content

Commit 48432be

Browse files
[libc]: Add vsscanf function
1 parent 3402a1a commit 48432be

File tree

4 files changed

+66
-0
lines changed

4 files changed

+66
-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: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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,
18+
(const char *, const char *,
19+
va_list vlist)) {
20+
internal::ArgList args(vlist); // This holder class allows for easier copying
21+
// and pointer semantics, as well as handling
22+
// destruction automatically.
23+
24+
25+
return -1;
26+
}
27+
28+
} // namespace LIBC_NAMESPACE

libc/src/stdio/vsscanf.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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,
17+
va_list vlist);
18+
19+
} // namespace LIBC_NAMESPACE
20+
21+
#endif // LLVM_LIBC_SRC_STDIO_VSSCANF_H

0 commit comments

Comments
 (0)