• R/O
  • SSH

quipu: Commit

quipu mercurial repository


Commit MetaInfo

Revision013b77b789b704d65073bffc2be84aa2305dddc3 (tree)
Zeit2020-03-27 03:49:19
AutorAgustina Arzille <avarzille@rise...>
CommiterAgustina Arzille

Log Message

Cleanup the IO code

Ändern Zusammenfassung

Diff

diff -r 579a117fe5f0 -r 013b77b789b7 sysdeps/io-unix.h
--- a/sysdeps/io-unix.h Wed Mar 25 23:07:46 2020 -0300
+++ b/sysdeps/io-unix.h Thu Mar 26 15:49:19 2020 -0300
@@ -140,12 +140,12 @@
140140 static int
141141 osfd_read (interpreter *interp, stream& strm, void *dst, uint32_t bytes)
142142 {
143- int fd = (int)(intptr_t)strm.cookie, ret;
143+ osfd_t fd = as_osfd (strm.cookie);
144144
145145 while (true)
146146 {
147147 interp->begin_blocking ();
148- ret = (int)read (fd, dst, bytes);
148+ int ret = (int)read (fd, dst, bytes);
149149 interp->end_blocking ();
150150
151151 if (ret < 0 && errno == EINTR)
@@ -161,7 +161,8 @@
161161 static int
162162 osfd_write (interpreter *interp, stream& strm, const void *ptr, uint32_t bytes)
163163 {
164- int fd = (int)(intptr_t)strm.cookie, ret = 0;
164+ osfd_t fd = as_osfd (strm.cookie);
165+ int ret = 0;
165166 const char *src = (const char *)ptr;
166167
167168 while (ret < (int)bytes)
@@ -194,14 +195,14 @@
194195 #endif
195196
196197 errno = 0;
197- pos.offset = lseek ((int)(intptr_t)strm.cookie, pos.offset, whence);
198+ pos.offset = lseek (as_osfd (strm.cookie), pos.offset, whence);
198199 return (errno == 0);
199200 }
200201
201202 static bool
202203 osfd_close (interpreter *, stream& strm)
203204 {
204- return (llio_close ((int)(intptr_t)strm.cookie));
205+ return (llio_close (as_osfd (strm.cookie)));
205206 }
206207
207208 static stream::xops file_ops (int)
diff -r 579a117fe5f0 -r 013b77b789b7 sysdeps/io-windows.h
--- a/sysdeps/io-windows.h Wed Mar 25 23:07:46 2020 -0300
+++ b/sysdeps/io-windows.h Thu Mar 26 15:49:19 2020 -0300
@@ -206,7 +206,10 @@
206206 {
207207 int ch = *inp;
208208 if (ch == 13 && inp[1] == 10)
209- *outp++ = *++inp;
209+ {
210+ *outp++ = 10;
211+ ++inp;
212+ }
210213 else
211214 *outp++ = ch;
212215 }
@@ -226,6 +229,8 @@
226229 *outp++ = b;
227230 }
228231 }
232+ else
233+ *outp++ = *inp;
229234
230235 return (outp - dst);
231236 }
Show on old repository browser