From 74ec7167549a1d7a53774cd006477995b66199a2 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Thu, 13 Mar 2008 06:25:11 +0000 Subject: [PATCH] --- ase/utl/stdio.c | 11 ++++++++--- ase/utl/stdio.h | 5 ++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ase/utl/stdio.c b/ase/utl/stdio.c index 2466cd90..001a3fc6 100644 --- a/ase/utl/stdio.c +++ b/ase/utl/stdio.c @@ -1,5 +1,5 @@ /* - * $Id: stdio.c 124 2008-03-12 12:21:33Z baconevi $ + * $Id: stdio.c 125 2008-03-12 12:25:11Z baconevi $ * * {License} */ @@ -395,7 +395,7 @@ ase_ssize_t ase_getdelim ( #else b = (ase_char_t*) malloc (sizeof(ase_char_t)*(capa+1)); #endif - if (b == ASE_NULL) return -1; + if (b == ASE_NULL) return -2; } if (ase_feof(fp)) @@ -410,6 +410,11 @@ ase_ssize_t ase_getdelim ( if (c == ASE_CHAR_EOF) { if (ase_ferror(fp)) + { + len = (ase_size_t)-2; + goto exit_task; + } + if (len == 0) { len = (ase_size_t)-1; goto exit_task; @@ -426,7 +431,7 @@ ase_ssize_t ase_getdelim ( nb = realloc (b, ncapa*sizeof(ase_char_t)); if (nb == ASE_NULL) { - len = (ase_size_t)-1; + len = (ase_size_t)-2; goto exit_task; } diff --git a/ase/utl/stdio.h b/ase/utl/stdio.h index b982c54b..09c83e40 100644 --- a/ase/utl/stdio.h +++ b/ase/utl/stdio.h @@ -1,5 +1,5 @@ /* - * $Id: stdio.h 122 2008-03-12 11:55:39Z baconevi $ + * $Id: stdio.h 125 2008-03-12 12:25:11Z baconevi $ */ #ifndef _ASE_UTL_STDIO_H_ @@ -64,6 +64,9 @@ int ase_dprintf (const ase_char_t* fmt, ...); FILE* ase_fopen (const ase_char_t* path, const ase_char_t* mode); FILE* ase_popen (const ase_char_t* cmd, const ase_char_t* mode); +/** + * returns -2 on error, -1 on eof, length of data read on success + */ ase_ssize_t ase_getline (ase_char_t **buf, ase_size_t *n, FILE *fp); ase_ssize_t ase_getdelim ( ase_char_t **buf, ase_size_t *n, ase_char_t delim, FILE *fp);