Beispiel #1
0
/**
 * Reads in one word from the file, allocates space for it,
 * and returns it.
 */
static const char * get_a_word(Dictionary dict, FILE * fp)
{
	char word[MAX_WORD+4]; /* allow for 4-byte wide chars */
	const char * s;
	wint_t c;
	mbstate_t mbss;
	int j;

	do {
		c = fgetwc(fp);
	} while ((c != WEOF) && iswspace(c));
	if (c == WEOF) return NULL;

	memset(&mbss, 0, sizeof(mbss));
	for (j=0; (j <= MAX_WORD-1) && (!iswspace(c)) && (c != WEOF);)
	{
		j += wctomb_check(&word[j], c, &mbss);
		c = fgetwc(fp);
	}

	if (j >= MAX_WORD) {
		word[MAX_WORD] = 0x0;
		prt_error("Fatal Error: The dictionary contains a word that "
		          "is too long. The word was: %s", word);
		exit(1);
	}
	word[j] = '\0';
	s = string_set_add(word, dict->string_set);
	return s;
}
Beispiel #2
0
void parse_comment(FILE *file, closure *accum)
{
    wchar_t c = fgetwc(file);
    while(c != L'\n'){
	c = fgetwc(file);
    }
}
Beispiel #3
0
static wchar_t * fwreadFile( FILE ** file, const char * fileName, char * fileMode ) {
    wchar_t * result   ;
    long      oldOffset;
    int       resultLen;
    int       i        ;
    if ( * file == NULL || fileName == NULL || fileMode == NULL ) { return NULL; }
    // save old file state
    oldOffset = ftell( * file );
    fclose( * file );
    // read file contents
    if ( ( * file = fopen( fileName, "r" ) ) == NULL ) { return NULL; }
    //fwide( * file, 1 );
    resultLen = 0;
    while ( fgetwc( * file ) != WEOF ) { resultLen++; }
    // ta_debug_printf( "fwreadFile : resultLen is %d\n", resultLen );
    fseek( * file, 0, SEEK_SET );
    if ( ( result = (wchar_t *)ta_alloc_memory( ( resultLen + 1 ) * sizeof( wchar_t ) ) ) != NULL ) { // + 1 - for final 0
        // fread( result, resultLen, sizeof( wchar_t ), * file );
        int i;
        for ( i = 0; i < resultLen; i++ ) { result[ i ] = fgetwc( * file ); }
        result[ resultLen ] = 0;
    }
    fclose( * file );
    // ta_debug_printf( "fwreadFile : result is [%s|%ls]\n", result, result );
    // restore old file state
    // fileMode = [analog replace_CString for char *]( fileMode, 'w', 'a' );
    for ( i = 0; i < strlen( fileMode ); i++ ) { if ( fileMode[ i ] == 'w' ) { fileMode[ i ] = 'a'; } }
    * file = fopen( fileName, fileMode );
    fwide( * file, 1 );
    fseek( * file, oldOffset, SEEK_SET );
    return result;
}
Beispiel #4
0
int main()
{
    int c,i;
    wchar_t s[100];
    FILE *fil = fopen("hi.txt","w+");
    printf("%d\n",fwide(fil,0));
    fputwc(L'c',fil);
    fputws(L"hi dave\n",fil);
    fwprintf(fil,L"%ls\n",L"geez");
    printf("%d\n",fwide(fil,0));
    printf("%d\n",fputc('z',fil));
    printf("%d\n",fwide(fil,-1));
    printf("%d\n",fputc('y',fil));
    printf("%d\n",fputc('y',fil));
    rewind(fil);
    printf("%d\n",fwide(fil,1));
    printf("%04x\n",fgetwc(fil));
    printf("%04x\n",fgetwc(fil));
    printf(":%x: ",fgetws(s,100,fil));
    for (i=0; i <wcslen(s); i++)
        printf("%04x ",s[i]);
    printf("\n");
    fwscanf(fil,L"%ls ",s);
    for (i=0; i <wcslen(s); i++)
        printf("%04x ",s[i]);
    printf("\n");
    printf("%d\n",fwide(fil,-1));
    printf("%02x\n",fgetc(fil));
    fclose(fil);
}
Beispiel #5
0
static int _read_for (FILE* fp, int(*match)(wchar_t), wchar_t* buffer, int ret)
{
	const wchar_t* skip = L" \n\t\r";
	wchar_t c;

	if(buffer==NULL){
		static wchar_t _buffer[1024];
		buffer = _buffer;
	}

	wchar_t* cur = buffer;

	while(wcinrange(c=fgetwc(fp), skip)){}
	ungetwc(c, fp);

	while(!feof(fp)){
		if(!match(c=fgetwc(fp))){
			break;
		}
		*cur++ = c;
	}
	if(ret){
		ungetwc(c, fp);
	}

	if(cur==buffer){
		return 0;
	}else{
		*cur++ = L'\0';
		return 1;
	}
}
Beispiel #6
0
closure *parse_null(FILE *file, closure *accum)
{
    //printf("parse null\n");
    wchar_t c = fgetwc(file);
    if(iswspace(c)){
	return parse_null(file, nil());
    } else if(c == L'$'){
	return parse_character(file, nil());
    } else if(c == L'#'){
	parse_comment(file, nil());
	return parse_null(file, accum);
    } else if(c == L'\"'){
	return parse_string(file, nil());
    } else if(c == L'\''){
	wchar_t c = fgetwc(file);
	if (!iswspace(c)){
	    ungetwc(c, file);
	    closure *boo = parse_null(file, nil());
	    if (boo != NULL) return quote(boo);
	}
	return symbol(QUOTE);
    } else if(c == L'@'){
	wchar_t c = fgetwc(file);
	if (!iswspace(c)){
	    ungetwc(c, file);
	    closure *boo = parse_null(file, nil());
	    if (boo != NULL) return list(2, symbol(ATPEND), boo);
	}
	return symbol(ATPEND);
    } else if(c == L','){
	wchar_t c = fgetwc(file);
	if (!iswspace(c)){
	    ungetwc(c, file);
	    closure *boo = parse_null(file, nil());
	    if (boo != NULL) return list(2, symbol(COMMA), boo);
	}
	return symbol(COMMA);
    } else if(c == L'*'){
	wchar_t c = fgetwc(file);
	if (!iswspace(c)){
	    ungetwc(c, file);
	    closure *boo = parse_null(file, nil());
	    if (boo != NULL) return list(2, symbol(ASTERIX), boo);
	}
	return symbol(ASTERIX);
    } else if(iswdigit(c)){
	ungetwc(c, file);
	return parse_number(file, nil());
    } else if(c == L'('){
	return parse_list(file, nil());
    } else if(c == L')'){
	ungetwc(c, file);
	return NULL;
    } else if(c == WEOF || c == EOF){
	return NULL;
    } else {
	return parse_symbol(file, cons(character(c), nil()));
    }
}
Beispiel #7
0
// Exercise the interaction between fpos and seek.
TEST(stdio, fpos_t_and_seek) {
  ASSERT_STREQ("C.UTF-8", setlocale(LC_CTYPE, "C.UTF-8"));
  uselocale(LC_GLOBAL_LOCALE);

  // In glibc-2.16 fseek doesn't work properly in wide mode
  // (https://sourceware.org/bugzilla/show_bug.cgi?id=14543). One workaround is
  // to close and re-open the file. We do it in order to make the test pass
  // with all glibcs.

  TemporaryFile tf;
  FILE* fp = fdopen(tf.fd, "w+");
  ASSERT_TRUE(fp != NULL);

  wchar_t mb_two_bytes = 0x00a2;
  wchar_t mb_three_bytes = 0x20ac;
  wchar_t mb_four_bytes = 0x24b62;

  // Write to file.
  ASSERT_EQ(mb_two_bytes, static_cast<wchar_t>(fputwc(mb_two_bytes, fp)));
  ASSERT_EQ(mb_three_bytes, static_cast<wchar_t>(fputwc(mb_three_bytes, fp)));
  ASSERT_EQ(mb_four_bytes, static_cast<wchar_t>(fputwc(mb_four_bytes, fp)));

  fflush(fp);
  fclose(fp);

  fp = fopen(tf.filename, "r");
  ASSERT_TRUE(fp != NULL);

  // Store a valid position.
  fpos_t mb_two_bytes_pos;
  ASSERT_EQ(0, fgetpos(fp, &mb_two_bytes_pos));

  // Move inside mb_four_bytes with fseek.
  long offset_inside_mb = 6;
  ASSERT_EQ(0, fseek(fp, offset_inside_mb, SEEK_SET));

  // Store the "inside multi byte" position.
  fpos_t pos_inside_mb;
  ASSERT_EQ(0, fgetpos(fp, &pos_inside_mb));
#if defined(__BIONIC__)
  ASSERT_EQ(offset_inside_mb, static_cast<off_t>(pos_inside_mb));
#endif

  // Reading from within a byte should produce an error.
  ASSERT_EQ(WEOF, fgetwc(fp));
  ASSERT_EQ(EILSEQ, errno);

  // Reverting to a valid position should work.
  ASSERT_EQ(0, fsetpos(fp, &mb_two_bytes_pos));
  ASSERT_EQ(mb_two_bytes, static_cast<wchar_t>(fgetwc(fp)));

  // Moving withing a multi byte with fsetpos should work but reading should
  // produce an error.
  ASSERT_EQ(0, fsetpos(fp, &pos_inside_mb));
  ASSERT_EQ(WEOF, fgetwc(fp));
  ASSERT_EQ(EILSEQ, errno);

  fclose(fp);
}
Beispiel #8
0
closure *parse_string(FILE *file, closure *accum)
{
    //printf("parse str\n");
    wchar_t c = fgetwc(file);
    if(c == L'\"'){
	return reverse(accum);
    } else if (c == '\\') {
	wchar_t c = fgetwc(file);
	return parse_string(file, cons(character(c), accum));
    } else {
	return parse_string(file, cons(character(c), accum));
    }
}
Beispiel #9
0
wint_t get_character(Dictionary dict, int quote_mode) {
/* This gets the next character from the input, eliminating comments.
   If we're in quote mode, it does not consider the % character for
   comments */
    
    wint_t c;
    
    c = fgetwc(dict->fp);
    if ((c == L'%') && (!quote_mode)) {
		while((c != WEOF) && (c != L'\n')) c = fgetwc(dict->fp);
    }
    if (c == L'\n') dict->line_number++;
    return c;
}
Beispiel #10
0
int next_wword(FILE *fp, wchar_t *wbuff, int len)
{
  int i;
  int in_word = 0;
  int word_length = 0;
  wchar_t w;
  for (i = 0; i < len; i++)
    {
      wbuff[i] = (wchar_t) 0;
    }
  for (i = 0; i < len; i++)
    {
      w = fgetwc(fp);
      if (w == WEOF)
	{
	  return word_length;
	}
      else if (!iswspace(w) && !iswpunct(w))
	{
	  in_word=1;
	  wbuff[word_length] = w;
	  word_length++;
	}
      else if (iswspace(w) || iswpunct(w))
	{
	  if (in_word)
	    {
	      return word_length;
	    }
	}
    }
  return word_length;
}
Beispiel #11
0
int main(int argc, char **argv)
{
  setlocale(LC_ALL, "");

  FILE *pFile;
  pFile = fopen(FILENAME, "r");

  if (pFile == (FILE*)NULL) {
    printf("%s: %s\n", FILENAME, strerror(errno));
    return -1;
  }

  /*
  wint_t wc;
  while ((wc = fgetwc(pFile)) != EOF) {
    wprintf(L"%lc", (wchar_t)wc);
  }
  */

  wint_t wc;
  while ((wc = fgetwc(pFile)) != EOF) {
    wprintf(L"%lc", (wchar_t)wc);
  }

  fclose(pFile);

  return 0;
}
Beispiel #12
0
/*
 * Experimental variant: use wide characters
 * (we assume UTF-8 encoding)
 *
 * We assume that int is large enough to store any character.
 * To do this properly, we should use wint_t.
 */
static int file_reader_next_wchar(reader_t *reader) {
  wint_t c;

  assert(reader->is_stream);

  if (reader->current == EOF) {
    return EOF;
  }

  if (reader->current == '\n') { // this should works in UTF-8?
    reader->line ++;
    reader->column ++;
  }

#if defined(LINUX)
  c = fgetwc_unlocked(reader->input.stream);
#else
  c = fgetwc(reader->input.stream);
#endif

  if (c == WEOF) {
    reader->current = EOF;
  } else {
    reader->current = c;
    reader->pos ++;
    reader->column += wcwidth(c);
  }

  return c;
}
Beispiel #13
0
int main()
{
    char file_in[ ]  = "local_in.txt",
         file_out[ ] = "local_out.txt";
    FILE *fp_in_wide, *fp_out_wide;
    wint_t wc;

    if ( setlocale( LC_CTYPE, "" ) == NULL)
       fwprintf( stderr,
                 L"Sorry, couldn't change to the system's native locale.\n"),
       exit(1);

    if (( fp_in_wide = fopen( file_in, "r" )) == NULL )
       fprintf( stderr, "Error opening the file %s\n", file_in), exit(2);

    if (( fp_out_wide = fopen( file_out, "w" )) == NULL )
       fprintf( stderr, "Error opening the file %s\n", file_out), exit(3);

    fwide( fp_in_wide, 1);            // Not strictly necessary, since first
    fwide( fp_out_wide, 1);           // file access also sets wide or byte mode.

    while (( wc = fgetwc( fp_in_wide )) != WEOF )
    {
       // ... process each wide character read ...

       if ( fputwc( (wchar_t)wc, fp_out_wide) == WEOF)
         break;
    }
    if ( ferror( fp_in_wide))
       fprintf( stderr, "Error reading the file %s\n", file_in);
    if ( ferror( fp_out_wide))
       fprintf( stderr, "Error writing to the file %s\n", file_out);

    return 0;
}
Beispiel #14
0
BOOL CLocalization::Load(LPCTSTR fileName) {
	FILE *file = _wfopen(fileName, _T("rb"));
	if (file == NULL) return FALSE;

	// skip two first bytes
	TCHAR ch = fgetwc(file);
	TCHAR row[ROW_LEN];
	while (fgetws(row, ROW_LEN, file) != NULL) {
		if (row[0] == ';') continue;		// comment
		TCHAR *equal = wcschr(row, '=');
		if (equal != NULL) {
			*equal = '\0';					// split into number and string parts
			TCHAR *str = equal + 1;			// localized string

			// get ID
			UINT id;
			swscanf(row, _T("%d"), &id);
			// remove trailing "
			TCHAR *quote = wcsrchr(str, '"');
			if (quote != NULL) *quote = '\0';
			// skip leading "
			quote = wcschr(str, '"');
			str = quote + 1;
			Str.Add(new CLocalizationStr(id, wcsdup(str)));
		}
	}

	fclose(file);

	qsort(Str.GetData(), Str.Count, sizeof(CLocalizationStr *), CompareLocStr);

	return TRUE;
}
int CpuProfileInputStream::readLine(gtString& str)
{
    wchar_t buf = L'\0';
    str.makeEmpty();

    if (!m_fileStream.isOpened())
    {
        return -1;
    }

    while (!isEof())
    {
        buf = fgetwc(m_fileStream.getHandler());

        if (buf == (wchar_t) WEOF)
        {
            break;
        }

        if (buf != L'\n')
        {
            str += buf;
        }
        else
        {
            str += L'\0';
            break;
        }
    }

    return str.length();
}
Beispiel #16
0
int readstream( FILE* stream, StatefulString* ss ) {
    unsigned int max_length = BASE_STRING_LENGTH;
    wchar_t *temp = malloc( ( max_length + 1 ) * sizeof( wchar_t ) );
    int length = 0;

    if ( temp == NULL ) {
        allocationerror( ( max_length + 1 ), L"StatefulString::readstream" );
        exit( EXIT_FAILURE );
    }
    
    while ( ( temp[ length++ ] = fgetwc( stream ) ) != WEOF ) { 
        if ( temp[ length - 1 ] == L'\n'  ) {
            addlinebreak( ss, length - 1 );
        }
        if ( length == max_length ) {
            max_length *= 2;
            temp        = realloc( temp, ( max_length + 1 ) * sizeof( wchar_t ) );
            if ( temp == NULL ) {
                allocationerror( max_length, L"StatefulString::readstream" );
                exit( EXIT_FAILURE );
            }
        }
    }
    length--;
    temp[ length ] = L'\0';

    ss->value   = temp;
    ss->length  = length;
    return ss->length;
}
Beispiel #17
0
TWCHAR &
SIMCharReaderIterator::operator*() const
{
    FILE *fp = reader->fp;
    std::deque<TWCHAR> & buf = reader->buf;

    for (int i = buf.size(); i <= idx; ) {
        wint_t wch = fgetwc(fp);
        if (wch == 0) {
            wch = 0x20; // make it like a space
        }
        if (wch == WEOF) {
            if (feof(fp)) {
                buf.push_back(TWCHAR(0));
                return buf.back();
            } else {
                fprintf(stderr, "File read error %d\n", ferror(fp));
                throw new int(60);
            }
        } else {
            buf.push_back(wch);
            ++i;
        }
    }
    if (idx >= (int) buf.size() && buf.back() == WCH_NULL)
        return buf.back();
    return buf[idx];
}
Beispiel #18
0
/*
 * Get a character for the lexical analyser routine.
 */
static wint_t
lexgetc()
{
	wint_t c;
	static char **files = &progfiles[0];

	if (progfp != FNULL && (c = fgetwc(progfp)) != WEOF)
		;
	else {
		if (progptr != NULL) {
			if (proglen-- <= 0)
				c = WEOF;
			else
				c = *progptr++;
		} else {
			if (progfp != FNULL) {
				if (progfp != stdin)
					(void) fclose(progfp);
				else
					clearerr(progfp);
				progfp = FNULL;
			}
			if (files < progfilep) {
				filename = *files++;
				lineno = 1;
				if (filename[0] == '-' && filename[1] == '\0')
					progfp = stdin;
				else if ((progfp = fopen(filename, r))
				    == FNULL) {
					(void) fprintf(stderr,
				gettext("script file \"%s\""), filename);
					exit(1);
				}
				c = fgetwc(progfp);
			}
		}
	}
	if (c == '\n')
		++lineno;
	if (conptr >= &context[NCONTEXT])
		conptr = &context[0];
	if (c != WEOF)
		*conptr++ = c;
	return (c);
}
Beispiel #19
0
void mglParser::Execute(mglGraph *gr, FILE *fp, bool print)
{
	if(gr==0 || fp==0)	return;
	std::wstring str;
	wchar_t ch;
	while(!feof(fp) && size_t(ch=fgetwc(fp))!=WEOF)	str.push_back(ch);
	Execute(gr,str.c_str());
	if(print)	printf("%s\n",gr->Message());
}
Beispiel #20
0
bool trie_load(trie_tree *tree, FILE *stream, alphabet *alpha)
{
	assert(tree != NULL);
	wchar_t empty_tree_char = fgetwc(stream);
	if(empty_tree_char == (wchar_t)WEOF)
		return false;
	if(empty_tree_char == EMPTY_TREE)
		return true;
	if(tree->root == NULL)
		tree->root = node_make_leaf(L'\0');
	return node_load(tree->root, stream, alpha);
}
Beispiel #21
0
wchar_t*
getws(wchar_t* s)
{
	register wchar_t*	p = s;
	register wchar_t*	e = s + BUFSIZ - 1;
	register wint_t		c;

	FWIDE(sfstdin, 0);
	while (p < e && (c = fgetwc(sfstdin)) != WEOF && (*p++ = c) != '\n');
	*p = 0;
	return s;
}
Beispiel #22
0
/*---------------------------------------------------------------------------
**        Name : CheckUnicodeFile
**      Author : Barry Tang
**        Date : 2011/3/21
** Description : Check if the file is Unicode file
**       Input : None
**      Output : TRUE or FALSE
**---------------------------------------------------------------------------*/
BOOL CUnicodeFile::CheckUnicodeFile()
{
	TCHAR ch = fgetwc(m_pFile);

	if (ch == 0xfeff)
	{
		return TRUE;
	}
	else
	{
		return FALSE;
	}
}
Beispiel #23
0
static int
do_test (void)
{
  TEST_VERIFY_EXIT (setlocale (LC_ALL, "de_DE.UTF-8") != NULL);
  /* Fill the stdio buffer and advance the read pointer.  */
  TEST_VERIFY_EXIT (fgetwc (stdin) != WEOF);
  /* This calls _IO_wfile_sync, it should not crash.  */
  TEST_VERIFY_EXIT (setvbuf (stdin, NULL, _IONBF, 0) == 0);
  /* Verify that the external file offset has been synchronized.  */
  TEST_COMPARE (xlseek (0, 0, SEEK_CUR), 1);

  return 0;
}
Beispiel #24
0
	size_t Stream::read_line( wchar_t* buffer, size_t length, bool skip_emtpy_line )
	{
		if( file_ == 0 ) throw Invalid_IO();

		size_t count;
		wchar_t c = 0;
		do
		{
			count = 0;
			while( count < length && !feof( file_ ) )
			{
				buffer[count] = c = fgetwc( file_ );
				count++;

				if( c == '\n' ) break;
				if( c == '\r' )
				{
					buffer[count - 1] = c = '\n';

					if( !feof( file_ ) )
					{
						size_t next = fgetwc( file_ );
						if( next != '\n' )
							ungetwc( next, file_ );
					}

					break;
				}
			}
		} while( skip_emtpy_line && count == 1 && c == '\n' );

		if( count < length )
			buffer[count] = 0;
		else if( length > 0 )
			buffer[length - 1] = 0;

		return count;
	}
Beispiel #25
0
wchar_t*
fgetws(wchar_t* s, int n, Sfio_t* f)
{
	register wchar_t*	p = s;
	register wchar_t*	e = s + n - 1;
	register wint_t		c;

	STDIO_PTR(f, "fgets", wchar_t*, (wchar_t*, int, Sfio_t*), (s, n, f))

	FWIDE(f, 0);
	while (p < e && (c = fgetwc(f)) != WEOF && (*p++ = c) != '\n');
	*p = 0;
	return s;
}
Beispiel #26
0
closure *parse_number(FILE *file, closure *accum)
{
    wchar_t c = fgetwc(file);
    if(iswdigit(c)){
	return parse_number(file, cons(character(c), accum));
    } else if(iswspace(c)) {
	return string_to_number(reverse(accum));
    } else if(c == L')') {
	ungetwc(c, file); 
	return string_to_number(reverse(accum));
    } else {
	ungetwc(c, file);
	return parse_symbol(file, accum);
    }
}
Beispiel #27
0
// Read the entire contents of a file into the specified string.
static wcstring read_file(FILE *f) {
    wcstring result;
    while (1) {
        wint_t c = fgetwc(f);
        if (c == WEOF) {
            if (ferror(f)) {
                wperror(L"fgetwc");
                exit(1);
            }
            break;
        }
        result.push_back((wchar_t)c);
    }
    return result;
}
Beispiel #28
0
int
do_test (void)
{
  /* The easiest way to set up the conditions under which you can
     notice whether the end-of-file indicator is sticky, is with a
     pseudo-tty.  This is also the case which applications are most
     likely to care about.  And it avoids any question of whether and
     how it is legitimate to access the same physical file with two
     independent FILE objects.  */
  int outer_fd, inner_fd;
  FILE *fp;

  support_openpty (&outer_fd, &inner_fd, 0, 0, 0);
  fp = fdopen (inner_fd, "r+");
  if (!fp)
    {
      perror ("fdopen");
      return 1;
    }

  XWRITE (outer_fd, "abc\n\004", "first line + EOF");
  TEST_COMPARE (fgetwc (fp), L'a');
  TEST_COMPARE (fgetwc (fp), L'b');
  TEST_COMPARE (fgetwc (fp), L'c');
  TEST_COMPARE (fgetwc (fp), L'\n');
  TEST_COMPARE (fgetwc (fp), WEOF);

  TEST_VERIFY_EXIT (feof (fp));
  TEST_VERIFY_EXIT (!ferror (fp));

  XWRITE (outer_fd, "d\n", "second line");

  /* At this point, there is a new full line of input waiting in the
     kernelside input buffer, but we should still observe EOF from
     stdio, because the end-of-file indicator has not been cleared.  */
  TEST_COMPARE (fgetwc (fp), WEOF);

  /* Clearing EOF should reveal the next line of input.  */
  clearerr (fp);
  TEST_COMPARE (fgetwc (fp), L'd');
  TEST_COMPARE (fgetwc (fp), L'\n');

  fclose (fp);
  close (outer_fd);
  return 0;
}
Beispiel #29
0
Result FStream_Get(FStream* pfStream, wchar_t* ch)
{
  int c = fgetwc(pfStream->file);

  if (ferror(pfStream->file) != 0)
  {
    return RESULT_FAIL;
  }

  if (c == WEOF)
  {
    *ch = L'\0';
    return RESULT_EOF;
  }
  *ch = (wchar_t)c;
  return RESULT_OK;
}
Beispiel #30
0
closure *parse_list(FILE *file, closure *accum)
{
    //printf("parse list\n");
    //print_closure(accum);
    wchar_t c = fgetwc(file);
    if(c == L')'){
	return reverse(accum);
    } else {
	ungetwc(c, file); 
	closure *boo = parse_null(file, nil());
	if (boo != NULL){
	    return parse_list(file, cons(boo, accum));
	} else {
	    return parse_list(file, accum);
	}
    }
}