scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit 25af93ba2433dadba394ac2f30640fccb37a81e5
parent 3e27f21368cb83a271b34cee758b8506dcd2b1fb
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun, 10 Feb 2019 14:21:12 +0000

[libmach] Rename artraverse() to formember()

It is more consisten with the other names.

Diffstat:
Minclude/scc/scc/mach.h | 6+++---
Msrc/cmd/ld/main.c | 2+-
Msrc/cmd/nm.c | 2+-
Msrc/cmd/ranlib.c | 2+-
Msrc/cmd/size.c | 2+-
Msrc/libmach/Makefile | 2+-
Dsrc/libmach/artraverse.c | 26--------------------------
Asrc/libmach/formember.c | 26++++++++++++++++++++++++++
8 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/include/scc/scc/mach.h b/include/scc/scc/mach.h @@ -51,9 +51,9 @@ struct object { }; -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), diff --git a/src/cmd/ld/main.c b/src/cmd/ld/main.c @@ -264,7 +264,7 @@ newlibrary(FILE *fp) { if (foridx(fp, newidx, NULL)) return 1; - return artraverse(fp, newmember, NULL); + return formember(fp, newmember, NULL); } static FILE * diff --git a/src/cmd/nm.c b/src/cmd/nm.c @@ -201,7 +201,7 @@ nm(char *fname) 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"); diff --git a/src/cmd/ranlib.c b/src/cmd/ranlib.c @@ -188,7 +188,7 @@ readsyms(FILE *fp) return 0; } - if (artraverse(fp, newmember, NULL) < 0) { + if (formember(fp, newmember, NULL) < 0) { error("while traversing archive"); return 0; } diff --git a/src/cmd/size.c b/src/cmd/size.c @@ -127,7 +127,7 @@ size(char *fname) 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"); diff --git a/src/libmach/Makefile b/src/libmach/Makefile @@ -8,7 +8,6 @@ OBJS = addr2line.o \ archive.o \ arindex.o \ armember.o \ - artraverse.o \ coffelf32.o \ objdel.o \ objlookup.o \ @@ -20,6 +19,7 @@ OBJS = addr2line.o \ forsym.o \ forsect.o \ foridx.o \ + formember.o \ objtype.o \ objwrite.o \ objfree.o \ diff --git a/src/libmach/artraverse.c b/src/libmach/artraverse.c @@ -1,26 +0,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); - } -} diff --git a/src/libmach/formember.c b/src/libmach/formember.c @@ -0,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); + } +}