mirror of
https://git.disroot.org/80486DX2-66/polonium.git
synced 2024-11-08 21:52:34 +05:30
downgrade POSIX C source version to 2001-12
Implement `strdup` to not require version 2008-09
This commit is contained in:
parent
20fb02fdf2
commit
adb7e9884d
2
Makefile
2
Makefile
@ -2,7 +2,7 @@ CC ?= gcc
|
|||||||
DEBUG ?= 0
|
DEBUG ?= 0
|
||||||
|
|
||||||
CFLAGS = -Wall -Werror -Wextra -Wpedantic -std=c99 -Ofast \
|
CFLAGS = -Wall -Werror -Wextra -Wpedantic -std=c99 -Ofast \
|
||||||
-D_POSIX_C_SOURCE=200809L
|
-D_POSIX_C_SOURCE=200112L
|
||||||
|
|
||||||
ifeq ($(DEBUG), 1)
|
ifeq ($(DEBUG), 1)
|
||||||
CFLAGS += -g -DDEBUG
|
CFLAGS += -g -DDEBUG
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
/* enums */
|
/* enums */
|
||||||
enum configurations_bitshift {
|
enum configurations_bitshift {
|
||||||
|
11
include/strdup.h
Normal file
11
include/strdup.h
Normal 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 */
|
@ -23,6 +23,7 @@
|
|||||||
#include "atoumax_base10.h"
|
#include "atoumax_base10.h"
|
||||||
#include "corrupter.h"
|
#include "corrupter.h"
|
||||||
#include "file_type.h"
|
#include "file_type.h"
|
||||||
|
#include "strdup.h"
|
||||||
|
|
||||||
/* enums */
|
/* enums */
|
||||||
enum arg_destinations {
|
enum arg_destinations {
|
||||||
|
17
src/strdup.c
Normal file
17
src/strdup.c
Normal 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;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user