Browse Source

generate variable oscompiled

test for variable
pre-master-46
Holger Vogt 6 years ago
parent
commit
ef95ff7edc
  1. 2
      configure.ac
  2. 34
      examples/utf-8/стекло/os_compiled.sp
  3. 37
      src/frontend/init.c

2
configure.ac

@ -321,7 +321,7 @@ case $host_os in
AC_DEFINE([OS_COMPILED], [7], [macOS]) AC_DEFINE([OS_COMPILED], [7], [macOS])
;; ;;
* ) * )
AC_DEFINE([OS_COMPILED], [8], [Other Operating System])
AC_DEFINE([OS_COMPILED], [0], [Other Operating System])
;; ;;
esac esac

34
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

37
src/frontend/init.c

@ -30,4 +30,41 @@ cp_init(void)
/* io redirection in streams.c: /* io redirection in streams.c:
cp_in set to cp_curin etc. */ cp_in set to cp_curin etc. */
cp_ioreset(); 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);
} }
Loading…
Cancel
Save