Skip to content

Commit 5568b4e

Browse files
committed
Updates
1 parent d2f9a76 commit 5568b4e

11 files changed

Lines changed: 286 additions & 116 deletions

File tree

compat/compat_fnmatch.c

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2121
*/
2222

23-
#if __TEST_FNMATCH__
24-
#include <assert.h>
25-
#endif
2623
#include <stddef.h>
2724

2825
#include <compat/fnmatch.h>
@@ -123,37 +120,3 @@ int rl_fnmatch(const char *pattern, const char *string, int flags)
123120
return 0;
124121
return FNM_NOMATCH;
125122
}
126-
127-
#if __TEST_FNMATCH__
128-
int main(void)
129-
{
130-
assert(rl_fnmatch("TEST", "TEST", 0) == 0);
131-
assert(rl_fnmatch("TE?T", "TEST", 0) == 0);
132-
assert(rl_fnmatch("TE[Ssa]T", "TEST", 0) == 0);
133-
assert(rl_fnmatch("TE[Ssda]T", "TEsT", 0) == 0);
134-
assert(rl_fnmatch("TE[Ssda]T", "TEdT", 0) == 0);
135-
assert(rl_fnmatch("TE[Ssda]T", "TEaT", 0) == 0);
136-
assert(rl_fnmatch("TEST*", "TEST", 0) == 0);
137-
assert(rl_fnmatch("TEST**", "TEST", 0) == 0);
138-
assert(rl_fnmatch("TE*ST*", "TEST", 0) == 0);
139-
assert(rl_fnmatch("TE**ST*", "TEST", 0) == 0);
140-
assert(rl_fnmatch("TE**ST*", "TExST", 0) == 0);
141-
assert(rl_fnmatch("TE**ST", "TEST", 0) == 0);
142-
assert(rl_fnmatch("TE**ST", "TExST", 0) == 0);
143-
assert(rl_fnmatch("TE\\**ST", "TE*xST", 0) == 0);
144-
assert(rl_fnmatch("*.*", "test.jpg", 0) == 0);
145-
assert(rl_fnmatch("*.jpg", "test.jpg", 0) == 0);
146-
assert(rl_fnmatch("*.[Jj][Pp][Gg]", "test.jPg", 0) == 0);
147-
assert(rl_fnmatch("*.[Jj]*[Gg]", "test.jPg", 0) == 0);
148-
assert(rl_fnmatch("TEST?", "TEST", 0) == FNM_NOMATCH);
149-
assert(rl_fnmatch("TES[asd", "TEST", 0) == FNM_NOMATCH);
150-
assert(rl_fnmatch("TEST\\", "TEST", 0) == FNM_NOMATCH);
151-
assert(rl_fnmatch("TEST*S", "TEST", 0) == FNM_NOMATCH);
152-
assert(rl_fnmatch("TE**ST", "TExT", 0) == FNM_NOMATCH);
153-
assert(rl_fnmatch("TE\\*T", "TExT", 0) == FNM_NOMATCH);
154-
assert(rl_fnmatch("TES?", "TES", 0) == FNM_NOMATCH);
155-
assert(rl_fnmatch("TE", "TEST", 0) == FNM_NOMATCH);
156-
assert(rl_fnmatch("TEST!", "TEST", 0) == FNM_NOMATCH);
157-
assert(rl_fnmatch("DSAD", "TEST", 0) == FNM_NOMATCH);
158-
}
159-
#endif

net/net_http_parse.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,3 @@ int string_parse_html_anchor(const char *line, char *link, char *name,
8484

8585
return 0;
8686
}
87-
88-
#ifndef RARCH_INTERNAL
89-
int main(int argc, char *argv[])
90-
{
91-
char link[1024];
92-
char name[1024];
93-
const char *line = "<a href=\"http://www.test.com/somefile.zip\">Test</a>\n";
94-
95-
link[0] = name[0] = '\0';
96-
97-
string_parse_html_anchor(line, link, name, sizeof(link), sizeof(name));
98-
99-
printf("link: %s\nname: %s\n", link, name);
100-
101-
return 1;
102-
}
103-
#endif
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/* Copyright (C) 2010-2020 The RetroArch team
2+
*
3+
* ---------------------------------------------------------------------------------------
4+
* The following license statement only applies to this file (compat_fnmatch_test.c).
5+
* ---------------------------------------------------------------------------------------
6+
*
7+
* Permission is hereby granted, free of charge,
8+
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
9+
* to deal in the Software without restriction, including without limitation the rights to
10+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11+
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16+
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21+
*/
22+
23+
#include <assert.h>
24+
#include <stddef.h>
25+
26+
#include <compat/fnmatch.h>
27+
28+
int main(void)
29+
{
30+
assert(rl_fnmatch("TEST", "TEST", 0) == 0);
31+
assert(rl_fnmatch("TE?T", "TEST", 0) == 0);
32+
assert(rl_fnmatch("TE[Ssa]T", "TEST", 0) == 0);
33+
assert(rl_fnmatch("TE[Ssda]T", "TEsT", 0) == 0);
34+
assert(rl_fnmatch("TE[Ssda]T", "TEdT", 0) == 0);
35+
assert(rl_fnmatch("TE[Ssda]T", "TEaT", 0) == 0);
36+
assert(rl_fnmatch("TEST*", "TEST", 0) == 0);
37+
assert(rl_fnmatch("TEST**", "TEST", 0) == 0);
38+
assert(rl_fnmatch("TE*ST*", "TEST", 0) == 0);
39+
assert(rl_fnmatch("TE**ST*", "TEST", 0) == 0);
40+
assert(rl_fnmatch("TE**ST*", "TExST", 0) == 0);
41+
assert(rl_fnmatch("TE**ST", "TEST", 0) == 0);
42+
assert(rl_fnmatch("TE**ST", "TExST", 0) == 0);
43+
assert(rl_fnmatch("TE\\**ST", "TE*xST", 0) == 0);
44+
assert(rl_fnmatch("*.*", "test.jpg", 0) == 0);
45+
assert(rl_fnmatch("*.jpg", "test.jpg", 0) == 0);
46+
assert(rl_fnmatch("*.[Jj][Pp][Gg]", "test.jPg", 0) == 0);
47+
assert(rl_fnmatch("*.[Jj]*[Gg]", "test.jPg", 0) == 0);
48+
assert(rl_fnmatch("TEST?", "TEST", 0) == FNM_NOMATCH);
49+
assert(rl_fnmatch("TES[asd", "TEST", 0) == FNM_NOMATCH);
50+
assert(rl_fnmatch("TEST\\", "TEST", 0) == FNM_NOMATCH);
51+
assert(rl_fnmatch("TEST*S", "TEST", 0) == FNM_NOMATCH);
52+
assert(rl_fnmatch("TE**ST", "TExT", 0) == FNM_NOMATCH);
53+
assert(rl_fnmatch("TE\\*T", "TExT", 0) == FNM_NOMATCH);
54+
assert(rl_fnmatch("TES?", "TES", 0) == FNM_NOMATCH);
55+
assert(rl_fnmatch("TE", "TEST", 0) == FNM_NOMATCH);
56+
assert(rl_fnmatch("TEST!", "TEST", 0) == FNM_NOMATCH);
57+
assert(rl_fnmatch("DSAD", "TEST", 0) == FNM_NOMATCH);
58+
}

samples/formats/xml/rxml_test.c

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/* Copyright (C) 2010-2018 The RetroArch team
2+
*
3+
* ---------------------------------------------------------------------------------------
4+
* The following license statement only applies to this file (rxml_test.c).
5+
* ---------------------------------------------------------------------------------------
6+
*
7+
* Permission is hereby granted, free of charge,
8+
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
9+
* to deal in the Software without restriction, including without limitation the rights to
10+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11+
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16+
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21+
*/
22+
23+
#include <formats/rxml.h>
24+
#include <stdio.h>
25+
26+
static void print_siblings(struct rxml_node *node, unsigned level)
27+
{
28+
fprintf(stderr, "\n%*sName: %s\n", level * 4, "", node->name);
29+
if (node->data)
30+
fprintf(stderr, "%*sData: %s\n", level * 4, "", node->data);
31+
32+
for (const struct rxml_attrib_node *attrib =
33+
node->attrib; attrib; attrib = attrib->next)
34+
fprintf(stderr, "%*s Attrib: %s = %s\n", level * 4, "",
35+
attrib->attrib, attrib->value);
36+
37+
if (node->children)
38+
print_siblings(node->children, level + 1);
39+
40+
if (node->next)
41+
print_siblings(node->next, level);
42+
}
43+
44+
static void rxml_log_document(const char *path)
45+
{
46+
rxml_document_t *doc = rxml_load_document(path);
47+
if (!doc)
48+
{
49+
fprintf(stderr, "rxml: Failed to load document: %s\n", path);
50+
return;
51+
}
52+
53+
print_siblings(rxml_root_node(doc), 0);
54+
rxml_free_document(doc);
55+
}
56+
57+
int main(int argc, char *argv[])
58+
{
59+
if (argc != 2)
60+
{
61+
fprintf(stderr, "Usage: %s <path>\n", argv[0]);
62+
return 1;
63+
}
64+
65+
rxml_log_document(argv[1]);
66+
}

samples/net/Makefile

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
TARGETS = http_test net_ifinfo
1+
TARGETS = http_test http_parse_test net_ifinfo
22

33
LIBRETRO_COMM_DIR := ../..
44

@@ -37,6 +37,19 @@ HTTP_TEST_C = \
3737

3838
HTTP_TEST_OBJS := $(HTTP_TEST_C:.c=.o)
3939

40+
HTTP_PARSE_TEST_C = \
41+
$(LIBRETRO_COMM_DIR)/net/net_http.c \
42+
$(LIBRETRO_COMM_DIR)/net/net_http_parse.c \
43+
$(LIBRETRO_COMM_DIR)/net/net_compat.c \
44+
$(LIBRETRO_COMM_DIR)/net/net_socket.c \
45+
$(LIBRETRO_COMM_DIR)/compat/compat_strl.c \
46+
$(LIBRETRO_COMM_DIR)/compat/compat_strcasestr.c \
47+
$(LIBRETRO_COMM_DIR)/encodings/encoding_utf.c \
48+
$(LIBRETRO_COMM_DIR)/string/stdstring.c \
49+
net_http_parse_test.c
50+
51+
HTTP_PARSE_TEST_OBJS := $(HTTP_PARSE_TEST_C:.c=.o)
52+
4053
NET_IFINFO_C = \
4154
$(LIBRETRO_COMM_DIR)/net/net_ifinfo.c \
4255
net_ifinfo_test.c
@@ -54,11 +67,14 @@ all: $(TARGETS)
5467
%.o: %.c
5568
$(CC) $(INCFLAGS) $< -c $(CFLAGS) -o $@
5669

70+
http_parse_test: $(HTTP_PARSE_TEST_OBJS)
71+
$(CC) $(INCFLAGS) $(HTTP_PARSE_TEST_OBJS) $(CFLAGS) -o $@
72+
5773
http_test: $(HTTP_TEST_OBJS)
5874
$(CC) $(INCFLAGS) $(HTTP_TEST_OBJS) $(CFLAGS) -o $@
5975

6076
net_ifinfo: $(NET_IFINFO_OBJS)
6177
$(CC) $(INCFLAGS) $(NET_IFINFO_OBJS) $(CFLAGS) -o $@
6278

6379
clean:
64-
rm -rf $(TARGETS) $(HTTP_TEST_OBJS) $(NET_IFINFO_OBJS)
80+
rm -rf $(TARGETS) $(HTTP_TEST_OBJS) $(HTTP_PARSE_TEST_OBJS) $(NET_IFINFO_OBJS)

samples/net/net_http_parse_test.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/* Copyright (C) 2010-2020 The RetroArch team
2+
*
3+
* ---------------------------------------------------------------------------------------
4+
* The following license statement only applies to this file (net_http_parse_test.c).
5+
* ---------------------------------------------------------------------------------------
6+
*
7+
* Permission is hereby granted, free of charge,
8+
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
9+
* to deal in the Software without restriction, including without limitation the rights to
10+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11+
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16+
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21+
*/
22+
23+
#include <stdio.h>
24+
#include <compat/strcasestr.h>
25+
26+
int main(int argc, char *argv[])
27+
{
28+
char link[1024];
29+
char name[1024];
30+
const char *line = "<a href=\"http://www.test.com/somefile.zip\">Test</a>\n";
31+
32+
link[0] = name[0] = '\0';
33+
34+
string_parse_html_anchor(line, link, name, sizeof(link), sizeof(name));
35+
36+
printf("link: %s\nname: %s\n", link, name);
37+
38+
return 1;
39+
}

samples/utils/Makefile

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ else
5252
EXE_EXT = .exe
5353
endif
5454

55+
PWD_DIR := .
5556
LIBRETRO_COMM_DIR := ../..
5657
CORE_DIR := $(LIBRETRO_COMM_DIR)/utils
5758

@@ -67,23 +68,33 @@ ASMFLAGS := -INEON/asm
6768
asflags += -mfpu=neon
6869
endif
6970

70-
OBJS += $(CORE_DIR)/djb2.o \
71-
$(CORE_DIR)/md5.o \
72-
$(CORE_DIR)/sha1.o \
73-
$(CORE_DIR)/sha1_main.o \
74-
$(CORE_DIR)/crc32.o
71+
DJB2_OBJS := $(CORE_DIR)/djb2.o
72+
73+
MD5_OBJS := $(CORE_DIR)/md5.o \
74+
$(PWD_DIR)/md5_test.o
75+
76+
SHA1_OBJS := $(CORE_DIR)/sha1.o \
77+
$(PWD_DIR)/sha1_main.o
78+
79+
CRC32_OBJS := $(PWD_DIR)/crc32.o \
80+
$(LIBRETRO_COMM_DIR)/compat/fopen_utf8.o \
81+
$(LIBRETRO_COMM_DIR)/compat/compat_strl.o \
82+
$(LIBRETRO_COMM_DIR)/encodings/encoding_utf.o \
83+
$(LIBRETRO_COMM_DIR)/streams/file_stream.o \
84+
$(LIBRETRO_COMM_DIR)/vfs/vfs_implementation.o \
85+
$(LIBRETRO_COMM_DIR)/encodings/encoding_crc32.o
7586

7687
UTILS := djb2$(EXE_EXT) md5$(EXE_EXT) sha1$(EXE_EXT) crc32$(EXE_EXT)
7788

7889
all: $(UTILS)
7990

80-
djb2$(EXE_EXT): $(CORE_DIR)/djb2.o
91+
djb2$(EXE_EXT): $(DJB2_OBJS)
8192

82-
md5$(EXE_EXT): $(CORE_DIR)/md5.o
93+
md5$(EXE_EXT): $(MD5_OBJS)
8394

84-
sha1$(EXE_EXT): $(CORE_DIR)/sha1.o $(CORE_DIR)/sha1_main.o
95+
sha1$(EXE_EXT): $(SHA1_OBJS)
8596

86-
crc32$(EXE_EXT): $(CORE_DIR)/crc32.o $(CORE_DIR)/../encodings/encoding_crc32.o
97+
crc32$(EXE_EXT): $(CRC32_OBJS)
8798

8899
%.o: %.S
89100
$(CC) -c -o $@ $(asflags) $(LDFLAGS) $(ASMFLAGS) $<
File renamed without changes.

0 commit comments

Comments
 (0)