aboutsummaryrefslogtreecommitdiff
path: root/winbuild
diff options
context:
space:
mode:
authorCNLohr <charles@cnlohr.com>2018-04-04 02:27:42 -0400
committerGitHub <noreply@github.com>2018-04-04 02:27:42 -0400
commitce6322b6b604b12018a2daf427dbd36afc5fbda2 (patch)
tree5929c2793c33c80e5392982a9baaa8d5ccaca724 /winbuild
parent6a45298c9bc34aac59cc2ebb9de2d82c7a42756e (diff)
parentc7d9d271796b20f886e2441de852498ecb25ca82 (diff)
downloadlibsurvive-ce6322b6b604b12018a2daf427dbd36afc5fbda2.tar.gz
libsurvive-ce6322b6b604b12018a2daf427dbd36afc5fbda2.tar.bz2
Merge pull request #122 from cnlohr/imu
Imu
Diffstat (limited to 'winbuild')
-rw-r--r--winbuild/getdelim.c36
1 files changed, 10 insertions, 26 deletions
diff --git a/winbuild/getdelim.c b/winbuild/getdelim.c
index ca808ab..69020ee 100644
--- a/winbuild/getdelim.c
+++ b/winbuild/getdelim.c
@@ -30,40 +30,29 @@
THE SOFTWARE.
*/
-
#include <errno.h>
#include <limits.h>
-#include <stdlib.h>
#include <stdio.h>
-
+#include <stdlib.h>
#if __STDC_VERSION__ >= 199901L
/* restrict is a keyword */
#else
-# define restrict
+#define restrict
#endif
-
#ifndef _POSIX_SOURCE
typedef long ssize_t;
#define SSIZE_MAX LONG_MAX
#endif
+ssize_t getdelim(char **restrict lineptr, size_t *restrict n, int delimiter, FILE *restrict stream);
+ssize_t getline(char **restrict lineptr, size_t *restrict n, FILE *restrict stream);
-ssize_t getdelim(char **restrict lineptr, size_t *restrict n, int delimiter,
- FILE *restrict stream);
-ssize_t getline(char **restrict lineptr, size_t *restrict n,
- FILE *restrict stream);
-
+#define _GETDELIM_GROWBY 128 /* amount to grow line buffer by */
+#define _GETDELIM_MINLEN 4 /* minimum line buffer size */
-
-#define _GETDELIM_GROWBY 128 /* amount to grow line buffer by */
-#define _GETDELIM_MINLEN 4 /* minimum line buffer size */
-
-
-ssize_t getdelim(char **restrict lineptr, size_t *restrict n, int delimiter,
- FILE *restrict stream)
-{
+ssize_t getdelim(char **restrict lineptr, size_t *restrict n, int delimiter, FILE *restrict stream) {
char *buf, *pos;
int c;
ssize_t bytes;
@@ -110,7 +99,7 @@ ssize_t getdelim(char **restrict lineptr, size_t *restrict n, int delimiter,
*lineptr = buf;
}
- *pos++ = (char) c;
+ *pos++ = (char)c;
if (c == delimiter) {
break;
}
@@ -125,19 +114,14 @@ ssize_t getdelim(char **restrict lineptr, size_t *restrict n, int delimiter,
return bytes;
}
-
-ssize_t getline(char **restrict lineptr, size_t *restrict n,
- FILE *restrict stream)
-{
+ssize_t getline(char **restrict lineptr, size_t *restrict n, FILE *restrict stream) {
return getdelim(lineptr, n, '\n', stream);
}
-
#ifdef _TEST_GETDELIM
/* TODO: this isn't a very extensive test. */
-int main(void)
-{
+int main(void) {
char *line = NULL;
size_t n = 0;
while (getline(&line, &n, stdin) > 0) {