Changeset 12803


Ignore:
Timestamp:
07/12/10 09:55:11 (13 years ago)
Author:
Mark Evenson
Message:

Revert bad commit.

Location:
trunk/abcl/src/org/armedbear/lisp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/Pathname.java

    r12802 r12803  
    6262    protected LispObject version = NIL;
    6363
    64     private String namestring;
     64    private volatile String namestring;
    6565
    6666    /** The protocol for changing any instance field (i.e. 'host', 'type', etc.)
     
    243243        }
    244244        if (Utilities.isPlatformWindows) {
    245             if (s.startsWith("\\\\")) {
     245            if (s.startsWith("\\\\")) { // XXX What if string starts with '//'?
    246246                //UNC path support
    247247                // match \\<server>\<share>\[directories-and-files]
     
    402402
    403403        if (Utilities.isPlatformWindows) {
    404             if (!s.contains(jarSeparator)) {
    405                 s = s.replace("/", "\\");
    406             } else {
    407               StringBuilder result = new StringBuilder();
    408               for (int i = 0; i < s.length(); i++) {
    409                   char c = s.charAt(i);
    410                   if ( c != '/') {
    411                       result.append(c);
    412                   } else {
    413                       if (i != 0 && s.charAt(i-1) != '!') {
    414                           result.append("\\");
    415                       } else {
    416                           result.append(c);
    417                       }
    418                   }
    419               }
    420               s = result.toString();
    421             }
     404            if (s.contains("\\")) {
     405                s = s.replace("\\", "/");
     406            }
    422407        }
    423408
     
    439424        String d = null;
    440425        // Find last file separator char.
    441         if (Utilities.isPlatformWindows) {
    442             for (int i = s.length(); i-- > 0;) {
    443                 char c = s.charAt(i);
    444                 if (c == '/' || c == '\\') {
    445                     d = s.substring(0, i + 1);
    446                     s = s.substring(i + 1);
    447                     break;
    448                 }
    449             }
    450         } else {
    451             for (int i = s.length(); i-- > 0;) {
    452                 if (s.charAt(i) == '/') {
    453                     d = s.substring(0, i + 1);
    454                     s = s.substring(i + 1);
    455                     break;
    456                 }
     426        for (int i = s.length(); i-- > 0;) {
     427            if (s.charAt(i) == '/') {
     428                d = s.substring(0, i + 1);
     429                s = s.substring(i + 1);
     430                break;
    457431            }
    458432        }
     
    618592                    sb.append(authority.getStringValue());
    619593                }
    620             } else {
    621                 if (!(this instanceof LogicalPathname)) {
    622                     sb.append("\\\\"); //UNC file support; if there's a host, it's a UNC path.
    623                 }
     594            } else if (this instanceof LogicalPathname) {
    624595                sb.append(host.getStringValue());
    625                 if (this instanceof LogicalPathname) {
    626                     sb.append(':');
    627                 } else {
    628                     sb.append(File.separatorChar);
    629                 }
     596                sb.append(':');
     597            } else {
     598                // UNC paths now use unprintable representation
     599                return null;
    630600            }
    631601        }
     
    665635        if (name instanceof AbstractString) {
    666636            String n = name.getStringValue();
    667             if (n.indexOf(File.separatorChar) >= 0) {
     637            if (n.indexOf('/') >= 0) {
    668638                Debug.assertTrue(namestring == null);
    669639                return null;
     
    736706        // the namestring." 19.2.2.2.3.1
    737707        if (directory != NIL) {
    738             final char separatorChar;
    739             if (isJar() || isURL()) {
    740                 separatorChar = '/';
    741             } else {
    742                 separatorChar = File.separatorChar;
    743             }
     708            final char separatorChar = '/';
    744709            LispObject temp = directory;
    745710            LispObject part = temp.car();
     
    789754        String path = p.getNamestring();
    790755        StringBuilder result = new StringBuilder();
    791         if (Utilities.isPlatformWindows) {
    792       for (int i = 0; i < path.length(); i++) {
    793     char c = path.charAt(i);
    794     if (c == '\\') {
    795         result.append('/');
    796     } else {
    797         result.append(c);
    798     }
    799       }
    800         } else  {
    801             result.append(path);
    802         }
     756        result.append(path);
     757
    803758        // Entries in jar files are always relative, but Pathname
    804759        // directories are :ABSOLUTE.
     
    879834    public String writeToString() {
    880835        final LispThread thread = LispThread.currentThread();
    881         boolean printReadably = (Symbol.PRINT_READABLY.symbolValue(thread) != NIL);
    882         boolean printEscape = (Symbol.PRINT_ESCAPE.symbolValue(thread) != NIL);
     836        final boolean printReadably = (Symbol.PRINT_READABLY.symbolValue(thread) != NIL);
     837        final boolean printEscape = (Symbol.PRINT_ESCAPE.symbolValue(thread) != NIL);
    883838        boolean useNamestring;
    884839        String s = null;
     
    902857                }
    903858            }
    904         } else {
     859        } else { 
    905860            useNamestring = false;
    906861        }
     
    924879            }
    925880        } else {
    926             sb.append("#P(");
    927             if (host != NIL) {
    928                 sb.append(":HOST ");
    929                 sb.append(host.writeToString());
    930                 sb.append(' ');
    931             }
    932             if (device != NIL) {
    933                 sb.append(":DEVICE ");
    934                 sb.append(device.writeToString());
    935                 sb.append(' ');
    936             }
    937             if (directory != NIL) {
    938                 sb.append(":DIRECTORY ");
    939                 sb.append(directory.writeToString());
    940                 sb.append(" ");
    941             }
    942             if (name != NIL) {
    943                 sb.append(":NAME ");
    944                 sb.append(name.writeToString());
    945                 sb.append(' ');
    946             }
    947             if (type != NIL) {
    948                 sb.append(":TYPE ");
    949                 sb.append(type.writeToString());
    950                 sb.append(' ');
    951             }
    952             if (version != NIL) {
    953                 sb.append(":VERSION ");
    954                 sb.append(version.writeToString());
    955                 sb.append(' ');
    956             }
    957             if (sb.charAt(sb.length() - 1) == ' ') {
    958                 sb.setLength(sb.length() - 1);
    959             }
    960             sb.append(')');
     881            final SpecialBindingsMark mark = thread.markSpecialBindings();
     882            thread.bindSpecial(Symbol.PRINT_ESCAPE, T);
     883            try {
     884                final boolean ANSI_COMPATIBLE = true;
     885                final String SPACE = " ";
     886                if (ANSI_COMPATIBLE) {
     887                    sb.append("#P(\"");
     888                } else {
     889                    sb.append("#P(");
     890
     891                }
     892                if (host != NIL) {
     893                    sb.append(":HOST ");
     894                    sb.append(host.writeToString());
     895                    sb.append(SPACE);
     896                }
     897                if (device != NIL) {
     898                    sb.append(":DEVICE ");
     899                    sb.append(device.writeToString());
     900                    sb.append(SPACE);
     901                }
     902                if (directory != NIL) {
     903                    sb.append(":DIRECTORY ");
     904                    sb.append(directory.writeToString());
     905                    sb.append(SPACE);
     906                }
     907                if (name != NIL) {
     908                    sb.append(":NAME ");
     909                    sb.append(name.writeToString());
     910                    sb.append(SPACE);
     911                }
     912                if (type != NIL) {
     913                    sb.append(":TYPE ");
     914                    sb.append(type.writeToString());
     915                    sb.append(SPACE);
     916                }
     917                if (version != NIL) {
     918                    sb.append(":VERSION ");
     919                    sb.append(version.writeToString());
     920                    sb.append(SPACE);
     921                }
     922                if (sb.charAt(sb.length() - 1) == ' ') { // XXX
     923                    sb.setLength(sb.length() - 1);
     924                }
     925                if (ANSI_COMPATIBLE) {
     926                    sb.append(')' + "\"");
     927                } else {
     928                    sb.append(')');
     929                }
     930            } finally {
     931                thread.resetSpecialBindings(mark);
     932            }
    961933        }
    962934        return sb.toString();
     
    12341206        } catch (IOException e) {
    12351207            Debug.trace("Failed to make a Pathname from "
    1236               + "'" + file + "'");
     1208              + "." + file + "'");
    12371209            return null;
    12381210        }
     
    13031275        final Pathname p;
    13041276        final boolean logical;
     1277        LispObject logicalHost = NIL;
    13051278        if (host != NIL) {
    13061279            if (host instanceof AbstractString) {
    1307                 host = LogicalPathname.canonicalizeStringComponent((AbstractString) host);
    1308             }
    1309             if (LOGICAL_PATHNAME_TRANSLATIONS.get(host) == null) {
    1310                 // Not a defined logical pathname host.
    1311                 error(new LispError(host.writeToString() + " is not defined as a logical pathname host."));
    1312             }
    1313             p = new LogicalPathname();
    1314             logical = true;
    1315             p.host = host;
     1280                logicalHost = LogicalPathname.canonicalizeStringComponent((AbstractString) host);
     1281            }
     1282            if (LOGICAL_PATHNAME_TRANSLATIONS.get(logicalHost) == null) {
     1283                // Not a defined logical pathname host -- A UNC path
     1284                //warning(new LispError(host.writeToString() + " is not defined as a logical pathname host."));
     1285                p = new Pathname();
     1286                logical = false;
     1287                p.host = host;
     1288            } else {
     1289                p = new LogicalPathname();
     1290                logical = true;
     1291                p.host = logicalHost;
     1292            }
    13161293            p.device = Keyword.UNSPECIFIC;
    13171294        } else {
     
    13761353        for (int i = 0; i < limit; i++) {
    13771354            char c = s.charAt(i);
     1355            // XXX '\\' should be illegal in all Pathnames at this point?
    13781356            if (c == '/' || c == '\\' && Utilities.isPlatformWindows) {
    13791357                error(new LispError("Invalid character #\\" + c
  • trunk/abcl/src/org/armedbear/lisp/ShellCommand.java

    r12802 r12803  
    236236    // run-shell-command command &key directory (output *standard-output*)
    237237    // ### %run-shell-command command directory output => exit-code
    238     private static final Primitive _RUN_SHELL_COMMAND =
    239         new Primitive("%run-shell-command", PACKAGE_SYS, false)
    240     {
     238    private static final Primitive _RUN_SHELL_COMMAND = new pf_run_shell_command();
     239    private static class pf_run_shell_command extends Primitive {
     240        pf_run_shell_command() {
     241            super("%run-shell-command", PACKAGE_SYS, false,
     242                  "command directory output => exit-code");
     243        }
     244       
    241245        @Override
    242246        public LispObject execute(LispObject first, LispObject second,
Note: See TracChangeset for help on using the changeset viewer.