shithub: scc

Download patch

ref: 30dd51b701334f8984bbc1359ca05357ed521ed5
parent: c34608fdf5ee53e1caba64bd1f8933e359a66ab0
author: Roberto E. Vargas Caballero <[email protected]>
date: Fri Feb 16 13:08:21 EST 2018

[ar] Open archive file for read+write

We do both operatons (mainly for update).

--- a/ar/main.c
+++ b/ar/main.c
@@ -51,7 +51,7 @@
 	FILE *fp;
 	char magic[SARMAG+1];
 
-	if ((fp = fopen(afile,"rb")) == NULL) {
+	if ((fp = fopen(afile,"r+b")) == NULL) {
 		if (!cflag)
 			fprintf(stderr, "ar: creating %s\n", afile);
 		if ((fp = fopen(afile, "w+b")) == NULL) {
@@ -134,9 +134,9 @@
 		perror("ar:seeking archive");
 		exit(1);
 	}
-	while ((fname = *list++) != NULL) {
+
+	while ((fname = *list++) != NULL)
 		archive(fname, fp, 'a');
-	}
 	if (fclose(fp) == EOF) {
 		perror("ar:error writing archive");
 		exit(1);
--- /dev/null
+++ b/tests/ar/execute/chktest.sh
@@ -1,0 +1,7 @@
+#!/bin/sh
+
+set -e
+
+cd files
+ar -qv ../test.a file1 file2
+ar -qv ../test.a file3
--- a/tests/ar/execute/tesh.sh
+++ /dev/null
@@ -1,7 +1,0 @@
-#!/bin/sh
-
-set -e
-
-cd files
-ar -qv ../test.a file1 file2
-ar -qv ../test.a file3