コード例 #1
0
int main( int argc, char **argv )
{
  int eax;
  double fp7;
  int i;
  char *cp = &ebx;
  double numerator, denominator;
  double new_size;
  int coption, boption, wide_flag;
  init_gvars( );
  default_out = stdout;
  gfp = stdout;
  wide_flag = 0;
  coption = 0;
  if ( i >= 0 )
  {
    if ( i + -98 + -98 <= 22 )
    {
      ;
    }
    usage( );
    exit( 2 );
  }
  else
  {
    if ( n_tokens <= 99 )
    {
      __fprintf_chk( stderr, 1, "%s: Expression array size too small.\n", prog_name );
      exit( 2 );
    }
    if ( init_mem( ) == 0 )
    {
      __fprintf_chk( stderr, 1, "%s: Not enough memory.\n", prog_name );
      exit( 2 );
    }
    if ( readline_enabled )
    {
      if ( numerator && prog_name )
      {
        __snprintf_chk( history_filename_storage, 4096, 1, 4096, "%s/.%s_history", cp, prog_name );
        history_filename = history_filename_storage;
      }
      rl_initialize( );
      using_history( );
      stifle_history( 500 );
      rl_inhibit_completion = 1;
      if ( html_flag == 0 )
      {
        color_flag = tigetnum( "colors" ) > 7;
      }
      read_history( history_filename );
    }
    get_screen_size( );
    if ( html_flag )
      __printf_chk( 1, "&lt;pre&gt;\n" );
    if ( test_mode == 0 )
    {
      if ( quiet_mode == 0 )
      {
        if ( security_level > 1 )
          __printf_chk( 1, "Secure " );
        __printf_chk( 1, "Mathomatic version %s (www.mathomatic.org)\n", "15.1.1" );
        __printf_chk( 1, "Copyright (C) 1987-2010 George Gesslein II.\n" );
        __printf_chk( 1, "%d equation spaces available, %ld kilobytes per equation space.\n", 100, (/*HI*/int)( ( n_tokens << 5 ) * 0x10624dd3 ) >> 6 );
        if ( test_mode == 0 )
          goto B32;
      }
B32:;
      if ( load_rc( ) == 0 )
        __fprintf_chk( stderr, 1, "%s: Error loading set options from \"%s\".\n", prog_name, rc_file );
    }
    if ( wide_flag )
    {
      screen_columns = 0;
      screen_rows = 0;
    }
    if ( coption & 1 )
      color_flag = color_flag == 0;
    if ( 0 )
    {
      color_flag = 1;
      bold_colors = 1;
    }
    if ( test_mode )
      color_flag = 0;
    if ( quiet_mode == 0 && color_flag )
    {
      __printf_chk( 1, "%s%s color mode enabled", html_flag != 0 ? "ANSI" : "HTML", bold_colors == 0 ? " bold" : "" );
      if ( 0 )
        __printf_chk( 1, ".\n" );
      else
        __printf_chk( 1, "; disable with the -c option or \"set no color\".\n" );
    }
    i = _setjmp( &jmp_save[0].__jmpbuf[0] );
    if ( _setjmp( &jmp_save[0].__jmpbuf[0] ) )
    {
      clean_up( );
      if ( i == 14 )
        error( "Expression too large." );
      __printf_chk( 1, "Operation aborted.\n" );
    }
    else
    {
      if ( set_signals( ) == 0 )
        __fprintf_chk( stderr, 1, "signal(2) setting failed.\n" );
      if ( !f_to_fraction( 0.500000000000, &denominator, ebp_36 ) || denominator != 1.000000000000 || ebp_36 != 2.000000000000 || 0 || !f_to_fraction( 0.333333333333, &denominator, ebp_36 ) || denominator != 1.000000000000 || 0 || ebp_36 != 3.000000000000 || ebp_36 != 3.000000000000 )
      {
        __fprintf_chk( stderr, 1, "%s: Cannot convert any floating point values to fractions.\n", prog_name );
        __fprintf_chk( stderr, 1, "Roots will not work properly.\n" );
      }
      i = optind;
      if ( argc <= optind || argv[ i ] == 0 )
      {
        main_io_loop( );
        exit_program( 0 );
        return 0;
      }
    {
      /* phantom */ size_t __s1_len;
      /* phantom */ size_t __s2_len;
      unsigned char *__s1;
      /* phantom */ int __result;
      do
      {
        if ( '-' == argv[ i ][0] && argv[ i ][1] == 0 )
          main_io_loop( );
        else
        {
          if ( read_file( argv[ i ] ) == 0 )
          {
            __fprintf_chk( stderr, 1, "Read of file \"%s\" failed.\n", argv[ i ] );
            exit_program( 1 );
          }
        }
        i++;
      }
      while ( i + 1 < argc && argv[ i + 1 + 1 ] );
    }
    }
  }
}
コード例 #2
0
ファイル: nc_test.c プロジェクト: PNCG/genesis
int
main(int argc, char *argv[])
{
    extern int optind;
    extern int optopt;
    extern char *optarg;
    int c;
    int  nfailsTotal = 0;        /* total number of failures */

#if 1		/* both CRAY MPP and OSF/1 Alpha systems need this */
	/*
	 * Some of the extreme test assignments in this program trigger
         * floating point exceptions on CRAY T90
	 */
	(void) signal(SIGFPE, SIG_IGN);
#endif

    progname = argv[0];
    create_file = 0;            /* file test.nc will normally already exist */
    read_only = 0;               /* assume may write in test dir as default */
    verbose = 0;
    max_nmpt = 8;
    while ((c = getopt(argc, argv, "chrvn:")) != EOF)
      switch(c) {
	case 'c':		/* Create file test.nc */
	  create_file = 1;
	  break;
	case 'r':		/* just perform read-only tests */
	  read_only = 1;
	  break;
	case 'v':		/* verbose mode */
	  verbose = 1;
	  break;
	case 'n':		/* verbose mode */
	  max_nmpt = atoi(optarg);
	  break;
	case 'h':
	case '?':
	  usage();
	  return 1;
      }

    /* Initialize global variables defining test file */
    init_gvars();

    if ( create_file ) {
	write_file(testfile);
	return nfailsTotal > 0;
    }

    /* delete any existing scratch netCDF file */
    if ( ! read_only )
	(void) remove(scratch);

    /* Test read-only functions, using pregenerated test-file */
    NC_TEST(nc_strerror);
    NC_TEST(nc_open);
    NC_TEST(nc_close);
    NC_TEST(nc_inq);
    NC_TEST(nc_inq_dimid);
    NC_TEST(nc_inq_dim);
    NC_TEST(nc_inq_dimlen);
    NC_TEST(nc_inq_dimname);
    NC_TEST(nc_inq_varid);
    NC_TEST(nc_inq_var);
    NC_TEST(nc_inq_natts);
    NC_TEST(nc_inq_ndims);
    NC_TEST(nc_inq_nvars);
    NC_TEST(nc_inq_unlimdim);
    NC_TEST(nc_inq_vardimid);
    NC_TEST(nc_inq_varname);
    NC_TEST(nc_inq_varnatts);
    NC_TEST(nc_inq_varndims);
    NC_TEST(nc_inq_vartype);
    NC_TEST(nc_get_var_text);
    NC_TEST(nc_get_var_uchar);
    NC_TEST(nc_get_var_schar);
    NC_TEST(nc_get_var_short);
    NC_TEST(nc_get_var_int);
    NC_TEST(nc_get_var_long);
    NC_TEST(nc_get_var_float);
    NC_TEST(nc_get_var_double);
    NC_TEST(nc_get_var1_text);
    NC_TEST(nc_get_var1_uchar);
    NC_TEST(nc_get_var1_schar);
    NC_TEST(nc_get_var1_short);
    NC_TEST(nc_get_var1_int);
    NC_TEST(nc_get_var1_long);
    NC_TEST(nc_get_var1_float);
    NC_TEST(nc_get_var1_double);
#ifdef TEST_VOIDSTAR
    NC_TEST(nc_get_var1);
#endif /* TEST_VOIDSTAR */
    NC_TEST(nc_get_vara_text);
    NC_TEST(nc_get_vara_uchar);
    NC_TEST(nc_get_vara_schar);
    NC_TEST(nc_get_vara_short);
    NC_TEST(nc_get_vara_int);
    NC_TEST(nc_get_vara_long);
    NC_TEST(nc_get_vara_float);
    NC_TEST(nc_get_vara_double);
#ifdef TEST_VOIDSTAR
    NC_TEST(nc_get_vara);
#endif /* TEST_VOIDSTAR */
    NC_TEST(nc_get_vars_text);
    NC_TEST(nc_get_vars_uchar);
    NC_TEST(nc_get_vars_schar);
    NC_TEST(nc_get_vars_short);
    NC_TEST(nc_get_vars_int);
    NC_TEST(nc_get_vars_long);
    NC_TEST(nc_get_vars_float);
    NC_TEST(nc_get_vars_double);
#ifdef TEST_VOIDSTAR
    NC_TEST(nc_get_vars);
#endif /* TEST_VOIDSTAR */
    NC_TEST(nc_get_varm_text);
    NC_TEST(nc_get_varm_uchar);
    NC_TEST(nc_get_varm_schar);
    NC_TEST(nc_get_varm_short);
    NC_TEST(nc_get_varm_int);
    NC_TEST(nc_get_varm_long);
    NC_TEST(nc_get_varm_float);
    NC_TEST(nc_get_varm_double);
#ifdef TEST_VOIDSTAR
    NC_TEST(nc_get_varm);
#endif /* TEST_VOIDSTAR */
    NC_TEST(nc_get_att_text);
    NC_TEST(nc_get_att_uchar);
    NC_TEST(nc_get_att_schar);
    NC_TEST(nc_get_att_short);
    NC_TEST(nc_get_att_int);
    NC_TEST(nc_get_att_long);
    NC_TEST(nc_get_att_float);
    NC_TEST(nc_get_att_double);
#ifdef TEST_VOIDSTAR
    NC_TEST(nc_get_att);
#endif /* TEST_VOIDSTAR */
    NC_TEST(nc_inq_att);
    NC_TEST(nc_inq_attname);
    NC_TEST(nc_inq_attid);
    NC_TEST(nc_inq_attlen);
    NC_TEST(nc_inq_atttype);

	/* Test write functions */
    if (! read_only) {
	NC_TEST(nc_create);
	NC_TEST(nc_redef);
	/* NC_TEST(nc_enddef); *//* redundant */
	NC_TEST(nc_sync);
	NC_TEST(nc_abort);
	NC_TEST(nc_def_dim);
	NC_TEST(nc_rename_dim);
	NC_TEST(nc_def_var);
	NC_TEST(nc_put_var_text);
	NC_TEST(nc_put_var_uchar);
	NC_TEST(nc_put_var_schar);
	NC_TEST(nc_put_var_short);
	NC_TEST(nc_put_var_int);
	NC_TEST(nc_put_var_long);
	NC_TEST(nc_put_var_float);
	NC_TEST(nc_put_var_double);
	NC_TEST(nc_put_var1_text);
	NC_TEST(nc_put_var1_uchar);
	NC_TEST(nc_put_var1_schar);
	NC_TEST(nc_put_var1_short);
	NC_TEST(nc_put_var1_int);
	NC_TEST(nc_put_var1_long);
	NC_TEST(nc_put_var1_float);
	NC_TEST(nc_put_var1_double);
#ifdef TEST_VOIDSTAR
	NC_TEST(nc_put_var1);
#endif /* TEST_VOIDSTAR */
	NC_TEST(nc_put_vara_text);
	NC_TEST(nc_put_vara_uchar);
	NC_TEST(nc_put_vara_schar);
	NC_TEST(nc_put_vara_short);
	NC_TEST(nc_put_vara_int);
	NC_TEST(nc_put_vara_long);
	NC_TEST(nc_put_vara_float);
	NC_TEST(nc_put_vara_double);
#ifdef TEST_VOIDSTAR
	NC_TEST(nc_put_vara);
#endif /* TEST_VOIDSTAR */
	NC_TEST(nc_put_vars_text);
	NC_TEST(nc_put_vars_uchar);
	NC_TEST(nc_put_vars_schar);
	NC_TEST(nc_put_vars_short);
	NC_TEST(nc_put_vars_int);
	NC_TEST(nc_put_vars_long);
	NC_TEST(nc_put_vars_float);
	NC_TEST(nc_put_vars_double);
#ifdef TEST_VOIDSTAR
	NC_TEST(nc_put_vars);
#endif /* TEST_VOIDSTAR */
	NC_TEST(nc_put_varm_text);
	NC_TEST(nc_put_varm_uchar);
	NC_TEST(nc_put_varm_schar);
	NC_TEST(nc_put_varm_short);
	NC_TEST(nc_put_varm_int);
	NC_TEST(nc_put_varm_long);
	NC_TEST(nc_put_varm_float);
	NC_TEST(nc_put_varm_double);
#ifdef TEST_VOIDSTAR
	NC_TEST(nc_put_varm);
#endif /* TEST_VOIDSTAR */
	NC_TEST(nc_rename_var);
	NC_TEST(nc_put_att_text);
	NC_TEST(nc_put_att_uchar);
	NC_TEST(nc_put_att_schar);
	NC_TEST(nc_put_att_short);
	NC_TEST(nc_put_att_int);
	NC_TEST(nc_put_att_long);
	NC_TEST(nc_put_att_float);
	NC_TEST(nc_put_att_double);
#ifdef TEST_VOIDSTAR
	NC_TEST(nc_put_att);
#endif /* TEST_VOIDSTAR */
	NC_TEST(nc_copy_att);
	NC_TEST(nc_rename_att);
	NC_TEST(nc_del_att);
	NC_TEST(nc_set_fill);
    }

    print( "\nTotal number of failures: %d\n", nfailsTotal);
    return nfailsTotal > 0;
}
コード例 #3
0
int
main(int argc, char *argv[])
{
    int i;
    int  nfailsTotal = 0;        /* total number of failures */

    /* Both CRAY MPP and OSF/1 Alpha systems need this.  Some of the
     * extreme test assignments in this program trigger floating point
     * exceptions on CRAY T90
     */
    (void) signal(SIGFPE, SIG_IGN);

    verbose = 0;
    max_nmpt = 8;

    /* Initialize global variables defining test file */
    init_gvars();

    /* If you uncomment the nc_set_log_level line, you will get a lot
     * of debugging info. If you set the number higher, you'll get
     * more. 6 is max, 0 shows only errors. 3 is a good place to
     * start. */
    /*nc_set_log_level(3);*/

    fprintf(stderr, "Testing %d different netCDF formats.\n", NUM_FORMATS);

    /* Go thru formats and run all tests for each of two (for netCDF-3
     * only builds), or 3 (for netCDF-4 builds) different formats. Do
     * the netCDF-4 format last, however, because, as an additional
     * test, the ../nc_test4/tst_nc_test_file program looks at the
     * output of this program. */
    for (i = 1; i <= NUM_FORMATS; i++)
    {
       switch (i) 
       {
	  case NC_FORMAT_CLASSIC:
	     nc_set_default_format(NC_FORMAT_CLASSIC, NULL);
	     fprintf(stderr, "\n\nSwitching to netCDF classic format.\n");
	     strcpy(testfile, "nc_test_classic.nc");
	     break;
	  case NC_FORMAT_64BIT:
	     nc_set_default_format(NC_FORMAT_64BIT, NULL);
	     fprintf(stderr, "\n\nSwitching to 64-bit offset format.\n");
	     strcpy(testfile, "nc_test_64bit.nc");
	     break;
#ifdef USE_NETCDF4
	  case NC_FORMAT_NETCDF4: /* actually it's _CLASSIC. */
	     nc_set_default_format(NC_FORMAT_NETCDF4_CLASSIC, NULL);
	     strcpy(testfile, "nc_test_netcdf4.nc");
	     fprintf(stderr, "\n\nSwitching to netCDF-4 format (with NC_CLASSIC_MODEL).\n");
	     break;
#endif
	  default:
	     fprintf(stderr, "Unexpected format!\n");
	     return 2;
       }

	/* Write the test file, needed for the read-only tests below. */
       write_file(testfile);

	/* delete any existing scratch netCDF file */
       (void) remove(scratch);

	/* Test read-only functions, using pre-generated test-file */
 	NC_TEST(nc_strerror);
	NC_TEST(nc_open);
	NC_TEST(nc_close);
	NC_TEST(nc_inq);
	NC_TEST(nc_inq_dimid);
	NC_TEST(nc_inq_dim);
	NC_TEST(nc_inq_dimlen);
	NC_TEST(nc_inq_dimname);
	NC_TEST(nc_inq_varid);
	NC_TEST(nc_inq_var);
	NC_TEST(nc_inq_natts);
	NC_TEST(nc_inq_ndims);
	NC_TEST(nc_inq_nvars);
	NC_TEST(nc_inq_unlimdim);
	NC_TEST(nc_inq_vardimid);
	NC_TEST(nc_inq_varname);
	NC_TEST(nc_inq_varnatts);
	NC_TEST(nc_inq_varndims);
	NC_TEST(nc_inq_vartype);
	NC_TEST(nc_get_var_text);
	NC_TEST(nc_get_var_uchar);
	NC_TEST(nc_get_var_schar);
	NC_TEST(nc_get_var_short);
	NC_TEST(nc_get_var_int);
	NC_TEST(nc_get_var_long);
	NC_TEST(nc_get_var_float);
	NC_TEST(nc_get_var_double);
	NC_TEST(nc_get_var1_text);
	NC_TEST(nc_get_var1_uchar);
	NC_TEST(nc_get_var1_schar);
	NC_TEST(nc_get_var1_short);
	NC_TEST(nc_get_var1_int);
	NC_TEST(nc_get_var1_long);
	NC_TEST(nc_get_var1_float);
	NC_TEST(nc_get_var1_double);
	NC_TEST(nc_get_var1);
	NC_TEST(nc_get_vara_text);
	NC_TEST(nc_get_vara_uchar);
	NC_TEST(nc_get_vara_schar);
	NC_TEST(nc_get_vara_short);
	NC_TEST(nc_get_vara_int);
	NC_TEST(nc_get_vara_long);
	NC_TEST(nc_get_vara_float);
	NC_TEST(nc_get_vara_double);
	NC_TEST(nc_get_vara);
	NC_TEST(nc_get_vars_text);
	NC_TEST(nc_get_vars_uchar);
	NC_TEST(nc_get_vars_schar);
	NC_TEST(nc_get_vars_short);
	NC_TEST(nc_get_vars_int);
	NC_TEST(nc_get_vars_long);
	NC_TEST(nc_get_vars_float);
	NC_TEST(nc_get_vars_double);
	NC_TEST(nc_get_vars);
	NC_TEST(nc_get_varm_text);
	NC_TEST(nc_get_varm_uchar);
	NC_TEST(nc_get_varm_schar);
	NC_TEST(nc_get_varm_short);
	NC_TEST(nc_get_varm_int);
	NC_TEST(nc_get_varm_long);
	NC_TEST(nc_get_varm_float);
	NC_TEST(nc_get_varm_double);
	NC_TEST(nc_get_varm);
	NC_TEST(nc_get_att_text);
	NC_TEST(nc_get_att_uchar);
	NC_TEST(nc_get_att_schar);
	NC_TEST(nc_get_att_short);
	NC_TEST(nc_get_att_int);
	NC_TEST(nc_get_att_long);
	NC_TEST(nc_get_att_float);
	NC_TEST(nc_get_att_double);
	NC_TEST(nc_get_att);
	NC_TEST(nc_inq_att);
	NC_TEST(nc_inq_attname);
	NC_TEST(nc_inq_attid);
	NC_TEST(nc_inq_attlen);
	NC_TEST(nc_inq_atttype);

	/* Test write functions */
	NC_TEST(nc_create);
	NC_TEST(nc_redef);
	/* NC_TEST(nc_enddef); *//* redundant */
	NC_TEST(nc_sync);
	NC_TEST(nc_abort);
	NC_TEST(nc_def_dim);
	NC_TEST(nc_rename_dim);
	NC_TEST(nc_def_var);
	NC_TEST(nc_put_var_text);
	NC_TEST(nc_put_var_uchar);
	NC_TEST(nc_put_var_schar);
	NC_TEST(nc_put_var_short);
	NC_TEST(nc_put_var_int);
	NC_TEST(nc_put_var_long);
	NC_TEST(nc_put_var_float);
	NC_TEST(nc_put_var_double);
	NC_TEST(nc_put_var1_text);
	NC_TEST(nc_put_var1_uchar);
	NC_TEST(nc_put_var1_schar);
	NC_TEST(nc_put_var1_short);
	NC_TEST(nc_put_var1_int);
	NC_TEST(nc_put_var1_long);
	NC_TEST(nc_put_var1_float);
	NC_TEST(nc_put_var1_double);
	NC_TEST(nc_put_var1);
	NC_TEST(nc_put_vara_text);
	NC_TEST(nc_put_vara_uchar);
	NC_TEST(nc_put_vara_schar);
	NC_TEST(nc_put_vara_short);
	NC_TEST(nc_put_vara_int);
	NC_TEST(nc_put_vara_long);
	NC_TEST(nc_put_vara_float);
	NC_TEST(nc_put_vara_double);
	NC_TEST(nc_put_vara);
	NC_TEST(nc_put_vars_text);
	NC_TEST(nc_put_vars_uchar);
	NC_TEST(nc_put_vars_schar);
	NC_TEST(nc_put_vars_short);
	NC_TEST(nc_put_vars_int);
	NC_TEST(nc_put_vars_long);
	NC_TEST(nc_put_vars_float);
	NC_TEST(nc_put_vars_double);
	NC_TEST(nc_put_vars);
	NC_TEST(nc_put_varm_text);
	NC_TEST(nc_put_varm_uchar);
	NC_TEST(nc_put_varm_schar);
	NC_TEST(nc_put_varm_short);
	NC_TEST(nc_put_varm_int);
	NC_TEST(nc_put_varm_long);
	NC_TEST(nc_put_varm_float);
	NC_TEST(nc_put_varm_double);
	NC_TEST(nc_put_varm);
	NC_TEST(nc_rename_var);
	NC_TEST(nc_put_att_text);
	NC_TEST(nc_put_att_uchar);
	NC_TEST(nc_put_att_schar);
	NC_TEST(nc_put_att_short);
	NC_TEST(nc_put_att_int);
	NC_TEST(nc_put_att_long);
	NC_TEST(nc_put_att_float);
	NC_TEST(nc_put_att_double);
	NC_TEST(nc_put_att);
	NC_TEST(nc_copy_att);
	NC_TEST(nc_rename_att);
	NC_TEST(nc_del_att);
	NC_TEST(nc_set_default_format);
    }

    fprintf(stderr, "\n*** Total number of failures: %d\n", nfailsTotal);

    if (nfailsTotal)
    {
       fprintf(stderr, "*** nc_test FAILURE!!!\n");
       return 2;
    }
    else
       fprintf(stderr, "*** nc_test SUCCESS!!!\n");

    return 0;
}