projects
/
idzebra-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
String arg in dict lookup is const.
[idzebra-moved-to-github.git]
/
index
/
dir.c
diff --git
a/index/dir.c
b/index/dir.c
index
c643b40
..
4228825
100644
(file)
--- a/
index/dir.c
+++ b/
index/dir.c
@@
-1,10
+1,16
@@
/*
/*
- * Copyright (C) 1994, Index Data I/S
+ * Copyright (C) 1995, Index Data I/S
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: dir.c,v $
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: dir.c,v $
- * Revision 1.1 1995-09-01 10:34:51 adam
+ * Revision 1.3 1995-09-01 14:06:35 adam
+ * Split of work into more files.
+ *
+ * Revision 1.2 1995/09/01 10:57:07 adam
+ * Minor changes.
+ *
+ * Revision 1.1 1995/09/01 10:34:51 adam
* Added dir.c
*
*/
* Added dir.c
*
*/
@@
-43,6
+49,9
@@
struct dir_entry *dir_open (const char *rep)
}
while ((dent = readdir (dir)))
{
}
while ((dent = readdir (dir)))
{
+ if (strcmp (dent->d_name, ".") == 0 ||
+ strcmp (dent->d_name, "..") == 0)
+ continue;
if (idx == entry_max-1)
{
struct dir_entry *entry_n;
if (idx == entry_max-1)
{
struct dir_entry *entry_n;
@@
-52,7
+61,7
@@
struct dir_entry *dir_open (const char *rep)
log (LOG_FATAL|LOG_ERRNO, "malloc");
exit (1);
}
log (LOG_FATAL|LOG_ERRNO, "malloc");
exit (1);
}
- memcpy (entry_n, entry, entry_max * sizeof(*entry));
+ memcpy (entry_n, entry, idx * sizeof(*entry));
free (entry);
entry = entry_n;
entry_max += 100;
free (entry);
entry = entry_n;
entry_max += 100;
@@
-63,13
+72,14
@@
struct dir_entry *dir_open (const char *rep)
exit (1);
}
strcpy (entry[idx].name, dent->d_name);
exit (1);
}
strcpy (entry[idx].name, dent->d_name);
+ idx++;
}
entry[idx].name = NULL;
closedir (dir);
return entry;
}
}
entry[idx].name = NULL;
closedir (dir);
return entry;
}
-int dir_cmp (const void *p1, const void *p2)
+static int dir_cmp (const void *p1, const void *p2)
{
return strcmp (((struct dir_entry *) p1)->name,
((struct dir_entry *) p2)->name);
{
return strcmp (((struct dir_entry *) p1)->name,
((struct dir_entry *) p2)->name);
@@
-90,7
+100,7
@@
void dir_free (struct dir_entry **e_p)
assert (e);
while (e[i].name)
assert (e);
while (e[i].name)
- free (e[i].name);
+ free (e[i++].name);
free (e);
*e_p = NULL;
}
free (e);
*e_p = NULL;
}