mirror of
https://github.com/Interlisp/maiko.git
synced 2026-03-20 00:17:51 +00:00
Compare commits
5 Commits
fgh_libbsd
...
nhb-rewrit
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
06399b0cf8 | ||
|
|
88dea29837 | ||
|
|
feac148fb4 | ||
|
|
a8f968f32d | ||
|
|
5060cae998 |
@@ -9,7 +9,7 @@
|
|||||||
char *lv_cp; \
|
char *lv_cp; \
|
||||||
char *lv_vp; \
|
char *lv_vp; \
|
||||||
unsigned lv_ver; \
|
unsigned lv_ver; \
|
||||||
char lv_ver_buf[VERSIONLEN]; \
|
char lv_ver_buf[VERSIONLEN + 3]; \
|
||||||
\
|
\
|
||||||
lv_cp = pathname; \
|
lv_cp = pathname; \
|
||||||
lv_vp = NULL; \
|
lv_vp = NULL; \
|
||||||
|
|||||||
385
inc/locfile.h
385
inc/locfile.h
@@ -8,10 +8,14 @@
|
|||||||
/* Manufactured in the United States of America. */
|
/* Manufactured in the United States of America. */
|
||||||
/* */
|
/* */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
#include <ctype.h> /* for isdigit */
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <limits.h> /* for NAME_MAX */
|
#include <limits.h> /* for NAME_MAX */
|
||||||
|
#include <string.h> /* for strlen */
|
||||||
|
#include <sys/param.h> /* for MAXPATHLEN */
|
||||||
#include <dirent.h> /* for MAXNAMLEN */
|
#include <dirent.h> /* for MAXNAMLEN */
|
||||||
#include "lispemul.h" /* for DLword */
|
#include "lispemul.h" /* for DLword */
|
||||||
|
#include "commondefs.h" /* for error */
|
||||||
|
|
||||||
#define FDEV_PAGE_SIZE 512 /* 1 page == 512 byte */
|
#define FDEV_PAGE_SIZE 512 /* 1 page == 512 byte */
|
||||||
|
|
||||||
@@ -63,6 +67,9 @@
|
|||||||
else if(((ptr) & SEGMASK)== S_NEGATIVE) {(place) = (int)((ptr)| 0xffff0000);}\
|
else if(((ptr) & SEGMASK)== S_NEGATIVE) {(place) = (int)((ptr)| 0xffff0000);}\
|
||||||
else {return(NIL);}} while (0)
|
else {return(NIL);}} while (0)
|
||||||
|
|
||||||
|
#ifndef min
|
||||||
|
#define min(a, b) (((a) <= (b))?(a):(b))
|
||||||
|
#endif /* min */
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* */
|
/* */
|
||||||
@@ -79,65 +86,65 @@
|
|||||||
/* */
|
/* */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
#ifndef BYTESWAP
|
#ifndef BYTESWAP
|
||||||
#define LispStringToCString(Lisp, C, MaxLen) \
|
static inline void LispStringToCString(LispPTR Lisp, char *C, size_t MaxLen)
|
||||||
do { \
|
{
|
||||||
OneDArray *lf_arrayp; \
|
OneDArray *lf_arrayp;
|
||||||
char *lf_base, *lf_dp; \
|
char *lf_base, *lf_dp;
|
||||||
short *lf_sbase; \
|
short *lf_sbase;
|
||||||
size_t lf_length; \
|
size_t lf_length;
|
||||||
lf_arrayp = (OneDArray *)NativeAligned4FromLAddr(Lisp); \
|
lf_arrayp = (OneDArray *)NativeAligned4FromLAddr(Lisp);
|
||||||
lf_length = min(MaxLen, lf_arrayp->fillpointer); \
|
lf_length = min(MaxLen, lf_arrayp->fillpointer);
|
||||||
switch(lf_arrayp->typenumber) \
|
switch(lf_arrayp->typenumber)
|
||||||
{ \
|
{
|
||||||
case THIN_CHAR_TYPENUMBER: \
|
case THIN_CHAR_TYPENUMBER:
|
||||||
lf_base = ((char *)(NativeAligned2FromLAddr(lf_arrayp->base))) \
|
lf_base = ((char *)(NativeAligned2FromLAddr(lf_arrayp->base)))
|
||||||
+ ((int)(lf_arrayp->offset)); \
|
+ ((int)(lf_arrayp->offset));
|
||||||
strncpy(C, lf_base, lf_length); \
|
strncpy(C, lf_base, lf_length);
|
||||||
(C)[lf_length] = '\0'; \
|
(C)[lf_length] = '\0';
|
||||||
break; \
|
break;
|
||||||
\
|
|
||||||
case FAT_CHAR_TYPENUMBER: \
|
case FAT_CHAR_TYPENUMBER:
|
||||||
lf_sbase = ((short *)(NativeAligned2FromLAddr(lf_arrayp->base))) \
|
lf_sbase = ((short *)(NativeAligned2FromLAddr(lf_arrayp->base)))
|
||||||
+ ((int)(lf_arrayp->offset)); \
|
+ ((int)(lf_arrayp->offset));
|
||||||
lf_dp = C; \
|
lf_dp = C;
|
||||||
for(size_t lf_i=0;lf_i<(lf_length);lf_i++) \
|
for(size_t lf_i=0;lf_i<(lf_length);lf_i++)
|
||||||
*lf_dp++ = (char)(*lf_sbase++); \
|
*lf_dp++ = (char)(*lf_sbase++);
|
||||||
*lf_dp = '\0'; \
|
*lf_dp = '\0';
|
||||||
break; \
|
break;
|
||||||
default: \
|
default:
|
||||||
error("LispStringToCString: Not a character array.\n"); \
|
error("LispStringToCString: Not a character array.\n");
|
||||||
} \
|
}
|
||||||
} while (0)
|
}
|
||||||
#else /* BYTESWAP == T CHANGED-BY-TAKE */
|
#else /* BYTESWAP == T CHANGED-BY-TAKE */
|
||||||
#define LispStringToCString(Lisp, C, MaxLen) \
|
static inline void LispStringToCString(LispPTR Lisp, char *C, size_t MaxLen)
|
||||||
do { \
|
{
|
||||||
OneDArray *lf_arrayp; \
|
OneDArray *lf_arrayp;
|
||||||
char *lf_base, *lf_dp; \
|
char *lf_base, *lf_dp;
|
||||||
short *lf_sbase; \
|
short *lf_sbase;
|
||||||
size_t lf_length; \
|
size_t lf_length;
|
||||||
lf_arrayp = (OneDArray *)(NativeAligned4FromLAddr(Lisp)); \
|
lf_arrayp = (OneDArray *)(NativeAligned4FromLAddr(Lisp));
|
||||||
lf_length = min(MaxLen, lf_arrayp->fillpointer); \
|
lf_length = min(MaxLen, lf_arrayp->fillpointer);
|
||||||
switch(lf_arrayp->typenumber) \
|
switch(lf_arrayp->typenumber)
|
||||||
{ \
|
{
|
||||||
case THIN_CHAR_TYPENUMBER: \
|
case THIN_CHAR_TYPENUMBER:
|
||||||
lf_base = ((char *)(NativeAligned2FromLAddr(lf_arrayp->base))) \
|
lf_base = ((char *)(NativeAligned2FromLAddr(lf_arrayp->base)))
|
||||||
+ ((int)(lf_arrayp->offset)); \
|
+ ((int)(lf_arrayp->offset));
|
||||||
StrNCpyFromLispToC(C , lf_base , lf_length ); \
|
StrNCpyFromLispToC(C , lf_base , lf_length );
|
||||||
(C)[lf_length] = '\0'; \
|
(C)[lf_length] = '\0';
|
||||||
break; \
|
break;
|
||||||
\
|
|
||||||
case FAT_CHAR_TYPENUMBER: \
|
case FAT_CHAR_TYPENUMBER:
|
||||||
lf_sbase = ((short *)(NativeAligned2FromLAddr(lf_arrayp->base))) \
|
lf_sbase = ((short *)(NativeAligned2FromLAddr(lf_arrayp->base)))
|
||||||
+ ((int)(lf_arrayp->offset)); \
|
+ ((int)(lf_arrayp->offset));
|
||||||
lf_dp = C; \
|
lf_dp = C;
|
||||||
for(size_t lf_ii=0;lf_ii<(lf_length);lf_ii++,lf_sbase++) \
|
for(size_t lf_ii=0;lf_ii<(lf_length);lf_ii++,lf_sbase++)
|
||||||
*lf_dp++ = (char)(GETWORD(lf_sbase)); \
|
*lf_dp++ = (char)(GETWORD(lf_sbase));
|
||||||
*lf_dp = '\0'; \
|
*lf_dp = '\0';
|
||||||
break; \
|
break;
|
||||||
default: \
|
default:
|
||||||
error("LispStringToCString: Not a character array.\n"); \
|
error("LispStringToCString: Not a character array.\n");
|
||||||
} \
|
}
|
||||||
} while (0)
|
}
|
||||||
|
|
||||||
#endif /* BYTESWAP */
|
#endif /* BYTESWAP */
|
||||||
|
|
||||||
@@ -189,10 +196,6 @@ do { \
|
|||||||
(cstringp) = (char *)(NativeAligned2FromLAddr(((OneDArray *)lf_naddress)->base)); \
|
(cstringp) = (char *)(NativeAligned2FromLAddr(((OneDArray *)lf_naddress)->base)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#ifndef min
|
|
||||||
#define min(a, b) (((a) <= (b))?(a):(b))
|
|
||||||
#endif /* min */
|
|
||||||
|
|
||||||
#define LispNumToCInt(Lisp) \
|
#define LispNumToCInt(Lisp) \
|
||||||
( (((Lisp) & SEGMASK) == S_POSITIVE) ? ((Lisp) & 0xFFFF) : \
|
( (((Lisp) & SEGMASK) == S_POSITIVE) ? ((Lisp) & 0xFFFF) : \
|
||||||
(((Lisp) & SEGMASK) == S_NEGATIVE) ? ((Lisp) | 0xFFFF0000) : \
|
(((Lisp) & SEGMASK) == S_NEGATIVE) ? ((Lisp) | 0xFFFF0000) : \
|
||||||
@@ -293,7 +296,7 @@ do { \
|
|||||||
goto truetag; /* NOLINT(bugprone-macro-parentheses) */ \
|
goto truetag; /* NOLINT(bugprone-macro-parentheses) */ \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Name: LispVersionToUnixVersion
|
* Name: LispVersionToUnixVersion
|
||||||
*
|
*
|
||||||
* Argument: char *pathname
|
* Argument: char *pathname
|
||||||
@@ -328,17 +331,13 @@ do { \
|
|||||||
#endif /* DOS */
|
#endif /* DOS */
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Name: UnixVersionToLispVersion
|
* Name: UnixVersionToLispVersion
|
||||||
*
|
*
|
||||||
* Argument: char *pathname
|
* Argument: char *pathname UNIX syntax pathname.
|
||||||
* UNIX syntax pathname.
|
* int vlessp If 0, versionless file is converted to version 1.
|
||||||
* int vlessp
|
|
||||||
* If 0, versionless file is converted to version 1.
|
|
||||||
* Otherwise, remains as versionless.
|
* Otherwise, remains as versionless.
|
||||||
*
|
*
|
||||||
* Value: If succeed, returns 1, otherwise 0.
|
|
||||||
*
|
|
||||||
* Side Effect: The version part of pathname is destructively modified.
|
* Side Effect: The version part of pathname is destructively modified.
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
@@ -350,67 +349,25 @@ do { \
|
|||||||
* version field will append a semicolon and it might make the routine be
|
* version field will append a semicolon and it might make the routine be
|
||||||
* confused.
|
* confused.
|
||||||
* The file which has not a valid version field, that is ".~##~" form, is
|
* The file which has not a valid version field, that is ".~##~" form, is
|
||||||
* dealt with as version 1.
|
* dealt with as version 1.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define UnixVersionToLispVersion(pathname, vlessp) do { \
|
#define UnixVersionToLispVersion(pathname, vlessp) \
|
||||||
\
|
do { \
|
||||||
char *start; \
|
char *n_end; \
|
||||||
char *end; \
|
char *v_start; \
|
||||||
char *lf_cp; \
|
int v_len; \
|
||||||
int ver_no; \
|
\
|
||||||
size_t len; \
|
if (!parse_file_version(pathname, 1, &n_end, &v_start, &v_len)) { \
|
||||||
char ver_buf[VERSIONLEN]; \
|
if (!vlessp) strcat(pathname, ";1"); \
|
||||||
\
|
} else { \
|
||||||
if ((start = strchr(pathname, '~')) != NULL) { \
|
*n_end++ = ';'; \
|
||||||
/* First of all, find the version field in pathname. */ \
|
while (v_len-- > 0) *n_end++ = *v_start++; \
|
||||||
end = start; \
|
*n_end = '\0'; \
|
||||||
lf_cp = start + 1; \
|
} \
|
||||||
while (*lf_cp) { \
|
} while (0)
|
||||||
if (*lf_cp == '~') { \
|
|
||||||
start = end; \
|
|
||||||
end = lf_cp; \
|
|
||||||
lf_cp++; \
|
|
||||||
} else { \
|
|
||||||
lf_cp++; \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
if (start != end && *(start - 1) == '.' && end == (lf_cp - 1)) { \
|
|
||||||
/* \
|
|
||||||
* pathname ends in the form ".~###~". But we \
|
|
||||||
* check ### is a valid number or not. \
|
|
||||||
*/ \
|
|
||||||
len = (end - start) - 1; \
|
|
||||||
strncpy(ver_buf, start + 1, len); \
|
|
||||||
ver_buf[len] = '\0'; \
|
|
||||||
NumericStringP(ver_buf, YES, NO); \
|
|
||||||
YES: \
|
|
||||||
*(start - 1) = ';'; \
|
|
||||||
*start = '\0'; \
|
|
||||||
*end = '\0'; \
|
|
||||||
/* call strtoul() to eliminate leading 0s. */ \
|
|
||||||
ver_no = strtoul(start + 1, (char **)NULL, 10); \
|
|
||||||
sprintf(ver_buf, "%u", ver_no); \
|
|
||||||
strcat(pathname, ver_buf); \
|
|
||||||
goto CONT; \
|
|
||||||
\
|
|
||||||
NO: \
|
|
||||||
/* Dealt with as version 1 unless vlessp */ \
|
|
||||||
if (!(vlessp)) strcat(pathname, ";1"); \
|
|
||||||
CONT: \
|
|
||||||
lf_cp--; /* Just for label */ \
|
|
||||||
} else { \
|
|
||||||
/* Dealt with as version 1 unless vlessp. */ \
|
|
||||||
if (!(vlessp)) strcat(pathname, ";1"); \
|
|
||||||
} \
|
|
||||||
} else { \
|
|
||||||
/* Dealt with as version 1 unless vlessp. */ \
|
|
||||||
if (!(vlessp)) strcat(pathname, ";1"); \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Name: ConcDirAndName
|
* Name: ConcDirAndName
|
||||||
*
|
*
|
||||||
* Argument: char *dir The name of the directory.
|
* Argument: char *dir The name of the directory.
|
||||||
@@ -428,45 +385,45 @@ do { \
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define ConcDirAndName(dir, name, fname) do { \
|
static inline void ConcDirAndName(char *dir, char *name, char *fname)
|
||||||
\
|
{
|
||||||
char *lf_cp1, *lf_cp2; \
|
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)
|
|
||||||
|
|
||||||
/*
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
* Name: ConcNameAndVersion
|
* Name: ConcNameAndVersion
|
||||||
*
|
*
|
||||||
* Argument: char *name The root file name.
|
* Argument: char *name The root file name.
|
||||||
@@ -481,20 +438,24 @@ do { \
|
|||||||
*
|
*
|
||||||
* Concatenate the root file name and its version in UNIX format.
|
* Concatenate the root file name and its version in UNIX format.
|
||||||
*
|
*
|
||||||
|
* XXX: this code is unsafe and could result in memory smashes if the
|
||||||
|
* sizes of the arguments are not correctly specified
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define ConcNameAndVersion(name, ver, rname) do { \
|
static inline void ConcNameAndVersion(char *name, char *ver, char *rname)
|
||||||
if (*(ver) != '\0') { \
|
{
|
||||||
strcpy(rname, name); \
|
if (*ver != '\0') {
|
||||||
strcat(rname, ".~"); \
|
strcpy(rname, name);
|
||||||
strcat(rname, ver); \
|
strcat(rname, ".~");
|
||||||
strcat(rname, "~"); \
|
strcat(rname, ver);
|
||||||
} else { \
|
strcat(rname, "~");
|
||||||
strcpy(rname, name); \
|
} else {
|
||||||
} \
|
strcpy(rname, name);
|
||||||
} while (0)
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#define VERSIONLEN 16
|
#define VERSIONLEN 10
|
||||||
|
|
||||||
#define MAXVERSION 999999999
|
#define MAXVERSION 999999999
|
||||||
|
|
||||||
@@ -542,7 +503,7 @@ do { \
|
|||||||
*(lf_cp-1) = '\0'; \
|
*(lf_cp-1) = '\0'; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define ChangeToVersionless(pathname) do { \
|
#define ChangeToVersionless(pathname) do { \
|
||||||
char *lf_cp; \
|
char *lf_cp; \
|
||||||
if( (lf_cp=strrchr(pathname, ';')) != 0) \
|
if( (lf_cp=strrchr(pathname, ';')) != 0) \
|
||||||
@@ -576,9 +537,9 @@ do { \
|
|||||||
TIMEOUT(lf_rval=rename(x, y)); \
|
TIMEOUT(lf_rval=rename(x, y)); \
|
||||||
if(lf_rval == -1){ \
|
if(lf_rval == -1){ \
|
||||||
switch(errno){ \
|
switch(errno){ \
|
||||||
case 2: \
|
case ENOENT: \
|
||||||
return(1); \
|
return(1); \
|
||||||
case 18: \
|
case EXDEV: \
|
||||||
*Lisp_errno = errno; \
|
*Lisp_errno = errno; \
|
||||||
return(0); \
|
return(0); \
|
||||||
default: \
|
default: \
|
||||||
@@ -601,20 +562,78 @@ do { \
|
|||||||
/*
|
/*
|
||||||
* For file name length check
|
* For file name length check
|
||||||
*/
|
*/
|
||||||
#define FNAMETOOLONG 200
|
|
||||||
|
|
||||||
#define FileNameTooLong(val) do { \
|
#define FileNameTooLong(val) do { \
|
||||||
*Lisp_errno = FNAMETOOLONG; \
|
*Lisp_errno = ENAMETOOLONG; \
|
||||||
return((val)); \
|
return((val)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
static inline int parse_file_version(char *name, int digitsonly, char **n_end,
|
||||||
|
char **v_start, int *v_length)
|
||||||
|
{
|
||||||
|
char *sp, *ep;
|
||||||
|
size_t name_len;
|
||||||
|
|
||||||
|
name_len = strlen(name);
|
||||||
|
ep = &name[name_len - 1];
|
||||||
|
|
||||||
|
/* handle special case of Alto/IFS names with !nnn version.
|
||||||
|
To be considered for this case the name MUST end with ![0-9]+, however
|
||||||
|
version 0 is not valid.
|
||||||
|
*/
|
||||||
|
sp = strrchr(name, '!');
|
||||||
|
if (sp != NULL) {
|
||||||
|
sp++; /* "!nnn" => "nnn" or "!" => "" */
|
||||||
|
if (*sp != '\0' && sp[strspn(sp, "0123456789")] == '\0') {
|
||||||
|
/* it was all digits after the '!', so go with it */
|
||||||
|
*n_end = sp - 1; /* name ends at '!' */
|
||||||
|
while (*sp == '0' && sp < ep) sp++; /* skip leading zeroes */
|
||||||
|
if (*sp == '0') return (0); /* version 0 is not valid */
|
||||||
|
*v_start = sp; /* version start after '!' */
|
||||||
|
*v_length = (ep - sp) + 1;
|
||||||
|
return ((*v_length >= VERSIONLEN) ? 0 : 1); /* fail on version too long */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* if the name is too short to have a name and a version number
|
||||||
|
".~#~" or doesn't end with "~" then there is no version number
|
||||||
|
*/
|
||||||
|
if (name_len < 4 || *ep != '~')
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
/* The name ends with a "~" so scan back in the filename looking for
|
||||||
|
another "~" terminating early if we need only digits and find
|
||||||
|
something else
|
||||||
|
*/
|
||||||
|
sp = ep - 1;
|
||||||
|
while (sp > name && *sp != '~') {
|
||||||
|
if (digitsonly && !isdigit(*sp)) return (0);
|
||||||
|
--sp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* test for no initial "~" or no "." before "~", or
|
||||||
|
* version number length not at least 1
|
||||||
|
*/
|
||||||
|
if (sp == name || *(sp - 1) != '.' || (ep - sp) - 1 < 1)
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
/* After this point we have a version number in the form .~#~ with sp
|
||||||
|
pointing at the starting "~", ep pointing at the last "~",
|
||||||
|
and there must be at least one digit. Scan past any leading
|
||||||
|
zeros in the version, taking care not to remove the last digit.
|
||||||
|
*/
|
||||||
|
|
||||||
|
*n_end = sp - 1; /* save location of "." */
|
||||||
|
|
||||||
|
sp++; /* skip over the "." */
|
||||||
|
while (*sp == '0' && sp < (ep - 1)) {
|
||||||
|
sp++;
|
||||||
|
}
|
||||||
|
if (*sp == '0') return (0); /* version 0 is not valid */
|
||||||
|
*v_start = sp; /* save location of first significant digit in version */
|
||||||
|
*v_length = (ep - sp); /* save length of version */
|
||||||
|
return ((*v_length >= VERSIONLEN) ? 0 : 1); /* fail on version too long */
|
||||||
|
}
|
||||||
|
|
||||||
/********************************************************/
|
/********************************************************/
|
||||||
/* file-system-specific defns */
|
/* file-system-specific defns */
|
||||||
|
|||||||
@@ -3246,6 +3246,7 @@ static int maintain_version(char *file, int forcep)
|
|||||||
* is versioned one higher than the existing highest version.
|
* is versioned one higher than the existing highest version.
|
||||||
*/
|
*/
|
||||||
FindHighestVersion(VA.files, entry, max_no);
|
FindHighestVersion(VA.files, entry, max_no);
|
||||||
|
if (max_no >= MAXVERSION) {*Lisp_errno = EIO; return (0);}
|
||||||
sprintf(ver, "%u", max_no + 1);
|
sprintf(ver, "%u", max_no + 1);
|
||||||
/*
|
/*
|
||||||
* The old file should have the same case name as the versionless
|
* The old file should have the same case name as the versionless
|
||||||
@@ -3570,6 +3571,7 @@ static int get_old(char *dir, FileName *varray, char *afile, char *vfile)
|
|||||||
* link missing versionless file.
|
* link missing versionless file.
|
||||||
*/
|
*/
|
||||||
FindHighestVersion(varray, entry, max_no);
|
FindHighestVersion(varray, entry, max_no);
|
||||||
|
if (max_no >= MAXVERSION) {*Lisp_errno = EIO; return (0);}
|
||||||
sprintf(vbuf, "%u", max_no + 1);
|
sprintf(vbuf, "%u", max_no + 1);
|
||||||
ConcNameAndVersion(vless, vbuf, vfile);
|
ConcNameAndVersion(vless, vbuf, vfile);
|
||||||
strcpy(afile, vless);
|
strcpy(afile, vless);
|
||||||
@@ -3578,6 +3580,7 @@ static int get_old(char *dir, FileName *varray, char *afile, char *vfile)
|
|||||||
/* A version is specified. */
|
/* A version is specified. */
|
||||||
ver_no = strtoul(ver, (char **)NULL, 10);
|
ver_no = strtoul(ver, (char **)NULL, 10);
|
||||||
FindHighestVersion(varray, entry, max_no);
|
FindHighestVersion(varray, entry, max_no);
|
||||||
|
if (max_no >= MAXVERSION) {*Lisp_errno = EIO; return (0);}
|
||||||
if (ver_no == max_no + 1) {
|
if (ver_no == max_no + 1) {
|
||||||
/*
|
/*
|
||||||
* If the version is one higher than the
|
* If the version is one higher than the
|
||||||
@@ -3926,6 +3929,7 @@ static int get_new(char *dir, FileName *varray, char *afile, char *vfile)
|
|||||||
* the existing highest version.
|
* the existing highest version.
|
||||||
*/
|
*/
|
||||||
FindHighestVersion(varray, entry, max_no);
|
FindHighestVersion(varray, entry, max_no);
|
||||||
|
if (max_no + 1 >= MAXVERSION) {*Lisp_errno = EIO; return (0);}
|
||||||
sprintf(vbuf, "%u", max_no + 1);
|
sprintf(vbuf, "%u", max_no + 1);
|
||||||
/*
|
/*
|
||||||
* We will use the file name of the existing highest
|
* We will use the file name of the existing highest
|
||||||
@@ -4018,6 +4022,7 @@ static int get_new(char *dir, FileName *varray, char *afile, char *vfile)
|
|||||||
* missing versionless file.
|
* missing versionless file.
|
||||||
*/
|
*/
|
||||||
FindHighestVersion(varray, entry, max_no);
|
FindHighestVersion(varray, entry, max_no);
|
||||||
|
if (max_no + 1 >= MAXVERSION) {*Lisp_errno = EIO; return (0);}
|
||||||
sprintf(vbuf, "%u", max_no + 2);
|
sprintf(vbuf, "%u", max_no + 2);
|
||||||
ConcNameAndVersion(vless, vbuf, vfile);
|
ConcNameAndVersion(vless, vbuf, vfile);
|
||||||
strcpy(afile, vfile);
|
strcpy(afile, vfile);
|
||||||
@@ -4081,6 +4086,7 @@ static int get_new(char *dir, FileName *varray, char *afile, char *vfile)
|
|||||||
* new file.
|
* new file.
|
||||||
*/
|
*/
|
||||||
FindHighestVersion(varray, entry, max_no);
|
FindHighestVersion(varray, entry, max_no);
|
||||||
|
if (max_no >= MAXVERSION) {*Lisp_errno = EIO; return (0);}
|
||||||
sprintf(vbuf, "%u", max_no + 1);
|
sprintf(vbuf, "%u", max_no + 1);
|
||||||
/*
|
/*
|
||||||
* We will use the name of the highest versioned file
|
* We will use the name of the highest versioned file
|
||||||
@@ -4297,6 +4303,7 @@ static int get_old_new(char *dir, FileName *varray, char *afile, char *vfile)
|
|||||||
* link missing versionless file.
|
* link missing versionless file.
|
||||||
*/
|
*/
|
||||||
FindHighestVersion(varray, entry, max_no);
|
FindHighestVersion(varray, entry, max_no);
|
||||||
|
if (max_no >= MAXVERSION) {*Lisp_errno = EIO; return (0);}
|
||||||
sprintf(vbuf, "%u", max_no + 1);
|
sprintf(vbuf, "%u", max_no + 1);
|
||||||
ConcNameAndVersion(vless, vbuf, vfile);
|
ConcNameAndVersion(vless, vbuf, vfile);
|
||||||
strcpy(afile, vless);
|
strcpy(afile, vless);
|
||||||
|
|||||||
Reference in New Issue
Block a user