Changeset 9980


Ignore:
Timestamp:
09/17/05 19:47:21 (16 years ago)
Author:
piso
Message:

Signal a PARSE-ERROR if an invalid character is encountered in the logical pathname namestring.

File:
1 edited

Legend:

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

    r9970 r9980  
    33 *
    44 * Copyright (C) 2004-2005 Peter Graves
    5  * $Id: LogicalPathname.java,v 1.14 2005-09-14 13:39:01 piso Exp $
     5 * $Id: LogicalPathname.java,v 1.15 2005-09-17 19:47:21 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    2727public final class LogicalPathname extends Pathname
    2828{
     29    private static final String LOGICAL_PATHNAME_CHARS =
     30        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-;*.";
     31
    2932    private static final HashMap map = new HashMap();
    3033
     
    3538    public LogicalPathname(String host, String rest) throws ConditionThrowable
    3639    {
     40        final int limit = rest.length();
     41        for (int i = 0; i < limit; i++) {
     42            char c = rest.charAt(i);
     43            if (LOGICAL_PATHNAME_CHARS.indexOf(c) < 0) {
     44                signal(new ParseError("The character #\\" + c + " is not valid in a logical pathname."));
     45                return;
     46            }
     47        }
     48
    3749        this.host = new SimpleString(host);
    3850
     
    93105    }
    94106
    95     private static final LispObject parseDirectory(String d)
     107    private static final LispObject parseDirectory(String s)
    96108        throws ConditionThrowable
    97109    {
    98110        LispObject result;
    99         if (d.charAt(0) == ';') {
     111        if (s.charAt(0) == ';') {
    100112            result = new Cons(Keyword.RELATIVE);
    101             d = d.substring(1);
     113            s = s.substring(1);
    102114        } else
    103115            result = new Cons(Keyword.ABSOLUTE);
    104         StringTokenizer st = new StringTokenizer(d, ";");
     116        StringTokenizer st = new StringTokenizer(s, ";");
    105117        while (st.hasMoreTokens()) {
    106118            String token = st.nextToken();
Note: See TracChangeset for help on using the changeset viewer.