home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / glass / glass.lha / GLASS / libtmc / fsccons.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-11-06  |  1.6 KB  |  67 lines

  1. /* 
  2.    Copyright (C) 1990 C van Reewijk, email: dutentb.uucp!reeuwijk
  3.  
  4. This file is part of GLASS.
  5.  
  6. GLASS is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 1, or (at your option)
  9. any later version.
  10.  
  11. GLASS is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GLASS; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. /* File: fsccons.c
  21.  * Last modified: CvR
  22.  *
  23.  * Reading of constructor names.
  24.  */
  25.  
  26. /* Standard UNIX libraries. */
  27. #include <stdio.h>
  28. #include <ctype.h>
  29.  
  30. /* The header of this library */
  31. #include "tmc.h"
  32. #include "config.h"
  33.  
  34. /* Try to read a constructor name in buffer `buf' */
  35. int fscancons( f, buf )
  36.  FILE *f;
  37.  char *buf;
  38. {
  39.     int c;
  40.     char *p;
  41.     char charstr[15];
  42.  
  43.     p = buf;
  44.     if( fscanspace( f ) ) return( 1 );
  45.     c = getc( f );
  46.     while( isalnum( c ) ){
  47.     *p++ = c;
  48.     c = getc( f );
  49.     }
  50.     ungetc( c, f );
  51.     *p = '\0';
  52.     if( p == buf ){
  53.     if( c == EOF ){
  54.         (void) sprintf( charstr, "EOF" );
  55.     }
  56.     else if( c>=' ' && c<='~' ){
  57.         (void) sprintf( charstr, "char '%c'", c );
  58.     }
  59.     else {
  60.         (void) sprintf( charstr, "char 0x%02x", c );
  61.     }
  62.     (void) sprintf( tmerrmsg, "Expected constructor name but got %s", charstr );
  63.     return( 1 );
  64.     }
  65.     return( 0 );
  66. }
  67.