summaryrefslogtreecommitdiff
path: root/support/regression/tests/gcc-torture-execute-980707-1.c
blob: a51bd6b3b15cbb8214a71fc18aa80ef21dbd9485 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
   980707-1.c from the execute part of the gcc torture suite.
 */

#include <testfwk.h>

#ifdef __SDCC
#pragma std_c99
#pragma disable_warning 85
#endif

#include <stdlib.h>
#include <string.h>

char **
buildargv (char *input)
{
#if !defined(__SDCC_mcs51) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15)
  static char *arglist[256];
#else
  static char *arglist[8];
#endif
  int numargs = 0;

  while (1)
    {
      while (*input == ' ')
	    input++;
      if (*input == 0)
	    break;
      arglist [numargs++] = input;
      while (*input != ' ' && *input != 0)
	    input++;
      if (*input == 0)
	    break;
      *(input++) = 0;
    }
  arglist [numargs] = NULL;
  return arglist;
}

void
testTortureExecute (void)
{
  char **args;
#if !defined(__SDCC_mcs51) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15)
  char input[256];
#else
  char input[8];
#endif
  int i;

  strcpy(input, " a b");
  args = buildargv(input);

  if (strcmp (args[0], "a"))
    ASSERT (0);
  if (strcmp (args[1], "b"))
    ASSERT (0);
  if (args[2] != NULL)
    ASSERT (0);
  
  return;
}