fix config file path
[AROS.git] / compiler / clib / gets.c
blob0a7aebe958516004fb9c5785870173338db457d0
1 /*
2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
3 $Id$
5 C99 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>
16 /*****************************************************************************
18 NAME */
19 #include <stdio.h>
21 char * gets (
23 /* SYNOPSIS */
24 char * buffer)
26 /* FUNCTION
27 Read one line of characters from the standard input stream into
28 the buffer. Reading will stop, when a newline ('\n') is encountered,
29 EOF or when the buffer is full. If a newline is read, then it is
30 replaced by '\0'. The last character in the buffer is always '\0'.
32 INPUTS
33 buffer - Write characters into this buffer
35 RESULT
36 buffer or NULL in case of an error or EOF.
38 NOTES
40 EXAMPLE
42 BUGS
43 Never use this function. gets() does not know how large the buffer
44 is and will continue to store characters past the end of the buffer
45 if it has not encountered a newline or EOF yet. Use fgets() instead.
47 SEE ALSO
48 fgets()
50 INTERNALS
52 ******************************************************************************/
54 char *s = fgets(buffer, BUFSIZ, stdin);
55 if (s)
57 /* strip trailing \n */
58 size_t sl = strlen(s);
59 if ( (sl > 0) && (s[sl-1] == '\n') )
61 s[sl-1] = '\0';
64 return s;
65 } /* gets */