9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] [p9p] problem with mk: variable being truncated
@ 2011-07-25 15:00 dexen deVries
  2011-07-25 15:12 ` Russ Cox
  0 siblings, 1 reply; 3+ messages in thread
From: dexen deVries @ 2011-07-25 15:00 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

hi,

this regards plan 9 port.

with a very simple mkfile, $prereq and $newprereq get truncated at slightly 
below 16*1024 characters.

essence of the mkfile:

allfiles=`{find -name '*.c'}
foo:VQ: $allfiles
	echo $newprereq
#	(alternatively: echo $prereq)



it seems to me formatted output library (fmt) is to blame, perhaps around the 
twisted code of counting formatted characters. poking in mk internals, down in 
dorecipe() i've stumbled upon a debug print():

print("lt=%s ln=%s lp=%s\n",wtos(head.next, ' '),wtos(ln.next, ' 
'),wtos(lp.next, ' '));

which (when un-commented) also prints truncated dump of the variable.

one clue i got so far is that adding a small print() after it fixes the output 
*from the debug print*:
print("\n");

any help or hints please?


regards,
-- 
dexen deVries

[[[↓][→]]]

For example, if the first thing in the file is:
   <?kzy irefvba="1.0" rapbqvat="ebg13"?>
an XML parser will recognize that the document is stored in the traditional 
ROT13 encoding.

(( Joe English, http://www.flightlab.com/~joe/sgml/faq-not.txt ))



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9fans] [p9p] problem with mk: variable being truncated
  2011-07-25 15:00 [9fans] [p9p] problem with mk: variable being truncated dexen deVries
@ 2011-07-25 15:12 ` Russ Cox
  2011-07-25 15:58   ` dexen deVries
  0 siblings, 1 reply; 3+ messages in thread
From: Russ Cox @ 2011-07-25 15:12 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

cd $PLAN9/src/cmd/mk
g 16384


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9fans] [p9p] problem with mk: variable being truncated
  2011-07-25 15:12 ` Russ Cox
@ 2011-07-25 15:58   ` dexen deVries
  0 siblings, 0 replies; 3+ messages in thread
From: dexen deVries @ 2011-07-25 15:58 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: Text/Plain, Size: 543 bytes --]

On Monday 25 of July 2011 17:12:03 Russ Cox wrote:
> cd $PLAN9/src/cmd/mk
> g 16384

thank you a lot, Russ.

will you accept the attached patch for p9p?

nb., i'm still curious why the output from debug print() was truncated as 
well.

-- 
dexen deVries

[[[↓][→]]]

For example, if the first thing in the file is:
   <?kzy irefvba="1.0" rapbqvat="ebg13"?>
an XML parser will recognize that the document is stored in the traditional 
ROT13 encoding.

(( Joe English, http://www.flightlab.com/~joe/sgml/faq-not.txt ))

[-- Attachment #2: 0001-mk-do-not-truncate-environmental-variable.patch --]
[-- Type: text/x-patch, Size: 922 bytes --]

mk: do not truncate environmental variable

use smprint() to support arbitrary long environmental variables

Signed-off-by: dexen deVries <dexen.devries@gmail.com>
---
 src/cmd/mk/unix.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/cmd/mk/unix.c b/src/cmd/mk/unix.c
index c63d3ce..6a1312a 100644
--- a/src/cmd/mk/unix.c
+++ b/src/cmd/mk/unix.c
@@ -55,16 +55,14 @@ exportenv(Envy *e, Shell *sh)
 {
 	int i;
 	char **p;
-	static char buf[16384];

 	p = 0;
 	for(i = 0; e->name; e++, i++) {
 		p = (char**) Realloc(p, (i+2)*sizeof(char*));
 		if(e->values)
-			snprint(buf, sizeof buf, "%s=%s", e->name,  wtos(e->values, sh->iws));
+			p[i] = smprint("%s=%s", e->name,  wtos(e->values, sh->iws));
 		else
-			snprint(buf, sizeof buf, "%s=", e->name);
-		p[i] = strdup(buf);
+			p[i] = smprint("%s=", e->name);
 	}
 	p[i] = 0;
 	environ = p;
--
1.7.4.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-07-25 15:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-25 15:00 [9fans] [p9p] problem with mk: variable being truncated dexen deVries
2011-07-25 15:12 ` Russ Cox
2011-07-25 15:58   ` dexen deVries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).