Skip to content

Commit

Permalink
Merge pull request #348 from olebole/mkpkg
Browse files Browse the repository at this point in the history
NOIRLAB: fixes and cleanup for the "mkpkg" tool
  • Loading branch information
olebole authored Jan 29, 2024
2 parents 0b3a4bb + f96867f commit 08f919e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 25 deletions.
5 changes: 2 additions & 3 deletions unix/boot/mkpkg/fncache.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#include <string.h>
#include <stdlib.h>

//#include "../bootProto.h"


/*
* FNCACHE -- Maintain a cache of system logical filenames (e.g., <config.h>)
Expand Down Expand Up @@ -109,14 +107,15 @@ m_fninit (int debug)
int total;

if (debug) {
char lname[SZ_FNAME+1];
char lname[SZ_FNAME+3];

total = fn_hits + fn_misses;
printf ("file name cache: %d hits, %d misses, %d%% of %d\n",
fn_hits, fn_misses, (total ? fn_hits * 100 / total : 0), total);

for (fn=fn_head; fn != NULL; fn=fn->dnlnk)
if (fn->lname[0]) {
memset (&lname[0], 0, SZ_FNAME+1);
sprintf (lname, "<%s>", fn->lname);
printf ("%3d (%05d) %-20s => %s\n",
fn->nrefs, fn->chksum, lname, fn->fname);
Expand Down
4 changes: 2 additions & 2 deletions unix/boot/mkpkg/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ h_incheck (
char *dir /* where to put the file */
)
{
char backup[SZ_PATHNAME+1];
char backup[SZ_PATHNAME+5];
char path[SZ_PATHNAME+1];
char fname[SZ_PATHNAME+1];
char *osfn, *ip;
Expand Down Expand Up @@ -387,7 +387,7 @@ h_outcheck (
* alternate source for the local file, which must be preserved.
*/
if (access (fname, 0) != -1) {
char backup[SZ_PATHNAME+1];
char backup[SZ_PATHNAME+5];

if (clobber) {
if (debug) {
Expand Down
13 changes: 6 additions & 7 deletions unix/boot/mkpkg/mkpkg.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define SZ_PBBUF 2048 /* push back buffer */
#define SZ_CMD 2048 /* buf for os escape */
#define SZ_IFSTACK 50 /* max $IF nesting */
#define SZ_PREDBUF 1024 /* largest $IF predicate */
#define SZ_PREDBUF 2050 /* largest $IF predicate */
#define SZ_PKGENV 256 /* pkgenv package list buffer */
#define MAX_ARGS 50 /* max args to a $IF */
#define MAX_FILES 512 /* max files in a module list */
Expand Down Expand Up @@ -193,8 +193,7 @@ struct context *push_context (register struct context *cx, char *module,
struct context *pop_context (register struct context *cx);
void get_dependency_list (struct context *cx, char *module,
char *dflist[], int maxfiles);
int up_to_date (struct context *cx, char *module, char *lname,
char *dflist[], int *useobj);
int up_to_date (char *module, char *lname, char *dflist[], int *useobj);
int open_mkpkgfile (register struct context *cx);
void close_mkpkgfile (register struct context *cx);
struct context *find_mkpkgfile ( struct context *head_cx,
Expand All @@ -208,11 +207,11 @@ int gettok (register struct context *cx, char *outstr, int maxch );
void do_osescape (register struct context *cx);
void do_ppdir (struct context *cx, char *token);
void do_if (struct context *cx, char *keyword);
void do_else (struct context *cx);
void do_endif (struct context *cx);
void do_else (void);
void do_endif (void);
void do_end (struct context *cx);
void do_call (struct context *cx, char *program, int islib);
void do_echo (struct context *cx, char *msg);
void do_echo (char *msg);
int do_goto (struct context *cx, char *symbol);
int do_include (struct context *cx, char *fname);
void do_omake (struct context *cx, char *fname);
Expand All @@ -226,7 +225,7 @@ int do_outcheck (struct context *cx);
int do_copyfile (struct context *cx);
int do_movefile (struct context *cx);
void do_delete (struct context *cx);
void do_purge (struct context *cx, char *dname);
void do_purge (char *dname);

int getcmd (register struct context *cx, char *prefix, char *cmd, int maxch);
char *getargs (register struct context *cx);
Expand Down
8 changes: 4 additions & 4 deletions unix/boot/mkpkg/pkg.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ do_mkpkg (
}

if (open_mkpkgfile (cx) == ERR) {
char fname[SZ_PATHNAME+1];
char fname[2*SZ_PATHNAME+1];
struct context *save_cx;

save_cx = topcx;
Expand Down Expand Up @@ -208,7 +208,7 @@ next_: tok = gettok (cx, token, SZ_FNAME);
parse_fname (srcname, dname, fname);
get_dependency_list (cx, modname, dflist, MAX_DEPFILES);

if (!up_to_date (cx, srcname, fname, dflist, &useobj)) {
if (!up_to_date (srcname, fname, dflist, &useobj)) {

/* If file is remote add its name to the remote file list
* and "checkout" the file, making it accessible in the
Expand Down Expand Up @@ -655,12 +655,13 @@ get_dependency_list (
case TOK_NEWLINE:
goto done;
case TOK_FNAME:
if (nfiles >= MAX_DEPFILES)
if (nfiles >= maxfiles)
errors ("too many dependency files for module `%s'", module);
dflist[nfiles++] = putstr (fname);
break;
case TOK_END:
errors ("unexpected EOF in dependency list for `%s'", module);
break;
default:
errors ("bad token `%s' in dependency list", fname);
}
Expand Down Expand Up @@ -696,7 +697,6 @@ get_dependency_list (
*/
int
up_to_date (
struct context *cx, /* current library context */
char *module, /* module to compare dates for */
char *lname, /* local name of module */
char *dflist[], /* list of dependent files */
Expand Down
17 changes: 8 additions & 9 deletions unix/boot/mkpkg/tok.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,16 +247,16 @@ do_ppdir (
if ( strncmp (token, "$if", 3) == 0)
do_if (cx, token);
else if (strncmp (token, "$else", 5) == 0)
do_else (cx);
do_else ();
else if (strncmp (token, "$endif", 6) == 0)
do_endif (cx);
do_endif ();
else if (strncmp (token, "$end", 4) == 0)
do_end (cx);

else if (strncmp (token, "$call", 5) == 0)
do_call (cx, getargs(cx), islib=NO);
else if (strncmp (token, "$echo", 5) == 0)
do_echo (cx, getargs(cx));
do_echo (getargs(cx));
else if (strncmp (token, "$goto", 5) == 0)
do_goto (cx, getargs(cx));
else if (strncmp (token, "$include", 8) == 0)
Expand Down Expand Up @@ -287,7 +287,7 @@ do_ppdir (
else if (strncmp (token, "$omake", 6) == 0)
do_omake (cx, getargs(cx));
else if (strncmp (token, "$purge", 6) == 0)
do_purge (cx, getargs(cx));
do_purge (getargs(cx));
else if (strncmp (token, "$xc", 3) == 0)
do_xc (cx);

Expand Down Expand Up @@ -518,7 +518,7 @@ do_if (struct context *cx, char *keyword)
* outer $IF.
*/
void
do_else (struct context *cx)
do_else (void)
{
if (debug > 1) {
printf ("do_else:\n");
Expand All @@ -538,7 +538,7 @@ do_else (struct context *cx)
* Pop the if stack.
*/
void
do_endif (struct context *cx)
do_endif (void)
{
if (debug > 1) {
printf ("do_endif:\n");
Expand Down Expand Up @@ -639,7 +639,7 @@ do_call (
/* DO_ECHO -- Print a message on the standard output.
*/
void
do_echo (struct context *cx, char *msg)
do_echo (char *msg)
{
if (ifstate[iflev] == PASS) {
printf ("%s\n", msg);
Expand Down Expand Up @@ -1220,7 +1220,6 @@ do_delete (struct context *cx)
*/
void
do_purge (
struct context *cx, /* not used */
char *dname /* logical directory name */
)
{
Expand Down Expand Up @@ -1295,7 +1294,7 @@ getargs (
)
{
register int ch;
static char args[SZ_PBBUF+1];
static char args[SZ_PBBUF+3];
char tokbuf[SZ_COMMAND+1];
int delim;

Expand Down

0 comments on commit 08f919e

Please sign in to comment.