标注更多 flavor

This commit is contained in:
Aoran Zeng 2025-08-20 12:02:37 +08:00
parent 6178b212a0
commit 6fb8677451
No known key found for this signature in database
GPG Key ID: 8F8BA8488E10ED98

View File

@ -126,6 +126,9 @@ static void _xy_println_bool (bool b) {printf("%s\n", (b) ? "true" : "false");
static void _xy_println_str (char *str) {printf ("%s\n", str);}
static void _xy_println_const_str (const char *str) {printf ("%s\n", str);}
/**
* @flavor Ruby, Python
*/
#define print(x) _Generic((x), \
int: _xy_print_int, \
long: _xy_print_long, \
@ -138,6 +141,9 @@ static void _xy_println_const_str (const char *str) {printf ("%s\n", str);}
default: assert(!"Unsupported type for print()!") \
)(x)
/**
* @flavor JVM family, Rust
*/
#define println(x) _Generic((x), \
int: _xy_println_int, \
long: _xy_println_long, \
@ -153,12 +159,16 @@ static void _xy_println_const_str (const char *str) {printf ("%s\n", str);}
#define say println
/* @flavor PHP */
#define echo println
/* @flavor HTML */
/**
* @flavor HTML
*/
void br () { puts (""); }
void p (const char *s) { printf ("%s\n", s); }
#define xy_arylen(x) (sizeof (x) / sizeof (x[0]))
static inline void *
xy_malloc0 (size_t size)
{
@ -175,6 +185,8 @@ xy_malloc0 (size_t size)
/**
* @brief str pat replace
*
* @flavor Ruby: String#gsub
*
* @param str
* @param pat
* @param replace
@ -409,6 +421,7 @@ new_str:
return buf;
}
static bool
xy_streql (const char *str1, const char *str2)
{
@ -444,6 +457,7 @@ xy_streql_ic(const char *str1, const char *str2)
return true;
}
static char *
xy_str_to_quietcmd (const char *cmd)
{
@ -456,6 +470,10 @@ xy_str_to_quietcmd (const char *cmd)
return ret;
}
/**
* @flavor Ruby: String#end_with?
*/
static bool
xy_str_end_with (const char *str, const char *suffix)
{
@ -480,6 +498,9 @@ xy_str_end_with (const char *str, const char *suffix)
return true;
}
/**
* @flavor Ruby: String#start_with?
*/
static bool
xy_str_start_with (const char *str, const char *prefix)
{
@ -509,6 +530,9 @@ xy_str_start_with (const char *str, const char *prefix)
return true;
}
/**
* @flavor Ruby: String#delete_prefix
*/
static char *
xy_str_delete_prefix (const char *str, const char *prefix)
{
@ -522,6 +546,9 @@ xy_str_delete_prefix (const char *str, const char *prefix)
return cur;
}
/**
* @flavor Ruby: String#delete_suffix
*/
static char *
xy_str_delete_suffix (const char *str, const char *suffix)
{
@ -537,6 +564,9 @@ xy_str_delete_suffix (const char *str, const char *suffix)
return new;
}
/**
* @flavor Ruby: String#strip
*/
static char *
xy_str_strip (const char *str)
{
@ -626,7 +656,7 @@ _xy_log (int level, const char *prompt, const char *content)
/**
* brkt pip 便使 xy.h
* @flavor brkt Python pip 便使 xy.h
*
* 1.
*
@ -778,7 +808,8 @@ xy_run (const char *cmd, unsigned long n)
******************************************************/
/**
* @note just os_family() windows, unix
* @flavor just os_family() windows, unix
*
* @return "windows" "unix"
*/
#define xy_os_family _xy_os_family ()