Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
libretro-handy
Commits
feddd545
Unverified
Commit
feddd545
authored
Oct 01, 2021
by
Libretro-Admin
Committed by
GitHub
Oct 01, 2021
Browse files
Merge pull request #95 from jdgleaver/vfs-no-fullpath
Assorted Improvements
parents
39a84f93
73b26adf
Pipeline
#56493
passed with stages
in 1 minute and 36 seconds
Changes
52
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Makefile
View file @
feddd545
...
...
@@ -580,7 +580,7 @@ CORE_DIR := .
include
Makefile.common
OBJECTS
:=
$(SOURCES_CXX:.cpp=.o)
OBJECTS
:=
$(SOURCES_CXX:.cpp=.o)
$(SOURCES_C:.c=.o)
ifeq
($(DEBUG),1)
FLAGS
+=
-O0
-g
...
...
Makefile.common
View file @
feddd545
...
...
@@ -17,15 +17,33 @@ ifeq ($(FRONTEND_SUPPORTS_XRGB8888), 1)
FLAGS
+=
-DFRONTEND_SUPPORTS_XRGB8888
endif
SOURCES_CXX
:=
$(CORE_DIR)
/lynx/lynxdec.cpp
\
$(CORE_DIR)
/lynx/cart.cpp
\
$(CORE_DIR)
/lynx/memmap.cpp
\
$(CORE_DIR)
/lynx/mikie.cpp
\
$(CORE_DIR)
/lynx/ram.cpp
\
$(CORE_DIR)
/lynx/rom.cpp
\
$(CORE_DIR)
/lynx/susie.cpp
\
$(CORE_DIR)
/lynx/system.cpp
\
$(CORE_DIR)
/lynx/eeprom.cpp
\
$(CORE_DIR)
/libretro/libretro.cpp
\
$(CORE_DIR)
/blip/Blip_Buffer.cpp
\
$(CORE_DIR)
/blip/Stereo_Buffer.cpp
SOURCES_CXX
:=
\
$(CORE_DIR)
/lynx/lynxdec.cpp
\
$(CORE_DIR)
/lynx/cart.cpp
\
$(CORE_DIR)
/lynx/memmap.cpp
\
$(CORE_DIR)
/lynx/mikie.cpp
\
$(CORE_DIR)
/lynx/ram.cpp
\
$(CORE_DIR)
/lynx/rom.cpp
\
$(CORE_DIR)
/lynx/susie.cpp
\
$(CORE_DIR)
/lynx/system.cpp
\
$(CORE_DIR)
/lynx/eeprom.cpp
\
$(CORE_DIR)
/libretro/libretro.cpp
\
$(CORE_DIR)
/blip/Blip_Buffer.cpp
\
$(CORE_DIR)
/blip/Stereo_Buffer.cpp
ifneq
($(STATIC_LINKING), 1)
SOURCES_C
:=
\
$(LIBRETRO_COMM_DIR)
/compat/compat_posix_string.c
\
$(LIBRETRO_COMM_DIR)
/compat/compat_snprintf.c
\
$(LIBRETRO_COMM_DIR)
/compat/compat_strcasestr.c
\
$(LIBRETRO_COMM_DIR)
/compat/compat_strl.c
\
$(LIBRETRO_COMM_DIR)
/compat/fopen_utf8.c
\
$(LIBRETRO_COMM_DIR)
/encodings/encoding_utf.c
\
$(LIBRETRO_COMM_DIR)
/file/file_path.c
\
$(LIBRETRO_COMM_DIR)
/file/file_path_io.c
\
$(LIBRETRO_COMM_DIR)
/streams/file_stream.c
\
$(LIBRETRO_COMM_DIR)
/streams/file_stream_transforms.c
\
$(LIBRETRO_COMM_DIR)
/string/stdstring.c
\
$(LIBRETRO_COMM_DIR)
/time/rtime.c
\
$(LIBRETRO_COMM_DIR)
/vfs/vfs_implementation.c
endif
blip/Blip_Buffer.cpp
View file @
feddd545
...
...
@@ -127,7 +127,23 @@ void Blip_Buffer::bass_freq( int freq )
void
Blip_Buffer
::
end_frame
(
blip_time_t
t
)
{
offset_
+=
t
*
factor_
;
assert
(
samples_avail
()
<=
(
long
)
buffer_size_
);
// time outside buffer length
// When using a 'fake' internal BIOS, core
// timers are started 'artificially' on
// load content. When using a real BIOS file
// this does not happen - and it takes one frame
// for the timers to start counting normally.
// This makes the first frame unusually 'long'
// (very high cycle count), which overflows
// the blip buffer. To enable the use of a real
// BIOS file, we therefore have to cap offset_
// here by resetting internal blip buffer counters
// and clearing any waiting samples in the event
// of an overflow
// > Original code just used an assert():
// assert( samples_avail() <= (long) buffer_size_ ); // time outside buffer length
if
(
samples_avail
()
>
(
long
)
buffer_size_
)
clear
(
0
);
}
void
Blip_Buffer
::
remove_silence
(
long
count
)
...
...
jni/Android.mk
View file @
feddd545
...
...
@@ -13,8 +13,9 @@ endif
include
$(CLEAR_VARS)
LOCAL_MODULE
:=
retro
LOCAL_SRC_FILES
:=
$(SOURCES_CXX)
LOCAL_SRC_FILES
:=
$(SOURCES_CXX)
$(SOURCES_C)
LOCAL_CXXFLAGS
:=
$(COREFLAGS)
LOCAL_CFLAGS
:=
$(COREFLAGS)
LOCAL_LDFLAGS
:=
-Wl
,-version-script
=
$(CORE_DIR)
/libretro/link.T
LOCAL_LDLIBS
:=
-lz
include
$(BUILD_SHARED_LIBRARY)
libretro-common/compat/compat_posix_string.c
0 → 100644
View file @
feddd545
/* Copyright (C) 2010-2020 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (compat_posix_string.c).
* ---------------------------------------------------------------------------------------
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <ctype.h>
#include <compat/posix_string.h>
#ifdef _WIN32
#undef strcasecmp
#undef strdup
#undef isblank
#undef strtok_r
#include <ctype.h>
#include <stdlib.h>
#include <stddef.h>
#include <compat/strl.h>
#include <string.h>
int
retro_strcasecmp__
(
const
char
*
a
,
const
char
*
b
)
{
while
(
*
a
&&
*
b
)
{
int
a_
=
tolower
(
*
a
);
int
b_
=
tolower
(
*
b
);
if
(
a_
!=
b_
)
return
a_
-
b_
;
a
++
;
b
++
;
}
return
tolower
(
*
a
)
-
tolower
(
*
b
);
}
char
*
retro_strdup__
(
const
char
*
orig
)
{
size_t
len
=
strlen
(
orig
)
+
1
;
char
*
ret
=
(
char
*
)
malloc
(
len
);
if
(
!
ret
)
return
NULL
;
strlcpy
(
ret
,
orig
,
len
);
return
ret
;
}
int
retro_isblank__
(
int
c
)
{
return
(
c
==
' '
)
||
(
c
==
'\t'
);
}
char
*
retro_strtok_r__
(
char
*
str
,
const
char
*
delim
,
char
**
saveptr
)
{
char
*
first
=
NULL
;
if
(
!
saveptr
||
!
delim
)
return
NULL
;
if
(
str
)
*
saveptr
=
str
;
do
{
char
*
ptr
=
NULL
;
first
=
*
saveptr
;
while
(
*
first
&&
strchr
(
delim
,
*
first
))
*
first
++
=
'\0'
;
if
(
*
first
==
'\0'
)
return
NULL
;
ptr
=
first
+
1
;
while
(
*
ptr
&&
!
strchr
(
delim
,
*
ptr
))
ptr
++
;
*
saveptr
=
ptr
+
(
*
ptr
?
1
:
0
);
*
ptr
=
'\0'
;
}
while
(
strlen
(
first
)
==
0
);
return
first
;
}
#endif
libretro-common/compat/compat_snprintf.c
0 → 100644
View file @
feddd545
/* Copyright (C) 2010-2020 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (compat_snprintf.c).
* ---------------------------------------------------------------------------------------
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* THIS FILE HAS NOT BEEN VALIDATED ON PLATFORMS BESIDES MSVC */
#ifdef _MSC_VER
#include <stdio.h>
#include <stdarg.h>
#if _MSC_VER < 1800
#define va_copy(dst, src) ((dst) = (src))
#endif
#if _MSC_VER < 1300
#define _vscprintf c89_vscprintf_retro__
static
int
c89_vscprintf_retro__
(
const
char
*
fmt
,
va_list
pargs
)
{
int
retval
;
va_list
argcopy
;
va_copy
(
argcopy
,
pargs
);
retval
=
vsnprintf
(
NULL
,
0
,
fmt
,
argcopy
);
va_end
(
argcopy
);
return
retval
;
}
#endif
/* http://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010 */
int
c99_vsnprintf_retro__
(
char
*
s
,
size_t
len
,
const
char
*
fmt
,
va_list
ap
)
{
int
count
=
-
1
;
if
(
len
!=
0
)
{
#if (_MSC_VER <= 1310)
count
=
_vsnprintf
(
s
,
len
-
1
,
fmt
,
ap
);
#else
count
=
_vsnprintf_s
(
s
,
len
,
len
-
1
,
fmt
,
ap
);
#endif
}
if
(
count
==
-
1
)
count
=
_vscprintf
(
fmt
,
ap
);
/* there was no room for a NULL, so truncate the last character */
if
(
count
==
len
&&
len
)
s
[
len
-
1
]
=
'\0'
;
return
count
;
}
int
c99_snprintf_retro__
(
char
*
s
,
size_t
len
,
const
char
*
fmt
,
...)
{
int
count
;
va_list
ap
;
va_start
(
ap
,
fmt
);
count
=
c99_vsnprintf_retro__
(
s
,
len
,
fmt
,
ap
);
va_end
(
ap
);
return
count
;
}
#endif
libretro-common/compat/compat_strcasestr.c
0 → 100644
View file @
feddd545
/* Copyright (C) 2010-2020 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (compat_strcasestr.c).
* ---------------------------------------------------------------------------------------
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <ctype.h>
#include <compat/strcasestr.h>
/* Pretty much strncasecmp. */
static
int
casencmp
(
const
char
*
a
,
const
char
*
b
,
size_t
n
)
{
size_t
i
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
int
a_lower
=
tolower
(
a
[
i
]);
int
b_lower
=
tolower
(
b
[
i
]);
if
(
a_lower
!=
b_lower
)
return
a_lower
-
b_lower
;
}
return
0
;
}
char
*
strcasestr_retro__
(
const
char
*
haystack
,
const
char
*
needle
)
{
size_t
i
,
search_off
;
size_t
hay_len
=
strlen
(
haystack
);
size_t
needle_len
=
strlen
(
needle
);
if
(
needle_len
>
hay_len
)
return
NULL
;
search_off
=
hay_len
-
needle_len
;
for
(
i
=
0
;
i
<=
search_off
;
i
++
)
if
(
!
casencmp
(
haystack
+
i
,
needle
,
needle_len
))
return
(
char
*
)
haystack
+
i
;
return
NULL
;
}
libretro-common/compat/compat_strl.c
0 → 100644
View file @
feddd545
/* Copyright (C) 2010-2020 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (compat_strl.c).
* ---------------------------------------------------------------------------------------
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdlib.h>
#include <ctype.h>
#include <compat/strl.h>
/* Implementation of strlcpy()/strlcat() based on OpenBSD. */
#ifndef __MACH__
size_t
strlcpy
(
char
*
dest
,
const
char
*
source
,
size_t
size
)
{
size_t
src_size
=
0
;
size_t
n
=
size
;
if
(
n
)
while
(
--
n
&&
(
*
dest
++
=
*
source
++
))
src_size
++
;
if
(
!
n
)
{
if
(
size
)
*
dest
=
'\0'
;
while
(
*
source
++
)
src_size
++
;
}
return
src_size
;
}
size_t
strlcat
(
char
*
dest
,
const
char
*
source
,
size_t
size
)
{
size_t
len
=
strlen
(
dest
);
dest
+=
len
;
if
(
len
>
size
)
size
=
0
;
else
size
-=
len
;
return
len
+
strlcpy
(
dest
,
source
,
size
);
}
#endif
char
*
strldup
(
const
char
*
s
,
size_t
n
)
{
char
*
dst
=
(
char
*
)
malloc
(
sizeof
(
char
)
*
(
n
+
1
));
strlcpy
(
dst
,
s
,
n
);
return
dst
;
}
libretro-common/compat/fopen_utf8.c
0 → 100644
View file @
feddd545
/* Copyright (C) 2010-2020 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (fopen_utf8.c).
* ---------------------------------------------------------------------------------------
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <compat/fopen_utf8.h>
#include <encodings/utf.h>
#include <stdio.h>
#include <stdlib.h>
#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0500 || defined(_XBOX)
#ifndef LEGACY_WIN32
#define LEGACY_WIN32
#endif
#endif
#ifdef _WIN32
#undef fopen
void
*
fopen_utf8
(
const
char
*
filename
,
const
char
*
mode
)
{
#if defined(LEGACY_WIN32)
FILE
*
ret
=
NULL
;
char
*
filename_local
=
utf8_to_local_string_alloc
(
filename
);
if
(
!
filename_local
)
return
NULL
;
ret
=
fopen
(
filename_local
,
mode
);
if
(
filename_local
)
free
(
filename_local
);
return
ret
;
#else
wchar_t
*
filename_w
=
utf8_to_utf16_string_alloc
(
filename
);
wchar_t
*
mode_w
=
utf8_to_utf16_string_alloc
(
mode
);
FILE
*
ret
=
NULL
;
if
(
filename_w
&&
mode_w
)
ret
=
_wfopen
(
filename_w
,
mode_w
);
if
(
filename_w
)
free
(
filename_w
);
if
(
mode_w
)
free
(
mode_w
);
return
ret
;
#endif
}
#endif
libretro-common/encodings/encoding_utf.c
0 → 100644
View file @
feddd545
/* Copyright (C) 2010-2020 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (encoding_utf.c).
* ---------------------------------------------------------------------------------------
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdint.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <boolean.h>
#include <compat/strl.h>
#include <retro_inline.h>
#include <encodings/utf.h>
#if defined(_WIN32) && !defined(_XBOX)
#include <windows.h>
#elif defined(_XBOX)
#include <xtl.h>
#endif
#define UTF8_WALKBYTE(string) (*((*(string))++))
static
unsigned
leading_ones
(
uint8_t
c
)
{
unsigned
ones
=
0
;
while
(
c
&
0x80
)
{
ones
++
;
c
<<=
1
;
}
return
ones
;
}
/* Simple implementation. Assumes the sequence is
* properly synchronized and terminated. */
size_t
utf8_conv_utf32
(
uint32_t
*
out
,
size_t
out_chars
,
const
char
*
in
,
size_t
in_size
)
{
unsigned
i
;
size_t
ret
=
0
;
while
(
in_size
&&
out_chars
)
{
unsigned
extra
,
shift
;
uint32_t
c
;
uint8_t
first
=
*
in
++
;
unsigned
ones
=
leading_ones
(
first
);
if
(
ones
>
6
||
ones
==
1
)
/* Invalid or desync. */
break
;
extra
=
ones
?
ones
-
1
:
ones
;
if
(
1
+
extra
>
in_size
)
/* Overflow. */
break
;
shift
=
(
extra
-
1
)
*
6
;
c
=
(
first
&
((
1
<<
(
7
-
ones
))
-
1
))
<<
(
6
*
extra
);
for
(
i
=
0
;
i
<
extra
;
i
++
,
in
++
,
shift
-=
6
)
c
|=
(
*
in
&
0x3f
)
<<
shift
;
*
out
++
=
c
;
in_size
-=
1
+
extra
;
out_chars
--
;
ret
++
;
}
return
ret
;
}
bool
utf16_conv_utf8
(
uint8_t
*
out
,
size_t
*
out_chars
,
const
uint16_t
*
in
,
size_t
in_size
)
{
size_t
out_pos
=
0
;
size_t
in_pos
=
0
;
static
const
uint8_t
utf8_limits
[
5
]
=
{
0xC0
,
0xE0
,
0xF0
,
0xF8
,
0xFC
};
for
(;;)
{
unsigned
num_adds
;
uint32_t
value
;
if
(
in_pos
==
in_size
)
{
*
out_chars
=
out_pos
;
return
true
;
}
value
=
in
[
in_pos
++
];
if
(
value
<
0x80
)
{
if
(
out
)
out
[
out_pos
]
=
(
char
)
value
;
out_pos
++
;
continue
;
}
if
(
value
>=
0xD800
&&
value
<
0xE000
)
{
uint32_t
c2
;
if
(
value
>=
0xDC00
||
in_pos
==
in_size
)
break
;
c2
=
in
[
in_pos
++
];
if
(
c2
<
0xDC00
||
c2
>=
0xE000
)
break
;
value
=
(((
value
-
0xD800
)
<<
10
)
|
(
c2
-
0xDC00
))
+
0x10000
;
}
for
(
num_adds
=
1
;
num_adds
<
5
;
num_adds
++
)
if
(
value
<
(((
uint32_t
)
1
)
<<
(
num_adds
*
5
+
6
)))
break
;
if
(
out
)
out
[
out_pos
]
=
(
char
)(
utf8_limits
[
num_adds
-
1
]
+
(
value
>>
(
6
*
num_adds
)));
out_pos
++
;
do
{