]> Kevux Git Server - fll/commitdiff
Update: ensure f_no_data is returned when applicable for fl_string and fl_utf functions
authorKevin Day <thekevinday@gmail.com>
Mon, 4 May 2020 02:43:05 +0000 (21:43 -0500)
committerKevin Day <thekevinday@gmail.com>
Mon, 4 May 2020 02:43:05 +0000 (21:43 -0500)
level_1/fl_string/c/private-string.c
level_1/fl_string/c/private-string.h
level_1/fl_string/c/string.c
level_1/fl_utf/c/private-utf.c
level_1/fl_utf/c/private-utf.h
level_1/fl_utf/c/utf.c

index 5f4f931..2b62f19 100644 (file)
@@ -411,6 +411,17 @@ extern "C" {
       if (status == f_false) break;
     } // for
 
+    if (*stop == *start) {
+      status = f_utf_is_whitespace(source + *stop, (stop_original - *stop) + 1);
+      if (f_status_is_error(status)) {
+        if (f_status_set_fine(status) == f_maybe) return f_status_set_error(f_invalid_utf);
+
+        return status;
+      }
+
+      if (status == f_true) return f_no_data;
+    }
+
     return f_none;
   }
 #endif // !defined(_di_fl_string_rip_) || !defined(_di_fl_string_dynamic_rip_) || !defined(_di_fl_string_rip_nulless_) || !defined(_di_fl_string_dynamic_rip_nulless_)
index 77994d7..1c7ee77 100644 (file)
@@ -211,6 +211,7 @@ extern "C" {
  *
  * @return
  *   f_none on success.
+ *   f_no_data on success but only whitespace found.
  *   f_invalid_parameter (with error bit) if a parameter is invalid.
  *   f_error_allocation (with error bit) on memory allocation error.
  *   f_error_reallocation (with error bit) on memory reallocation error.
index e59f5e8..9d61eba 100644 (file)
@@ -652,6 +652,7 @@ extern "C" {
     f_status status = private_fl_string_rip_find_range(source, &begin, &end);
 
     if (f_status_is_error(status)) return status;
+    if (status == f_no_data) return status;
 
     return private_fl_string_append(source, begin, end, destination);
   }
@@ -670,6 +671,7 @@ extern "C" {
     f_status status = private_fl_string_rip_find_range(source, &begin, &end);
 
     if (f_status_is_error(status)) return status;
+    if (status == f_no_data) return status;
 
     return private_fl_string_append_nulless(source, begin, end, destination);
   }
index cfd223a..48b10ec 100644 (file)
@@ -378,6 +378,17 @@ extern "C" {
       if (status == f_false) break;
     } // for
 
+    if (*stop == *start) {
+      status = f_utf_character_is_whitespace(source[*stop]);
+      if (f_status_is_error(status)) {
+        if (f_status_set_fine(status) == f_maybe) return f_status_set_error(f_invalid_utf);
+
+        return status;
+      }
+
+      if (status == f_true) return f_no_data;
+    }
+
     return f_none;
   }
 #endif // !defined(_di_fl_utf_string_rip_) || !defined(_di_fl_utf_string_dynamic_rip_) || !defined(_di_fl_utf_string_rip_nulless_) || !defined(_di_fl_utf_string_dynamic_rip_nulless_)
index 6e0d215..a2417f0 100644 (file)
@@ -211,6 +211,7 @@ extern "C" {
  *
  * @return
  *   f_none on success.
+ *   f_no_data on success but only whitespace found.
  *   f_invalid_parameter (with error bit) if a parameter is invalid.
  *   f_error_allocation (with error bit) on memory allocation error.
  *   f_error_reallocation (with error bit) on memory reallocation error.
index 1e9ef87..9bf9443 100644 (file)
@@ -562,6 +562,7 @@ extern "C" {
     f_status status = private_fl_utf_string_rip_find_range(source, &begin, &end);
 
     if (f_status_is_error(status)) return status;
+    if (status == f_no_data) return status;
 
     return private_fl_utf_string_append(source, begin, end, destination);
   }
@@ -580,6 +581,7 @@ extern "C" {
     f_status status = private_fl_utf_string_rip_find_range(source, &begin, &end);
 
     if (f_status_is_error(status)) return status;
+    if (status == f_no_data) return status;
 
     return private_fl_utf_string_append_nulless(source, begin, end, destination);
   }