Skip to content

Commit

Permalink
Update version to 4.0.5 and fix POSIX compliance
Browse files Browse the repository at this point in the history
  • Loading branch information
horta committed Jun 17, 2024
1 parent a293d38 commit bdde38c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.16.3 FATAL_ERROR)
project(
athr
VERSION 4.0.4
VERSION 4.0.5
LANGUAGES C)
set(PROJECT_DESCRIPTION "Progress indicator library written in C.")

Expand Down
5 changes: 5 additions & 0 deletions src/term_curses.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200809L
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif

#include "term_curses.h"
#include "logger.h"
#include "terminal.h"
Expand Down
16 changes: 15 additions & 1 deletion src/widget_text.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,26 @@ static unsigned max_len(struct athr_widget const *w)
return ((struct athr_widget_text *)w->derived)->len;
}

static void *__memccpy(void *restrict dest, const void *restrict src, int c,
size_t n)
{
unsigned char *d = dest;
const unsigned char *s = src;

c = (unsigned char)c;
for (; n && (*d = *s) != c; n--, s++, d++)
;
return n ? d + 1 : 0;
if (n) return d + 1;
return 0;
}

static struct athr_widget_vtable const vtable = {update, finish, min_len,
max_len};

void __athr_widget_text_create(struct athr_widget_text *text, char const *buff)
{
char const *ptr = memccpy(text->buff, buff, 0, ATHR_WIDGET_TEXT_MAX_LEN);
char const *ptr = __memccpy(text->buff, buff, 0, ATHR_WIDGET_TEXT_MAX_LEN);
if (ptr)
text->len = (unsigned)(ptr - text->buff - 1);
else
Expand Down

0 comments on commit bdde38c

Please sign in to comment.