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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.c-torture/] [compile/] [pr23946.c] - Blame information for rev 859

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 297 jeremybenn
 
2
extern int foo (void);
3
 
4
int
5
avi_parse_comments (int fd, char *buf, int space_left)
6
{
7
  int len = 0, readlen = 0, k;
8
  char *data, *c, *d;
9
 
10
  if (fd <= 0 || !buf || space_left <= 0)
11
    return -1;
12
 
13
  memset (buf, 0, space_left);
14
 
15
  readlen = foo ();
16
  if (!(data = malloc (readlen * sizeof (char) + 1)))
17
    return -1;
18
 
19
  c = data;
20
  space_left--;
21
 
22
  while (len < space_left)
23
    {
24
      if (!c || *c == '\0')
25
        break;
26
      else if (*c == 'I')
27
        {
28
          d = c + 4;
29
 
30
          k = 0;
31
          while (d[k] != '\r' && d[k] != '\n' && d[k] != '\0')
32
            ++k;
33
          if (k >= space_left)
34
            return len;
35
 
36
 
37
          memcpy (buf + len, c, 4);
38
          len += 4;
39
 
40
 
41
          long2str (buf + len, k + 1);
42
          len += 4;
43
 
44
 
45
          memcpy (buf + len, d, k);
46
 
47
          *(buf + len + k + 1) = '\0';
48
 
49
 
50
          if ((k + 1) & 1)
51
            {
52
              k++;
53
              *(buf + len + k + 1) = '\0';
54
            }
55
          len += k + 1;
56
 
57
 
58
          while (*c != '\n' && *c != '\0')
59
            ++c;
60
          if (*c != '\0')
61
            ++c;
62
          else
63
            break;
64
 
65
        }
66
    }
67
  free (data);
68
 
69
  return len;
70
}
71
 
72
 

powered by: WebSVN 2.1.0

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