From ba4557fc9d049b27fce357301c72433139f2a44a Mon Sep 17 00:00:00 2001
From: Fumitoshi UKAI <ukai@debian.or.jp>
Date: Sun, 2 Dec 2001 16:26:08 +0000
Subject: [w3m-dev 02605] From: Kiyokazu SUTO <suto@ks-and-ks.ne.jp>

---
 ChangeLog        | 30 ++++++++++++++++++++++++++++++
 XMakefile        |  5 +++--
 display.c        |  4 ++--
 etc.c            |  8 ++++----
 file.c           |  4 ++--
 func.c           |  4 ++--
 history.c        |  6 +++---
 indep.c          |  6 +++---
 linein.c         |  4 ++--
 local.c          |  4 ++--
 main.c           | 10 +++++-----
 parsetagx.c      |  4 ++--
 terms.c          |  4 ++--
 textlist.h       |  4 ++--
 url.c            | 22 +++++++++++-----------
 w3mhelperpanel.c |  4 ++--
 16 files changed, 77 insertions(+), 46 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 32cf44d..9405dc9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,33 @@
+2001-12-03  Kiyokazu SUTO <suto@ks-and-ks.ne.jp>
+
+	* [w3m-dev 02605] $(PWD) / allocStr()
+	
+	* XMakefile (install-scripts): use $$TOPDIR instead of $(PWD)
+
+	* indep.c (allocStr): if len is negative, it will copy string in `s'
+	* display.c (record_err_message): pass -1 as length to allocStr
+	* etc.c (lastFileName): ditto
+	* etc.c (mybasename): ditto
+	* etc.c (FQDN): ditto
+	* file.c (push_tag): ditto
+	* func.c (addKeyList): ditto
+	* history.c (unshiftHist): ditto
+	* history.c (pushHist): ditto
+	* indep.c (cleanupName): ditto
+	* linein.c (inputLineHist): ditto
+	* local.c (dirBuffer): ditto
+	* main.c (gotoLabel): ditto
+	* main.c (searchKeyData): ditto
+	* parsetagx.c (parsedtag_set_value): ditto
+	* terms.c (GETSTR): ditto
+	* textlist.h (pushText): ditto
+	* url.c (DefaultFile): ditto
+	* url.c (parseURL): ditto
+	* url.c (ALLOC_STR): ditto
+	* url.c (parseURL2): ditto
+	* url.c (openURL): ditto
+	* w3mhelperpanel.c (extractMailcapEntry): ditto
+
 2001-12-02  Fumitoshi UKAI  <ukai@debian.or.jp>
 
 	* [w3m-dev 02604]
diff --git a/XMakefile b/XMakefile
index d34c21d..48d7a6c 100644
--- a/XMakefile
+++ b/XMakefile
@@ -1,4 +1,4 @@
-# $Id: XMakefile,v 1.11 2001/11/30 16:48:15 ukai Exp $
+# $Id: XMakefile,v 1.12 2001/12/02 16:26:08 ukai Exp $
 SRCS=main.c file.c buffer.c display.c etc.c search.c linein.c table.c local.c \
 	form.c map.c frame.c rc.c menu.c mailcap.c\
 	func.c cookie.c history.c backend.c $(KEYBIND_SRC)
@@ -107,7 +107,8 @@ all-scripts:
 install-scripts: all-scripts
 	for dir in $(SCRIPTSUBDIRS);	\
 	do	\
-		(cd $$dir; $(MAKE) PERL='$(PERL)' BIN_DIR='$(BIN_DIR)' LIB_DIR='$(LIB_DIR)' HELP_DIR='$(HELP_DIR)' DESTDIR='$(DESTDIR)' INSTALL='sh $(PWD)/install.sh' install);	\
+		TOPDIR=`pwd`; \
+		(cd $$dir; $(MAKE) PERL='$(PERL)' BIN_DIR='$(BIN_DIR)' LIB_DIR='$(LIB_DIR)' HELP_DIR='$(HELP_DIR)' DESTDIR='$(DESTDIR)' INSTALL="sh $$TOPDIR/install.sh" install);	\
 	done
 
 uninstall:
diff --git a/display.c b/display.c
index 146aa36..4b99816 100644
--- a/display.c
+++ b/display.c
@@ -1,4 +1,4 @@
-/* $Id: display.c,v 1.10 2001/11/29 09:34:14 ukai Exp $ */
+/* $Id: display.c,v 1.11 2001/12/02 16:26:08 ukai Exp $ */
 #include <signal.h>
 #include "fm.h"
 
@@ -782,7 +782,7 @@ record_err_message(char *s)
 	    message_list = newGeneralList();
 	if (message_list->nitem >= LINES)
 	    popValue(message_list);
-	pushValue(message_list, allocStr(s, 0));
+	pushValue(message_list, allocStr(s, -1));
     }
 }
 
diff --git a/etc.c b/etc.c
index a828970..81e7516 100644
--- a/etc.c
+++ b/etc.c
@@ -1,4 +1,4 @@
-/* $Id: etc.c,v 1.8 2001/11/24 02:01:26 ukai Exp $ */
+/* $Id: etc.c,v 1.9 2001/12/02 16:26:08 ukai Exp $ */
 #include "fm.h"
 #include <pwd.h>
 #include "myctype.h"
@@ -640,7 +640,7 @@ lastFileName(char *path)
 	p++;
     }
 
-    return allocStr(q, 0);
+    return allocStr(q, -1);
 }
 
 #ifndef HAVE_BCOPY
@@ -704,7 +704,7 @@ mybasename(char *s)
 	p++;
     else
 	p = s;
-    return allocStr(p, 0);
+    return allocStr(p, -1);
 }
 
 char *
@@ -1518,7 +1518,7 @@ FQDN(char *host)
     if (!(entry = gethostbyname(host)))
 	return NULL;
 
-    return allocStr(entry->h_name, 0);
+    return allocStr(entry->h_name, -1);
 #else				/* INET6 */
     for (af = ai_family_order_table[DNS_order];; af++) {
 	int error;
diff --git a/file.c b/file.c
index 6a6d379..74add5e 100644
--- a/file.c
+++ b/file.c
@@ -1,4 +1,4 @@
-/* $Id: file.c,v 1.24 2001/12/02 14:27:11 ukai Exp $ */
+/* $Id: file.c,v 1.25 2001/12/02 16:26:08 ukai Exp $ */
 #include "fm.h"
 #include <sys/types.h>
 #include "myctype.h"
@@ -1675,7 +1675,7 @@ static void
 push_tag(struct readbuffer *obuf, char *cmdname, int cmd)
 {
     obuf->tag_stack[obuf->tag_sp] = New(struct cmdtable);
-    obuf->tag_stack[obuf->tag_sp]->cmdname = allocStr(cmdname, 0);
+    obuf->tag_stack[obuf->tag_sp]->cmdname = allocStr(cmdname, -1);
     obuf->tag_stack[obuf->tag_sp]->cmd = cmd;
     obuf->tag_sp++;
     if (obuf->tag_sp >= TAG_STACK_SIZE || obuf->flag & (RB_SPECIAL & ~RB_NOBR))
diff --git a/func.c b/func.c
index 4150982..da85327 100644
--- a/func.c
+++ b/func.c
@@ -1,4 +1,4 @@
-/* $Id: func.c,v 1.4 2001/11/24 02:01:26 ukai Exp $ */
+/* $Id: func.c,v 1.5 2001/12/02 16:26:08 ukai Exp $ */
 /*
  * w3m func.c
  */
@@ -248,7 +248,7 @@ addKeyList(KeyList *list, int key, char *data)
     if (data == NULL || *data == '\0')
 	data = NULL;
     else
-	data = allocStr(data, 0);
+	data = allocStr(data, -1);
     item = searchKeyList(list, key);
     if (item == NULL) {
 	if (data == NULL)
diff --git a/history.c b/history.c
index 22bb42a..583b72a 100644
--- a/history.c
+++ b/history.c
@@ -1,4 +1,4 @@
-/* $Id: history.c,v 1.4 2001/11/24 02:01:26 ukai Exp $ */
+/* $Id: history.c,v 1.5 2001/12/02 16:26:08 ukai Exp $ */
 #include "fm.h"
 
 #ifdef USE_HISTORY
@@ -89,7 +89,7 @@ unshiftHist(Hist *hist, char *ptr)
 
     if (hist == NULL || hist->list == NULL)
 	return NULL;
-    item = (HistItem *)newListItem((void *)allocStr(ptr, 0),
+    item = (HistItem *)newListItem((void *)allocStr(ptr, -1),
 				   (ListItem *)hist->list->first, NULL);
     if (hist->list->first)
 	hist->list->first->prev = item;
@@ -107,7 +107,7 @@ pushHist(Hist *hist, char *ptr)
 
     if (hist == NULL || hist->list == NULL)
 	return NULL;
-    item = (HistItem *)newListItem((void *)allocStr(ptr, 0),
+    item = (HistItem *)newListItem((void *)allocStr(ptr, -1),
 				   NULL, (ListItem *)hist->list->last);
     if (hist->list->last)
 	hist->list->last->next = item;
diff --git a/indep.c b/indep.c
index 5f5a2f5..827ec09 100644
--- a/indep.c
+++ b/indep.c
@@ -1,4 +1,4 @@
-/* $Id: indep.c,v 1.13 2001/11/27 18:29:24 ukai Exp $ */
+/* $Id: indep.c,v 1.14 2001/12/02 16:26:08 ukai Exp $ */
 #include "fm.h"
 #include <stdio.h>
 #include <pwd.h>
@@ -18,7 +18,7 @@ allocStr(const char *s, int len)
 
     if (s == NULL)
 	return NULL;
-    if (len == 0)
+    if (len < 0)
 	len = strlen(s);
     ptr = NewAtom_N(char, len + 1);
     if (ptr == NULL) {
@@ -80,7 +80,7 @@ cleanupName(char *name)
 {
     char *buf, *p, *q;
 
-    buf = allocStr(name, 0);
+    buf = allocStr(name, -1);
     p = buf;
     q = name;
     while (*q != '\0') {
diff --git a/linein.c b/linein.c
index 44fc98e..5612e00 100644
--- a/linein.c
+++ b/linein.c
@@ -1,4 +1,4 @@
-/* $Id: linein.c,v 1.9 2001/11/29 09:34:14 ukai Exp $ */
+/* $Id: linein.c,v 1.10 2001/12/02 16:26:08 ukai Exp $ */
 #include "fm.h"
 #include "local.h"
 #include "myctype.h"
@@ -293,7 +293,7 @@ inputLineHist(char *prompt, char *def_str, int flag, Hist *hist)
     if (flag & IN_FILENAME)
 	return expandName(p);
     else
-	return allocStr(p, 0);
+	return allocStr(p, -1);
 }
 
 #ifdef __EMX__
diff --git a/local.c b/local.c
index c646ca7..e4d7278 100644
--- a/local.c
+++ b/local.c
@@ -1,4 +1,4 @@
-/* $Id: local.c,v 1.10 2001/11/29 09:34:14 ukai Exp $ */
+/* $Id: local.c,v 1.11 2001/12/02 16:26:08 ukai Exp $ */
 #include "fm.h"
 #include <string.h>
 #include <stdio.h>
@@ -64,7 +64,7 @@ dirBuffer(char *dname)
     flist = New_N(char *, nfile_max);
     nfile = 0;
     while ((dir = readdir(d)) != NULL) {
-	flist[nfile++] = allocStr(dir->d_name, 0);
+	flist[nfile++] = allocStr(dir->d_name, -1);
 	if (nfile == nfile_max) {
 	    nfile_max *= 2;
 	    flist = New_Reuse(char *, flist, nfile_max);
diff --git a/main.c b/main.c
index f083016..1d8bf81 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.30 2001/11/30 18:06:28 ukai Exp $ */
+/* $Id: main.c,v 1.31 2001/12/02 16:26:08 ukai Exp $ */
 #define MAINPROGRAM
 #include "fm.h"
 #include <signal.h>
@@ -2448,7 +2448,7 @@ gotoLabel(char *label)
     copyBuffer(buf, Currentbuf);
     for (i = 0; i < MAX_LB; i++)
 	buf->linkBuffer[i] = NULL;
-    buf->currentURL.label = allocStr(label, 0);
+    buf->currentURL.label = allocStr(label, -1);
     pushHashHist(URLHist, parsedURL2Str(&buf->currentURL)->ptr);
     (*buf->clone)++;
     pushBuffer(buf);
@@ -4619,17 +4619,17 @@ searchKeyData(void)
     KeyListItem *item;
 
     if (CurrentKeyData != NULL && *CurrentKeyData != '\0')
-	return allocStr(CurrentKeyData, 0);
+	return allocStr(CurrentKeyData, -1);
 #ifdef USE_MENU
     if (CurrentMenuData != NULL && *CurrentMenuData != '\0')
-	return allocStr(CurrentMenuData, 0);
+	return allocStr(CurrentMenuData, -1);
 #endif
     if (CurrentKey < 0)
 	return NULL;
     item = searchKeyList(&w3mKeyList, CurrentKey);
     if (item == NULL || item->data == NULL || *item->data == '\0')
 	return NULL;
-    return allocStr(item->data, 0);
+    return allocStr(item->data, -1);
 }
 
 static int
diff --git a/parsetagx.c b/parsetagx.c
index dfacdce..08b3f8e 100644
--- a/parsetagx.c
+++ b/parsetagx.c
@@ -1,4 +1,4 @@
-/* $Id: parsetagx.c,v 1.6 2001/11/29 09:34:15 ukai Exp $ */
+/* $Id: parsetagx.c,v 1.7 2001/12/02 16:26:08 ukai Exp $ */
 #include "fm.h"
 #include "myctype.h"
 #include "indep.h"
@@ -232,7 +232,7 @@ parsedtag_set_value(struct parsed_tag *tag, int id, char *value)
     i = tag->map[id];
     tag->attrid[i] = id;
     if (value)
-	tag->value[i] = allocStr(value, 0);
+	tag->value[i] = allocStr(value, -1);
     else
 	tag->value[i] = NULL;
     tag->need_reconstruct = TRUE;
diff --git a/terms.c b/terms.c
index e294d45..8965912 100644
--- a/terms.c
+++ b/terms.c
@@ -1,4 +1,4 @@
-/* $Id: terms.c,v 1.19 2001/11/30 10:10:24 ukai Exp $ */
+/* $Id: terms.c,v 1.20 2001/12/02 16:26:08 ukai Exp $ */
 /* 
  * An original curses library for EUC-kanji by Akinori ITO,     December 1989
  * revised by Akinori ITO, January 1995
@@ -577,7 +577,7 @@ setgraphchar(void)
 
 #define graphchar(c) (((unsigned)(c)>=' ' && (unsigned)(c)<128)? gcmap[(c)-' '] : (c))
 
-#define GETSTR(v,s) {v = pt; suc = tgetstr(s,&pt); if (!suc) v = ""; else v = allocStr(suc,0); }
+#define GETSTR(v,s) {v = pt; suc = tgetstr(s,&pt); if (!suc) v = ""; else v = allocStr(suc, -1); }
 
 void
 getTCstr(void)
diff --git a/textlist.h b/textlist.h
index 55a2e65..72da85c 100644
--- a/textlist.h
+++ b/textlist.h
@@ -1,4 +1,4 @@
-/* $Id: textlist.h,v 1.3 2001/11/24 02:01:26 ukai Exp $ */
+/* $Id: textlist.h,v 1.4 2001/12/02 16:26:08 ukai Exp $ */
 #ifndef TEXTLIST_H
 #define TEXTLIST_H
 #include "Str.h"
@@ -39,7 +39,7 @@ typedef struct _textlist {
 } TextList;
 
 #define newTextList() ((TextList *)newGeneralList())
-#define pushText(tl, s) pushValue((GeneralList *)(tl), (void *)allocStr((s)?(s):"",0))
+#define pushText(tl, s) pushValue((GeneralList *)(tl), (void *)allocStr((s)?(s):"",-1))
 #define popText(tl) ((char *)popValue((GeneralList *)(tl)))
 #define rpopText(tl) ((char *)rpopValue((GeneralList *)(tl)))
 #define appendTextList(tl, tl2) ((TextList *)appendGeneralList((GeneralList *)(tl), (GeneralList *)(tl2)))
diff --git a/url.c b/url.c
index 147cbeb..6bb0cbd 100644
--- a/url.c
+++ b/url.c
@@ -1,4 +1,4 @@
-/* $Id: url.c,v 1.16 2001/11/30 14:06:27 ukai Exp $ */
+/* $Id: url.c,v 1.17 2001/12/02 16:26:08 ukai Exp $ */
 #include "fm.h"
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -212,15 +212,15 @@ DefaultFile(int scheme)
 #ifdef USE_SSL
     case SCM_HTTPS:
 #endif				/* USE_SSL */
-	return allocStr(HTTP_DEFAULT_FILE, 0);
+	return allocStr(HTTP_DEFAULT_FILE, -1);
 #ifdef USE_GOPHER
     case SCM_GOPHER:
-	return allocStr("1", 0);
+	return allocStr("1", -1);
 #endif				/* USE_GOPHER */
     case SCM_LOCAL:
     case SCM_LOCAL_CGI:
     case SCM_FTP:
-	return allocStr("/", 0);
+	return allocStr("/", -1);
     }
     return NULL;
 }
@@ -830,7 +830,7 @@ parseURL(char *url, ParsedURL *p_url, ParsedURL *current)
 	    q++;
 	if (IS_ALPHA(q[0]) && (q[1] == ':' || q[1] == '|')) {
 	    if (q[1] == '|') {
-		p = allocStr(q, 0);
+		p = allocStr(q, -1);
 		p[1] = ':';
 	    }
 	    else
@@ -914,17 +914,17 @@ parseURL(char *url, ParsedURL *p_url, ParsedURL *current)
   do_label:
     if (p_url->scheme == SCM_MISSING) {
 	p_url->scheme = SCM_LOCAL;
-	p_url->file = allocStr(p, 0);
+	p_url->file = allocStr(p, -1);
 	p_url->label = NULL;
     }
     else if (*p == '#')
-	p_url->label = allocStr(p + 1, 0);
+	p_url->label = allocStr(p + 1, -1);
     else
 	p_url->label = NULL;
 }
 
 #define initParsedURL(p) bzero(p,sizeof(ParsedURL))
-#define ALLOC_STR(s) ((s)==NULL?NULL:allocStr(s,0))
+#define ALLOC_STR(s) ((s)==NULL?NULL:allocStr(s,-1))
 
 void
 copyParsedURL(ParsedURL *p, ParsedURL *q)
@@ -997,7 +997,7 @@ parseURL2(char *url, ParsedURL *pu, ParsedURL *current)
 #ifdef USE_GOPHER
 	    else if (pu->scheme == SCM_GOPHER && pu->file[0] == '/') {
 		p = pu->file;
-		pu->file = allocStr(p + 1, 0);
+		pu->file = allocStr(p + 1, -1);
 	    }
 #endif				/* USE_GOPHER */
 	}
@@ -1485,7 +1485,7 @@ openURL(char *url, ParsedURL *pu, ParsedURL *current,
 	return uf;
     case SCM_FTP:
 	if (pu->file == NULL)
-	    pu->file = allocStr("/", 0);
+	    pu->file = allocStr("/", -1);
 	if (non_null(FTP_proxy) &&
 	    !Do_not_use_proxy &&
 	    pu->host != NULL && !check_no_proxy(pu->host)) {
@@ -1509,7 +1509,7 @@ openURL(char *url, ParsedURL *pu, ParsedURL *current,
     case SCM_HTTPS:
 #endif				/* USE_SSL */
 	if (pu->file == NULL)
-	    pu->file = allocStr("/", 0);
+	    pu->file = allocStr("/", -1);
 	if (request && request->method == FORM_METHOD_POST && request->body)
 	    hr.command = HR_COMMAND_POST;
 	if (request && request->method == FORM_METHOD_HEAD)
diff --git a/w3mhelperpanel.c b/w3mhelperpanel.c
index 6186a61..87c602f 100644
--- a/w3mhelperpanel.c
+++ b/w3mhelperpanel.c
@@ -1,4 +1,4 @@
-/* $Id: w3mhelperpanel.c,v 1.6 2001/11/24 02:01:26 ukai Exp $ */
+/* $Id: w3mhelperpanel.c,v 1.7 2001/12/02 16:26:08 ukai Exp $ */
 #include <errno.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -46,7 +46,7 @@ extractMailcapEntry(char *mcap_entry, char **type, char **cmd)
 	j++;
     while (mcap_entry[j] && IS_SPACE(mcap_entry[j]))
 	j++;
-    *cmd = allocStr(&mcap_entry[j], 0);
+    *cmd = allocStr(&mcap_entry[j], -1);
 }
 
 static void
-- 
cgit v1.2.3