/* * Copyright (c) 1995, 1996 Gunther Schadow. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "pg_config.h" #pragma implementation "support.h" #include "misc.h" #include #include "exception.h" /* * Seek the stream `is' for any character in the string `dset'. If * one is found stop *before* the delimiter character and test if we * have just found the first character of `dset'. If so, consume that * character * * RETURN: TRUE if we stopped at the first character of `dset' * FALSE otherwise */ bool match(istream &is, const char *dset) { char ch; while (!is.eof()) { ch = is.peek(); if ( strchr(dset,ch) != 0 ) { if (ch==*dset) { is.get(); return TRUE; } else return FALSE; } else is.get(); } /* EXCPT(E_EOF); don't raise the EOF exception, since we must poll for * EOF anyway */ return FALSE; } /* * DO NOT USE SKIP IF MATCH CAN MEET YOUR NEEDS * * Seek the stream is for any character in the null termiated string * dset. Stop reading *at* the found delimiter character. * * RETURN: SUCCESS if a delimiter was found * FAIL if the stream ended before a delimiter was found */ result skip(istream &is, const char *dset) { char ch; while (!is.eof()) { ch=is.peek(); if ( strchr(dset,ch) != 0) return SUCCESS; is.get(); } /* EXCPT(E_EOF); don't raise the EOF exception, since we must poll for * EOF anyway */ return FAIL; }