patch: parentheses and remaining prototypes
Werner Almesberger
almesber@lrc.epfl.ch
Thu Aug 24 16:26:00 GMT 2000
J. Johnston wrote:
> Patch has been checked in.
Thanks ! Here's another one that just ran into.
Possibly controversial issue: HAVE_NO_D_NAMLEN - I set it in my
sys/dirent.h because Linux doesn't have such a field.
- Werner
---------------------------------- ChangeLog ----------------------------------
2000-08-25 Werner Almesberger <Werner.Almesberger@epfl.ch>
* libc/posix/scandir.c (DIRSIZ, scandir): don't use
struct dirent.d_namlen if HAVE_NO_D_NAMLEN is defined
* libc/posix/scandir.c (alphasort): aligned prototype with
libc/sys/cygwin/sys/dirent.h and simplified function body
* libc/posix/telldir.c (telldir): aligned prototype with
libc/sys/cygwin/sys/dirent.h
------------------------------------ patch ------------------------------------
--- orig/newlib/libc/posix/scandir.c Thu Feb 17 20:39:47 2000
+++ src/newlib/libc/posix/scandir.c Fri Aug 25 01:16:40 2000
@@ -57,8 +57,13 @@
* null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
*/
#undef DIRSIZ
+#ifndef HAVE_NO_D_NAMLEN
#define DIRSIZ(dp) \
((sizeof (struct dirent) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
+#else
+#define DIRSIZ(dp) \
+ ((sizeof (struct dirent) - (MAXNAMLEN+1)) + ((strlen((dp)->d_name)+1 + 3) &~ 3))
+#endif
#ifndef __P
#define __P(args) ()
@@ -103,8 +108,12 @@
return(-1);
p->d_ino = d->d_ino;
p->d_reclen = d->d_reclen;
+#ifndef HAVE_NO_D_NAMLEN
p->d_namlen = d->d_namlen;
bcopy(d->d_name, p->d_name, p->d_namlen + 1);
+#else
+ strcpy(p->d_name, d->d_name);
+#endif
/*
* Check to make sure the array has space left and
* realloc the maximum size.
@@ -132,11 +141,10 @@
*/
int
alphasort(d1, d2)
- const void *d1;
- const void *d2;
+ const struct dirent **d1;
+ const struct dirent **d2;
{
- return(strcmp((*(struct dirent **)d1)->d_name,
- (*(struct dirent **)d2)->d_name));
+ return(strcmp((*d1)->d_name, (*d2)->d_name));
}
#endif /* ! HAVE_OPENDIR */
--- orig/newlib/libc/posix/telldir.c Thu Feb 17 20:39:47 2000
+++ src/newlib/libc/posix/telldir.c Fri Aug 25 01:10:05 2000
@@ -71,9 +71,9 @@
/*
* return a pointer into a directory
*/
-long
+off_t
telldir(dirp)
- const DIR *dirp;
+ DIR *dirp;
{
register int index;
register struct ddloc *lp;
--
_________________________________________________________________________
/ Werner Almesberger, ICA, EPFL, CH werner.almesberger@ica.epfl.ch /
/_IN_N_032__Tel_+41_21_693_6621__Fax_+41_21_693_6610_____________________/
More information about the Newlib
mailing list