]> git.pld-linux.org Git - packages/gcc2.git/blob - gcc2-cpp-dos-newlines.patch
- move compressed patch to distfiles
[packages/gcc2.git] / gcc2-cpp-dos-newlines.patch
1 # DP: Handle DOS newlines after backslashes.
2 # DP: Patch from http://www.cygnus.com/ml/egcs/1999-Jan/0784.html
3
4 --- gcc/cccp.c.orig     Thu Jun 24 15:11:40 1999
5 +++ gcc/cccp.c  Mon Aug  9 12:21:55 1999
6 @@ -1023,7 +1023,8 @@
7     retrying if necessary.  If MAX_READ_LEN is defined, read at most
8     that bytes at a time.  Return a negative value if an error occurs,
9     otherwise return the actual number of bytes read,
10 -   which must be LEN unless end-of-file was reached.  */
11 +   which may be < LEN if CRs have been skipped, though we try not to do
12 +   that.  */
13  
14  static int
15  safe_read (desc, ptr, len)
16 @@ -1032,6 +1033,7 @@
17       int len;
18  {
19    int left, rcount, nchars;
20 +  char *rptr;
21  
22    left = len;
23    while (left > 0) {
24 @@ -1051,8 +1053,20 @@
25        }
26      if (nchars == 0)
27        break;
28 -    ptr += nchars;
29 +
30 +    /* CRLF pairs, found with Unix when processing DOS files,
31 +       throw off backslash-newline removal.
32 +       Therefore, CRs are thrown away here. */
33      left -= nchars;
34 +    rptr = ptr;
35 +    while(nchars--)
36 +      {
37 +       if(*rptr == '\r' && *(rptr+1) == '\n')
38 +         left++;
39 +       else
40 +         *ptr++ = *rptr;
41 +       rptr++;
42 +      }
43    }
44    return len - left;
45  }
46 @@ -2085,8 +2099,8 @@
47      for (;;) {
48        cnt = safe_read (f, (char *) fp->buf + size, bsize - size);
49        if (cnt < 0) goto perror;        /* error! */
50 +      if (cnt == 0) break; /* End of file */
51        size += cnt;
52 -      if (size != bsize) break;        /* End of file */
53        bsize *= 2;
54        fp->buf = (U_CHAR *) xrealloc (fp->buf, bsize + 2);
55      }
56 @@ -5024,6 +5038,8 @@
57           map_list_ptr->map_list_map = ptr;
58  
59           while ((ch = getc (f)) != '\n')
60 +           if (ch == '\r')
61 +               continue;
62             if (ch == EOF)
63               break;
64         }
65 @@ -5256,9 +5272,9 @@
66        i = safe_read (f, (char *) fp->buf + st_size, bsize - st_size);
67        if (i < 0)
68         goto nope;      /* error! */
69 -      st_size += i;
70 -      if (st_size != bsize)
71 +      if (i == 0)
72         break;  /* End of file */
73 +      st_size += i;
74        bsize *= 2;
75        fp->buf = (U_CHAR *) xrealloc (fp->buf, bsize + 2);
76      }
This page took 0.066812 seconds and 3 git commands to generate.