shithub: scc

Download patch

ref: bc9383cd3876e4e4548078caa4f3c5c32dfabf42
parent: 7ae4cdf7ae71be76936061c036d07e7e34545ec4
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sun Feb 10 09:21:12 EST 2019

[libmach] Rename artraverse() to formember()

It is more consisten with the other names.

--- a/include/scc/scc/mach.h
+++ b/include/scc/scc/mach.h
@@ -51,9 +51,9 @@
 };
 
 
-extern int artraverse(FILE *fp,
-                      int (*fn)(FILE *, char *, void *),
-                      void *data);
+extern int formember(FILE *fp,
+                     int (*fn)(FILE *, char *, void *),
+                     void *data);
 
 extern int forsym(Obj *obj,
                   int (*fn)(Objsym *sym, void *data),
--- a/src/cmd/ld/main.c
+++ b/src/cmd/ld/main.c
@@ -264,7 +264,7 @@
 {
 	if (foridx(fp, newidx, NULL))
 		return 1;
-	return artraverse(fp, newmember, NULL);
+	return formember(fp, newmember, NULL);
 }
 
 static FILE *
--- a/src/cmd/nm.c
+++ b/src/cmd/nm.c
@@ -201,7 +201,7 @@
 	if ((t = objtype(fp, NULL)) != -1)
 		newobject(fp, t);
 	else if (archive(fp))
-		artraverse(fp, newmember, NULL);
+		formember(fp, newmember, NULL);
 	else
 		error("bad format");
 
--- a/src/cmd/ranlib.c
+++ b/src/cmd/ranlib.c
@@ -188,7 +188,7 @@
 		return 0;
 	}
 
-	if (artraverse(fp, newmember, NULL) < 0) {
+	if (formember(fp, newmember, NULL) < 0) {
 		error("while traversing archive");
 		return 0;
 	}
--- a/src/cmd/size.c
+++ b/src/cmd/size.c
@@ -127,7 +127,7 @@
 	if ((t = objtype(fp, NULL)) != -1)
 		newobject(fp, t);
 	else if (archive(fp))
-		artraverse(fp, newmember, NULL);
+		formember(fp, newmember, NULL);
 	else
 		error("bad format");
 
--- a/src/libmach/Makefile
+++ b/src/libmach/Makefile
@@ -8,7 +8,6 @@
        archive.o \
        arindex.o \
        armember.o \
-       artraverse.o \
        coffelf32.o \
        objdel.o \
        objlookup.o \
@@ -20,6 +19,7 @@
        forsym.o \
        forsect.o \
        foridx.o \
+       formember.o \
        objtype.o \
        objwrite.o \
        objfree.o \
--- a/src/libmach/artraverse.c
+++ /dev/null
@@ -1,26 +1,0 @@
-#include <stdio.h>
-
-#include <scc/ar.h>
-#include <scc/mach.h>
-
-int
-artraverse(FILE *fp, int (*fn)(FILE *, char *, void *), void *data)
-{
-	int r;
-	long off;
-	fpos_t pos;
-	char name[SARNAM+1];
-
-	for (;;) {
-		fgetpos(fp, &pos);
-
-		if ((off = armember(fp, name)) <= 0)
-			return off;
-		r = (*fn)(fp, name, data);
-		if (r <= 0)
-			return r;
-
-		fsetpos(fp, &pos);
-		fseek(fp, off, SEEK_CUR);
-	}
-}
--- /dev/null
+++ b/src/libmach/formember.c
@@ -1,0 +1,26 @@
+#include <stdio.h>
+
+#include <scc/ar.h>
+#include <scc/mach.h>
+
+int
+formember(FILE *fp, int (*fn)(FILE *, char *, void *), void *data)
+{
+	int r;
+	long off;
+	fpos_t pos;
+	char name[SARNAM+1];
+
+	for (;;) {
+		fgetpos(fp, &pos);
+
+		if ((off = armember(fp, name)) <= 0)
+			return off;
+		r = (*fn)(fp, name, data);
+		if (r <= 0)
+			return r;
+
+		fsetpos(fp, &pos);
+		fseek(fp, off, SEEK_CUR);
+	}
+}