[LON-CAPA-cvs] cvs: loncom(version_1_2_X) /interface lonprintout.pm

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 19 Aug 2004 20:03:47 -0000


albertel		Thu Aug 19 16:03:47 2004 EDT

  Modified files:              (Branch: version_1_2_X)
    /loncom/interface	lonprintout.pm 
  Log:
  - backport 1.328
  
  
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.316 loncom/interface/lonprintout.pm:1.316.2.1
--- loncom/interface/lonprintout.pm:1.316	Thu Jul 15 12:00:16 2004
+++ loncom/interface/lonprintout.pm	Thu Aug 19 16:03:47 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.316 2004/07/15 16:00:16 sakharuk Exp $
+# $Id: lonprintout.pm,v 1.316.2.1 2004/08/19 20:03:47 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -629,24 +629,21 @@
 }
 
 sub path_to_problem {
-    my ($urlp,$LaTeXwidth)=@_;
+    my ($urlp,$colwidth)=@_;
     my $newurlp = '';
-    $LaTeXwidth=~s/\s*mm\s*$//;
-    my $HowMany = length($urlp)*2;
-    if ($HowMany > $LaTeXwidth) {
-	my @temporrary = split '/',$urlp;
-	my $HowManyNew = 0;
-	for (my $ii=0;$ii<=$#temporrary;$ii++) {
-	    if ($temporrary[$ii] ne '') {
-		$HowManyNew += length($temporrary[$ii])*2;
-		if ($HowManyNew < $LaTeXwidth ) {
-		    $newurlp .=  '/'.$temporrary[$ii];
-		} else {
-		    $HowManyNew = 0;
-		    $newurlp .=  '|\vskip -1 mm \noindent \verb|';
-		    $ii--;
-		}
+    $colwidth=~s/\s*mm\s*$//;
+#characters average about 2 mm in width
+    if (length($urlp)*2 > $LaTeXwidth) {
+	my @elements = split '/',$urlp;
+	my $curlength=0;
+	foreach my $element (@elements) {
+	    if ($curlength+(length($element)*2) > $colwidth) {
+		$newurlp .=  '|\vskip -1 mm \noindent \verb|';
+		$curlength=0;
+	    } else {
+		$curlength+=length($element)*2;
 	    }
+	    $newurlp.='/'.$element;
 	}
     } else {
 	$newurlp=$urlp;