Changeset 2119
- Timestamp:
- Jun 30, 2005, 6:50:38 AM (20 years ago)
- Location:
- trunk/src/emx
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/ChangeLog.LIBC
-
Property cvs2svn:cvs-rev
changed from
1.75
to1.76
r2118 r2119 8 8 o Added ieeefp.h and functions from FreeBSD - this is 9 9 the SysV/386 FP control interface. (inline only) 10 o Added fgets_unlocked and gets_unlocked. 10 11 11 12 2005-06-28: knut st. osmundsen <bird-gccos2-spam@anduin.net> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/stdio.h
-
Property cvs2svn:cvs-rev
changed from
1.16
to1.17
r2118 r2119 374 374 int fputc_unlocked(int, FILE *); 375 375 int fputs_unlocked(const char * __restrict, FILE * __restrict); 376 char *fgets_unlocked(char * __restrict, int, FILE * __restrict); 376 377 int puts_unlocked(const char *); 378 char *gets_unlocked(char *); 377 379 #endif 378 380 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/fgets.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r2118 r2119 9 9 #include "getputc.h" 10 10 11 char *_STD(fgets) 11 char *_STD(fgets)(char *buffer, int n, FILE *stream) 12 12 { 13 int c; 14 char *dst; 13 STREAM_LOCK(stream); 14 char *psz = fgets_unlocked(buffer, n, stream); 15 STREAM_UNLOCK(stream); 16 return psz; 17 } 15 18 16 if (n <= 0)17 return NULL;18 dst = buffer;19 19 20 STREAM_LOCK (stream); 21 while (n > 1) 20 char *_STD(fgets_unlocked)(char *buffer, int n, FILE *stream) 21 { 22 int c; 23 char *dst; 24 25 if (n <= 0) 26 return NULL; 27 dst = buffer; 28 29 while (n > 1) 22 30 { 23 c = _getc_inline(stream);24 if (c == EOF)31 c = _getc_inline(stream); 32 if (c == EOF) 25 33 { 26 /* ISO/IEC 9899:1990, 7.9.7.2: "If end-of-file is27 encountered and no characters have been read into the28 array, the contents of the array remain unchanged and a29 null pointer is returned. If a read error occurs during30 the operation, the array contents are indeterminate and a31 null pointer is returned." */34 /* ISO/IEC 9899:1990, 7.9.7.2: "If end-of-file is 35 encountered and no characters have been read into the 36 array, the contents of the array remain unchanged and a 37 null pointer is returned. If a read error occurs during 38 the operation, the array contents are indeterminate and a 39 null pointer is returned." */ 32 40 33 if (dst == buffer || ferror (stream)) 34 { 35 STREAM_UNLOCK (stream); 36 return NULL; 37 } 38 else 41 if (dst == buffer || ferror(stream)) 42 return NULL; 39 43 break; /* EOF after reading at least one char */ 40 44 } 41 *dst++ = (char)c;42 if (c == '\n')43 break;44 --n;45 *dst++ = (char)c; 46 if (c == '\n') 47 break; 48 --n; 45 49 } 46 STREAM_UNLOCK (stream); 47 *dst = 0; 48 return buffer; 50 *dst = '\0'; 51 return buffer; 49 52 } 53 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/gets.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r2118 r2119 9 9 #include "getputc.h" 10 10 11 char *_STD(gets )(char *buffer)11 char *_STD(gets_unlocked)(char *buffer) 12 12 { 13 int c;14 char *dst;13 int c; 14 char *dst; 15 15 16 dst = buffer; 17 STREAM_LOCK (stdin); 18 for (;;) 16 dst = buffer; 17 for (;;) 19 18 { 20 c = _getc_inline(stdin);21 if (c == EOF)19 c = _getc_inline(stdin); 20 if (c == EOF) 22 21 { 23 if (dst == buffer)22 if (dst == buffer) 24 23 { 25 *dst = 0; 26 STREAM_UNLOCK (stdin); 27 return NULL; 24 *dst = '\0'; 25 return NULL; 28 26 } 29 else30 27 break; 31 28 } 32 if (c == '\n')33 break;34 *dst++ = (char)c;29 if (c == '\n') 30 break; 31 *dst++ = (char)c; 35 32 } 36 STREAM_UNLOCK (stdin); 37 *dst = 0; 38 return buffer; 33 *dst = 0; 34 return buffer; 39 35 } 36 37 char *_STD(gets)(char *buffer) 38 { 39 STREAM_LOCK(stdin); 40 char *psz = gets_unlocked(buffer); 41 STREAM_UNLOCK(stdin); 42 return psz; 43 } 44 45 46 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/libc.def
-
Property cvs2svn:cvs-rev
changed from
1.118
to1.119
r2118 r2119 1744 1744 "__std_rawmemchr" @1745 1745 1745 "__std_strchrnul" @1746 1746 "__std_fgets_unlocked" @1747 1747 "__std_gets_unlocked" @1748 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.