Exemple #1
0
int main ()
{
  int i, failures = 0;
  static const struct foo x[] =
  {
    TEST  (	-2,	-1),
    TESTZ (	-2,	 0),
    TEST  (	-2,	 1),
    TEST  (	-1,	-1),
    TESTZ (	-1,	 0),
    TEST  (	-1,	 1),
    TEST  (	 0,	-1),
    TESTZ (	 0,	 0),
    TEST  (	 0,	 1),
    TEST  (	 1,	-1),
    TESTZ (	 1,	 0),
    TEST  (	 1,	 1),
    TEST  (	 2,	-1),
    TESTZ (	 2,	 0),
    TEST  (	 2,	 1)
  };

  for (i = 0; i < sizeof x / sizeof x[0]; i++)
    {
      TRY (add, "+");
      TRY (sub, "-");
      TRY (mul, "*");
      TRY (div, "/");
    }

  if (failures)
    abort ();
  exit (0);
}
Exemple #2
0
int main(int argc, char *argv[])
{
  int i;
  int retval = 0;

  kpse_set_progname(argv[0]);
  progname = xstrdup(program_invocation_short_name);

#ifdef _WIN32
  SetConsoleCtrlHandler((PHANDLER_ROUTINE)sigint_handler, TRUE);
#else
# ifdef SIGHUP
  signal (SIGHUP, sigint_handler);
# endif
# ifdef SIGINT
  signal (SIGINT, sigint_handler);
# endif
# ifdef SIGQUIT
  signal (SIGQUIT, sigint_handler);
# endif
# ifdef SIGEMT
  signal (SIGEMT, sigint_handler);
# endif
# ifdef SIGPIPE
  signal (SIGPIPE, sigint_handler);
# endif
# ifdef SIGTERM
  signal (SIGTERM, sigint_handler);
# endif
#endif

  if (strlen(progname) > 4 && FILESTRNCASEEQ(progname + strlen(progname) - 4, ".exe", 4)) {
    *(progname + strlen(progname) - 4) = '\0';
  }
  is_ht = FILESTRCASEEQ(progname, "ht");

  argv = parse_arguments(&argc, argv);

#if 0
  fprintf(stderr, "%s:\n", progname);
  for (i = 1; i < argc; i++) 
    fprintf(stderr, "\t argv[%d] = %s\n", i, argv[i]);
  fprintf(stderr, "\nconfig(%d,%d) = ", math, dtd);
  for (i = 0; i < 3; i++)
    fprintf(stderr, "%s ", stdcfg[math][dtd][i]);
  fprintf(stderr, "\n");
#endif
  
  texargs = (force ? "--interaction=nonstopmode" : "");

  if (TESTZ(argv[1])) {
    fprintf(stderr, "%s: error, no file specified.\n", progname);
    exit(1);
  }

  texsrc = xstrdup(argv[1]);

#if 0
  /* Rely on latex / kpathsea to find the right source file. */
  if ((strlen(texsrc) < 4)
      || _strnicmp(texsrc + strlen(texsrc) - 4, ".tex", 4) != 0) {
    texsrc = concat(texsrc, ".tex");
  }
#endif

  texfile = xstrdup(texsrc);

  if ((strlen(texfile) >= 4) 
      && _strnicmp(texfile + strlen(texfile) - 4, ".tex", 4) == 0) {
    *(texfile + strlen(texfile) - 4) = '\0';
  }

  if (TESTZ(output_name)) {
    output_name = xstrdup(texfile);
  }
  else {
    if ((strlen(output_name) >= 4) 
	&& _strnicmp(output_name + strlen(output_name) - 4, ".tex", 4) == 0) {
      *(output_name + strlen(output_name) - 4) = '\0';
    }
    texargs = concat3(texargs, " --jobname=", output_name);
  }

#if 0
  // copy the original name to output name if needed
  if (TESTNZ(output_dir)) {
    texfile = concat3(output_dir, "\\", output_name);
  }
  else if (TESTNZ(output_name)) {
    texfile = xstrdup(output_name);
  }
  else 
    texfile = NULL;

  if (texfile) {
    unixtodos_filename(texfile);
    
    if (dry_run) {
      fprintf(stderr, "%s: copying %s to %s\n", progname, texsrc, texfile);
    }
    else {
      if (CopyFile(texsrc, texfile, false) == 0) {
	fprintf(stderr, "%s: failed to copy %s to %s (Error %d)\n",
		progname, texsrc, texfile, GetLastError());
      }
    }
    free(texfile);
  }

  texfile = xstrdup(output_name);

  if (TESTNZ(output_dir)) {
    pushd(output_dir);
    xputenv("KPSE_DOT", cwd);
    xputenv("TEXINPUTS", concatn(cwd, "/", output_dir, ";", NULL));
    if (dry_run) {
      fprintf(stderr, "%s: changing directory to %s\n", progname, output_dir);
      fprintf(stderr, "%s: setting KPSE_DOT to %s\n", progname, cwd);
    }
  }
#endif
  if (is_ht) {
    retval = ht(argc, argv);
  }
  else if (FILESTRCASEEQ(progname, "httex")) {
    retval = ht_engine(runstr_tex, argc, argv);
  }
  else if (FILESTRCASEEQ(progname, "htlatex")) {
    retval = ht_engine(runstr_latex, argc, argv);
  }
  else if (FILESTRCASEEQ(progname, "httexi")) {
    retval = ht_engine(runstr_texi, argc, argv);
  }
  else {
    fprintf(stderr, "%s: %s is unknown, aborting.\n", argv[0], progname);
    retval = 1;
  }

  if (opt_index) {
    /* copy dest_dir/output_name.html to dest_dir/index.html */
    char *destfile = output_name;
    char *indexfile = "index.html";

    if (TESTNZ(output_dir)) {
      destfile = concat3(output_dir, "\\", output_name);
      indexfile = concat(output_dir, "\\index.html");
    }

    if ((strlen(destfile) < 5) 
	|| _strnicmp(destfile + strlen(destfile) - 5, ".html", 5) != 0) {
      destfile = concat(destfile, ".html");
    }
    
    if (CopyFile(destfile, indexfile, false) == 0) {
      fprintf(stderr, "%s: failed to copy %s to %s (Error %d)\n",
	      progname, destfile, indexfile, GetLastError());
    }
  }

  mt_exit(retval);

  /* Not Reached */
  return retval;
}