Changeset 9982


Ignore:
Timestamp:
09/18/05 17:51:23 (16 years ago)
Author:
piso
Message:

canonicalizeStringComponent()

File:
1 edited

Legend:

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

    r9980 r9982  
    33 *
    44 * Copyright (C) 2004-2005 Peter Graves
    5  * $Id: LogicalPathname.java,v 1.15 2005-09-17 19:47:21 piso Exp $
     5 * $Id: LogicalPathname.java,v 1.16 2005-09-18 17:51:23 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    103103                name = new SimpleString(n.toUpperCase());
    104104        }
     105    }
     106
     107    private static final String LOGICAL_PATHNAME_COMPONENT_CHARS =
     108        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-";
     109
     110    public static final SimpleString canonicalizeStringComponent(AbstractString s)
     111        throws ConditionThrowable
     112    {
     113        final int limit = s.length();
     114        for (int i = 0; i < limit; i++) {
     115            char c = s.charAt(i);
     116            if (LOGICAL_PATHNAME_COMPONENT_CHARS.indexOf(c) < 0) {
     117                signal(new ParseError("Invalid character #\\" + c +
     118                                      " in logical pathname component \"" + s +
     119                                      '"'));
     120                // Not reached.
     121                return null;
     122            }
     123        }
     124        return new SimpleString(s.getStringValue().toUpperCase());
    105125    }
    106126
Note: See TracChangeset for help on using the changeset viewer.