int streambuf::xsputn(register const char* s, int n) { if (n <= 0) return 0; register int more = n; for (;;) { int count = _epptr - _pptr; // Space available. if (count > 0) { if (count > more) count = more; if (count > 20) { memcpy(_pptr, s, count); s += count; _pptr += count; } else if (count <= 0) count = 0; else { register char *p = _pptr; for (register int i = count; --i >= 0; ) *p++ = *s++; _pptr = p; } more -= count; } if (more == 0 || __overflow(this, (unsigned char)*s++) == EOF) break; more--; } return n - more; }
_IO_size_t attribute_compat_text_section _IO_old_file_xsputn (_IO_FILE *f, const void *data, _IO_size_t n) { const char *s = (char *) data; _IO_size_t to_do = n; int must_flush = 0; _IO_size_t count = 0; if (n <= 0) return 0; /* This is an optimized implementation. If the amount to be written straddles a block boundary (or the filebuf is unbuffered), use sys_write directly. */ /* First figure out how much space is available in the buffer. */ if ((f->_flags & _IO_LINE_BUF) && (f->_flags & _IO_CURRENTLY_PUTTING)) { count = f->_IO_buf_end - f->_IO_write_ptr; if (count >= n) { const char *p; for (p = s + n; p > s; ) { if (*--p == '\n') { count = p - s + 1; must_flush = 1; break; } } } } else if (f->_IO_write_end > f->_IO_write_ptr) count = f->_IO_write_end - f->_IO_write_ptr; /* Space available. */ /* Then fill the buffer. */ if (count > 0) { if (count > to_do) count = to_do; if (count > 20) { #ifdef _LIBC f->_IO_write_ptr = __mempcpy (f->_IO_write_ptr, s, count); #else memcpy (f->_IO_write_ptr, s, count); f->_IO_write_ptr += count; #endif s += count; } else { char *p = f->_IO_write_ptr; int i = (int) count; while (--i >= 0) *p++ = *s++; f->_IO_write_ptr = p; } to_do -= count; } if (to_do + must_flush > 0) { _IO_size_t block_size, do_write; /* Next flush the (full) buffer. */ if (__overflow (f, EOF) == EOF) return to_do == 0 ? EOF : n - to_do; /* Try to maintain alignment: write a whole number of blocks. dont_write is what gets left over. */ block_size = f->_IO_buf_end - f->_IO_buf_base; do_write = to_do - (block_size >= 128 ? to_do % block_size : 0); if (do_write) { count = old_do_write (f, s, do_write); to_do -= count; if (count < do_write) return n - to_do; } /* Now write out the remainder. Normally, this will fit in the buffer, but it's somewhat messier for line-buffered files, so we let _IO_default_xsputn handle the general case. */ if (to_do) to_do -= _IO_default_xsputn (f, s+do_write, to_do); } return n - to_do; }
extern __inline __attribute__ ((__gnu_inline__)) int putc_unlocked (int __c, FILE *__stream) { return (__builtin_expect (((__stream)->_IO_write_ptr >= (__stream)->_IO_write_end), 0) ? __overflow (__stream, (unsigned char) (__c)) : (unsigned char) (*(__stream)->_IO_write_ptr++ = (__c))); }
extern __inline __attribute__ ((__gnu_inline__)) int putchar_unlocked (int __c) { return (__builtin_expect (((stdout)->_IO_write_ptr >= (stdout)->_IO_write_end), 0) ? __overflow (stdout, (unsigned char) (__c)) : (unsigned char) (*(stdout)->_IO_write_ptr++ = (__c))); }
// address: 80498b0 void proc5(char *param1, FILE *param2, char param3[], char param4[], char param5[], __size32 *param6) { __size32 eax; // r24 __size32 ebx; // r27 eax = *param6; if (eax != 0) { do { eax = *(param6 + 4); } while (eax != 0); } if (param3 == 0) { fprintf(param2, "%s %s\n", param4, param5); } else { fprintf(param2, "%s (%s) %s\n", param3, param4, param5); } switch(ebx) { case 0: case 1: L16: L15: dcgettext(0, param1, 5); vfprintf(); eax = *(param2 + 20); if (eax < *(param2 + 24)) { *(__size8*)eax = 10; *(__size32*)(param2 + 20)++; L9: eax = *0x804b7d0; fputs_unlocked(eax, param2); eax = *(param2 + 20); if (eax < *(param2 + 24)) { *(__size8*)eax = 10; *(__size32*)(param2 + 20)++; L4: dcgettext(0, "This is free software; see the source for copying conditions. There is NO\nwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n", 5); fputs_unlocked(eax, param2); return; } __overflow(); goto L4; } __overflow(); goto L9; case 2: goto L15; case 3: goto L16; case 4: goto L16; case 5: goto L16; case 6: goto L15; case 7: goto L15; case 8: goto L16; case 9: goto L16; } abort(); return; }
int filebuf::xsputn(const char *s, int n) { if (n <= 0) return 0; // This is an optimized implementation. // If the amount to be written straddles a block boundary // (or the filebuf is unbuffered), use sys_write directly. int to_do = n; int must_flush = 0; // First figure out how much space is available in the buffer. int count = _epptr - _pptr; // Space available. if (linebuffered() && (_flags & _S_CURRENTLY_PUTTING)) { count =_ebuf - _pptr; if (count >= n) { for (register const char *p = s + n; p > s; ) { if (*--p == '\n') { count = p - s + 1; must_flush = 1; break; } } } } // Then fill the buffer. if (count > 0) { if (count > to_do) count = to_do; if (count > 20) { memcpy(pptr(), s, count); s += count; } else { register char *p = pptr();; for (register int i = count; --i >= 0; ) *p++ = *s++; } pbump(count); to_do -= count; } if (to_do + must_flush > 0) { // Next flush the (full) buffer. if (__overflow(this, EOF) == EOF) return n - to_do; // Try to maintain alignment: write a whole number of blocks. // dont_write is what gets left over. int block_size = _ebuf - _base; int dont_write = block_size >= 128 ? to_do % block_size : 0; _G_ssize_t count = to_do - dont_write; if (do_write(s, count) == EOF) return n - to_do; to_do = dont_write; // Now write out the remainder. Normally, this will fit in the // buffer, but it's somewhat messier for line-buffered files, // so we let streambuf::xsputn handle the general case. if (dont_write) to_do -= streambuf::xsputn(s+count, dont_write); } return n - to_do; }