1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-02-26 08:43:40 +00:00

Replaces ConcNameAndVersion and ConcDirAndName macros with functions

Replaces ConcNameAndVersion and ConcDirAndName macros with
conc_name_and_version and conc_dir_and_name functions respectively,
moves the definitions from locfile.h to dsk.c, and adds them to
dskdefs.h for use by other source files.
This commit is contained in:
Nick Briggs
2025-02-03 18:55:53 -08:00
parent f0bd8e0f1f
commit 6a550b4ca3
4 changed files with 183 additions and 178 deletions

View File

@@ -19,6 +19,8 @@ LispPTR COM_writepage(LispPTR *args);
LispPTR COM_truncatefile(LispPTR *args);
LispPTR COM_changedir(LispPTR *args);
LispPTR COM_getfreeblock(LispPTR *args);
void conc_dir_and_name(char *dir, char *name, char *fname);
void conc_name_and_version(char *name, char *ver, char *rname);
void separate_version(char *name, char *ver, int checkp);
int unpack_filename(char *file, char *dir, char *name, char *ver, int checkp);
int true_name(char *path);

View File

@@ -396,90 +396,6 @@ do { \
} \
} while (0)
/*
* Name: ConcDirAndName
*
* Argument: char *dir The name of the directory.
* char *name The name of a file.
* char *fname The place where the full file name should be
* stored.
* Value: N/A
*
* Side Effect: fname is replaced with the full file name.
*
* Description:
*
* Concatenate the directory name and root file name. Checks if dir contains
* the trail directory delimiter or not.
*
*/
#define ConcDirAndName(dir, name, fname) do { \
\
char *lf_cp1, *lf_cp2; \
\
lf_cp1 = dir; \
lf_cp2 = dir; \
\
while (*lf_cp2 != '\0') { \
switch (*lf_cp2) { \
\
case '/': \
lf_cp1 = lf_cp2; \
lf_cp2++; \
break; \
\
default: \
lf_cp2++; \
break; \
} \
} \
if (lf_cp1 == (lf_cp2 - 1)) { \
if (lf_cp1 == (dir)) { \
/* dir is a root directory. */ \
strcpy(fname, "/"); \
strcat(fname, name); \
} else { \
/* The trail directory is included. */ \
strcpy(fname, dir); \
strcat(fname, name); \
} \
} else { \
/* The trail directory is not included */ \
strcpy(fname, dir); \
strcat(fname, "/"); \
strcat(fname, name); \
} \
} while (0)
/*
* Name: ConcNameAndVersion
*
* Argument: char *name The root file name.
* char *ver The file version.
* char *rname The place where the concatenated file name will be
* stored.
* Value: N/A
*
* Side Effect: rname is replaced with the concatenated file name.
*
* Description:
*
* Concatenate the root file name and its version in UNIX format.
*
*/
#define ConcNameAndVersion(name, ver, rname) do { \
if (*(ver) != '\0') { \
strcpy(rname, name); \
strcat(rname, ".~"); \
strcat(rname, ver); \
strcat(rname, "~"); \
} else { \
strcpy(rname, name); \
} \
} while (0)
#define VERSIONLEN 16
#define MAXVERSION 999999999