~ubuntu-branches/ubuntu/trusty/eclipse-linuxtools/trusty

« back to all changes in this revision

Viewing changes to gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/utils/GcovStringReader.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2012-06-29 12:07:30 UTC
  • Revision ID: package-import@ubuntu.com-20120629120730-bfri1xys1i71dpn6
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*******************************************************************************
 
2
 * Copyright (c) 2009 STMicroelectronics.
 
3
 * All rights reserved. This program and the accompanying materials
 
4
 * are made available under the terms of the Eclipse Public License v1.0
 
5
 * which accompanies this distribution, and is available at
 
6
 * http://www.eclipse.org/legal/epl-v10.html
 
7
 *
 
8
 * Contributors:
 
9
 *    Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
 
10
 *******************************************************************************/
 
11
package org.eclipse.linuxtools.internal.gcov.utils;
 
12
 
 
13
import java.io.DataInput;
 
14
import java.io.IOException;
 
15
 
 
16
public class GcovStringReader {
 
17
 
 
18
 
 
19
        public static String readString(DataInput stream) throws IOException {
 
20
                String res = "NULL string";
 
21
                long length = stream.readInt()&MasksGenerator.UNSIGNED_INT_MASK;                
 
22
                if (length != 0) {
 
23
                        int ln = ((int) length) << 2;
 
24
                        byte[] name = new byte[ln];
 
25
                        stream.readFully(name);
 
26
                        StringBuffer sb = new StringBuffer();
 
27
                        for(int j=0; j < ln; j++){
 
28
                                if(name[j]!=0){
 
29
                                        char c = (char) name[j];
 
30
                                        sb.append(c);
 
31
                                }
 
32
                        }
 
33
                        res = sb.toString();
 
34
                }
 
35
                return res;
 
36
        }
 
37
 
 
38
}