FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
libCopyRight.php
1 <?php
2 /*
3  Copyright (C) 2010 Hewlett-Packard Development Company, L.P.
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License
7  version 2 as published by the Free Software Foundation.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License along
15  with this program; if not, write to the Free Software Foundation, Inc.,
16  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
32 function cleanString($string)
33 {
34  $clean = NULL;
35  if(strlen($string) == 0)
36  {
37  return($clean);
38  }
39  $cleanText = str_replace("\n", '', $string);
40  $clean = trim($cleanText);
41  return($clean);
42 }
43 
63 function checkStandard($list, $standard, $testName)
64 {
65  if(empty($list))
66  {
67  return(array('ERROR! empty list passed in'));
68  }
69  if(empty($standard))
70  {
71  return(array('ERROR! empty Standard list passed in'));
72  }
73  if((strlen($testName)) == 0)
74  {
75  return(array('ERROR! no testName supplied'));
76  }
77 
78  $results = array();
79 
80  foreach($list as $uiData) {
81  $cleanText = cleanString($uiData['textOrLink']);
82  print "ckSTDB: cleanText is:$cleanText\n";
83  if (array_key_exists($cleanText, $standard)) {
84  $stdCount = $standard[$cleanText];
85  if($stdCount != $uiData['count'])
86  {
87  $results[] = "$testName FAILED! Should be $stdCount files " .
88  "got:$uiData[count] for row with text:\n$cleanText\n";
89  }
90  }
91  else
92  {
93  $results[] = "$testName FAILED! $cleanText did not meet the test Standard\n";
94  }
95  }
96  //print "ckStdDB: results are:\n";print_r($results) . "\n";
97  return($results);
98 }
char * trim(char *ptext)
Trimming whitespace.
Definition: fossconfig.c:695