Skip to content

Commit

Permalink
Final phase
Browse files Browse the repository at this point in the history
  • Loading branch information
pcollinson committed Jul 16, 2023
1 parent d8f3fdf commit c52218e
Show file tree
Hide file tree
Showing 166 changed files with 26,176 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,8 @@ docs/_build/
# Emacs files
*~
*_flymake.*

# Ignore development files
time-dev/
MT
UT
58 changes: 58 additions & 0 deletions aredit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# _aredit_ - better editing of _ar_ libraries

The _aredit_ program is a solution to the problems that I outlined in [Notes on ar](../notes/ar.md). It allows you to name a file in an _ar_ library and insert or append another file before or after it. You can also ask it to replace the marker file with a new binary.

### Example

Here's an example of use:

The new _ctime.c_ code in [../time](../time) replaces _ctime.o_ and also introduces some assembler code from V7 in _ctsup.o_. It turns out that this code needs to be some way up the library, so to be safe I want to put it directly after _ctime.o_.

To make this insertion happen, go to some convenient directory, compile to get the new binary files. Copy _lib/libc.a_ into the directory. Now:

```sh
aredit ca libc.a ctime.o ctsup.o
```
which says in _libc.a_, change _ctime.o_ and append _ctsup.o_ after it. The program now:

* Creates a working directory called _aredit.tmp_
* Changes into it
* unpacks _../libc.a_ - remembering the order of files
* copies _../ctime.o_ into the directory because it's been asked to replace it by the _c_ flag
* copies _../ctsup.o_ into the directory
* starts to process the files in its list, adding them to a new archive file. When it gets to _ctime.o_, it is loaded into the archive, and will also load the new file _ctsup.o_ after it. The _ctime.o_ is the new version because it's been copied earlier.
* when it's done with all the files, it replaces _libc.a_ with the archive it's built
* then it tidies up removing all the files in _aredit.tmp_ and finally the directory itself.

If you are happy you can replace the _libc.a_ in _/lib_ with the new copy.

Here's a sample output of this process:

``` sh
# aredit ca libc.a ctime.o ctsup.o
Making aredit.tmp
Changing dir into aredit.tmp
Cleaning aredit.tmp
Extracting ../libc.a contents
Copying ../ctime.o to ctime.o
Copying ../ctsup.o to ctsup.o
Rebuilding archive into templib.a
Found ctime.o
Append ctsup.o
Copying templib.a to ../libc.a
Removing temporary contents
Cleaning aredit.tmp
Change dir to parent
Removing aredit.tmp
```

Notice that the working directory has to be a child of the directory you are in because the program makes use of the '..' links to move back up to its parent, and also to access files in its parent.

### Moving a file in a library

You can use aredit to move a file in a library:

* Copy the library to a local directory
* extract the file you want to move - ```ar x lib.a tomove.o```
* append the file in a new place - ```aredit a lib.a afterme.o tomove.o```
_aredit_ will notice that _tomove.o_ is a file to be appended and will ignore the copy that it obtained by extracting the library. It will tell you that this has happened.
83 changes: 83 additions & 0 deletions aredit/aredit.6
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
.th AREDIT 7/14/23
.sh Name
aredit \- add files into archive files
.sh SYNOPSIS
.bd aredit
[
.bd c
] [
.bd ia
] [
.bd p
] arfile.a marker append
.sh DESCRIPTION
.it Aredit
inserts the
.it append
file before or after
.it marker
file in the archive file
.it arfile.a.
The command arguments are as follows:
.s3
.lp +4 4
\fBi\fR inserts
.it append
before the
.it marker.
.lp +4 4
\fBa\fR places
.it append
after the
.it marker.
.lp +4 4
\fBc\fR can be used to replace the
.it marker
file in addition to adding or inserting the
.it append
file.
.lp +4 4
\fBp\fR preserves the temporary files.
.i0
.s3
The
.it archive
file, the
.it append
file and the
.it marker
file should all be present in the same directory.
A new temporary directory
.i aredit.tmp
is created, and the program changes into it.
The archive file is unpacked into the directory.
The
.it append
file is copied into the directory, as is
.it marker
file if the \fBc\fR flag is given.
.s3
The archive is rebuilt into
.it templib.a
maintaining the original file order. When the
.it marker
file is found, it's copied into
.it templib.a
with the
.it append
file placed before or after it, depending on the \fBi\fR or \fBa\fB
flags.
.s3
Finally the temporary archive is copied over the source archive file
and all temporary files are removed.
.s3
The
.it append
file will be ignored if is found in the list while processing, this
allows the program to be used to move items in the archive.
.sh FILES
aredit.tmp, templib.a
.SH SEE ALSO
ar(I)
.SH AUTHOR
Peter Collinson
Loading

0 comments on commit c52218e

Please sign in to comment.