diff --git a/lib/xy.h b/lib/xy.h index bb7df84..76831e2 100644 --- a/lib/xy.h +++ b/lib/xy.h @@ -8,7 +8,7 @@ * Contributors : juzeon * | * Created On : <2023-08-28> - * Last Modified : <2024-12-14> + * Last Modified : <2025-06-20> * * xy: 襄阳、咸阳 * Corss-Platform C utilities for CLI applications in Ruby flavor @@ -17,8 +17,10 @@ #ifndef XY_H #define XY_H -#define _XY_Version "v0.1.4.4-2024/12/14" -#define _XY_Maintain_URL "https://gitee.com/RubyMetric/chsrc/blob/main/include/xy.h" +#define _XY_Version "v0.1.5.0-2025/06/20" +#define _XY_Maintain_URL "https://github.com/RubyMetric/chsrc/blob/main/lib/xy.h" +#define _XY_Maintain_URL2 "https://gitee.com/RubyMetric/chsrc/blob/main/lib/xy.h" + #include #include @@ -646,6 +648,41 @@ xy_run (const char *cmd, unsigned long n) } + + +/****************************************************** + * cross OS + ******************************************************/ + + /** + * 该函数同 just 中的 os_family(),只区分 windows, unix + * + * @return 返回 "windows" 或 "unix" + */ +#define xy_os_family _xy_os_family () +static char * +_xy_os_family () +{ + if (xy_on_windows) + return "windows"; + else + return "unix"; +} + + +/** + * 该函数返回所在 os family 的对应字符串 + */ +static const char * +xy_os_depend_str (const char *str_for_win, const char *str_for_unix) +{ + if (xy_on_windows) + return str_for_win; + else + return str_for_unix; +} + + #define xy_os_home _xy_os_home () static char * _xy_os_home () diff --git a/test/xy.c b/test/xy.c index 1edd52c..78c3828 100644 --- a/test/xy.c +++ b/test/xy.c @@ -6,7 +6,7 @@ * Contributors : Nil Null * | * Created On : <2023-08-30> - * Last Modified : <2025-06-19> + * Last Modified : <2025-06-20> * * Test xy.h * ------------------------------------------------------------*/ @@ -17,6 +17,9 @@ int main (int argc, char const *argv[]) { xy_useutf8 (); + + puts (xy_os_depend_str ("Hello, Windows!", "Hello, Unix!")); + puti (3); double dbl = 3.1415; putf (dbl);