compiler/clib: Rename IoErr2errno() to __arosc_ioerr2errno(); function is now defined...
[AROS.git] / compiler / clib / gets.c
blobbba30d28370fb2cfe3ba0b62977468ecf15f2b47
1 /*
2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
3 $Id$
5 ANSI C function gets().
6 */
8 #include <dos/dos.h>
9 #include <dos/dosextens.h>
10 #include <proto/exec.h>
11 #include <proto/dos.h>
12 #include "__fdesc.h"
14 #include <string.h>
15 #include <stdio.h>
16 #undef gets
18 /*****************************************************************************
20 NAME */
21 #include <stdio.h>
23 char * gets (
25 /* SYNOPSIS */
26 char * buffer)
28 /* FUNCTION
29 Read one line of characters from the standard input stream into
30 the buffer. Reading will stop, when a newline ('\n') is encountered,
31 EOF or when the buffer is full. If a newline is read, then it is
32 replaced by '\0'. The last character in the buffer is always '\0'.
34 INPUTS
35 buffer - Write characters into this buffer
37 RESULT
38 buffer or NULL in case of an error or EOF.
40 NOTES
42 EXAMPLE
44 BUGS
45 Never use this function. gets() does not know how large the buffer
46 is and will continue to store characters past the end of the buffer
47 if it has not encountered a newline or EOF yet. Use fgets() instead.
49 SEE ALSO
50 fgets()
52 INTERNALS
54 ******************************************************************************/
56 char *s = fgets(buffer, BUFSIZ, stdin);
57 if (s)
59 /* strip trailing \n */
60 size_t sl = strlen(s);
61 if ( (sl > 0) && (s[sl-1] == '\n') )
63 s[sl-1] = '\0';
66 return s;
67 } /* gets */