diff --git a/libretro-common/compat/compat_fnmatch.c b/libretro-common/compat/compat_fnmatch.c index 19f87cc76a..4c817dd612 100644 --- a/libretro-common/compat/compat_fnmatch.c +++ b/libretro-common/compat/compat_fnmatch.c @@ -20,9 +20,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#if __TEST_FNMATCH__ -#include -#endif #include #include @@ -123,37 +120,3 @@ int rl_fnmatch(const char *pattern, const char *string, int flags) return 0; return FNM_NOMATCH; } - -#if __TEST_FNMATCH__ -int main(void) -{ - assert(rl_fnmatch("TEST", "TEST", 0) == 0); - assert(rl_fnmatch("TE?T", "TEST", 0) == 0); - assert(rl_fnmatch("TE[Ssa]T", "TEST", 0) == 0); - assert(rl_fnmatch("TE[Ssda]T", "TEsT", 0) == 0); - assert(rl_fnmatch("TE[Ssda]T", "TEdT", 0) == 0); - assert(rl_fnmatch("TE[Ssda]T", "TEaT", 0) == 0); - assert(rl_fnmatch("TEST*", "TEST", 0) == 0); - assert(rl_fnmatch("TEST**", "TEST", 0) == 0); - assert(rl_fnmatch("TE*ST*", "TEST", 0) == 0); - assert(rl_fnmatch("TE**ST*", "TEST", 0) == 0); - assert(rl_fnmatch("TE**ST*", "TExST", 0) == 0); - assert(rl_fnmatch("TE**ST", "TEST", 0) == 0); - assert(rl_fnmatch("TE**ST", "TExST", 0) == 0); - assert(rl_fnmatch("TE\\**ST", "TE*xST", 0) == 0); - assert(rl_fnmatch("*.*", "test.jpg", 0) == 0); - assert(rl_fnmatch("*.jpg", "test.jpg", 0) == 0); - assert(rl_fnmatch("*.[Jj][Pp][Gg]", "test.jPg", 0) == 0); - assert(rl_fnmatch("*.[Jj]*[Gg]", "test.jPg", 0) == 0); - assert(rl_fnmatch("TEST?", "TEST", 0) == FNM_NOMATCH); - assert(rl_fnmatch("TES[asd", "TEST", 0) == FNM_NOMATCH); - assert(rl_fnmatch("TEST\\", "TEST", 0) == FNM_NOMATCH); - assert(rl_fnmatch("TEST*S", "TEST", 0) == FNM_NOMATCH); - assert(rl_fnmatch("TE**ST", "TExT", 0) == FNM_NOMATCH); - assert(rl_fnmatch("TE\\*T", "TExT", 0) == FNM_NOMATCH); - assert(rl_fnmatch("TES?", "TES", 0) == FNM_NOMATCH); - assert(rl_fnmatch("TE", "TEST", 0) == FNM_NOMATCH); - assert(rl_fnmatch("TEST!", "TEST", 0) == FNM_NOMATCH); - assert(rl_fnmatch("DSAD", "TEST", 0) == FNM_NOMATCH); -} -#endif diff --git a/libretro-common/net/net_http_parse.c b/libretro-common/net/net_http_parse.c index 113eeaa00a..96de3eadbf 100644 --- a/libretro-common/net/net_http_parse.c +++ b/libretro-common/net/net_http_parse.c @@ -84,20 +84,3 @@ int string_parse_html_anchor(const char *line, char *link, char *name, return 0; } - -#ifndef RARCH_INTERNAL -int main(int argc, char *argv[]) -{ - char link[1024]; - char name[1024]; - const char *line = "Test\n"; - - link[0] = name[0] = '\0'; - - string_parse_html_anchor(line, link, name, sizeof(link), sizeof(name)); - - printf("link: %s\nname: %s\n", link, name); - - return 1; -} -#endif diff --git a/libretro-common/samples/compat/fnmatch/Makefile b/libretro-common/samples/compat/fnmatch/Makefile new file mode 100644 index 0000000000..66d741ad9c --- /dev/null +++ b/libretro-common/samples/compat/fnmatch/Makefile @@ -0,0 +1,24 @@ +TARGET := compat_fnmatch_test + +LIBRETRO_COMM_DIR := ../../.. + +SOURCES := \ + compat_fnmatch_test.c \ + $(LIBRETRO_COMM_DIR)/compat/compat_fnmatch.c + +OBJS := $(SOURCES:.c=.o) + +CFLAGS += -Wall -pedantic -std=gnu99 -g -I$(LIBRETRO_COMM_DIR)/include + +all: $(TARGET) + +%.o: %.c + $(CC) -c -o $@ $< $(CFLAGS) + +$(TARGET): $(OBJS) + $(CC) -o $@ $^ $(LDFLAGS) + +clean: + rm -f $(TARGET) $(OBJS) + +.PHONY: clean diff --git a/libretro-common/samples/compat/fnmatch/compat_fnmatch_test.c b/libretro-common/samples/compat/fnmatch/compat_fnmatch_test.c new file mode 100644 index 0000000000..42c33667c0 --- /dev/null +++ b/libretro-common/samples/compat/fnmatch/compat_fnmatch_test.c @@ -0,0 +1,58 @@ +/* Copyright (C) 2010-2020 The RetroArch team + * + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (compat_fnmatch_test.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 +#include + +#include + +int main(void) +{ + assert(rl_fnmatch("TEST", "TEST", 0) == 0); + assert(rl_fnmatch("TE?T", "TEST", 0) == 0); + assert(rl_fnmatch("TE[Ssa]T", "TEST", 0) == 0); + assert(rl_fnmatch("TE[Ssda]T", "TEsT", 0) == 0); + assert(rl_fnmatch("TE[Ssda]T", "TEdT", 0) == 0); + assert(rl_fnmatch("TE[Ssda]T", "TEaT", 0) == 0); + assert(rl_fnmatch("TEST*", "TEST", 0) == 0); + assert(rl_fnmatch("TEST**", "TEST", 0) == 0); + assert(rl_fnmatch("TE*ST*", "TEST", 0) == 0); + assert(rl_fnmatch("TE**ST*", "TEST", 0) == 0); + assert(rl_fnmatch("TE**ST*", "TExST", 0) == 0); + assert(rl_fnmatch("TE**ST", "TEST", 0) == 0); + assert(rl_fnmatch("TE**ST", "TExST", 0) == 0); + assert(rl_fnmatch("TE\\**ST", "TE*xST", 0) == 0); + assert(rl_fnmatch("*.*", "test.jpg", 0) == 0); + assert(rl_fnmatch("*.jpg", "test.jpg", 0) == 0); + assert(rl_fnmatch("*.[Jj][Pp][Gg]", "test.jPg", 0) == 0); + assert(rl_fnmatch("*.[Jj]*[Gg]", "test.jPg", 0) == 0); + assert(rl_fnmatch("TEST?", "TEST", 0) == FNM_NOMATCH); + assert(rl_fnmatch("TES[asd", "TEST", 0) == FNM_NOMATCH); + assert(rl_fnmatch("TEST\\", "TEST", 0) == FNM_NOMATCH); + assert(rl_fnmatch("TEST*S", "TEST", 0) == FNM_NOMATCH); + assert(rl_fnmatch("TE**ST", "TExT", 0) == FNM_NOMATCH); + assert(rl_fnmatch("TE\\*T", "TExT", 0) == FNM_NOMATCH); + assert(rl_fnmatch("TES?", "TES", 0) == FNM_NOMATCH); + assert(rl_fnmatch("TE", "TEST", 0) == FNM_NOMATCH); + assert(rl_fnmatch("TEST!", "TEST", 0) == FNM_NOMATCH); + assert(rl_fnmatch("DSAD", "TEST", 0) == FNM_NOMATCH); +} diff --git a/libretro-common/samples/net/Makefile b/libretro-common/samples/net/Makefile index 4d5908b637..6c523d5e66 100644 --- a/libretro-common/samples/net/Makefile +++ b/libretro-common/samples/net/Makefile @@ -1,4 +1,4 @@ -TARGETS = http_test net_ifinfo +TARGETS = http_test http_parse_test net_ifinfo LIBRETRO_COMM_DIR := ../.. @@ -37,6 +37,19 @@ HTTP_TEST_C = \ HTTP_TEST_OBJS := $(HTTP_TEST_C:.c=.o) +HTTP_PARSE_TEST_C = \ + $(LIBRETRO_COMM_DIR)/net/net_http.c \ + $(LIBRETRO_COMM_DIR)/net/net_http_parse.c \ + $(LIBRETRO_COMM_DIR)/net/net_compat.c \ + $(LIBRETRO_COMM_DIR)/net/net_socket.c \ + $(LIBRETRO_COMM_DIR)/compat/compat_strl.c \ + $(LIBRETRO_COMM_DIR)/compat/compat_strcasestr.c \ + $(LIBRETRO_COMM_DIR)/encodings/encoding_utf.c \ + $(LIBRETRO_COMM_DIR)/string/stdstring.c \ + net_http_parse_test.c + +HTTP_PARSE_TEST_OBJS := $(HTTP_PARSE_TEST_C:.c=.o) + NET_IFINFO_C = \ $(LIBRETRO_COMM_DIR)/net/net_ifinfo.c \ net_ifinfo_test.c @@ -54,6 +67,9 @@ all: $(TARGETS) %.o: %.c $(CC) $(INCFLAGS) $< -c $(CFLAGS) -o $@ +http_parse_test: $(HTTP_PARSE_TEST_OBJS) + $(CC) $(INCFLAGS) $(HTTP_PARSE_TEST_OBJS) $(CFLAGS) -o $@ + http_test: $(HTTP_TEST_OBJS) $(CC) $(INCFLAGS) $(HTTP_TEST_OBJS) $(CFLAGS) -o $@ @@ -61,4 +77,4 @@ net_ifinfo: $(NET_IFINFO_OBJS) $(CC) $(INCFLAGS) $(NET_IFINFO_OBJS) $(CFLAGS) -o $@ clean: - rm -rf $(TARGETS) $(HTTP_TEST_OBJS) $(NET_IFINFO_OBJS) + rm -rf $(TARGETS) $(HTTP_TEST_OBJS) $(HTTP_PARSE_TEST_OBJS) $(NET_IFINFO_OBJS) diff --git a/libretro-common/samples/net/http_test b/libretro-common/samples/net/http_test deleted file mode 100755 index bcdeb816d8..0000000000 Binary files a/libretro-common/samples/net/http_test and /dev/null differ diff --git a/libretro-common/samples/net/net_http_parse_test.c b/libretro-common/samples/net/net_http_parse_test.c new file mode 100644 index 0000000000..014b89fe88 --- /dev/null +++ b/libretro-common/samples/net/net_http_parse_test.c @@ -0,0 +1,39 @@ +/* Copyright (C) 2010-2020 The RetroArch team + * + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (net_http_parse_test.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 +#include + +int main(int argc, char *argv[]) +{ + char link[1024]; + char name[1024]; + const char *line = "Test\n"; + + link[0] = name[0] = '\0'; + + string_parse_html_anchor(line, link, name, sizeof(link), sizeof(name)); + + printf("link: %s\nname: %s\n", link, name); + + return 1; +} diff --git a/libretro-common/samples/net/net_ifinfo b/libretro-common/samples/net/net_ifinfo deleted file mode 100755 index 0b8dc0ee7c..0000000000 Binary files a/libretro-common/samples/net/net_ifinfo and /dev/null differ