Permalink
Browse files

worked around compile issues with 1.9.3-p0 on CentOS 5.4

  • Loading branch information...
1 parent 37e9580 commit ae5fd3d100a3ab0622b5666b6a17bad15ef8cafc Peter Ohler committed Apr 13, 2012
Showing with 44 additions and 25 deletions.
  1. +1 −0 .gitignore
  2. +2 −2 README.md
  3. +12 −20 ext/oj/dump.c
  4. +11 −0 ext/oj/extconf.rb
  5. +11 −0 ext/oj/fast.c
  6. +1 −1 lib/oj/version.rb
  7. +6 −2 notes
View
@@ -8,5 +8,6 @@ Makefile
*.bundle
.rbenv-version
*.rbc
+.rbx
doc
.yardoc
View
@@ -24,9 +24,9 @@ A fast JSON parser and Object marshaller as a Ruby gem.
## <a name="release">Release Notes</a>
-### Release 1.2.3
+### Release 1.2.4
- - Fixed compile error for the latest RBX on Travis.
+ - Removed all use of math.h to get around CentOS 5.4 compile problem.
## <a name="description">Description</a>
View
@@ -34,7 +34,6 @@
#include <time.h>
#include <stdio.h>
#include <string.h>
-#include <math.h>
#include "oj.h"
#include "cache8.h"
@@ -43,6 +42,8 @@
#define rb_eEncodingError rb_eException
#endif
+#define DBL_INF 1.e500
+
typedef unsigned long ulong;
typedef struct _Out {
@@ -391,39 +392,30 @@ dump_bignum(VALUE obj, Out out) {
*out->cur = '\0';
}
+// Removed dependencies on math due to problems with CentOS 5.4.
static void
dump_float(VALUE obj, Out out) {
char buf[64];
char *b;
double d = rb_num2dbl(obj);
int cnt;
- switch (fpclassify(d)) {
- case FP_NAN:
- printf("*** nan\n");
- cnt = sprintf(buf, "%0.16g", d); // used sprintf due to bug in snprintf
- break;
- case FP_INFINITE:
- b = buf;
- cnt = 8;
- if (d < 0.0) {
- *b++ = '-';
- cnt++;
- }
- strcpy(b, "Infinity");
- break;
- case FP_ZERO:
+ if (0.0 == d) {
b = buf;
*b++ = '0';
*b++ = '.';
*b++ = '0';
*b++ = '\0';
cnt = 3;
- break;
- default:
+ } else if (DBL_INF == d) {
+ strcpy(buf, "Infinity");
+ cnt = 8;
+ } else if (-DBL_INF == d) {
+ strcpy(buf, "-Infinity");
+ cnt = 9;
+ } else {
cnt = sprintf(buf, "%0.16g", d); // used sprintf due to bug in snprintf
- break;
- }
+ }
if (out->end - out->cur <= (long)cnt) {
grow(out, cnt);
}
View
@@ -24,6 +24,15 @@
'HAS_PROC_WITH_BLOCK' => ('ruby' == type && '1' == version[0] && '9' == version[1]) ? 1 : 0,
'HAS_TOP_LEVEL_ST_H' => ('ree' == type || ('ruby' == type && '1' == version[0] && '8' == version[1])) ? 1 : 0,
}
+# This is a monster hack to get around issues with 1.9.3-p0 on CentOS 5.4. SO
+# some reason math.h and string.h contents are not processed. Might be a
+# missing #define. This is the quick and easy way around it.
+if 'x86_64-linux' == RUBY_PLATFORM && '1.9.3' == RUBY_VERSION && '2011-10-30' == RUBY_RELEASE_DATE
+ begin
+ dflags['NEEDS_STPCPY'] = nil if `more /etc/issue`.include?('CentOS release 5.4')
+ rescue Exception => e
+ end
+end
dflags.each do |k,v|
if v.nil?
@@ -35,3 +44,5 @@
$CPPFLAGS += ' -Wall'
#puts "*** $CPPFLAGS: #{$CPPFLAGS}"
create_makefile(extension_name)
+
+%x{make clean}
View
@@ -112,6 +112,17 @@ static VALUE doc_size(VALUE self);
VALUE oj_doc_class = 0;
+// This is only for CentOS 5.4 with Ruby 1.9.3-p0.
+#ifdef NEEDS_STPCPY
+char *stpcpy(char *dest, const char *src) {
+ size_t cnt = strlen(src);
+
+ strcpy(dest, src);
+
+ return dest + cnt;
+}
+#endif
+
inline static void
next_non_white(ParseInfo pi) {
for (; 1; pi->s++) {
View
@@ -1,5 +1,5 @@
module Oj
# Current version of the module.
- VERSION = '1.2.3'
+ VERSION = '1.2.4'
end
View
8 notes
@@ -5,6 +5,10 @@
- next
+ - optimize read_hex in load.c
+ - add options for path in fetch
+ - wild cards
+
- setup travis to run tests
- does not load the oj gem in some cases
@@ -17,8 +21,8 @@
- object_end
- array_start
- array_end
- - value
- - key
+ - value - provide accessor call or object to get value
+ - key - provide accessor call or object to get value
- default callbacks use straight C and create Hash or Object according to mode
- callback object

0 comments on commit ae5fd3d

Please sign in to comment.