- Give PCI controllers lower unit numbers than legacy controllers.
[cake.git] / compiler / clib / gets.c
blobedaad70d32bcf9e314b9026b22cec1ee7ecd63a5
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 ANSI C function gets().
6 */
8 #include <errno.h>
9 #include <dos/dos.h>
10 #include <dos/dosextens.h>
11 #include <proto/exec.h>
12 #include <proto/dos.h>
13 #include "__open.h"
14 #include "__errno.h"
16 #include <string.h>
17 #include <stdio.h>
18 #undef gets
20 /*****************************************************************************
22 NAME */
23 #include <stdio.h>
25 char * gets (
27 /* SYNOPSIS */
28 char * buffer)
30 /* FUNCTION
31 Read one line of characters from the standard input stream into
32 the buffer. Reading will stop, when a newline ('\n') is encountered,
33 EOF or when the buffer is full. If a newline is read, then it is
34 replaced by '\0'. The last character in the buffer is always '\0'.
36 INPUTS
37 buffer - Write characters into this buffer
39 RESULT
40 buffer or NULL in case of an error or EOF.
42 NOTES
44 EXAMPLE
46 BUGS
47 Never use this function. gets() does not know how large the buffer
48 is and will continue to store characters past the end of the buffer
49 if it has not encountered a newline or EOF yet. Use fgets() instead.
51 SEE ALSO
52 fgets()
54 INTERNALS
56 ******************************************************************************/
58 char *s = fgets(buffer, BUFSIZ, stdin);
59 if (s)
61 /* strip trailing \n */
62 size_t sl = strlen(s);
63 if ( (sl > 0) && (s[sl-1] == '\n') )
65 s[sl-1] = '\0';
68 return s;
69 } /* gets */