Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Commit

Permalink
remove several warnings (Johannes Stezenbach)
Browse files Browse the repository at this point in the history
  • Loading branch information
leitner committed Sep 14, 2003
1 parent edcfe83 commit 8ab6791
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Unfortunately, correct overflow checking enlarged the routine by 20%.
(reported by Manuel Novoa III)
two stdio bug fixes (also reported by Manuel Novoa III)
remove several warnings (Johannes Stezenbach)

0.23:
update sys/soundcard.h
Expand Down
4 changes: 2 additions & 2 deletions contrib/elftrunc.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ void trunc64(int fd)
{
if ((n=read(in,buf,sizeof(buf)))>0)
{
write(out,buf,(size_t)((len<(size_t)n)?len:n));
len-=(len<(size_t)n)?len:n;
write(out,buf,(size_t)((len<(size_t)n)?len:(size_t)n));
len-=(len<(size_t)n)?len:(size_t)n;
} else die(2,"read error");
}

Expand Down
2 changes: 0 additions & 2 deletions include/getopt.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

__BEGIN_DECLS

extern int optopt;

struct option {
const char* name;
int has_arg;
Expand Down
4 changes: 2 additions & 2 deletions include/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

__BEGIN_DECLS

int optind,opterr;
char *optarg;
extern int optind,opterr,optopt;
extern char *optarg;
int getopt(int argc, char *const argv[], const char *options);

/* Values for the second argument to access.
Expand Down
10 changes: 7 additions & 3 deletions lib/__dtostr.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,21 @@ static int copystring(char* buf,int maxlen, const char* s) {

int __dtostr(double d,char *buf,unsigned int maxlen,unsigned int prec,unsigned int prec2) {
#if 1
unsigned long long *x=(unsigned long long *)&d;
union {
unsigned long long l;
double d;
} u;
u.d=d;
/* step 1: extract sign, mantissa and exponent */
signed long e=((*x>>52)&((1<<11)-1))-1023;
signed long e=((u.l>>52)&((1<<11)-1))-1023;
#else
#if __BYTE_ORDER == __LITTLE_ENDIAN
signed long e=(((((unsigned long*)&d)[1])>>20)&((1<<11)-1))-1023;
#else
signed long e=(((*((unsigned long*)&d))>>20)&((1<<11)-1))-1023;
#endif
#endif
/* unsigned long long m=*x & ((1ull<<52)-1); */
/* unsigned long long m=u.l & ((1ull<<52)-1); */
/* step 2: exponent is base 2, compute exponent for base 10 */
signed long e10;
/* step 3: calculate 10^e10 */
Expand Down
8 changes: 6 additions & 2 deletions lib/__isinf.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#include <math.h>

int isinf(double d) {
unsigned long long *x=(unsigned long long *)&d;
return (*x==0x7FF0000000000000ll?1:*x==0xFFF0000000000000ll?-1:0);
union {
unsigned long long l;
double d;
} u;
u.d=d;
return (u.l==0x7FF0000000000000ll?1:u.l==0xFFF0000000000000ll?-1:0);
}
int __isinf(double d) __attribute__((alias("isinf")));

Expand Down
8 changes: 6 additions & 2 deletions lib/__isnan.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#include <math.h>

int isnan(double d) {
unsigned long long *x=(unsigned long long *)&d;
return (*x==0x7FF8000000000000ll || *x==0x7FF0000000000000 || *x==0xfff8000000000000);
union {
unsigned long long l;
double d;
} u;
u.d=d;
return (u.l==0x7FF8000000000000ll || u.l==0x7FF0000000000000ll || u.l==0xfff8000000000000ll);
}
int __isnan(double d) __attribute__((alias("isnan")));

Expand Down
2 changes: 1 addition & 1 deletion liblatin1/latin1-isgraph.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

int isgraph(int x) {
unsigned char c=x&0xff;
return (c>=33 && c<=126) || (c>=161 && c<=255);
return (c>=33 && c<=126) || c>=161;
}

2 changes: 1 addition & 1 deletion liblatin1/latin1-islower.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

int islower(int c) {
unsigned char x=c&0xff;
return (x>='a' && x<='z') || (x>=223 && x<=255 && x!=247);
return (x>='a' && x<='z') || (x>=223 && x!=247);
}

0 comments on commit 8ab6791

Please sign in to comment.