/*
 * This one bails out of the copy loop as soon as the end of buffer is
 * reached, keeping only one extra spot at the end for either a '\0' or a
 * '<', but not both.
 */

#include "../../../../../lib/stubs.h"

int main (void)
{
  char buffer[BASE_SZ+1];
  char input[BASE_SZ+70];
  char *buf;
  char *buflim;
  char *in;
  char cur;
  int anglelev;
  int skipping;

  in = input;
  buf = buffer;
  buflim = &buffer[sizeof buffer - 1];
    // didn't reserve enough space for both '>' and '\0'!

  skipping = 0;

  cur = *in;
  while (cur != EOS)
  {
    if (buf == buflim)
      break;

    if (cur == '<')
      anglelev = 1;
    else
      goto out;

    *buf = cur;
    buf++;

out:
    in++;
    cur = *in;
  }

  if (anglelev > 0)
  {
    *buf = '>';
    buf++;
  }

  /* BAD */
  *buf = EOS;
  buf++;

  return 0;
}
