delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1992/07/15/11:04:47

Date: Wed, 15 Jul 92 16:28:50 +0100
From: buers AT dg1 DOT chemie DOT uni-konstanz DOT de (Dieter Buerssner)
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: patch for doscan.c

When you open a file in binary mode, fscanf does not work correctly.
It doesn't consider '\r' as whitespace, so it fails on files with
the usal MSDOS "\r\n" end of line. The following patch should help.
If you want to try it, please let me know, whether it worked or not.

	Dieter

doscan.c is in libsrc/c/io

*** doscan.org	Tue Apr  7 22:45:26 1992
--- doscan.c	Wed Jul 15 09:45:06 1992
***************
*** 80,87 ****
  
  	case ' ':
  	case '\n':
  	case '\t': 
! 		while ((ch1 = getc(iop))==' ' || ch1=='\t' || ch1=='\n')
  			;
  		if (ch1 != EOF)
  			ungetc(ch1, iop);
--- 80,88 ----
  
  	case ' ':
  	case '\n':
+     /* case '\r': do we need this too */
  	case '\t': 
! 		while ((ch1 = getc(iop))==' ' || ch1=='\t' || ch1=='\n' || ch1 =='\r')
  			;
  		if (ch1 != EOF)
  			ungetc(ch1, iop);
***************
*** 126,132 ****
  	np = numbuf;
  	expseen = 0;
  	negflg = 0;
! 	while ((c = getc(iop))==' ' || c=='\t' || c=='\n');
  	if (c=='-') {
  		negflg++;
  		*np++ = c;
--- 127,133 ----
  	np = numbuf;
  	expseen = 0;
  	negflg = 0;
! 	while ((c = getc(iop))==' ' || c=='\t' || c=='\n' || c=='\r');
  	if (c=='-') {
  		negflg++;
  		*np++ = c;

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019