[amx-netlinx-common] r37 committed - - added commenting for remove_string_by_length()...

3 views
Skip to first unread message

amx-netli...@googlecode.com

unread,
Sep 6, 2010, 1:15:51 AM9/6/10
to netlinx-comm...@googlegroups.com
Revision: 37
Author: kim.john.burgess
Date: Sun Sep 5 22:15:18 2010
Log: - added commenting for remove_string_by_length()
- fixed bug in return size checking in remove_string_by_length()
- removed whitespace
http://code.google.com/p/amx-netlinx-common/source/detail?r=37

Modified:
/trunk/math.axi
/trunk/string.axi
/trunk/test/test_math.axi

=======================================
--- /trunk/math.axi Sun Aug 8 17:00:49 2010
+++ /trunk/math.axi Sun Sep 5 22:15:18 2010
@@ -239,13 +239,13 @@
define_function char is_numeric(char a[])
{
stack_var integer i
-
+
for (i = 1; i <= length_string(a); i++) {
if (!(a[i] >= $30 && a[i] <= $39)) {
return 0
- }
- }
-
+ }
+ }
+
return 1
}

=======================================
--- /trunk/string.axi Sun Aug 8 17:00:49 2010
+++ /trunk/string.axi Sun Sep 5 22:15:18 2010
@@ -589,10 +589,20 @@
return "a, ret"
}

+/**
+ * Returns the left substring of a string up to the specified number of
+ * characters.
+ * WARNING: this is a destructive removal - the returned substring will be
+ * removed from string 'a'.
+ *
+ * @param a a string to remove the substring from
+ * @param len the number of characters to remove
+ * @return a string containing the first 'len' characters of 'a'
+ */
define_function char[STRING_RETURN_SIZE_LIMIT] remove_string_by_length(
char a[], integer len)
{
- if (length_string(a) - len > STRING_RETURN_SIZE_LIMIT) {
+ if (len > STRING_RETURN_SIZE_LIMIT) {
return string_size_error()
}

=======================================
--- /trunk/test/test_math.axi Thu May 27 23:58:59 2010
+++ /trunk/test/test_math.axi Sun Sep 5 22:15:18 2010
@@ -630,8 +630,8 @@
// Check for correct functionality
for (i = TEST_MATH_ITERATIONS; i; i--) {
error = test_math_error(res[i] * res[i], test_data[i])
- test_check(error <= 0.0001,
- "'exceeds maximum error (x = ', ftoa(test_data[i]),
+ test_check(error <= 0.0001,
+ "'exceeds maximum error (x = ', ftoa(test_data[i]),
', error = ', ftoa(error), '%)'")
if (error > max_err) {
max_err = error
@@ -687,8 +687,8 @@
for (i = TEST_MATH_ITERATIONS; i; i--) {
error = test_math_error(test_data[i] * test_data[i] * res[i] * res[i],
test_data[i])
- test_check(error <= 0.35,
- "'exceeds maximum error (x = ', ftoa(test_data[i]),
+ test_check(error <= 0.35,
+ "'exceeds maximum error (x = ', ftoa(test_data[i]),
', error = ', ftoa(error), '%)'")
if (error > max_err) {
max_err = error
@@ -734,8 +734,8 @@
// Check for correct functionality
for (i = TEST_MATH_ITERATIONS; i; i--) {
error = test_math_error(res[i] * res[i], test_data[i])
- test_check(error <= 0.35,
- "'exceeds maximum error (x = ', ftoa(test_data[i]),
+ test_check(error <= 0.35,
+ "'exceeds maximum error (x = ', ftoa(test_data[i]),
', error = ', ftoa(error), '%)'")
if (error > max_err) {
max_err = error

Reply all
Reply to author
Forward
0 new messages