Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/Makefile b/Makefile
- index f0fa37a..dd22b84 100644
- --- a/Makefile
- +++ b/Makefile
- @@ -1,3 +1,4 @@
- +# Add -DNEEDS_STRCHRNUL to end of CFLAGS if necessary
- CFLAGS = -ggdb3 -O0 -march=native -std=gnu99 -Wall
- LDFLAGS = $(CFLAGS) -lz
- RARAS = ./raras
- @@ -14,7 +15,7 @@ RARLD = ./rarld
- all: raras rarld sample.rar test
- rarld: rarld.o bitbuffer.o
- -raras: parser.o raras.o bitbuffer.o
- +raras: strchrnul.o parser.o raras.o bitbuffer.o
- bitbuffer_test: bitbuffer_test.o bitbuffer.o
- test: bitbuffer_test
- diff --git a/raras.c b/raras.c
- index 5ee96ea..e4be757 100644
- --- a/raras.c
- +++ b/raras.c
- @@ -22,6 +22,8 @@
- #include "bitbuffer.h"
- #include "rar.h"
- +#include "strchrnul.h"
- +
- int main(int argc, char **argv)
- {
- FILE *input = NULL;
- diff --git a/strchrnul.c b/strchrnul.c
- new file mode 100644
- index 0000000..a3fec5e
- --- /dev/null
- +++ b/strchrnul.c
- @@ -0,0 +1,14 @@
- +#include <string.h>
- +#include "strchrnul.h"
- +
- +char *strchrnul(const char *s, int c)
- +{
- + char *ptr = strchr(s, c);
- +
- + if (!ptr)
- + {
- + ptr = strchr(s, '\0');
- + }
- +
- + return ptr;
- +}
- \ No newline at end of file
- diff --git a/strchrnul.h b/strchrnul.h
- new file mode 100644
- index 0000000..b7fb1bb
- --- /dev/null
- +++ b/strchrnul.h
- @@ -0,0 +1,8 @@
- +#ifndef __STRCHRNUL_H
- +#define __STRCHRNUL_H
- +
- +#ifdef NEEDS_STRCHRNUL
- + char *strchrnul(const char *s, int c);
- +#endif
- +
- +#endif
- \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement