]> err.no Git - sope/blobdiff - sope-core/NGStreams/NGCharBuffer.m
Drop apache 1 build-dependency
[sope] / sope-core / NGStreams / NGCharBuffer.m
index 6db0023463b980e56d1e08cae39502ad3af5cd73..23f3ac5eaceb2bc0596cd51a6d8e249e62cf6335 100644 (file)
@@ -1,32 +1,27 @@
 /*
-  Copyright (C) 2000-2003 SKYRIX Software AG
+  Copyright (C) 2000-2005 SKYRIX Software AG
 
-  This file is part of OGo
+  This file is part of SOPE.
 
-  OGo is free software; you can redistribute it and/or modify it under
+  SOPE is free software; you can redistribute it and/or modify it under
   the terms of the GNU Lesser General Public License as published by the
   Free Software Foundation; either version 2, or (at your option) any
   later version.
 
-  OGo is distributed in the hope that it will be useful, but WITHOUT ANY
+  SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
   WARRANTY; without even the implied warranty of MERCHANTABILITY or
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
   License for more details.
 
   You should have received a copy of the GNU Lesser General Public
-  License along with OGo; see the file COPYING.  If not, write to the
+  License along with SOPE; see the file COPYING.  If not, write to the
   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
   02111-1307, USA.
 */
-// $Id$
 
 #include "NGCharBuffer.h"
 #include "common.h"
 
-#if LIB_FOUNDATION_LIBRARY
-#  include <extensions/exceptions/GeneralExceptions.h>
-#endif
-
 typedef struct NGCharBufferLA {
   unichar character;
   char    isEOF:1;
@@ -44,15 +39,8 @@ typedef struct NGCharBufferLA {
     int size = 0;
 
     if (_la < 1) {
-#if LIB_FOUNDATION_LIBRARY
-      [[[RangeException alloc]
-                        initWithReason:@"LA is less than one"
-                        size:1 index:_la]
-                        raise];
-#else
       [NSException raise:NSRangeException
                    format:@"lookahead depth is less than one (%d)", _la];
-#endif
     }
 
     // Find first power of 2 >= to requested size
@@ -72,7 +60,7 @@ typedef struct NGCharBufferLA {
     self->wasEOF      = NO;
 
     if ([self->source respondsToSelector:@selector(methodForSelector:)]) {
-      self->readCharacter =
+      self->readCharacter = (unichar (*)(id, SEL))
         [(NSObject *)self->source methodForSelector:@selector(readCharacter)];
     }
   }
@@ -107,7 +95,7 @@ typedef struct NGCharBufferLA {
   return character;
 }
 
-// LA
+/* LA */
 
 - (int)la:(int)_la {
   int result = -1;
@@ -116,17 +104,9 @@ typedef struct NGCharBufferLA {
   idx = *(&idx);
   
   if (_la > self->sizeLessOne) {
-#if LIB_FOUNDATION_LIBRARY
-    [[[RangeException alloc]
-                      initWithReason:@"LA out of bounds"
-                      size:self->bufLen
-                      index:_la]
-                      raise];
-#else
     [NSException raise:NSRangeException
                  format:@"tried to look ahead too far (la=%d, max=%d)", 
                   _la, self->bufLen];
-#endif
   }
   
   if (self->wasEOF) {
@@ -150,9 +130,10 @@ typedef struct NGCharBufferLA {
 
           if (self->readCharacter == NULL) 
             character = [self->source readCharacter];
-          else
-            character = (int)self->readCharacter(self->source,
-                                                 @selector(readCharacter));
+          else {
+            character = self->readCharacter(self->source,
+                                           @selector(readCharacter));
+         }
           ix = (self->headIdx + i) & self->sizeLessOne;      
           self->la[ix].character = character;
           self->la[ix].isFetched = 1;
@@ -201,15 +182,12 @@ typedef struct NGCharBufferLA {
   }
 }
 
-// description
+/* description */
 
 - (NSString *)description {
-  return [NSString stringWithFormat:@"<%@[0x%08X] source=%@ la=%d",
-                     NSStringFromClass([self class]),
-                     (unsigned)self,
-                     self->source,
-                     self->bufLen
-                   ];
+  return [NSString stringWithFormat:@"<%@[0x%p] source=%@ la=%d",
+                    NSStringFromClass([self class]), self,
+                     self->source, self->bufLen];
 }
 
-@end
+@end /* NGCharBuffer */