Page MenuHomeFreeBSD

D40619.diff
No OneTemporary

D40619.diff

diff --git a/bin/sh/alias.h b/bin/sh/alias.h
--- a/bin/sh/alias.h
+++ b/bin/sh/alias.h
@@ -42,3 +42,4 @@
};
struct alias *lookupalias(const char *, int);
+const struct alias *iteralias(const struct alias *);
diff --git a/bin/sh/alias.c b/bin/sh/alias.c
--- a/bin/sh/alias.c
+++ b/bin/sh/alias.c
@@ -53,7 +53,7 @@
static void setalias(const char *, const char *);
static int unalias(const char *);
-static struct alias **hashalias(const char *);
+static size_t hashalias(const char *);
static
void
@@ -62,7 +62,7 @@
struct alias *ap, **app;
unalias(name);
- app = hashalias(name);
+ app = &atab[hashalias(name)];
INTOFF;
ap = ckmalloc(sizeof (struct alias));
ap->name = savestr(name);
@@ -87,7 +87,7 @@
{
struct alias *ap, **app;
- app = hashalias(name);
+ app = &atab[hashalias(name)];
for (ap = *app; ap; app = &(ap->next), ap = ap->next) {
if (equal(name, ap->name)) {
@@ -145,7 +145,7 @@
if (aliases == 0)
return (NULL);
- for (ap = *hashalias(name); ap; ap = ap->next) {
+ for (ap = atab[hashalias(name)]; ap; ap = ap->next) {
if (equal(name, ap->name)) {
if (check && (ap->flag & ALIASINUSE))
return (NULL);
@@ -242,7 +242,7 @@
return (i);
}
-static struct alias **
+static size_t
hashalias(const char *p)
{
unsigned int hashval;
@@ -250,5 +250,22 @@
hashval = (unsigned char)*p << 4;
while (*p)
hashval+= *p++;
- return &atab[hashval % ATABSIZE];
+ return (hashval % ATABSIZE);
+}
+
+const struct alias *
+iteralias(const struct alias *index)
+{
+ size_t i = 0;
+
+ if (index != NULL) {
+ if (index->next != NULL)
+ return (index->next);
+ i = hashalias(index->name) + 1;
+ }
+ for (; i < ATABSIZE; i++)
+ if (atab[i] != NULL)
+ return (atab[i]);
+
+ return (NULL);
}

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 9, 7:26 AM (21 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14552903
Default Alt Text
D40619.diff (1 KB)

Event Timeline