Diff for /loncom/interface/loncommon.pm between versions 1.560 and 1.561

version 1.560, 2007/08/11 14:22:14 version 1.561, 2007/08/11 15:18:24
Line 5994  sub record_sep { Line 5994  sub record_sep {
             $i++;              $i++;
         }          }
     } else {      } else {
         my @allfields;          my $separator=',';
         if ($env{'form.upfiletype'} eq 'semisv') {          if ($env{'form.upfiletype'} eq 'semisv') {
             @allfields=split(/\s*;\s*/,$record,-1);              $separator=';';
         } else {  
             @allfields=split(/\s*\,\s*/,$record,-1);  
         }          }
         my $i=0;          my $i=0;
         my $j;  # the character we are looking for to indicate the end of a quote or a record 
         for ($j=0;$j<=$#allfields;$j++) {          my $looking_for=$separator;
             my $field=$allfields[$j];  # do not add the characters to the fields
             if ($field=~/^\s*(\"|\')/) {          my $ignore=0;
  my $delimiter=$1;  # we just encountered a separator (or the beginning of the record)
                 while (($field!~/$delimiter$/) && ($j<$#allfields)) {          my $just_found_separator=1;
     $j++;  # store the field we are working on here
     $field.=','.$allfields[$j];          my $field='';
  }  # work our way through all characters in record
                 $field=~s/^\s*$delimiter//;          foreach my $character ($record=~/(.)/g) {
                 $field=~s/$delimiter\s*$//;              if ($character eq $looking_for) {
                  if ($character ne $separator) {
   # Found the end of a quote, again looking for separator
                     $looking_for=$separator;
                     $ignore=1;
                  } else {
   # Found a separator, store away what we got
                     $components{&takeleft($i)}=$field;
             $i++;
                     $just_found_separator=1;
                     $ignore=0;
                     $field='';
                  }
                  next;
             }              }
             $components{&takeleft($i)}=$field;  # single or double quotation marks after a separator indicate beginning of a quote
     $i++;  # we are now looking for the end of the quote and need to ignore separators
               if ((($character eq '"') || ($character eq "'")) && ($just_found_separator))  {
                  $looking_for=$character;
                  next;
               }
   # ignore would be true after we reached the end of a quote
               if ($ignore) { next; }
               if (($just_found_separator) && ($character=~/\s/)) { next; }
               $field.=$character;
               $just_found_separator=0; 
         }          }
   # catch the very last entry, since we never encountered the separator
           $components{&takeleft($i)}=$field;
     }      }
     return %components;      return %components;
 }  }

Removed from v.1.560  
changed lines
  Added in v.1.561


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>