packaging: Initial packaging
[platform/upstream/make.git] / packaging / make-3.81-err-reporting.patch
1 --- make-3.80/misc.c.jj 2002-09-12 18:15:58.000000000 -0400
2 +++ make-3.80/misc.c    2005-08-22 05:46:05.000000000 -0400
3 @@ -311,17 +311,31 @@ strerror (errnum)
4  /* Print an error message from errno.  */
5  
6 +void
7 +perror_with_name_err (const char *str, const char *name, int errnum)
8 +{
9 +  error (NILF, _("%s%s: %s"), str, name, strerror (errnum));
10 +}
11 +
12  void
13  perror_with_name (const char *str, const char *name)
14  {
15 -  error (NILF, _("%s%s: %s"), str, name, strerror (errno));
16 +  perror_with_name_err (str, name, errno);
17  }
18  
19  /* Print an error message from errno and exit.  */
20  
21 +void
22 +pfatal_with_name_err (const char *name, int errnum)
23 +{
24 +  fatal (NILF, _("%s: %s"), name, strerror (errnum));
25 +
26 +  /* NOTREACHED */
27 +}
28 +
29  void
30  pfatal_with_name (const char *name)
31  {
32 -  fatal (NILF, _("%s: %s"), name, strerror (errno));
33 +  pfatal_with_name_err (name, errno);
34  
35    /* NOTREACHED */
36  }
37
38 --- make-3.81/main.c.jj 2006-05-23 12:51:25.000000000 +0200
39 +++ make-3.81/main.c    2006-05-23 12:50:48.000000000 +0200
40 @@ -1502,13 +1502,13 @@
41             strcat (template, DEFAULT_TMPFILE);
42             outfile = open_tmpfile (&stdin_nm, template);
43             if (outfile == 0)
44 -             pfatal_with_name (_("fopen (temporary file)"));
45 +             pfatal_with_name_err (_("fopen (temporary file)"), errno);
46             while (!feof (stdin) && ! ferror (stdin))
47               {
48                 char buf[2048];
49                 unsigned int n = fread (buf, 1, sizeof (buf), stdin);
50                 if (n > 0 && fwrite (buf, 1, n, outfile) != n)
51 -                 pfatal_with_name (_("fwrite (temporary file)"));
52 +                 pfatal_with_name_err (_("fwrite (temporary file)"), errno);
53               }
54             (void) fclose (outfile);
55  
56 @@ -1681,7 +1681,7 @@
57      else if ((job_rfd = dup (job_fds[0])) < 0)
58        {
59          if (errno != EBADF)
60 -          pfatal_with_name (_("dup jobserver"));
61 +          pfatal_with_name_err (_("dup jobserver"), errno);
62  
63          error (NILF,
64                 _("warning: jobserver unavailable: using -j1.  Add `+' to parent make rule."));
65 @@ -1721,7 +1721,7 @@
66        char c = '+';
67  
68        if (pipe (job_fds) < 0 || (job_rfd = dup (job_fds[0])) < 0)
69 -       pfatal_with_name (_("creating jobs pipe"));
70 +       pfatal_with_name_err (_("creating jobs pipe"), errno);
71  
72        /* Every make assumes that it always has one job it can run.  For the
73           submakes it's the token they were given by their parent.  For the
74 @@ -1736,7 +1736,7 @@
75  
76            EINTRLOOP (r, write (job_fds[1], &c, 1));
77            if (r != 1)
78 -            pfatal_with_name (_("init jobserver pipe"));
79 +            pfatal_with_name_err (_("init jobserver pipe"), errno);
80          }
81  
82        /* Fill in the jobserver_fds struct for our children.  */
83 @@ -2151,8 +2151,8 @@
84    /* If there is a temp file from reading a makefile from stdin, get rid of
85       it now.  */
86    if (stdin_nm && unlink (stdin_nm) < 0 && errno != ENOENT)
87 -    perror_with_name (_("unlink (temporary file): "), stdin_nm);
88 +    perror_with_name_err (_("unlink (temporary file): "), stdin_nm, errno);
89  
90    {
91      int status;
92
93 --- make-3.81/make.h.jj 2006-05-23 12:54:45.000000000 +0200
94 +++ make-3.81/make.h    2006-05-23 12:55:00.000000000 +0200
95 @@ -414,6 +414,8 @@
96  extern void log_working_directory PARAMS ((int));
97  extern void pfatal_with_name PARAMS ((const char *)) __attribute__ ((noreturn));
98  extern void perror_with_name PARAMS ((const char *, const char *));
99 +extern void pfatal_with_name_err PARAMS ((const char *, int errnum)) __attribute__ ((noreturn));
100 +extern void perror_with_name_err PARAMS ((const char *, const char *, int errnum));
101  extern char *savestring PARAMS ((const char *, unsigned int));
102  extern char *concat PARAMS ((const char *, const char *, const char *));
103  extern char *xmalloc PARAMS ((unsigned int));
104
105 --- make-3.81/job.c.jj  2006-05-23 13:01:35.000000000 +0200
106 +++ make-3.81/job.c     2006-05-23 13:50:44.000000000 +0200
107 @@ -859,7 +859,7 @@
108  
109        EINTRLOOP (r, write (job_fds[1], &token, 1));
110        if (r != 1)
111 -       pfatal_with_name (_("write jobserver"));
112 +       pfatal_with_name_err (_("write jobserver"), errno);
113  
114        DB (DB_JOBS, (_("Released token for child 0x%08lx (%s).\n"),
115                      (unsigned long int) child, child->file->name));
116 @@ -1699,6 +1699,7 @@
117  
118          /* Set interruptible system calls, and read() for a job token.  */
119         set_child_handler_action_flags (1, waiting_jobs != NULL);
120 +       errno = 0;
121         got_token = read (job_rfd, &token, 1);
122         saved_errno = errno;
123         set_child_handler_action_flags (0, waiting_jobs != NULL);
124 @@ -1713,10 +1714,14 @@
125  
126          /* If the error _wasn't_ expected (EINTR or EBADF), punt.  Otherwise,
127             go back and reap_children(), and try again.  */
128 -       errno = saved_errno;
129 -        if (errno != EINTR && errno != EBADF)
130 -          pfatal_with_name (_("read jobs pipe"));
131 -        if (errno == EBADF)
132 +        if (saved_errno != EINTR && saved_errno != EBADF)
133 +         {
134 +           if (got_token == 0)
135 +             fatal (NILF, _("read jobs pipe EOF"));
136 +           else
137 +             pfatal_with_name_err (_("read jobs pipe"), saved_errno);
138 +         }
139 +        if (saved_errno == EBADF)
140            DB (DB_JOBS, ("Read returned EBADF.\n"));
141        }
142  #endif
143 @@ -1831,7 +1836,7 @@
144             error (NILF,
145                     _("cannot enforce load limits on this operating system"));
146           else
147 -           perror_with_name (_("cannot enforce load limit: "), "getloadavg");
148 +           perror_with_name_err (_("cannot enforce load limit: "), "getloadavg", errno);
149         }
150        lossage = errno;
151        load = 0;