Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Ports/AvailablePorts.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ This list is also available at [ports.serenityos.net](https://ports.serenityos.n
| [`cowsay`](cowsay/) | cowsay | 3.04 | https://github.com/tnalpgge/rank-amateur-cowsay |
| [`cpio`](cpio/) | GNU cpio archive utility | 2.15 | https://www.gnu.org/software/cpio/ |
| [`curl`](curl/) | curl | 8.22.0 | https://curl.se/ |
| [`dash`](dash/) | DASH | 0.5.10.2 | http://gondor.apana.org.au/~herbert/dash |
| [`dash`](dash/) | DASH | 0.5.13.5 | http://gondor.apana.org.au/~herbert/dash |
| [`deutex`](deutex/) | DeuTex | 5.2.3 | https://github.com/Doom-Utils/deutex |
| [`DevilutionX`](DevilutionX/) | DevilutionX | 1.5.5 | https://github.com/diasurgical/DevilutionX |
| [`dialog`](dialog/) | Dialog | 1.3-20260721 | https://invisible-island.net/dialog/ |
Expand Down
8 changes: 4 additions & 4 deletions Ports/dash/package.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env -S bash ../.port_include.sh
port=dash
version=0.5.10.2
useconfigure=true
port='dash'
version='0.5.13.5'
useconfigure='true'
files=(
"http://gondor.apana.org.au/~herbert/dash/files/dash-${version}.tar.gz#3c663919dc5c66ec991da14c7cf7e0be8ad00f3db73986a987c118862b5f6071"
"http://gondor.apana.org.au/~herbert/dash/files/dash-${version}.tar.gz#40090101a2a491f13e901d3d48e90414f26634628b9bfff35ff540363c227a7d"
)

configure() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ wait3() does not exist on serenity.
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/jobs.c b/src/jobs.c
index 606d603..92ac84d 100644
index 914b383a953d1e24c72e713ffa67d58895ea26b0..3e2f63ad60025339cf66a65c20c8cf26562a50d8 100644
--- a/src/jobs.c
+++ b/src/jobs.c
@@ -1147,7 +1147,7 @@ waitproc(int block, int *status)

do {
gotsigchld = 0;
- err = wait3(status, flags, NULL);
+ err = waitpid(-1, status, flags);
if (err || !block)
break;
@@ -1208,7 +1208,7 @@ waitproc(int block, int *status)
#ifdef HAVE_WAIT3
err = wait3(status, flags, NULL);
#else
- err = waitpid((pid_t)-1, status, flags, NULL);
+ err = waitpid((pid_t)-1, status, flags);
#endif
while (err < 0 && errno == EINTR);

12 changes: 6 additions & 6 deletions Ports/dash/patches/0002-Skip-building-helpers-by-default.patch
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ Subject: [PATCH] Skip building helpers by default
2 files changed, 5 insertions(+)

diff --git a/configure.ac b/configure.ac
index 4829288..9f9a155 100644
index a247d95cc63f4434f5af3dcf741abb61170578c9..f99ba6093cdc65d8a846aa3fc7eacd5bfe87d3bf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -181,5 +181,8 @@ AC_ARG_ENABLE(lineno, AS_HELP_STRING(--disable-lineno, \
@@ -228,5 +228,8 @@ AC_ARG_ENABLE(lineno, AS_HELP_STRING(--disable-lineno, \
if test "$enable_lineno" != "no"; then
AC_DEFINE([WITH_LINENO], 1, [Define if you build with -DWITH_LINENO])
fi
Expand All @@ -22,16 +22,16 @@ index 4829288..9f9a155 100644
AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT
diff --git a/src/Makefile.am b/src/Makefile.am
index 139355e..e95491a 100644
index 173246535de4c8058a5f61ffbc3df569a44ec556..a128d0f2eb979e4a6aa0fddb2c2ee4e1bc622f76 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -66,7 +66,9 @@ syntax.c syntax.h: mksyntax
@@ -64,7 +64,9 @@ syntax.c syntax.h: mksyntax
signames.c: mksignames
./$^
$(AM_V_GEN)./$^

+if BUILD_HELPERS
mksyntax: token.h

$(HELPERS): %: %.c
$(COMPILE_FOR_BUILD) -o $@ $<
$(AM_V_CC)$(COMPILE_FOR_BUILD) -o $@ $<
+endif
1 change: 1 addition & 0 deletions Tests/LibC/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ set(TEST_SOURCES
TestSnprintf.cpp
TestStackSmash.cpp
TestStdio.cpp
TestStpncpy.cpp
TestStrlcpy.cpp
TestStrtodAccuracy.cpp
TestTruncate.cpp
Expand Down
50 changes: 50 additions & 0 deletions Tests/LibC/TestStpncpy.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2026, Linus Groh <mail@linusgroh.de>
*
* SPDX-License-Identifier: BSD-2-Clause
*/

#include <LibTest/TestCase.h>

#include <string.h>

TEST_CASE(src_longer_than_dest)
{
char dest[8] = {};
memset(dest, 'X', sizeof(dest));

char* result = stpncpy(dest, "Hello World!", sizeof(dest));
EXPECT_EQ(result, dest + sizeof(dest));
EXPECT(memcmp(dest, "Hello Wo", sizeof(dest)) == 0);
}

TEST_CASE(src_shorter_than_dest)
{
char dest[8] = {};
memset(dest, 'X', sizeof(dest));

char* result = stpncpy(dest, "Hello", sizeof(dest));
EXPECT_EQ(result, dest + 5);
EXPECT(memcmp(dest, "Hello\0\0\0", sizeof(dest)) == 0);
}

TEST_CASE(dest_empty)
{
char dest[8] = {};
memset(dest, 'X', sizeof(dest));

char* result = stpncpy(dest, "Hello World!", 0);
EXPECT_EQ(result, dest);
EXPECT(memcmp(dest, "XXXXXXXX", sizeof(dest)) == 0);
}

TEST_CASE(nul_in_src)
{
char dest[8] = {};
memset(dest, 'X', sizeof(dest));

char const src[] = { 'a', 'b', '\0', 'c', 'd' };
char* result = stpncpy(dest, src, sizeof(dest));
EXPECT_EQ(result, dest + 2);
EXPECT(memcmp(dest, "ab\0\0\0\0\0\0", sizeof(dest)) == 0);
}
12 changes: 12 additions & 0 deletions Userland/Libraries/LibC/string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,18 @@ char* stpcpy(char* dest, char const* src)
return dest;
}

// https://pubs.opengroup.org/onlinepubs/9699919799/functions/stpncpy.html
char* stpncpy(char* dest, char const* src, size_t n)
{
size_t i;
for (i = 0; i < n && src[i] != '\0'; ++i)
dest[i] = src[i];
char* result = &dest[i];
for (; i < n; ++i)
dest[i] = '\0';
return result;
}

// https://pubs.opengroup.org/onlinepubs/9699919799/functions/strncpy.html
char* strncpy(char* dest, char const* src, size_t n)
{
Expand Down
1 change: 1 addition & 0 deletions Userland/Libraries/LibC/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ __attribute__((malloc)) char* strndup(char const*, size_t);
char* strcpy(char* dest, char const* src);
char* stpcpy(char* dest, char const* src);
char* strncpy(char* dest, char const* src, size_t);
char* stpncpy(char* dest, char const* src, size_t);
__attribute__((warn_unused_result)) size_t strlcpy(char* dest, char const* src, size_t);

char* strchr(char const*, int c);
Expand Down
Loading