update Thu Jun 17 06:37:00 PDT 2010
[pkgsrc.git] / math / gcalctool / patches / patch-aa
1 $NetBSD: patch-aa,v 1.15 2010/06/17 08:56:46 obache Exp $
2
3 portability fix (no advantage to use getline(3) here)
4   https://bugzilla.gnome.org/show_bug.cgi?id=621863
5
6 --- src/gcalccmd.c.orig 2010-04-26 01:14:22.000000000 +0000
7 +++ src/gcalccmd.c
8 @@ -73,7 +73,7 @@ int
9  main(int argc, char **argv)
10  {
11      char *equation;
12 -    int bytes_read;
13 +    char *line_read;
14      size_t nbytes = MAXLINE;
15  
16      /* Seed random number generator. */
17 @@ -82,12 +82,12 @@ main(int argc, char **argv)
18      equation = (char *) malloc(MAXLINE * sizeof(char));
19      while (1) {
20          printf("> ");
21 -        bytes_read = getline(&equation, &nbytes, stdin);
22 +        line_read = fgets(equation, nbytes, stdin);
23        
24 -        if (bytes_read >= 0)
25 +        if (line_read != NULL)
26              str_adjust(equation);
27  
28 -        if (bytes_read < 0 || strcmp(equation, "exit") == 0 || strcmp(equation, "quit") == 0 || strlen(equation) == 0)
29 +        if (line_read == NULL || strcmp(equation, "exit") == 0 || strcmp(equation, "quit") == 0 || strlen(equation) == 0)
30              break;
31  
32          solve(equation);