curvedraw

changeset 11:099fd7adb900

curve parser works
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 19 Dec 2015 22:39:18 +0200
parents 95fada20c638
children 84a647283237
files src/curvefile.cc
diffstat 1 files changed, 17 insertions(+), 5 deletions(-) [+]
line diff
     1.1 --- a/src/curvefile.cc	Sat Dec 19 17:40:27 2015 +0200
     1.2 +++ b/src/curvefile.cc	Sat Dec 19 22:39:18 2015 +0200
     1.3 @@ -17,7 +17,7 @@
     1.4  
     1.5  bool save_curves(FILE *fp, const Curve * const *curves, int count)
     1.6  {
     1.7 -	fprintf(stderr, "GCURVES\n");
     1.8 +	fprintf(fp, "GCURVES\n");
     1.9  
    1.10  	for(int i=0; i<count; i++) {
    1.11  		if(!save_curve(fp, curves[i])) {
    1.12 @@ -68,11 +68,23 @@
    1.13  {
    1.14  	std::string s;
    1.15  	int c;
    1.16 -	while((c = fgetc(fp)) != -1 && isspace(c));	// skip whitespace
    1.17 +	while((c = fgetc(fp)) != -1) {
    1.18 +		if(!isspace(c)) {
    1.19 +			ungetc(c, fp);
    1.20 +			break;
    1.21 +		}
    1.22 +	}
    1.23 +
    1.24  	if(feof(fp)) return s;
    1.25 -	while((c = fgetc(fp)) != -1 && !isspace(c)) {
    1.26 +	while((c = fgetc(fp)) != -1) {
    1.27 +		if(isspace(c)) {
    1.28 +			ungetc(c, fp);
    1.29 +			break;
    1.30 +		}
    1.31  		s.push_back(c);
    1.32  	}
    1.33 +
    1.34 +	printf("TOKEN: \"%s\"\n", s.c_str());
    1.35  	return s;
    1.36  }
    1.37  
    1.38 @@ -80,7 +92,7 @@
    1.39  {
    1.40  	std::string tok = next_token(fp);
    1.41  	if(tok != std::string(s)) {
    1.42 -		if(!(tok.empty() && feof(fp))) {
    1.43 +		if(tok.empty() && feof(fp)) {
    1.44  			fprintf(stderr, "expected: %s\n", s);
    1.45  		}
    1.46  		return false;
    1.47 @@ -144,7 +156,7 @@
    1.48  				goto err;
    1.49  			}
    1.50  		} else {
    1.51 -			if(!expect_str(fp, "cp")) {
    1.52 +			if(tok != "cp") {
    1.53  				goto err;
    1.54  			}
    1.55  			Vector3 cp;