[gcalctool] Use fgets instead of getline which is a GNU extension
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gcalctool] Use fgets instead of getline which is a GNU extension
- Date: Thu, 17 Jun 2010 23:02:52 +0000 (UTC)
commit 436147a1f63fbf980d117f880d253fa0abbd11f8
Author: OBATA Akio <obata lins jp>
Date: Fri Jun 18 09:02:33 2010 +1000
Use fgets instead of getline which is a GNU extension
src/gcalccmd.c | 11 +++++------
1 files changed, 5 insertions(+), 6 deletions(-)
---
diff --git a/src/gcalccmd.c b/src/gcalccmd.c
index 95fcc31..88a9dc6 100644
--- a/src/gcalccmd.c
+++ b/src/gcalccmd.c
@@ -73,8 +73,7 @@ str_adjust(char *str)
int
main(int argc, char **argv)
{
- char *equation;
- int bytes_read;
+ char *equation, *line;
size_t nbytes = MAXLINE;
/* Seed random number generator. */
@@ -83,12 +82,12 @@ main(int argc, char **argv)
equation = (char *) malloc(MAXLINE * sizeof(char));
while (1) {
printf("> ");
- bytes_read = getline(&equation, &nbytes, stdin);
-
- if (bytes_read >= 0)
+ line = fgets(equation, nbytes, stdin);
+
+ if (line != NULL)
str_adjust(equation);
- if (bytes_read < 0 || strcmp(equation, "exit") == 0 || strcmp(equation, "quit") == 0 || strlen(equation) == 0)
+ if (line == NULL || strcmp(equation, "exit") == 0 || strcmp(equation, "quit") == 0 || strlen(equation) == 0)
break;
solve(equation);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]