- int msgnum, prefix_len, len, *mi;
- struct msgs *mp;
- struct stat st;
- struct dirent *dp;
- DIR *dd;
-
- name = m_mailpath (name);
- if (!(dd = opendir (name))) {
- free (name);
- return NULL;
- }
-
- if (stat (name, &st) == -1) {
- free (name);
- return NULL;
- }
-
- /* Allocate the main structure for folder information */
- if (!(mp = (struct msgs *) malloc ((size_t) sizeof(*mp))))
- adios (NULL, "unable to allocate folder storage");
-
- clear_folder_flags (mp);
- mp->foldpath = name;
- mp->lowmsg = 0;
- mp->hghmsg = 0;
- mp->curmsg = 0;
- mp->lowsel = 0;
- mp->hghsel = 0;
- mp->numsel = 0;
- mp->nummsg = 0;
-
- if (access (name, W_OK) == -1 || st.st_uid != getuid())
- set_readonly (mp);
- prefix_len = strlen(BACKUP_PREFIX);
-
- /*
- * Allocate a temporary place to record the
- * name of the messages in this folder.
- */
- len = NUMMSGS;
- if (!(mi = (int *) malloc ((size_t) (len * sizeof(*mi)))))
- adios (NULL, "unable to allocate storage");
-
- while ((dp = readdir (dd))) {
- if ((msgnum = m_atoi (dp->d_name)) && msgnum > 0) {
- /*
- * Check if we need to allocate more
- * temporary elements for message names.
- */
- if (mp->nummsg >= len) {
- len += NUMMSGS;
- if (!(mi = (int *) realloc (mi,
- (size_t) (len * sizeof(*mi))))) {
- adios (NULL, "unable to allocate storage");
+ int i;
+ /* For compatibility with nmh, ignore rmm backup files. */
+ if (e->d_name[0] == '.' || e->d_name[0] == ',' || e->d_name[0] == '#') {
+ return 0;
+ }
+ for (i = 0; e->d_name[i]; i++) {
+ if ((i == 0 && e->d_name[i] == '0') || e->d_name[i] < '0' || e->d_name[i] > '9') {
+ others = 1;
+ return 0;