1 // $Id: tab.cpp,v 1.9 2002/08/02 21:29:48 ericb Exp $
2 //
3 // This software is subject to the terms of the IBM Jikes Compiler
4 // License Agreement available at the following URL:
5 // http://ibm.com/developerworks/opensource/jikes.
6 // Copyright (C) 1996, 1999, 2000, 2001 International Business
7 // Machines Corporation and others.  All Rights Reserved.
8 // You must accept the terms of that agreement to use this software.
9 //
10 
11 #include "tab.h"
12 
13 #ifdef HAVE_JIKES_NAMESPACE
14 namespace Jikes { // Open namespace Jikes block
15 #endif
16 
17 int Tab::tab_size = Tab::DEFAULT_TAB_SIZE;
18 
19 //
20 // Compute the length of a wide character string segment after expanding tabs,
21 // and any non-printable ASCII characters in unicode expansion mode.
22 //
Wcslen(wchar_t * line,int start,int end)23 int Tab::Wcslen(wchar_t *line, int start, int end)
24 {
25     bool expand = Coutput.ExpandWchar();
26     for (int i = start--; i <= end; i++)
27     {
28         if (line[i] == U_HORIZONTAL_TAB)
29         {
30             int offset = (i - start) - 1;
31             start -= ((tab_size - 1) - offset % tab_size);
32         }
33         else if (expand && (line[i] < U_SPACE || line[i] > 0xFF))
34         {
35             start -= 5;
36             assert(line[i] != U_CARRIAGE_RETURN && line[i] != U_LINE_FEED);
37         }
38     }
39 
40     return (end - start);
41 }
42 
43 #ifdef HAVE_JIKES_NAMESPACE
44 } // Close namespace Jikes block
45 #endif
46 
47