Changeset 9ad1f13 in rtems for c/build-tools/unhex.c


Ignore:
Timestamp:
01/21/98 18:28:09 (25 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
ba024755
Parents:
d73ed76b
Message:

Added autoconf support for strerror/sys_errlist per Ralf Corsepius'
direction. This fixes a problem reported by Steve Evans of Radstone
since he is using glibc2.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/build-tools/unhex.c

    rd73ed76b r9ad1f13  
    3939#include <stdarg.h>
    4040
     41#include "config.h"
     42
     43#ifndef VMS
     44#ifndef HAVE_STRERROR
     45extern int sys_nerr;
     46extern char *sys_errlist[];
     47
     48#define strerror( _err ) \
     49  ((_err) < sys_nerr) ? sys_errlist [(_err)] : "unknown error"
     50
     51#else   /* HAVE_STRERROR */
     52char *strerror ();
     53#endif
     54#else   /* VMS */
     55char *strerror (int,...);
     56#endif
     57
     58
    4159#define OK      0
    4260#define FAILURE (-1)
     
    120138char *MISTYPE = "Incompatible record types";
    121139
    122 int
    123 main(argc, argv)
    124 int argc;
    125 char **argv;
     140int main(
     141  int argc,
     142  char **argv
     143)
    126144{
    127145    register int c;
     
    681699    va_list arglist;
    682700    register char *format;
    683     extern char *sys_errlist[];
    684     extern int sys_nerr;
    685701    int local_errno;
    686702
     
    700716
    701717    if (local_errno)
    702         if ((local_errno > 0) && (local_errno < sys_nerr))
    703             (void) fprintf(stderr, " (%s)\n", sys_errlist[local_errno]);
    704         else
    705             (void) fprintf(stderr, " (unknown errno=%d)\n", local_errno);
     718      (void) fprintf(stderr, " (%s)\n", strerror(local_errno));
    706719    else
    707         (void) fprintf(stderr, "\n");
     720      (void) fprintf(stderr, "\n");
    708721
    709722    (void) fflush(stderr);
Note: See TracChangeset for help on using the changeset viewer.