Advertisement
flarn2006

Patch to add strchrnul to RarVM

Oct 31st, 2012
617
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.43 KB | None | 0 0
  1. diff --git a/Makefile b/Makefile
  2. index f0fa37a..dd22b84 100644
  3. --- a/Makefile
  4. +++ b/Makefile
  5. @@ -1,3 +1,4 @@
  6. +# Add -DNEEDS_STRCHRNUL to end of CFLAGS if necessary
  7.  CFLAGS = -ggdb3 -O0 -march=native -std=gnu99 -Wall
  8.  LDFLAGS    = $(CFLAGS) -lz
  9.  RARAS  = ./raras
  10. @@ -14,7 +15,7 @@ RARLD = ./rarld
  11.  
  12.  all:   raras rarld sample.rar test
  13.  rarld: rarld.o bitbuffer.o
  14. -raras: parser.o raras.o bitbuffer.o
  15. +raras: strchrnul.o parser.o raras.o bitbuffer.o
  16.  bitbuffer_test: bitbuffer_test.o bitbuffer.o
  17.  
  18.  test: bitbuffer_test
  19. diff --git a/raras.c b/raras.c
  20. index 5ee96ea..e4be757 100644
  21. --- a/raras.c
  22. +++ b/raras.c
  23. @@ -22,6 +22,8 @@
  24.  #include "bitbuffer.h"
  25.  #include "rar.h"
  26.  
  27. +#include "strchrnul.h"
  28. +
  29.  int main(int argc, char **argv)
  30.  {
  31.      FILE     *input       = NULL;
  32. diff --git a/strchrnul.c b/strchrnul.c
  33. new file mode 100644
  34. index 0000000..a3fec5e
  35. --- /dev/null
  36. +++ b/strchrnul.c
  37. @@ -0,0 +1,14 @@
  38. +#include <string.h>
  39. +#include "strchrnul.h"
  40. +
  41. +char *strchrnul(const char *s, int c)
  42. +{
  43. +   char *ptr = strchr(s, c);
  44. +  
  45. +   if (!ptr)
  46. +   {
  47. +       ptr = strchr(s, '\0');
  48. +   }
  49. +  
  50. +   return ptr;
  51. +}
  52. \ No newline at end of file
  53. diff --git a/strchrnul.h b/strchrnul.h
  54. new file mode 100644
  55. index 0000000..b7fb1bb
  56. --- /dev/null
  57. +++ b/strchrnul.h
  58. @@ -0,0 +1,8 @@
  59. +#ifndef __STRCHRNUL_H
  60. +#define __STRCHRNUL_H
  61. +
  62. +#ifdef NEEDS_STRCHRNUL
  63. +   char *strchrnul(const char *s, int c);
  64. +#endif
  65. +
  66. +#endif
  67. \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement