OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [920726-1.c] - Blame information for rev 688

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 688 jeremybenn
#include <stdio.h>
2
#include <stdarg.h>
3
 
4
struct spurious
5
{
6
    int anumber;
7
};
8
 
9
int first(char *buf, char *fmt, ...)
10
{
11
  int pos, number;
12
  va_list args;
13
  int dummy;
14
  char *bp = buf;
15
 
16
  va_start(args, fmt);
17
  for (pos = 0; fmt[pos]; pos++)
18
    if (fmt[pos] == 'i')
19
      {
20
        number = va_arg(args, int);
21
        sprintf(bp, "%d", number);
22
        bp += strlen(bp);
23
      }
24
    else
25
      *bp++ = fmt[pos];
26
 
27
  va_end(args);
28
  *bp = 0;
29
  return dummy;
30
}
31
 
32
struct spurious second(char *buf,char *fmt, ...)
33
{
34
  int pos, number;
35
  va_list args;
36
  struct spurious dummy;
37
  char *bp = buf;
38
 
39
  va_start(args, fmt);
40
  for (pos = 0; fmt[pos]; pos++)
41
    if (fmt[pos] == 'i')
42
      {
43
        number = va_arg(args, int);
44
        sprintf(bp, "%d", number);
45
        bp += strlen(bp);
46
      }
47
    else
48
      *bp++ = fmt[pos];
49
 
50
  va_end(args);
51
  *bp = 0;
52
  return dummy;
53
}
54
 
55
main()
56
{
57
  char buf1[100], buf2[100];
58
  first(buf1, "i i ", 5, 20);
59
  second(buf2, "i i ", 5, 20);
60
  if (strcmp ("5 20 ", buf1) || strcmp ("5 20 ", buf2))
61
    abort();
62
  exit(0);
63
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.