Back to index

glibc  2.9
Defines | Functions | Variables
iowpadn.c File Reference
#include "libioP.h"

Go to the source code of this file.

Defines

#define PADSIZE   16

Functions

_IO_ssize_t _IO_wpadn (_IO_FILE *fp, wint_t pad, _IO_ssize_t count)

Variables

static wchar_t const blanks [PADSIZE]
static wchar_t const zeroes [PADSIZE]

Define Documentation

#define PADSIZE   16

Definition at line 30 of file iowpadn.c.


Function Documentation

_IO_ssize_t _IO_wpadn ( _IO_FILE fp,
wint_t  pad,
_IO_ssize_t  count 
)

Definition at line 43 of file iowpadn.c.

{
  wchar_t padbuf[PADSIZE];
  const wchar_t *padptr;
  int i;
  _IO_size_t written = 0;
  _IO_size_t w;

  if (pad == L' ')
    padptr = blanks;
  else if (pad == L'0')
    padptr = zeroes;
  else
    {
      for (i = PADSIZE; --i >= 0; )
       padbuf[i] = pad;
      padptr = padbuf;
    }
  for (i = count; i >= PADSIZE; i -= PADSIZE)
    {
      w = _IO_sputn (fp, (char *) padptr, PADSIZE);
      written += w;
      if (w != PADSIZE)
       return written;
    }

  if (i > 0)
    {
      w = _IO_sputn (fp, (char *) padptr, i);
      written += w;
    }
  return written;
}

Variable Documentation

wchar_t const blanks[PADSIZE] [static]
Initial value:
{
  L' ', L' ', L' ', L' ', L' ', L' ', L' ', L' ',
  L' ', L' ', L' ', L' ', L' ', L' ', L' ', L' '
}

Definition at line 31 of file iowpadn.c.

wchar_t const zeroes[PADSIZE] [static]
Initial value:
{
  L'0', L'0', L'0', L'0', L'0', L'0', L'0', L'0',
  L'0', L'0', L'0', L'0', L'0', L'0', L'0', L'0'
}

Definition at line 36 of file iowpadn.c.