This file is indexed.

/usr/include/OpenMS/CONCEPT/FuzzyStringComparator.h is in libopenms-dev 1.11.1-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
// --------------------------------------------------------------------------
//                   OpenMS -- Open-Source Mass Spectrometry
// --------------------------------------------------------------------------
// Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
// ETH Zurich, and Freie Universitaet Berlin 2002-2013.
//
// This software is released under a three-clause BSD license:
//  * Redistributions of source code must retain the above copyright
//    notice, this list of conditions and the following disclaimer.
//  * Redistributions in binary form must reproduce the above copyright
//    notice, this list of conditions and the following disclaimer in the
//    documentation and/or other materials provided with the distribution.
//  * Neither the name of any author or any participating institution
//    may be used to endorse or promote products derived from this software
//    without specific prior written permission.
// For a full list of authors, refer to the file AUTHORS.
// --------------------------------------------------------------------------
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
// INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// --------------------------------------------------------------------------
// $Maintainer: Stephan Aiche $
// $Authors: Clemens Groepl, Stephan Aiche $
// --------------------------------------------------------------------------

#ifndef OPENMS_CONCEPT_FUZZYSTRINGCOMPARATOR_H
#define OPENMS_CONCEPT_FUZZYSTRINGCOMPARATOR_H

#include <OpenMS/CONCEPT/Types.h>
#include <OpenMS/DATASTRUCTURES/String.h>
#include <OpenMS/DATASTRUCTURES/StringList.h>

#include <cstdlib> // for strtod()
#include <fstream>
#include <iostream>
#include <cctype> // for isspace()
#include <limits> // for NaN
#include <sstream>
#include <map>

namespace OpenMS
{
  namespace Internal
  {
    namespace ClassTest
    {
      void OPENMS_DLLAPI
      testStringSimilar(const char * file, int line,
                        const std::string & string_1,
                        const char * string_1_stringified,
                        const std::string & string_2,
                        const char * string_2_stringified);
      bool OPENMS_DLLAPI
      isFileSimilar(const std::string &, const std::string &);
    }
  }

  /**
   @brief Fuzzy comparison of strings, tolerates numeric differences.

   */
  class OPENMS_DLLAPI FuzzyStringComparator
  {

    friend void OPENMS_DLLAPI
    Internal::ClassTest::testStringSimilar(
      const char * file,
      int line,
      const std::string & string_1,
      const char * string_1_stringified,
      const std::string & string_2,
      const char * string_2_stringified);
    friend bool OPENMS_DLLAPI
    Internal::ClassTest::isFileSimilar(const std::string &,
                                       const std::string &);

    /// %Internal exception class.
    struct AbortComparison
    {
    };

public:

    ///@name the fabulous four
    //@{

    /// Constructor
    FuzzyStringComparator();

    /// Destructor
    virtual
    ~FuzzyStringComparator();

    /// Copy constructor intentionally not implemented
    FuzzyStringComparator(const FuzzyStringComparator & rhs);

    /// Assignment operator intentionally not implemented
    FuzzyStringComparator &
    operator=(const FuzzyStringComparator & rhs);

    //@}

    /// Acceptable relative error (a number >= 1.0)
    const double &
    getAcceptableRelative() const
    {
      return ratio_max_allowed_;
    }

    /// Acceptable relative error (a number >= 1.0)
    void
    setAcceptableRelative(const double rhs)
    {
      this->ratio_max_allowed_ = rhs;
      if (ratio_max_allowed_ < 1.0)
        ratio_max_allowed_ = 1
                             / ratio_max_allowed_;

    }

    /// Acceptable absolute difference (a number >= 0.0)
    const double &
    getAcceptableAbsolute() const
    {
      return absdiff_max_allowed_;
    }

    /// Acceptable absolute difference (a number >= 0.0)
    void
    setAcceptableAbsolute(const double rhs)
    {
      this->absdiff_max_allowed_ = rhs;
      if (absdiff_max_allowed_ < 0.0)
        absdiff_max_allowed_
          = -absdiff_max_allowed_;
    }

    /// White list.  If both lines contain the same element from this list, they are skipped over.
    const StringList &
    getWhitelist() const
    {
      return whitelist_;
    }

    /// White list.  If both lines contain the same element from this list, they are skipped over.
    StringList &
    getWhitelist()
    {
      return whitelist_;
    }

    /// White list.  If both lines contain the same element from this list, they are skipped over.
    void
    setWhitelist(const StringList & rhs)
    {
      whitelist_ = rhs;
    }

    /**@brief verbose level

     - 0 = very quiet mode (absolutely no output)
     - 1 = quiet mode (no output unless differences detected)
     - 2 = default (include summary at end)
     - 3 = continue after errors
     .
     */
    const int &
    getVerboseLevel() const
    {
      return verbose_level_;
    }

    /**@brief verbose level

     - 0 = very quiet mode (absolutely no output)
     - 1 = quiet mode (no output unless differences detected)
     - 2 = default (include summary at end)
     - 3 = continue after errors
     .
     */
    void
    setVerboseLevel(const int rhs)
    {
      this->verbose_level_ = rhs;
    }

    /**@brief get tab width (for column numbers)
     */
    const int &
    getTabWidth() const
    {
      return tab_width_;
    }

    /**@brief set tab width (for column numbers)
     */
    void
    setTabWidth(const int rhs)
    {
      this->tab_width_ = rhs;
    }

    /**@brief get first column (for column numbers)
     */
    const int &
    getFirstColumn() const
    {
      return first_column_;
    }

    /**@brief set first column (for column numbers)
     */
    void
    setFirstColumn(const int rhs)
    {
      this->first_column_ = rhs;
    }

    /**@brief Log output is written to this destination.

     The default is std::cout.  Use std::ostringstream etc. to save the output
     in a string.
     */
    std::ostream &
    getLogDestination() const
    {
      return *log_dest_;
    }

    /**@brief Log output is written to this destination.

     The default is std::cout.  Use std::ostringstream etc. to save the output
     in a string.

     @internal There seems to be an issue with this under Windows, see comment
     in FuzzyStringComparator_test.C

     */
    void
    setLogDestination(std::ostream & rhs)
    {
      this->log_dest_ = &rhs;
    }

    /**@brief Compare two strings.

     This compares all lines of the input.

     returns true in case of no differences found
     */
    bool
    compareStrings(std::string const & lhs, std::string const & rhs);

    /**@brief Compare two streams of input.

     This compares all lines of the input.  Intended to be used for file
     streams.

     returns true in case of no differences found
     */
    bool
    compareStreams(std::istream & input_1, std::istream & input_2);

    /**@brief Simple diff-like application to compare two input files.
     Numeric differences are tolerated up to a certain ratio or absolute
     difference.

     where
     @param filename_1 first input file
     @param filename_2 second input file
     @return true in case of no differences found

     @sa ratio_max_allowed_
     @sa absdiff_max_allowed_
     @sa verbose_level_
     */
    bool
    compareFiles(const std::string & filename_1,
                 const std::string & filename_2);

protected:

    /**@brief Compare two lines of input.

     This implements the core functionality.  Intended to be used for a single
     line of input.

     returns true (non-zero) in case of success
     */
    bool
    compareLines_(std::string const & line_str_1,
                  std::string const & line_str_2);

    /// Report good news.
    void
    reportSuccess_() const;

    /// Report bad news.
    /// @exception AbortComparison
    void
    reportFailure_(char const * const message) const;

    /// Write info about hits in the whitelist
    void writeWhitelistCases_(const std::string & prefix) const;

    /// read the next line in input stream, skipping over empty lines
    /// and lines consisting of whitespace only
    void readNextLine_(std::istream & input_stream, std::string & line_string, int & line_number) const;

    /// opens and checks an input file stream std::ifstream
    bool openInputFileStream_(const std::string & filename, std::ifstream & input_stream) const;

    /// Log and results output goes here
    std::ostream * log_dest_;

    /// Name of first input e.g., filename
    std::string input_1_name_;
    /// Name of second input e.g., filename
    std::string input_2_name_;

    /// Stores information about the current input line (i.e., stream for the line and the current position in the stream)
    struct InputLine
    {
      std::stringstream line_;
      std::ios::pos_type line_position_;

      InputLine() :
        line_()
      {
      }

      /// Initialize the input line to the passed string
      void setToString(const std::string & s)
      {
        line_.str(s);
        line_.seekp(0);
        line_.clear();
        line_.unsetf(std::ios::skipws);

        line_position_ = line_.tellg();
      }

      /// Save current position of the stream
      void updatePosition()
      {
        line_position_ = (Int(line_.tellg()) != -1 ? line_.tellg() : std::ios::pos_type(line_.str().length()));             // save current reading position
      }

      /// Resets the stream to the last saved position
      void seekGToSavedPosition()
      {
        line_.clear();             // reset status
        line_.seekg(line_position_);             // rewind to saved position
      }

      /**
          Convert to bool

		      The function indicates success when none of the error flags (either failbit or badbit of the nested std::stringstream) are set.

          @return False on error, true otherwise.
          */
      bool ok() const
      {
        return !line_.fail(); // failbit AND badbit are both NOT set; using fail() seems the only portable solution for both C++98 and C++11
                              // operator bool() (C++11 only) and operator void*() (C++98 only) are both not very sexy since they are not "safe bool idiomic" and would require
                              // a macro here... So we use a real function name (both internally and externally)
      }
    };

    InputLine input_line_1_;
    InputLine input_line_2_;

    int line_num_1_;
    int line_num_2_;

    int line_num_1_max_;
    int line_num_2_max_;

    std::string line_str_1_max_;
    std::string line_str_2_max_;

    /// Maximum ratio of numbers allowed, see @em ratio_max_.
    double ratio_max_allowed_;

    /// Maximum ratio of numbers observed so far, see @em ratio_max_allowed_.
    double ratio_max_;

    /// Maximum absolute difference of numbers allowed, see @em absdiff_max_.
    double absdiff_max_allowed_;

    /// Maximum difference of numbers observed so far, see @em absdiff_max_allowed_.
    double absdiff_max_;

    /// Stores information about characters, numbers, and whitesspaces loaded from the InputStream
    struct StreamElement_
    {
      double number;
      unsigned char letter;
      bool is_number;
      bool is_space;

      StreamElement_() :
        number(0),
        letter(0),
        is_number(false),
        is_space(false)
      {}

      /// reset all elements of the element to default value
      void reset()
      {
        is_number = false;
        is_space = false;
        letter = '\0';
        number = std::numeric_limits<double>::quiet_NaN();
      }

      /// Read the next element from an InputLine and update the InputLine accordingly
      void fillFromInputLine(InputLine & input_line)
      {
        // first reset all internal variables so we do not mess with
        // old values
        reset();

        input_line.updatePosition();
        input_line.line_ >> letter;             // read letter
        if ((is_space = (isspace(letter) != 0)))               // is whitespace?
        {
          input_line.line_ >> std::ws;               // skip over further whitespace
        }
        else
        {
          input_line.seekGToSavedPosition();
          if ((is_number = (bool(input_line.line_ >> number))))       // is a number? (explicit bool op for C11)
          {
          }
          else
          {
            input_line.seekGToSavedPosition();
            input_line.line_ >> letter;                 // read letter
          }
        }
      }

    };

    /// Stores information about characters, numbers, and whitesspaces loaded from the first input stream
    StreamElement_ element_1_;
    /// Stores information about characters, numbers, and whitesspaces loaded from the second input stream
    StreamElement_ element_2_;

    /// Wrapper for the prefix information computed for the failure report
    struct PrefixInfo_
    {
      OpenMS::String prefix;
      OpenMS::String prefix_whitespaces;
      int line_column;

      PrefixInfo_(const InputLine & input_line, const int tab_width_, const int first_column_) :
        prefix(input_line.line_.str()), line_column(0)
      {
        prefix = prefix.prefix(size_t(input_line.line_position_));
        prefix_whitespaces = prefix;
        for (String::iterator iter = prefix_whitespaces.begin(); iter != prefix_whitespaces.end(); ++iter)
        {
          if (*iter != '\t')
          {
            * iter = ' ';
            ++line_column;
          }
          else
          {
            line_column = (line_column / tab_width_ + 1) * tab_width_;
          }
        }
        line_column += first_column_;
      }

    };

    bool is_absdiff_small_;

    int verbose_level_;
    int tab_width_;
    int first_column_;

    /**@brief Has comparison been sucessful so far?  Note: this flag is
     changed in reportFailure_();
     */
    bool is_status_success_;

    /// use a prefix when reporting
    bool use_prefix_;

    StringList whitelist_;
    std::map<String, UInt> whitelist_cases_;

  }; // class FuzzyStringComparator

} //namespace OpenMS

#endif //OPENMS_CONCEPT_FUZZYSTRINGCOMPARATOR_H