Description: <short summary of the patch>
TODO: Put a short summary on the line above and replace this paragraph
with a longer explanation of this change. Complete the meta-information
with other relevant fields (see below for details). To make it easier, the
information below has been extracted from the changelog. Adjust it or drop
it.
.
gcl (2.6.12-90) unstable; urgency=medium
.
* Version_2_6_13pre87
* latest standards
Author: Camm Maguire <camm@debian.org>
---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:
Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: 2019-12-18
--- gcl-2.6.12.orig/h/pool.h
+++ gcl-2.6.12/h/pool.h
@@ -20,9 +20,8 @@ static struct pool {
ufixnum s;
} *Pool;
-static struct flock pl,*plp=&pl;
-
-static const char *gcl_pool="/tmp/gcl_pool";
+static struct flock f,pl,*plp=&pl;
+static char gcl_pool[PATH_MAX];
static int
set_lock(void) {
@@ -66,8 +65,8 @@ open_pool(void) {
if (pool==-1) {
- struct flock f;
-
+ massert(!home_namestring1("~",1,FN1,sizeof(FN1)));
+ massert(snprintf(gcl_pool,sizeof(gcl_pool),"%sgcl_pool",FN1)>=0);
massert((pool=open(gcl_pool,O_CREAT|O_RDWR,0644))!=-1);
massert(!ftruncate(pool,sizeof(struct pool)));
massert((Pool=mmap(NULL,sizeof(struct pool),PROT_READ|PROT_WRITE,MAP_SHARED,pool,0))!=(void *)-1);
@@ -111,6 +110,9 @@ close_pool(void) {
#ifndef NO_FILE_LOCKING
if (pool!=-1) {
+ f.l_type=F_WRLCK;
+ if (!fcntl(pool,F_SETLK,&f))
+ massert(!unlink(gcl_pool));
register_pool(-1);
massert(!close(pool));
massert(!munmap(Pool,sizeof(struct pool)));
--- gcl-2.6.12.orig/h/protoize.h
+++ gcl-2.6.12/h/protoize.h
@@ -1971,3 +1971,6 @@ travel_find_sharing(object,object);
object
new_cfdata(void);
+
+int
+home_namestring1(const char *,int,char *,int);
--- gcl-2.6.12.orig/o/unixfsys.c
+++ gcl-2.6.12/o/unixfsys.c
@@ -95,16 +95,20 @@ DEFUN_NEW("UID-TO-NAME",object,fSuid_to_
#endif
}
-DEFUN_NEW("HOME-NAMESTRING",object,fShome_namestring,SI,1,1,NONE,OO,OO,OO,OO,(object nm),"") {
+int
+home_namestring1(const char *n,int s,char *o,int so) {
-#ifndef __MINGW32__
+ #ifndef __MINGW32__
struct passwd *pwent,pw;
long r;
+ massert(s>0);
+ massert(*n=='~');
+
massert((r=sysconf(_SC_GETPW_R_SIZE_MAX))>=0);
massert(r<=sizeof(GETPW_BUF));/*FIXME maybe once at image startup*/
- if (nm->st.st_fillp==1)
+ if (s==1)
if ((pw.pw_dir=getenv("HOME")))
pwent=&pw;
@@ -113,26 +117,44 @@ DEFUN_NEW("HOME-NAMESTRING",object,fShom
else {
- massert(nm->st.st_fillp<sizeof(FN2));
- memcpy(FN2,nm->st.st_self+1,nm->st.st_fillp-1);
- FN2[nm->st.st_fillp-1]=0;
+ massert(s<sizeof(FN2));
+ memcpy(FN2,n+1,s-1);
+ FN2[s-1]=0;
massert(!getpwnam_r(FN2,&pw,GETPW_BUF,r,&pwent) && pwent);
}
- massert((r=strlen(pwent->pw_dir))+2<sizeof(FN3));
- memcpy(FN3,pwent->pw_dir,r);
- FN3[r]='/';
- FN3[r+1]=0;
- RETURN1(make_simple_string(FN3));
+ massert((r=strlen(pwent->pw_dir))+2<so);
+ memcpy(o,pwent->pw_dir,r);
+ o[r]='/';
+ o[r+1]=0;
+ return 0;
#else
- massert(snprintf(FN1,sizeof(FN1)-1,"%s%s",getenv("SystemDrive"),getenv("HOMEPATH"))>=0);
- RETURN1(make_simple_string(FN1));
+ massert(snprintf(o,so-1,"%s%s",getenv("SystemDrive"),getenv("HOMEPATH"))>=0);
+ return 0;
#endif
}
+
+DEFUN_NEW("HOME-NAMESTRING",object,fShome_namestring,SI,1,1,NONE,OO,OO,OO,OO,(object nm),"") {
+
+ check_type_string(&nm);
+
+ massert(!home_namestring1(nm->st.st_self,nm->st.st_fillp,FN1,sizeof(FN1)));
+ RETURN1(make_simple_string(FN1));
+
+}
+#ifdef STATIC_FUNCTION_POINTERS
+object
+fShome_namestring(object x) {
+ return FFN(fShome_namestring)(x);
+}
+#endif
+
+
+
#define FILE_EXISTS_P(a_,b_) !stat(a_,&b_) && S_ISREG(b_.st_mode)
#define DIR_EXISTS_P(a_,b_) !stat(a_,&b_) && S_ISDIR(b_.st_mode)