Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
itdan3344
stb
提交
ec3fecd2
S
stb
项目概览
itdan3344
/
stb
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
stb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ec3fecd2
编写于
1月 22, 2016
作者:
S
Sean Barrett
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'stb_h_fix'
上级
e0dafae0
820f63be
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
89 addition
and
37 deletion
+89
-37
stb.h
stb.h
+82
-34
stb_tilemap_editor.h
stb_tilemap_editor.h
+6
-2
tests/stb.dsp
tests/stb.dsp
+1
-1
未找到文件。
stb.h
浏览文件 @
ec3fecd2
/* stb.h - v2.2
5
- Sean's Tool Box -- public domain -- http://nothings.org/stb.h
/* stb.h - v2.2
6
- Sean's Tool Box -- public domain -- http://nothings.org/stb.h
no warranty is offered or implied; use this code at your own risk
This is a single header file with a bunch of useful utilities
...
...
@@ -25,6 +25,7 @@
Version History
2.26 various warning & buffixes
2.25 various warning & bugfixes
2.24 various warning & bugfixes
2.23 fix 2.22
...
...
@@ -186,6 +187,9 @@ CREDITS
Mojofreem@github
Ryan Whitworth
Vincent Isambart
Mike Sartain
Eugene Opalev
Tim Sjostrand
*/
#ifndef STB__INCLUDE_STB_H
...
...
@@ -206,10 +210,16 @@ CREDITS
#endif
#endif
#ifdef _WIN32
#if defined(_WIN32) && !defined(__MINGW32__)
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif
#ifndef _CRT_NONSTDC_NO_DEPRECATE
#define _CRT_NONSTDC_NO_DEPRECATE
#endif
#ifndef _CRT_NON_CONFORMING_SWPRINTFS
#define _CRT_NON_CONFORMING_SWPRINTFS
#endif
#if !defined(_MSC_VER) || _MSC_VER > 1700
#include <intrin.h> // _BitScanReverse
#endif
...
...
@@ -714,20 +724,41 @@ STB_EXTERN char * stb_sstrdup(char *s);
STB_EXTERN
void
stbprint
(
const
char
*
fmt
,
...);
STB_EXTERN
char
*
stb_sprintf
(
const
char
*
fmt
,
...);
STB_EXTERN
char
*
stb_mprintf
(
const
char
*
fmt
,
...);
STB_EXTERN
int
stb_snprintf
(
char
*
s
,
size_t
n
,
const
char
*
fmt
,
...);
STB_EXTERN
int
stb_vsnprintf
(
char
*
s
,
size_t
n
,
const
char
*
fmt
,
va_list
v
);
#ifdef STB_DEFINE
int
stb_vsnprintf
(
char
*
s
,
size_t
n
,
const
char
*
fmt
,
va_list
v
)
{
int
res
;
#ifdef _WIN32
// Could use "_vsnprintf_s(s, n, _TRUNCATE, fmt, v)" ?
res
=
_vsnprintf
(
s
,
n
,
fmt
,
v
);
#else
res
=
vsnprintf
(
s
,
n
,
fmt
,
v
);
#endif
if
(
n
)
s
[
n
-
1
]
=
0
;
// Unix returns length output would require, Windows returns negative when truncated.
return
(
res
>=
(
int
)
n
||
res
<
0
)
?
-
1
:
res
;
}
int
stb_snprintf
(
char
*
s
,
size_t
n
,
const
char
*
fmt
,
...)
{
int
res
;
va_list
v
;
va_start
(
v
,
fmt
);
res
=
stb_vsnprintf
(
s
,
n
,
fmt
,
v
);
va_end
(
v
);
return
res
;
}
char
*
stb_sprintf
(
const
char
*
fmt
,
...)
{
static
char
buffer
[
1024
];
va_list
v
;
va_start
(
v
,
fmt
);
#ifdef _WIN32
_vsnprintf
(
buffer
,
1024
,
fmt
,
v
);
#else
vsnprintf
(
buffer
,
1024
,
fmt
,
v
);
#endif
stb_vsnprintf
(
buffer
,
1024
,
fmt
,
v
);
va_end
(
v
);
buffer
[
1023
]
=
0
;
return
buffer
;
}
...
...
@@ -736,13 +767,8 @@ char *stb_mprintf(const char *fmt, ...)
static
char
buffer
[
1024
];
va_list
v
;
va_start
(
v
,
fmt
);
#ifdef _WIN32
_vsnprintf
(
buffer
,
1024
,
fmt
,
v
);
#else
vsnprintf
(
buffer
,
1024
,
fmt
,
v
);
#endif
stb_vsnprintf
(
buffer
,
1024
,
fmt
,
v
);
va_end
(
v
);
buffer
[
1023
]
=
0
;
return
strdup
(
buffer
);
}
...
...
@@ -842,9 +868,8 @@ void stbprint(const char *fmt, ...)
va_list
v
;
va_start
(
v
,
fmt
);
res
=
_vsnprintf
(
buffer
,
sizeof
(
buffer
),
fmt
,
v
);
res
=
stb
_vsnprintf
(
buffer
,
sizeof
(
buffer
),
fmt
,
v
);
va_end
(
v
);
buffer
[
sizeof
(
buffer
)
-
1
]
=
0
;
if
(
res
<
0
)
{
tbuf
=
(
char
*
)
malloc
(
16384
);
...
...
@@ -1765,6 +1790,7 @@ STB_EXTERN char * stb_strichr(char *s, char t);
STB_EXTERN
char
*
stb_stristr
(
char
*
s
,
char
*
t
);
STB_EXTERN
int
stb_prefix_count
(
char
*
s
,
char
*
t
);
STB_EXTERN
char
*
stb_plural
(
int
n
);
// "s" or ""
STB_EXTERN
size_t
stb_strscpy
(
char
*
d
,
const
char
*
s
,
size_t
n
);
STB_EXTERN
char
**
stb_tokens
(
char
*
src
,
char
*
delimit
,
int
*
count
);
STB_EXTERN
char
**
stb_tokens_nested
(
char
*
src
,
char
*
delimit
,
int
*
count
,
char
*
nest_in
,
char
*
nest_out
);
...
...
@@ -1779,6 +1805,17 @@ STB_EXTERN char **stb_tokens_quoted(char *src, char *delimit, int *count);
#ifdef STB_DEFINE
size_t
stb_strscpy
(
char
*
d
,
const
char
*
s
,
size_t
n
)
{
size_t
len
=
strlen
(
s
);
if
(
len
>=
n
)
{
if
(
n
)
d
[
0
]
=
0
;
return
0
;
}
strcpy
(
d
,
s
);
return
len
+
1
;
}
char
*
stb_plural
(
int
n
)
{
return
n
==
1
?
""
:
"s"
;
...
...
@@ -3062,7 +3099,7 @@ typedef struct
#define stb_arr_insertn(a,i,n) (stb__arr_insertn((void **) &(a), sizeof(*a), i, n))
// insert an element at i
#define stb_arr_insert(a,i,v) (stb__arr_insertn((void **) &(a), sizeof(*a), i,
n
), ((a)[i] = v))
#define stb_arr_insert(a,i,v) (stb__arr_insertn((void **) &(a), sizeof(*a), i,
1
), ((a)[i] = v))
// delete N elements from the middle starting at index 'i'
#define stb_arr_deleten(a,i,n) (stb__arr_deleten((void **) &(a), sizeof(*a), i, n))
...
...
@@ -3248,7 +3285,7 @@ void stb__arr_insertn_(void **pp, int size, int i, int n STB__PARAMS)
}
z
=
stb_arr_len2
(
p
);
stb__arr_addlen_
(
&
p
,
size
,
i
STB__ARGS
);
stb__arr_addlen_
(
&
p
,
size
,
n
STB__ARGS
);
memmove
((
char
*
)
p
+
(
i
+
n
)
*
size
,
(
char
*
)
p
+
i
*
size
,
size
*
(
z
-
i
));
}
*
pp
=
p
;
...
...
@@ -3258,7 +3295,7 @@ void stb__arr_deleten_(void **pp, int size, int i, int n STB__PARAMS)
{
void
*
p
=
*
pp
;
if
(
n
)
{
memmove
((
char
*
)
p
+
i
*
size
,
(
char
*
)
p
+
(
i
+
n
)
*
size
,
size
*
(
stb_arr_len2
(
p
)
-
i
));
memmove
((
char
*
)
p
+
i
*
size
,
(
char
*
)
p
+
(
i
+
n
)
*
size
,
size
*
(
stb_arr_len2
(
p
)
-
(
i
+
n
)
));
stb_arrhead2
(
p
)
->
len
-=
n
;
}
*
pp
=
p
;
...
...
@@ -5863,11 +5900,18 @@ void stb_readdir_free(char **files)
stb_arr_free
(
f2
);
}
static
int
isdotdirname
(
char
*
name
)
{
if
(
name
[
0
]
==
'.'
)
return
(
name
[
1
]
==
'.'
)
?
!
name
[
2
]
:
!
name
[
1
];
return
0
;
}
STB_EXTERN
int
stb_wildmatchi
(
char
*
expr
,
char
*
candidate
);
static
char
**
readdir_raw
(
char
*
dir
,
int
return_subdirs
,
char
*
mask
)
{
char
**
results
=
NULL
;
char
buffer
[
512
],
with_slash
[
512
];
char
buffer
[
4096
],
with_slash
[
4096
];
size_t
n
;
#ifdef _MSC_VER
...
...
@@ -5885,25 +5929,28 @@ static char **readdir_raw(char *dir, int return_subdirs, char *mask)
DIR
*
z
;
#endif
strcpy
(
buffer
,
dir
);
n
=
stb_strscpy
(
buffer
,
dir
,
sizeof
(
buffer
));
if
(
!
n
||
n
>=
sizeof
(
buffer
))
return
NULL
;
stb_fixpath
(
buffer
);
n
=
strlen
(
buffer
)
;
n
--
;
if
(
n
>
0
&&
(
buffer
[
n
-
1
]
!=
'/'
))
{
buffer
[
n
++
]
=
'/'
;
}
buffer
[
n
]
=
0
;
strcpy
(
with_slash
,
buffer
);
if
(
!
stb_strscpy
(
with_slash
,
buffer
,
sizeof
(
with_slash
)))
return
NULL
;
#ifdef _MSC_VER
strcpy
(
buffer
+
n
,
"*.*"
);
if
(
!
stb_strscpy
(
buffer
+
n
,
"*.*"
,
sizeof
(
buffer
)
-
n
))
return
NULL
;
ws
=
stb__from_utf8
(
buffer
);
z
=
_wfindfirst
((
const
wchar_t
*
)
ws
,
&
data
);
#else
z
=
opendir
(
dir
);
#endif
if
(
z
!=
none
)
{
int
nonempty
=
STB_TRUE
;
#ifndef _MSC_VER
...
...
@@ -5924,17 +5971,18 @@ static char **readdir_raw(char *dir, int return_subdirs, char *mask)
is_subdir
=
!!
(
data
.
attrib
&
_A_SUBDIR
);
#else
char
*
name
=
data
->
d_name
;
strcpy
(
buffer
+
n
,
name
);
DIR
*
y
=
opendir
(
buffer
)
;
is_subdir
=
(
y
!=
NULL
);
i
f
(
y
!=
NULL
)
closedir
(
y
);
if
(
!
stb_strscpy
(
buffer
+
n
,
name
,
sizeof
(
buffer
)
-
n
))
break
;
// Could follow DT_LNK, but would need to check for recursive links.
i
s_subdir
=
!!
(
data
->
d_type
&
DT_DIR
);
#endif
if
(
is_subdir
==
return_subdirs
)
{
if
(
!
is_subdir
||
name
[
0
]
!=
'.'
)
{
if
(
!
is_subdir
||
!
isdotdirname
(
name
)
)
{
if
(
!
mask
||
stb_wildmatchi
(
mask
,
name
))
{
char
buffer
[
512
],
*
p
=
buffer
;
sprintf
(
buffer
,
"%s%s"
,
with_slash
,
name
);
char
buffer
[
4096
],
*
p
=
buffer
;
if
(
stb_snprintf
(
buffer
,
sizeof
(
buffer
),
"%s%s"
,
with_slash
,
name
)
<
0
)
break
;
if
(
buffer
[
0
]
==
'.'
&&
buffer
[
1
]
==
'/'
)
p
=
buffer
+
2
;
stb_arr_push
(
results
,
strdup
(
p
));
...
...
@@ -7786,7 +7834,7 @@ stb_ps *stb_ps_remove_any(stb_ps *ps, void **value)
void
**
stb_ps_getlist
(
stb_ps
*
ps
,
int
*
count
)
{
int
i
,
n
=
0
;
void
**
p
;
void
**
p
=
NULL
;
switch
(
3
&
(
int
)
ps
)
{
case
STB_ps_direct
:
if
(
ps
==
NULL
)
{
*
count
=
0
;
return
NULL
;
}
...
...
stb_tilemap_editor.h
浏览文件 @
ec3fecd2
// stb_tilemap_editor.h - v0.3
6
- Sean Barrett - http://nothings.org/stb
// stb_tilemap_editor.h - v0.3
7
- Sean Barrett - http://nothings.org/stb
// placed in the public domain - not copyrighted - first released 2014-09
//
// Embeddable tilemap editor for C/C++
...
...
@@ -259,7 +259,7 @@
// #define STBTE_MAX_CATEGORIES 100
// #define STBTE_UNDO_BUFFER_BYTES (1 << 24) // 16 MB
// #define STBTE_MAX_COPY 90000 // e.g. 300x300
// #define STBTE_MAX_PROPERTIES
ERTIES
10 // max properties per tile
// #define STBTE_MAX_PROPERTIES 10 // max properties per tile
//
// API
//
...
...
@@ -275,6 +275,7 @@
// either approach allows cut&pasting between levels.)
//
// REVISION HISTORY
// 0.37 fix warning
// 0.36 minor compiler support
// 0.35 layername button changes
// - layername buttons grow with the layer panel
...
...
@@ -311,6 +312,7 @@
// Josh Huelsman
// Bugfixes:
// Ryan Whitworth
// Eugene Opalev
//
// LICENSE
//
...
...
@@ -328,7 +330,9 @@
#define STB_TILEMAP_INCLUDE_STB_TILEMAP_EDITOR_H
#ifdef _WIN32
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <stdlib.h>
#include <stdio.h>
#endif
...
...
tests/stb.dsp
浏览文件 @
ec3fecd2
...
...
@@ -66,7 +66,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /GX /Zi /Od /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "
VORBIS
_TEST" /FR /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /GX /Zi /Od /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "
MAIN
_TEST" /FR /FD /GZ /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录