Do away with POSIX
This commit is contained in:
parent
fedde03f1e
commit
f0337aa481
2
Makefile
2
Makefile
|
@ -1,4 +1,4 @@
|
||||||
CFLAGS = -std=gnu99 -Wall -Wextra -ggdb
|
CFLAGS = -std=c99 -Wall -Wextra -ggdb
|
||||||
all: ell
|
all: ell
|
||||||
ell: ell.c
|
ell: ell.c
|
||||||
$(CC) $(CFLAGS) $< -o $@
|
$(CC) $(CFLAGS) $< -o $@
|
||||||
|
|
18
ell.c
18
ell.c
|
@ -17,8 +17,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _XOPEN_SOURCE 500
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -28,7 +26,6 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <strings.h>
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
|
|
||||||
|
@ -53,12 +50,12 @@ vformat (const char *format, va_list ap) {
|
||||||
if (size < 0)
|
if (size < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
char buf[size + 1];
|
char *buf = malloc (size + 1);
|
||||||
size = vsnprintf (buf, sizeof buf, format, ap);
|
if (buf && vsnprintf (buf, size + 1, format, ap) < 0) {
|
||||||
if (size < 0)
|
free (buf);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
return strdup (buf);
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
|
@ -184,10 +181,7 @@ new_clone_list (const struct item *item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct item *
|
static struct item *
|
||||||
new_string (const char *s, ssize_t len) {
|
new_string (const char *s, size_t len) {
|
||||||
if (len < 0)
|
|
||||||
len = strlen (s);
|
|
||||||
|
|
||||||
struct item *item = calloc (1, sizeof *item + len + 1);
|
struct item *item = calloc (1, sizeof *item + len + 1);
|
||||||
if (!item)
|
if (!item)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue