]> Kevux Git Server - fll/commitdiff
Bugfix: Compilation/Portability problems exposed when building against musl-libc.
authorKevin Day <thekevinday@gmail.com>
Fri, 7 May 2021 04:33:08 +0000 (23:33 -0500)
committerKevin Day <thekevinday@gmail.com>
Fri, 7 May 2021 04:33:08 +0000 (23:33 -0500)
Some headers are missing.

Change the length types: f_console_parameter_size and f_array_length_t.
I have seen problems where the max allowed size is reached in f_array_length_t.
Compiling against musl-libc further exposes this problem and so I have reduced the practice to using a set length of 2^63 (aka: signed long).

level_0/f_color/c/color.h
level_0/f_console/c/console-common.h
level_0/f_directory/c/directory.h
level_0/f_type/c/type.h
level_1/fl_print/c/print.h

index a9c0286ebb37b13ea00025326cdb7a3bf43101a6..17105a5f4f9c92a77de5d1e4c2cdf8355de2ee1c 100644 (file)
@@ -15,6 +15,7 @@
 
 // libc includes
 #include <stdarg.h>
+#include <stdio.h>
 #include <string.h>
 
 // fll-0 includes
index 3795c3fbcdf0a96f00a63773cbadc1632ef6113a..3ae999440ed148b980fdd05ae1de6878c1924c03 100644 (file)
@@ -168,9 +168,12 @@ extern "C" {
 
 /**
  * The maximum size for a single parameter (the length of the string representing the parameter).
+ *
+ * The ideal parameter value is f_array_length_t_size, which generally defaults to 2^64 (unsigned).
+ * However, the libc/POSIX appears to limit this to 2^63 (signed).
  */
 #ifndef _di_f_console_length_size_
-  #define f_console_parameter_size f_array_length_t_size
+  #define f_console_parameter_size f_type_size_max_64_positive
 #endif // _di_f_console_length_size_
 
 /**
index ccac433cc5a3c642c494b769463bae57819e9115..6aca2d20bc2ddad4ba633489c548976ec5c9c5e3 100644 (file)
@@ -14,6 +14,7 @@
 #include <dirent.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <limits.h>
 #include <stdio.h>
 #include <string.h>
 #include <sys/stat.h>
index 250001af313626c9e61344b81cf5b3ea5e6729f9..b7144980b42449d5d1724ab1b5f34e194d6d2410 100644 (file)
@@ -187,12 +187,16 @@ extern "C" {
 
 /**
  * Defines a variable to be used by arrays.
+ *
+ * There are problems in some libc's and systems that do not handle lengths greater than 2^63.
+ * This is primarily a problem with libc string functions.
+ * For general compatiblity reasons, this is set to a signed 64-bit integer.
  */
 #ifndef _di_f_array_t_
-  typedef f_number_unsigned_t f_array_length_t;
+  typedef f_number_signed_t f_array_length_t;
 
-  #define f_array_length_t_size     f_number_t_size_unsigned
-  #define f_array_length_t_size_max f_number_t_size_max_unsigned
+  #define f_array_length_t_size     f_type_size_64_positive
+  #define f_array_length_t_size_max f_type_size_max_64_positive
 #endif // _di_f_array_t_
 
 /**
index a9aded12c940f39da69a8ee7fb7432a3bce650e7..a69bebe30426ac403ff81d625cae1fff139e4acb 100644 (file)
@@ -12,6 +12,9 @@
 #ifndef _FL_print_h
 #define _FL_print_h
 
+// libc includes
+#include <stdio.h>
+
 // fll-0 includes
 #include <fll/level_0/type.h>
 #include <fll/level_0/status.h>