Changeset 10140


Ignore:
Timestamp:
10/17/05 18:52:55 (16 years ago)
Author:
piso
Message:

SYS:COERCE-TO-PATHNAME => SYS::%PARSE-NAMESTRING

File:
1 edited

Legend:

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

    r10135 r10140  
    33 *
    44 * Copyright (C) 2003-2005 Peter Graves
    5  * $Id: Pathname.java,v 1.105 2005-10-17 16:45:19 piso Exp $
     5 * $Id: Pathname.java,v 1.106 2005-10-17 18:52:55 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    707707    };
    708708
    709     // ### coerce-to-pathname thing &optional host => pathname
    710     private static final Primitive COERCE_TO_PATHNAME =
    711         new Primitive("coerce-to-pathname", PACKAGE_SYS, true,
    712                       "thing &optional host")
    713     {
    714         public LispObject execute(LispObject arg) throws ConditionThrowable
    715         {
    716             return coerceToPathname(arg);
    717         }
    718         public LispObject execute(LispObject first, LispObject second)
     709    // ### %parse-namestring string host default-pathname => pathname, position
     710    private static final Primitive _PARSE_NAMESTRING =
     711        new Primitive("%parse-namestring", PACKAGE_SYS, false,
     712                      "namestring host default-pathname")
     713    {
     714        public LispObject execute(LispObject first, LispObject second,
     715                                  LispObject third)
    719716            throws ConditionThrowable
    720717        {
    721             if (second == NIL)
    722                 return coerceToPathname(first);
    723             // FIXME Support other types for first argument (and verify that
    724             // hosts match).
    725             if (first instanceof AbstractString) {
    726                 AbstractString namestring = (AbstractString) first;
    727                 final AbstractString host;
    728                 try {
    729                     host = (AbstractString) second;
    730                 }
    731                 catch (ClassCastException e) {
    732                     return signalTypeError(second, Symbol.STRING);
    733                 }
    734                 return parseNamestring(namestring, host);
    735             }
    736             return signal(new LispError("COERCE-TO-PATHNAME: unsupported case."));
     718            final LispThread thread = LispThread.currentThread();
     719            final AbstractString namestring;
     720            try {
     721                namestring = (AbstractString) first;
     722            }
     723            catch (ClassCastException e) {
     724                return signalTypeError(first, Symbol.STRING);
     725            }
     726            // The HOST parameter must be a string or NIL.
     727            if (second == NIL) {
     728                // "If HOST is NIL, DEFAULT-PATHNAME is a logical pathname, and
     729                // THING is a syntactically valid logical pathname namestring
     730                // without an explicit host, then it is parsed as a logical
     731                // pathname namestring on the host that is the host component
     732                // of DEFAULT-PATHNAME."
     733                third = coerceToPathname(third);
     734                if (third instanceof LogicalPathname)
     735                    second = ((LogicalPathname)third).host;
     736                else
     737                    return thread.setValues(parseNamestring(namestring),
     738                                            namestring.LENGTH());
     739            }
     740            Debug.assertTrue(second != NIL);
     741            final AbstractString host;
     742            try {
     743                host = (AbstractString) second;
     744            }
     745            catch (ClassCastException e) {
     746                return signalTypeError(second, Symbol.STRING);
     747            }
     748            return thread.setValues(parseNamestring(namestring, host),
     749                                    namestring.LENGTH());
    737750        }
    738751    };
Note: See TracChangeset for help on using the changeset viewer.