You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2016/03/20 04:59:57 UTC

[1/2] lucy-clownfish git commit: Ensure nul-terminated arg to strtod.

Repository: lucy-clownfish
Updated Branches:
  refs/heads/master fa009460e -> f3bab0eec


Ensure nul-terminated arg to strtod.

Inside Str_To_F64 we use strtod, which requires a nul-terminated C
string argument.  Now that Clownfish Strings consistently lack
nul-termination, we need to copy content into a nul-terminated buffer
and pass that to strtod.


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/4dab61a5
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/4dab61a5
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/4dab61a5

Branch: refs/heads/master
Commit: 4dab61a5717135c4f60fc6d063e21870a453bb1f
Parents: f5139ff
Author: Marvin Humphrey <ma...@rectangular.com>
Authored: Mon Mar 14 16:05:23 2016 -0700
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Mon Mar 14 16:05:23 2016 -0700

----------------------------------------------------------------------
 runtime/core/Clownfish/String.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/4dab61a5/runtime/core/Clownfish/String.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/String.c b/runtime/core/Clownfish/String.c
index 7c2c0fa..ac17bad 100644
--- a/runtime/core/Clownfish/String.c
+++ b/runtime/core/Clownfish/String.c
@@ -263,8 +263,8 @@ Str_BaseX_To_I64_IMP(String *self, uint32_t base) {
     return retval;
 }
 
-static double
-S_safe_to_f64(String *self) {
+double
+Str_To_F64_IMP(String *self) {
     size_t amount = self->size < 511 ? self->size : 511;
     char buf[512];
     memcpy(buf, self->ptr, amount);
@@ -272,17 +272,6 @@ S_safe_to_f64(String *self) {
     return strtod(buf, NULL);
 }
 
-double
-Str_To_F64_IMP(String *self) {
-    char   *end;
-    double  value    = strtod(self->ptr, &end);
-    size_t  consumed = end - self->ptr;
-    if (consumed > self->size) { // strtod overran
-        value = S_safe_to_f64(self);
-    }
-    return value;
-}
-
 char*
 Str_To_Utf8_IMP(String *self) {
     char *buf = (char*)malloc(self->size + 1);


[2/2] lucy-clownfish git commit: Merge 'CLOWNFISH-84-nul-term-strtod'

Posted by ma...@apache.org.
Merge 'CLOWNFISH-84-nul-term-strtod'

Make safer usage of `strtod`.

This closes #64.


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/f3bab0ee
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/f3bab0ee
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/f3bab0ee

Branch: refs/heads/master
Commit: f3bab0eec219330b561c6c3a12a5aa641816afe7
Parents: fa00946 4dab61a
Author: Marvin Humphrey <ma...@rectangular.com>
Authored: Sat Mar 19 20:56:51 2016 -0700
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Sat Mar 19 20:56:51 2016 -0700

----------------------------------------------------------------------
 runtime/core/Clownfish/String.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)
----------------------------------------------------------------------