1
0
mirror of https://git.disroot.org/80486DX2-66/polonium.git synced 2024-11-08 13:42:31 +05:30

downgrade POSIX C source version to 2001-12

Implement `strdup` to not require version 2008-09
This commit is contained in:
Intel A80486DX2-66 2024-08-06 22:49:43 +03:00
parent 20fb02fdf2
commit adb7e9884d
Signed by: 80486DX2-66
GPG Key ID: 83631EF27054609B
5 changed files with 31 additions and 1 deletions

View File

@ -2,7 +2,7 @@ CC ?= gcc
DEBUG ?= 0
CFLAGS = -Wall -Werror -Wextra -Wpedantic -std=c99 -Ofast \
-D_POSIX_C_SOURCE=200809L
-D_POSIX_C_SOURCE=200112L
ifeq ($(DEBUG), 1)
CFLAGS += -g -DDEBUG

View File

@ -6,6 +6,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
/* enums */
enum configurations_bitshift {

11
include/strdup.h Normal file
View File

@ -0,0 +1,11 @@
#ifndef _STRDUP_H
#define _STRDUP_H
#include <errno.h>
#include <stdlib.h>
#include <string.h>
/* functions definitions */
char* strdup(const char* s);
#endif /* _STRDUP_H */

View File

@ -23,6 +23,7 @@
#include "atoumax_base10.h"
#include "corrupter.h"
#include "file_type.h"
#include "strdup.h"
/* enums */
enum arg_destinations {

17
src/strdup.c Normal file
View File

@ -0,0 +1,17 @@
#include "strdup.h"
/* function implementations */
char* strdup(const char* s) {
if (s == NULL) {
errno = EINVAL;
return NULL;
}
char* copy = malloc((strlen(s) + 1) * sizeof(char));
if (copy == NULL)
return NULL;
strcpy(copy, s);
return copy;
}