m4_undivert (struct obstack *obs, int argc, token_data **argv)
{
  int i, file;
  FILE *fp;
  char *endp;

  if (argc == 1)
    undivert_all ();
  else
    for (i = 1; i < argc; i++)
      {
	file = strtol (ARG (i), &endp, 10);
	if (*endp == '\0' && !isspace (to_uchar (*ARG (i))))
	  insert_diversion (file);
	else if (no_gnu_extensions)
	  M4ERROR ((warning_status, 0,
		    "non-numeric argument to builtin `%s'", ARG (0)));
	else
	  {
	    fp = m4_path_search (ARG (i), NULL);
	    if (fp != NULL)
	      {
		insert_file (fp);
		if (fclose (fp) == EOF)
		  M4ERROR ((warning_status, errno,
			    "error undiverting `%s'", ARG (i)));
	      }
	    else
	      M4ERROR ((warning_status, errno,
			"cannot undivert `%s'", ARG (i)));
	  }
      }
}
m4_undivert (struct obstack *obs, int argc, token_data **argv)
{
  int i, file;
  FILE *fp;
  char *endp;

  if (argc == 1)
    undivert_all ();
  else
    for (i = 1; i < argc; i++)
      {
	file = strtol (ARG (i), &endp, 10);
	if (*endp == '\0' && !isspace (to_uchar (*ARG (i))))
	  insert_diversion (file);
	else if (no_gnu_extensions)
	  M4ERROR ((warning_status, 0,
		    "non-numeric argument to builtin `%s'", ARG (0)));
	else
	  {
	    fp = m4_path_search (ARG (i), NULL);
	    if (fp != NULL)
	      {
		insert_file (fp);
		if (fclose (fp) == EOF)
		  M4ERROR ((warning_status, errno,
			    "error undiverting `%s'", ARG (i)));
	      }
	    else
	      M4ERROR ((warning_status, errno,
			"cannot undivert `%s'", ARG (i)));
	  }
      }
}