From: <zy...@us...> - 2008-10-06 19:00:39
|
Revision: 5361 http://jython.svn.sourceforge.net/jython/?rev=5361&view=rev Author: zyasoft Date: 2008-10-06 18:57:58 +0000 (Mon, 06 Oct 2008) Log Message: ----------- Fixed test_quopri by encoding space or tab before newline and resetting the column count upon a newline Fixed #1144 so that -mMODULE works and remaining args are passed in sys.argv Modified Paths: -------------- trunk/jython/src/org/python/modules/binascii.java trunk/jython/src/org/python/util/jython.java Modified: trunk/jython/src/org/python/modules/binascii.java =================================================================== --- trunk/jython/src/org/python/modules/binascii.java 2008-10-06 03:12:34 UTC (rev 5360) +++ trunk/jython/src/org/python/modules/binascii.java 2008-10-06 18:57:58 UTC (rev 5361) @@ -984,12 +984,25 @@ int count = 0; for (int i=0, m=s.length(); i<m; i++) { char c = s.charAt(i); - if (('!' <= c && c <= '<') + + // RFC 1521 requires that the line ending in a space or tab must have + // that trailing character encoded. + if (lineEnding(s, lineEnd, i)) { + count = 0; + sb.append(lineEnd); + if (lineEnd.length() > 1) i++; + } + else if ((c == '\t' || c == ' ' ) && endOfLine(s, lineEnd, i + 1)) { + count += 3; + qpEscape(sb, c); + } + else if (('!' <= c && c <= '<') || ('>' <= c && c <= '^') || ('`' <= c && c <= '~') || (c == '_' && !header) || (c == '\n' || c == '\r' && istext)) { - if (count == 75) { +// if (count == 75 && i < s.length() - 1) { + if (count == 75 && !endOfLine(s, lineEnd, i + 1)) { sb.append("=").append(lineEnd); count = 0; } @@ -1023,7 +1036,16 @@ } return sb.toString(); } - + + private static boolean endOfLine(String s, String lineEnd, int i) { + return (s.length() == i || lineEnding(s, lineEnd, i)); + } + + private static boolean lineEnding(String s, String lineEnd, int i) { + return + (s.length() > i && s.substring(i).startsWith(lineEnd)); + } + /* public static void main(String[] args) { String l = b2a_uu("Hello"); Modified: trunk/jython/src/org/python/util/jython.java =================================================================== --- trunk/jython/src/org/python/util/jython.java 2008-10-06 03:12:34 UTC (rev 5360) +++ trunk/jython/src/org/python/util/jython.java 2008-10-06 18:57:58 UTC (rev 5361) @@ -7,6 +7,7 @@ import java.io.InputStream; import java.nio.charset.Charset; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -439,7 +440,10 @@ } else if (arg.startsWith("-m")) { runModule = true; - if ((index + 1) < args.length) { + if (arg.length() > 2) { + moduleName = arg.substring(2); + } + else if ((index + 1) < args.length) { moduleName = args[++index]; } else { System.err.println("Argument expected for the -m option"); @@ -450,6 +454,15 @@ if (!fixInteractive) { interactive = false; } + + index++; + int n = args.length-index+1; + argv = new String[n]; + argv[0] = moduleName; + for (int i = 1; index < args.length; i++, index++) { + argv[i] = args[index]; + } + return true; } else { String opt = args[index]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |