<commit_before>// $Id$
// Copyright (c) 2008 <NAME> <<EMAIL>>
// Alle Rechte vorbehalten.

#include <fstream>

#include "helper.h"
#include "WPL1000File.h"

#ifdef _MSC_VER
#include <Winsock2.h>
#else
#include <netinet/in.h>
#endif


using namespace std;


namespace GPS {

    WPL1000File::WPL1000File(const char* filename) : GPSTrackFile(filename)
    { /* ... */ }


    WPL1000File::WPL1000File(const string& filename) : GPSTrackFile(filename)
    { /* ... */ }


    inline void swapBytes(char& a, char& b)
    {
        char t = b;
        b = a;
        a = t;
    }


    template <typename T>
    inline void readField(fstream& fs, T* data) 
    {
        char *d = reinterpret_cast<char*>(data);
        fs.read(d, sizeof(T));
        if (is_bigendian())
        {
  	    switch (sizeof(T))
            {
            case 32:
                swapBytes(d[0], d[3]);
                swapBytes(d[1], d[2]);
                break;
            case 16:
                swapBytes(d[0], d[1]);
                break;
            case 8:
                /* fall-through */
            default:
                break;
            }
        }<commit_msg>gpslib: Bugfix in WPL1000File<commit_after>// $Id$
// Copyright (c) 2008 <NAME> <<EMAIL>>
// Alle Rechte vorbehalten.

#include <fstream>

#include "helper.h"
#include "WPL1000File.h"

#ifdef _MSC_VER
#include <Winsock2.h>
#else
#include <netinet/in.h>
#endif


using namespace std;


namespace GPS {

    WPL1000File::WPL1000File(const char* filename) : GPSTrackFile(filename)
    { /* ... */ }


    WPL1000File::WPL1000File(const string& filename) : GPSTrackFile(filename)
    { /* ... */ }


    inline void swapBytes(char& a, char& b)
    {
        char t = b;
        b = a;
        a = t;
    }


    template <typename T>
    inline void readField(fstream& fs, T* data) 
    {
        char *d = reinterpret_cast<char*>(data);
        int sz = sizeof(T);
        fs.read(d, sz);
        if (is_bigendian())
        {
            switch (sz)
            {
            case 4:
                swapBytes(d[0], d[3]);
                swapBytes(d[1], d[2]);
                break;
            case 2:
                swapBytes(d[0], d[1]);
                break;
            case 1:
                /* fall-through */
            default:
                break;
            }
        }
{'fraction_non_alphanumeric': 0.139683895771038, 'fraction_numerical': 0.031610422896198205, 'mean_word_length': 1.5539803707742639, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1512745', 'n_tokens_mistral': 857, 'n_tokens_neox': 768, 'n_words': 176}