5858#endif
5959
6060
61- bool xy_on_windows = false;
62- bool xy_on_linux = false;
63- bool xy_on_macos = false;
64- bool xy_on_bsd = false;
65- bool xy_on_android = false;
66-
6761
6862/* 全局变量 与 全局状态 */
6963struct
@@ -892,7 +886,7 @@ xy_run_capture (const char *cmd, char **output)
892886static char *
893887_xy_os_family ()
894888{
895- if (xy_on_windows )
889+ if (xy . on_windows )
896890 return "windows" ;
897891 else
898892 return "unix" ;
@@ -905,7 +899,7 @@ _xy_os_family ()
905899static const char *
906900xy_os_depend_str (const char * str_for_win , const char * str_for_unix )
907901{
908- if (xy_on_windows )
902+ if (xy . on_windows )
909903 return str_for_win ;
910904 else
911905 return str_for_unix ;
@@ -923,7 +917,7 @@ static char *
923917_xy_os_home ()
924918{
925919 char * home = NULL ;
926- if (xy_on_windows )
920+ if (xy . on_windows )
927921 home = getenv ("USERPROFILE" );
928922 else
929923 home = getenv ("HOME" );
@@ -965,7 +959,7 @@ _xy_win_documents ()
965959static char *
966960_xy_win_powershell_profile ()
967961{
968- if (xy_on_windows )
962+ if (xy . on_windows )
969963 {
970964 char * documents_dir = _xy_win_documents ();
971965 char * profile_path = xy_2strcat (documents_dir , "\\PowerShell\\Microsoft.PowerShell_profile.ps1" );
@@ -985,7 +979,7 @@ _xy_win_powershell_profile ()
985979static char *
986980_xy_win_powershellv5_profile ()
987981{
988- if (xy_on_windows )
982+ if (xy . on_windows )
989983 {
990984 char * documents_dir = _xy_win_documents ();
991985 char * profile_path = xy_2strcat (documents_dir , "\\WindowsPowerShell\\Microsoft.PowerShell_profile.ps1" );
@@ -1023,15 +1017,15 @@ static bool
10231017xy_dir_exist (const char * path )
10241018{
10251019 const char * dir = path ;
1026- if (xy_on_windows )
1020+ if (xy . on_windows )
10271021 {
10281022 if (xy_str_start_with (path , "~" ))
10291023 {
10301024 dir = xy_2strcat (xy_os_home , path + 1 );
10311025 }
10321026 }
10331027
1034- if (xy_on_windows )
1028+ if (xy . on_windows )
10351029 {
10361030#ifdef XY_Build_On_Windows
10371031 // 也可以用 opendir() #include <dirent.h>
@@ -1085,7 +1079,7 @@ xy_normalize_path (const char *path)
10851079 new = xy_2strcat (xy_os_home , xy_str_delete_prefix (new , "~" ));
10861080 }
10871081
1088- if (xy_on_windows )
1082+ if (xy . on_windows )
10891083 return xy_str_gsub (new , "/" , "\\" );
10901084 else
10911085 return new ;
@@ -1121,7 +1115,7 @@ xy_parent_dir (const char *path)
11211115 * last = '\0' ;
11221116
11231117 /* Windows上重新使用 \ 作为路径分隔符 */
1124- if (xy_on_windows )
1118+ if (xy . on_windows )
11251119 return xy_str_gsub (dir , "/" , "\\" );
11261120 else
11271121 return dir ;
@@ -1141,7 +1135,7 @@ xy_detect_os ()
11411135 DIR * d = opendir (path );
11421136 if (d )
11431137 {
1144- xy_on_windows = true;
1138+ xy . on_windows = true;
11451139 closedir (d );
11461140 return ;
11471141 }
@@ -1155,12 +1149,12 @@ xy_detect_os ()
11551149 fclose (fp );
11561150 if (strstr (buf , "Android" ))
11571151 {
1158- xy_on_android = true;
1152+ xy . on_android = true;
11591153 return ;
11601154 }
11611155 else if (strstr (buf , "Linux" ))
11621156 {
1163- xy_on_linux = true;
1157+ xy . on_linux = true;
11641158 return ;
11651159 }
11661160 }
@@ -1173,7 +1167,7 @@ xy_detect_os ()
11731167 d = opendir ("/Library/Apple" );
11741168 if (d )
11751169 {
1176- xy_on_macos = true;
1170+ xy . on_macos = true;
11771171 closedir (d );
11781172 }
11791173 }
@@ -1185,7 +1179,7 @@ xy_detect_os ()
11851179 if (opendir ("/etc/rc.d" ))
11861180 {
11871181 closedir (d );
1188- xy_on_bsd = true;
1182+ xy . on_bsd = true;
11891183 return ;
11901184 }
11911185 }
@@ -1195,10 +1189,10 @@ xy_detect_os ()
11951189 fgets (buf , sizeof (buf ), fp );
11961190 pclose (fp );
11971191 if (strstr (buf , "BSD" ) != NULL )
1198- xy_on_bsd = true;
1192+ xy . on_bsd = true;
11991193 }
12001194
1201- if (!(xy_on_windows || xy_on_linux || xy_on_android || xy_on_macos || xy_on_bsd ))
1195+ if (!(xy . on_windows || xy . on_linux || xy . on_android || xy . on_macos || xy . on_bsd ))
12021196 xy_panic ("Unknown operating system" );
12031197}
12041198
@@ -1220,7 +1214,7 @@ xy_init ()
12201214{
12211215 xy_detect_os ();
12221216
1223- if (xy_on_windows )
1217+ if (xy . on_windows )
12241218 xy .os_devnull = "nul" ;
12251219 else
12261220 xy .os_devnull = "/dev/null" ;
0 commit comments