# include "version.h"
# include "decl.h"
# include "macros.h"


void ri_rc_version (void) {
//	char * cp;
	version = VERSION_ENG;
   
# ifdef FOR_OS_WINDOWS_UTF8
   FILE *streamtmp;
   char line[256];
   // char * fnametmp = "r5_init_tmp.r5tmp"; // 77777, Nemytykh 26-04-2025
 
   if ( (system("ver > r5_init_tmp.r5tmp") == 0) && (system("chcp >> r5_init_tmp.r5tmp") == 0) 
        && ( fopen_s( &streamtmp, "r5_init_tmp.r5tmp", "r" ) == 0 )
      )
   {   /* Empty string and "Microsoft Windows [Version dd.0.26100.3775]", 0 < dd < 100 */
      if ( (fgets( line, 3, streamtmp ) != NULL) && (fgets( line, 256, streamtmp ) != NULL) &&
           (((strncmp("Version ", (char *)line+19, 8) == 0)) && ( line[29] == '.')) &&
           ('0' < line[27]) && (line[27] <= '9') && ('0' <= line[28]) && (line[28] <= '9')
         ) {   /* "Active code page: 65001" -- UTF-8 */
         if ( (fgets( line, 256, streamtmp ) != NULL) &&
              ((strncmp("code page: 65001", (char *)line+7, 16) == 0))
            )
         version = VERSION;
      }
     fclose( streamtmp );
     system("del r5_init_tmp.r5tmp");
   }
# else /* LINUX-UTF8 */
	char * cp;

	if ( (NULL != (cp = getenv ("LANG"))) &&
	     (((strncmp("ru_", cp, 3) == 0)) && ((strcmp(".UTF-8", cp+5) == 0)))
	   ) {
		version = VERSION;
	} /* else {
		version = VERSION_ENG;
	} */
# endif
}