Over the years, I have gotten numerous mails from people having difficulty compiling mg on other platforms. Most of these mails fall into one of two categories:
* struct dirent problems, * basename, dirname problems This diff addresses the former. The essential problem is that many platforms don't have d_namlen in their struct dirent. I really doubt this is a significant performance hit for too many people. Still, I've been wrong (frequently) in the past. Comments? Index: fileio.c =================================================================== RCS file: /cvs/src/usr.bin/mg/fileio.c,v retrieving revision 1.82 diff -u -r1.82 fileio.c --- fileio.c 15 Sep 2008 16:11:35 -0000 1.82 +++ fileio.c 19 Jan 2011 03:53:25 -0000 @@ -529,10 +529,8 @@ while ((dent = readdir(dirp)) != NULL) { int isdir; - - if (dent->d_namlen < len || memcmp(cp, dent->d_name, len) != 0) + if (strncmp(cp, dent->d_name, len) != 0) continue; - isdir = 0; if (dent->d_type == DT_DIR) { isdir = 1;