@@ -215,7 +215,7 @@ xy_malloc0 (size_t size)
215215 * @param new_str 新的字符串指针
216216 */
217217static inline void
218- xy_str_swap (char * * old_ptr , char * new_str )
218+ xy_str_replace (char * * old_ptr , char * new_str )
219219{
220220 if (old_ptr && * old_ptr )
221221 {
@@ -749,7 +749,7 @@ xy_file_read (const char *path)
749749 buf [read_bytes ] = '\0' ;
750750
751751 char * formatted_str = xy_str_gsub (buf , "\r\n" , "\n" );
752- xy_str_swap (& formatted_str , xy_str_gsub (formatted_str , "\r" , "\n" ));
752+ xy_str_replace (& formatted_str , xy_str_gsub (formatted_str , "\r" , "\n" ));
753753
754754 free (buf );
755755
@@ -1258,12 +1258,12 @@ xy_normalize_path (const char *path)
12581258 char * tmp = xy_str_delete_prefix (new , "~" );
12591259 char * joined = xy_2strcat (xy_os_home , tmp );
12601260 free (tmp );
1261- xy_str_swap (& new , joined );
1261+ xy_str_replace (& new , joined );
12621262 }
12631263
12641264 if (xy .on_windows )
12651265 {
1266- xy_str_swap (& new , xy_str_gsub (new , "/" , "\\" ));
1266+ xy_str_replace (& new , xy_str_gsub (new , "/" , "\\" ));
12671267 }
12681268 return new ;
12691269}
@@ -1282,10 +1282,10 @@ xy_parent_dir (const char *path)
12821282 char * dir = xy_normalize_path (path );
12831283
12841284 /* 不管是否为Windows,全部统一使用 / 作为路径分隔符,方便后续处理 */
1285- xy_str_swap (& dir , xy_str_gsub (dir , "\\" , "/" ));
1285+ xy_str_replace (& dir , xy_str_gsub (dir , "\\" , "/" ));
12861286
12871287 if (xy_str_end_with (dir , "/" ))
1288- xy_str_swap (& dir , xy_str_delete_suffix (dir , "/" ));
1288+ xy_str_replace (& dir , xy_str_delete_suffix (dir , "/" ));
12891289
12901290 char * last = NULL ;
12911291
@@ -1300,7 +1300,7 @@ xy_parent_dir (const char *path)
13001300 /* Windows上重新使用 \ 作为路径分隔符 */
13011301 if (xy .on_windows )
13021302 {
1303- xy_str_swap (& dir , xy_str_gsub (dir , "/" , "\\" ));
1303+ xy_str_replace (& dir , xy_str_gsub (dir , "/" , "\\" ));
13041304 }
13051305 return dir ;
13061306}
0 commit comments