diff --git a/configure.ac b/configure.ac index 9b3275438..215ac59aa 100644 --- a/configure.ac +++ b/configure.ac @@ -321,7 +321,7 @@ case $host_os in AC_DEFINE([OS_COMPILED], [7], [macOS]) ;; * ) - AC_DEFINE([OS_COMPILED], [8], [Other Operating System]) + AC_DEFINE([OS_COMPILED], [0], [Other Operating System]) ;; esac diff --git a/examples/utf-8/стекло/os_compiled.sp b/examples/utf-8/стекло/os_compiled.sp new file mode 100644 index 000000000..dec8ddcfa --- /dev/null +++ b/examples/utf-8/стекло/os_compiled.sp @@ -0,0 +1,34 @@ +*ng_script test for oscompiled + +.control +if $oscompiled = 0 + echo [0], Other +endif +if $oscompiled = 1 + echo [1], MINGW for MS Windows +endif +if $oscompiled = 2 + echo [2], Cygwin for MS Windows +endif +if $oscompiled = 3 + echo [3], FreeBSD +endif +if $oscompiled = 4 + echo [4], OpenBSD +endif +if $oscompiled = 5 + echo [5], Solaris +endif +if $oscompiled = 6 + echo [6], Linux +endif +if $oscompiled = 7 + echo [7], macOS +endif +if $oscompiled = 8 + echo [8], Visual Studio for MS Windows +endif + +.endc + +.end diff --git a/src/frontend/init.c b/src/frontend/init.c index 5e963e585..fe494a34d 100644 --- a/src/frontend/init.c +++ b/src/frontend/init.c @@ -30,4 +30,41 @@ cp_init(void) /* io redirection in streams.c: cp_in set to cp_curin etc. */ cp_ioreset(); + + /*set a variable oscompiled containing the OS at compile time + [0], Other + [1], MINGW for MS Windows + [2], Cygwin for MS Windows + [3], FreeBSD + [4], OpenBSD + [5], Solaris + [6], Linux + [7], macOS + [8], Visual Studio for MS Windows + The variable may be used in a .control section to perform OS + specific actions (setting fonts etc.). + */ + int itmp; +#if OS_COMPILED == 1 + itmp = 1; +#elif OS_COMPILED == 2 + itmp = 2; +#elif OS_COMPILED == 3 + itmp = 3; +#elif OS_COMPILED == 4 + itmp = 4; +#elif OS_COMPILED == 5 + itmp = 5; +#elif OS_COMPILED == 6 + itmp = 6; +#elif OS_COMPILED == 7 + itmp = 7; +#else + itmp = 0; +#endif + /* not using configure.ac */ +#ifdef _MSC_VER + itmp = 8; +#endif + cp_vset("oscompiled", CP_NUM, &itmp); }