From 6d4f4ee1eeef43e48937bdd3dd1837e12a1e9892 Mon Sep 17 00:00:00 2001 From: John van Groningen Date: Fri, 16 Jul 2004 09:31:45 +0000 Subject: add code for freadsubstring and fwritesubstring for linux, not yet enabled --- ufileIO2.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 4 deletions(-) (limited to 'ufileIO2.c') diff --git a/ufileIO2.c b/ufileIO2.c index d4a6d57..ba8484f 100644 --- a/ufileIO2.c +++ b/ufileIO2.c @@ -593,7 +593,7 @@ int file_read_real (long fn,double *r_p) } } else if (f->mode & (1<file,"%lg",r_p)!=1) - return 0; + return 0; } else IO_error ("FReadR: read from an output file"); @@ -601,8 +601,19 @@ int file_read_real (long fn,double *r_p) } } +#define OLD_READ_STRING 1 +#define OLD_WRITE_STRING 1 + +#if OLD_READ_STRING unsigned long file_read_string (long fn,unsigned long max_length,struct clean_string *s) { +#else +unsigned long file_read_characters (long fn,unsigned long *length_p,char *s) +{ + unsigned long max_length; + + max_length=*length_p; +#endif unsigned long length; if (fncharacters,1,max_length,stdin); +#if OLD_READ_STRING + length = fread (s->characters,1,max_length,stdin); s->length=length; +#else + length = fread (s,1,max_length,stdin); + *length_p=length; +#endif return length; default: IO_error ("FReadS: can't open this file"); @@ -626,9 +642,13 @@ unsigned long file_read_string (long fn,unsigned long max_length,struct clean_st IO_error ("FReadS: read from an output file"); fd=f->file; +#if OLD_READ_STRING length = fread (s->characters,1,max_length,fd); s->length=length; - +#else + length = fread (s,1,max_length,fd); + *length_p=length; +#endif return length; } } @@ -646,6 +666,25 @@ unsigned long file_read_line (long fn,unsigned long max_length,char *string) int c; length=0; +#if 0 + fgets (string,max_length,stdin); + + string [max_length-1]='\0'; + while (string[length]!='\0') + ++length; + + if (lengthcharacters,s->length); +#else + ew_print_text (p,length); +#endif break; case 1: +#if OLD_WRITE_STRING w_print_text (s->characters,s->length); +#else + w_print_text (p,length); +#endif break; default: IO_error ("FWriteS: can't open this file"); @@ -884,8 +936,11 @@ void file_write_string (struct clean_string *s,long fn) if (f->mode & ~((1<characters,sizeof (char),s->length,f->file); +#else + fwrite (p,sizeof (char),length,f->file); +#endif } } -- cgit v1.2.3