comparison src/ls-ascii-helper.cc @ 10315:57a59eae83cc

untabify src C++ source files
author John W. Eaton <jwe@octave.org>
date Thu, 11 Feb 2010 12:41:46 -0500
parents cd96d29c5efa
children fd0a3ac60b0e
comparison
equal deleted inserted replaced
10314:07ebe522dac2 10315:57a59eae83cc
47 while (is) 47 while (is)
48 { 48 {
49 char c = is.peek (); 49 char c = is.peek ();
50 50
51 if (c == '\n' || c == '\r') 51 if (c == '\n' || c == '\r')
52 { 52 {
53 // Reached newline. 53 // Reached newline.
54 if (! keep_newline) 54 if (! keep_newline)
55 { 55 {
56 // Eat the CR or LF character. 56 // Eat the CR or LF character.
57 char d; 57 char d;
58 is.get (d); 58 is.get (d);
59 59
60 // Make sure that for binary-mode opened ascii files 60 // Make sure that for binary-mode opened ascii files
61 // containing CRLF line endings we skip the LF after CR. 61 // containing CRLF line endings we skip the LF after CR.
62 if (c == '\r' && is.peek () == '\n') 62 if (c == '\r' && is.peek () == '\n')
63 { 63 {
64 // Yes, LF following CR, eat it. 64 // Yes, LF following CR, eat it.
65 is.get (d); 65 is.get (d);
66 } 66 }
67 } 67 }
68 68
69 // Newline was found, and read from stream if 69 // Newline was found, and read from stream if
70 // keep_newline == true, so exit loop. 70 // keep_newline == true, so exit loop.
71 break; 71 break;
72 } 72 }
73 else 73 else
74 { 74 {
75 // No newline charater peeked, so read it and proceed to next 75 // No newline charater peeked, so read it and proceed to next
76 // character. 76 // character.
77 char d; 77 char d;
78 is.get (d); 78 is.get (d);
79 } 79 }
80 } 80 }
81 } 81 }
82 82
83 83
84 // If stream IS currently points to a newline (a leftover from a 84 // If stream IS currently points to a newline (a leftover from a
96 96
97 if (c == '\n' || c == '\r') 97 if (c == '\n' || c == '\r')
98 { 98 {
99 // Yes, at newline. 99 // Yes, at newline.
100 do 100 do
101 { 101 {
102 // Eat the CR or LF character. 102 // Eat the CR or LF character.
103 char d; 103 char d;
104 is.get (d); 104 is.get (d);
105 105
106 // Make sure that for binary-mode opened ascii files 106 // Make sure that for binary-mode opened ascii files
107 // containing CRLF line endings we skip the LF after CR. 107 // containing CRLF line endings we skip the LF after CR.
108 if (c == '\r' && is.peek () == '\n') 108 if (c == '\r' && is.peek () == '\n')
109 { 109 {
110 // Yes, LF following CR, eat it. 110 // Yes, LF following CR, eat it.
111 is.get (d); 111 is.get (d);
112 } 112 }
113 113
114 // Peek into next character. 114 // Peek into next character.
115 c = is.peek (); 115 c = is.peek ();
116 116
117 // Loop while still a newline ahead. 117 // Loop while still a newline ahead.
118 } 118 }
119 while (c == '\n' || c == '\r'); 119 while (c == '\n' || c == '\r');
120 } 120 }
121 } 121 }
122 122
123 // Read charaters from stream IS until a newline is reached. 123 // Read charaters from stream IS until a newline is reached.
136 while (is) 136 while (is)
137 { 137 {
138 char c = is.peek (); 138 char c = is.peek ();
139 139
140 if (c == '\n' || c == '\r') 140 if (c == '\n' || c == '\r')
141 { 141 {
142 // Reached newline. 142 // Reached newline.
143 if (! keep_newline) 143 if (! keep_newline)
144 { 144 {
145 // Eat the CR or LF character. 145 // Eat the CR or LF character.
146 char d; 146 char d;
147 is.get (d); 147 is.get (d);
148 148
149 // Make sure that for binary-mode opened ascii files 149 // Make sure that for binary-mode opened ascii files
150 // containing CRLF line endings we skip the LF after 150 // containing CRLF line endings we skip the LF after
151 // CR. 151 // CR.
152 152
153 if (c == '\r' && is.peek () == '\n') 153 if (c == '\r' && is.peek () == '\n')
154 { 154 {
155 // Yes, LF following CR, eat it. 155 // Yes, LF following CR, eat it.
156 is.get (d); 156 is.get (d);
157 } 157 }
158 } 158 }
159 159
160 // Newline was found, and read from stream if 160 // Newline was found, and read from stream if
161 // keep_newline == true, so exit loop. 161 // keep_newline == true, so exit loop.
162 break; 162 break;
163 } 163 }
164 else 164 else
165 { 165 {
166 // No newline charater peeked, so read it, store it, and 166 // No newline charater peeked, so read it, store it, and
167 // proceed to next. 167 // proceed to next.
168 char d; 168 char d;
169 is.get (d); 169 is.get (d);
170 buf << d; 170 buf << d;
171 } 171 }
172 } 172 }
173 173
174 return buf.str (); 174 return buf.str ();
175 } 175 }