1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
From 6b7c74e063269d3ec9e0e0628eb66226468f3fa8 Mon Sep 17 00:00:00 2001
From: Balint Reczey <balint.reczey@canonical.com>
Date: Tue, 13 Feb 2018 01:28:49 +0700
Subject: [PATCH 2/2] Fix spline2d info
Fixes spline2d_test.
---
ext/gsl_native/spline2d.c | 30 +++++++++++++++++++++---------
1 file changed, 21 insertions(+), 9 deletions(-)
diff --git a/ext/gsl_native/spline2d.c b/ext/gsl_native/spline2d.c
index 34e0c2b..5b9c262 100644
--- a/ext/gsl_native/spline2d.c
+++ b/ext/gsl_native/spline2d.c
@@ -180,15 +180,27 @@ static VALUE rb_gsl_spline2d_info(VALUE self)
rb_gsl_spline2d *p = NULL;
char buf[256];
Data_Get_Struct(self, rb_gsl_spline2d, p);
- sprintf(buf, "Class: %s\n", rb_class2name(CLASS_OF(self)));
- sprintf(buf, "%sSuperClass: %s\n", buf, rb_class2name(RCLASS_SUPER(CLASS_OF(self))));
- sprintf(buf, "%sType: %s\n", buf, gsl_interp2d_name(&p->s->interp_object));
- sprintf(buf, "%sxmin: %f\n", buf, p->s->interp_object.xmin);
- sprintf(buf, "%sxmax: %f\n", buf, p->s->interp_object.xmax);
- sprintf(buf, "%symin: %f\n", buf, p->s->interp_object.ymin);
- sprintf(buf, "%symax: %f\n", buf, p->s->interp_object.ymax);
- sprintf(buf, "%sxSize: %d\n", buf, (int) p->s->interp_object.xsize);
- sprintf(buf, "%sySize: %d\n", buf, (int) p->s->interp_object.ysize);
+ snprintf(buf, sizeof(buf) - 1,
+ "Class: %s\n"
+ "SuperClass: %s\n"
+ "Type: %s\n"
+ "xmin: %f\n"
+ "xmax: %f\n"
+ "ymin: %f\n"
+ "ymax: %f\n"
+ "xSize: %d\n"
+ "ySize: %d\n",
+ rb_class2name(CLASS_OF(self)),
+ rb_class2name(RCLASS_SUPER(CLASS_OF(self))),
+ gsl_interp2d_name(&p->s->interp_object),
+ p->s->interp_object.xmin,
+ p->s->interp_object.xmax,
+ p->s->interp_object.ymin,
+ p->s->interp_object.ymax,
+ (int) p->s->interp_object.xsize,
+ (int) p->s->interp_object.ysize);
+ buf[sizeof(buf) - 1] = '\0';
+
return rb_str_new2(buf);
}
--
2.14.1
|